diff --git a/src/degenbot/uniswap/managers.py b/src/degenbot/uniswap/managers.py index 48b62700..26aa1ea4 100644 --- a/src/degenbot/uniswap/managers.py +++ b/src/degenbot/uniswap/managers.py @@ -15,7 +15,7 @@ from ..manager.token_manager import Erc20TokenHelperManager from ..registry.all_pools import AllPools from .abi import UNISWAP_V2_FACTORY_ABI -from .v2_liquidity_pool import LiquidityPool +from .v2_liquidity_pool import LiquidityPool, CamelotLiquidityPool from .v3_functions import generate_v3_pool_address from .v3_liquidity_pool import V3LiquidityPool from .v3_snapshot import UniswapV3LiquiditySnapshot @@ -227,14 +227,7 @@ def get_pool( raise PoolNotAssociated(f"Pool {pool_address} is not associated with this DEX") try: - pool_helper = LiquidityPool( - address=pool_address, - silent=silent, - state_block=state_block, - factory_address=self._factory_address, - factory_init_hash=self._factory_init_hash, - update_method=update_method, - ) + pool_helper = self._create_pool(pool_address, silent, state_block, update_method) except Exception as e: self._untracked_pools.add( pool_address @@ -245,6 +238,29 @@ def get_pool( self._add_pool(pool_helper) return pool_helper + def _create_pool(self, pool_address, silent, state_block, update_method): + return LiquidityPool( + address=pool_address, + silent=silent, + state_block=state_block, + factory_address=self._factory_address, + factory_init_hash=self._factory_init_hash, + update_method=update_method, + ) + + +class CamelotV2LiquidityPoolManager(UniswapV2LiquidityPoolManager): + + def _create_pool(self, pool_address, silent, state_block, update_method): + return CamelotLiquidityPool( + address=pool_address, + silent=silent, + state_block=state_block, + factory_address=self._factory_address, + factory_init_hash=self._factory_init_hash, + update_method=update_method, + ) + class UniswapV3LiquidityPoolManager(UniswapLiquidityPoolManager): """ diff --git a/src/degenbot/uniswap/v2_liquidity_pool.py b/src/degenbot/uniswap/v2_liquidity_pool.py index 51a978a5..3b125e16 100644 --- a/src/degenbot/uniswap/v2_liquidity_pool.py +++ b/src/degenbot/uniswap/v2_liquidity_pool.py @@ -52,6 +52,7 @@ def __init__( silent: bool = False, state_block: int | None = None, empty: bool = False, + w3_contract: Contract | None = None, update_reserves_on_start: bool | None = None, # deprecated unload_brownie_contract_after_init: bool | None = None, # deprecated ) -> None: @@ -122,7 +123,7 @@ def __init__( self.abi = abi if abi is not None else UNISWAP_V2_POOL_ABI _w3 = config.get_web3() - _w3_contract = self._w3_contract + _w3_contract = self._w3_contract if w3_contract is None else w3_contract if factory_address: if factory_init_hash is None: @@ -792,19 +793,10 @@ def __init__( update_method: str = "polling", abi: List[Any] | None = None, silent: bool = False, - update_reserves_on_start: bool | None = None, # deprecated - unload_brownie_contract_after_init: bool | None = None, # deprecated + state_block: int | None = None, + factory_address: str | None = None, + factory_init_hash: str | None = None, ) -> None: - if unload_brownie_contract_after_init is not None: # pragma: no cover - warnings.warn( - "unload_brownie_contract_after_init is no longer needed and is " - "ignored. Remove constructor argument to stop seeing this " - "message." - ) - - if update_reserves_on_start is not None: # pragma: no cover - warnings.warn("update_reserves_on_start has been deprecated.") - address = to_checksum_address(address) if abi is None: @@ -813,8 +805,6 @@ def __init__( _w3 = config.get_web3() _w3_contract = config.get_web3().eth.contract(address=address, abi=abi) - state_block = _w3.eth.get_block_number() - ( _, _, @@ -836,6 +826,9 @@ def __init__( fee=(fee_token0, fee_token1), silent=silent, state_block=state_block, + factory_address=factory_address, + factory_init_hash=factory_init_hash, + w3_contract=_w3_contract, ) self.stable_swap: bool = _w3_contract.functions.stableSwap().call()