UniswapV2Deployment
Documentation for eth_defi.uniswap_v2.deployment.UniswapV2Deployment Python class.
- class UniswapV2Deployment[source]
Uniswap v2 deployment description.
Data for a deployment fetched from live chain based on factory address and other factors
Test deployment through
eth_defi.uniswap_v2.deployment.deploy_uniswap_v2_like()
.
Attributes summary
The Web3 instance for which the instances of this class are bound
Factory address.
WETH/WBNB etc.
Router address.
The hash of deployed pair contract code.
Pair contract.
Methods summary
__init__
(web3, factory, weth, router, ...)get_pair_contract
(token_a, token_b)Get a contract for a trading pair.
pair_for
(token_a, token_b)Calculate CREATE2 contract address for a trading pair.
- web3: web3.main.Web3
The Web3 instance for which the instances of this class are bound
- factory: web3.contract.contract.Contract
Factory address. Factory deploys new pair contracts and defines the exchange instance on a blockchain. See the Solidity source code.
- weth: Optional[web3.contract.contract.Contract]
WETH/WBNB etc. wrapper contract address. See the Solidity source code.
If the router contract ABI has renamed this variable from WETH to something else, e.g. Trader Joe, this is left empty.
TDOO: Allow to provision the exchange with different router ABI files.
- router: web3.contract.contract.Contract
Router address. New routers can be deployed to optimise trade routing and price impact. See the Solidity source code.
- init_code_hash: eth_typing.encoding.HexStr
The hash of deployed pair contract code. Needed to derive new pair contract addresses. See here for more details.
- PairContract: Type[web3.contract.contract.Contract]
Pair contract. Holds the token0 and token1 side of the liquidity pool. Executes actual trades. Mints/burns new liquidity provider (LP) tokens. See UniswapV2Pair smartc contract for details.
- __init__(web3, factory, weth, router, init_code_hash, PairContract)