Documentation for eth_defi.uniswap_v2.deployment.fetch_deployment function.

fetch_deployment(web3, factory_address, router_address, init_code_hash=None, allow_different_weth_var=True)[source]

Construct Uniswap deployment based on on-chain data.

Fetches init code hash from on-chain.

Factory does not know about routers, so they must be explicitly given.

Read more details here.

Example how to get PancakeSwap v2 deployment:

def pancakeswap_v2(web3) -> UniswapV2Deployment:
    deployment = fetch_deployment(
        # Taken from https://bscscan.com/address/0xca143ce32fe78f1f7019d7d551a6402fc5350c73#readContract
    return deployment
  • init_code_hash (Optional[Union[eth_typing.encoding.HexStr, str]]) – Read init code hash from the caller. If not given call pairCodeHash (SushiSwap) on the factory.

  • allow_different_weth_var – We assume Uniswap v2 ABI that has router.WETH() accessor. Some DEXes like Trader Joe do not have it, using WAVAX instead, needing a different ABI file. If set (default) ignore this error and just have None as the value for the wrapped token.

  • web3 (web3.main.Web3) –

  • factory_address (Union[eth_typing.evm.HexAddress, str]) –

  • router_address (Union[eth_typing.evm.HexAddress, str]) –


Data class representing Uniswap v3 exchange deployment

Return type