diff --git a/contracts/LpSugar.vy b/contracts/LpSugar.vy index 94e7253..edfd255 100644 --- a/contracts/LpSugar.vy +++ b/contracts/LpSugar.vy @@ -259,7 +259,8 @@ interface IAlmLpWrapper: # Vars registry: public(IFactoryRegistry) -voter: public(IVoter) +voter: public(IVoter) # Voter on root , LeafVoter on leaf chain +factories: public(DynArray[address, MAX_FACTORIES]) convertor: public(address) cl_helper: public(ISlipstreamHelper) alm_factory: public(IAlmFactory) @@ -267,13 +268,14 @@ alm_factory: public(IAlmFactory) # Methods @external -def __init__(_voter: address, _registry: address, _convertor: address, \ - _slipstream_helper: address, _alm_factory: address): +def __init__(_registry: address, _voter: address, _factories: DynArray[address, MAX_FACTORIES], \ + _convertor: address, _slipstream_helper: address, _alm_factory: address): """ @dev Sets up our external contract addresses """ - self.voter = IVoter(_voter) self.registry = IFactoryRegistry(_registry) + self.voter = IVoter(_voter) + self.factories = _factories self.convertor = _convertor self.cl_helper = ISlipstreamHelper(_slipstream_helper) self.alm_factory = IAlmFactory(_alm_factory) @@ -288,7 +290,7 @@ def _pools(_limit: uint256, _offset: uint256)\ @notice Returns a compiled list of pool and its factory and gauge @return Array of four addresses (factory, pool, gauge, nfpm) """ - factories: DynArray[address, MAX_FACTORIES] = self.registry.poolFactories() + factories: DynArray[address, MAX_FACTORIES] = self.factories factories_count: uint256 = len(factories) to_skip: uint256 = _offset @@ -336,7 +338,7 @@ def forSwaps(_limit: uint256, _offset: uint256) -> DynArray[SwapLp, MAX_POOLS]: @param _offset The amount of pools to skip @return `SwapLp` structs """ - factories: DynArray[address, MAX_FACTORIES] = self.registry.poolFactories() + factories: DynArray[address, MAX_FACTORIES] = self.factories factories_count: uint256 = len(factories) pools: DynArray[SwapLp, MAX_POOLS] = empty(DynArray[SwapLp, MAX_POOLS]) @@ -608,7 +610,7 @@ def positions(_limit: uint256, _offset: uint256, _account: address)\ @param _offset The amount of pools to skip (for optimization) @return Array for Lp structs """ - factories: DynArray[address, MAX_FACTORIES] = self.registry.poolFactories() + factories: DynArray[address, MAX_FACTORIES] = self.factories return self._positions(_limit, _offset, _account, factories) @@ -656,7 +658,10 @@ def _positions( pools_done: uint256 = 0 factories_count: uint256 = len(_factories) - alm_core: IAlmCore = IAlmCore(self.alm_factory.getImmutableParams()[0]) + + alm_core: IAlmCore = empty(IAlmCore) + if self.alm_factory != empty(IAlmFactory): + alm_core = IAlmCore(self.alm_factory.getImmutableParams()[0]) for index in range(0, MAX_FACTORIES): if index >= factories_count: @@ -723,7 +728,7 @@ def _positions( # fetch ALM positions for pindex in range(0, MAX_POOLS): - if pindex >= pools_count or pools_done >= _limit: + if pindex >= pools_count or pools_done >= _limit or self.alm_factory == empty(IAlmFactory): break # Basically skip calls for offset records... @@ -1000,8 +1005,10 @@ def _cl_lp(_data: address[4], _token0: address, _token1: address) -> Lp: if gauge_alive and gauge.periodFinish() > block.timestamp: emissions = gauge.rewardRate() - - alm_addresses: address[2] = self.alm_factory.poolToAddresses(pool.address) + + alm_addresses: address[2] = [empty(address), empty(address)] + if self.alm_factory != empty(IAlmFactory): + alm_addresses = self.alm_factory.poolToAddresses(pool.address) return Lp({ lp: pool.address, @@ -1339,11 +1346,15 @@ def _fetch_nfpm(_factory: address) -> address: @notice Returns the factory NFPM if available. CL pools should have one! @param _factory The factory address """ - # Returns the votingRewardsFactory and the gaugeFactory - factory_data: address[2] = self.registry.factoriesToPoolFactory(_factory) + factory: address = _factory + + if self.registry != empty(IFactoryRegistry): + # Returns the votingRewardsFactory and the gaugeFactory + factory_data: address[2] = self.registry.factoriesToPoolFactory(_factory) + factory = factory_data[1] response: Bytes[32] = raw_call( - factory_data[1], + factory, method_id("nft()"), max_outsize=32, is_delegate_call=False, diff --git a/env.example b/env.example index ee38c9f..aaed678 100644 --- a/env.example +++ b/env.example @@ -1,11 +1,8 @@ VOTER_ADDRESS=0x41C914ee0c7E1A5edCD0295623e6dC557B5aBf3C -REGISTRY_ADDRESS=0xF4c67CdEAaB8360370F41514d06e32CcD8aA1d7B DIST_ADDRESS=0x9D4736EC60715e71aFe72973f7885DCBC21EA99b -CONVERTOR_ADDRESS=0x585Af0b397AC42dbeF7f18395426BF878634f18D -RELAY_REGISTRY_ADDRESSES=0xe9F00f2e61CB0c6fb00A2e457546aCbF0fC303C2,0x6b1253B116B5919932399295C75116d33F8EfF96 -SLIPSTREAM_HELPER_ADDRESS=0x5Bd7E2221C2d59c99e6A9Cd18D80A5F4257D0f32 -ALM_FACTORY_ADDRESS=0xeD8b81E3fF6c54951621715F5992CA52007D88bA GOVERNOR_ADDRESS=0x1F82e10D58aEf03DeA2e478029fB0387A1cbE989 +RELAY_REGISTRY_ADDRESSES=0xe9F00f2e61CB0c6fb00A2e457546aCbF0fC303C2,0x6b1253B116B5919932399295C75116d33F8EfF96 + LP_SUGAR_ADDRESS=0x0937DA94887472239Ada5483c6DBd2904FfD4ACF VE_SUGAR_ADDRESS=0x94f913362b232e31daB49a1aFB775cfd25DaA6a1 RELAY_SUGAR_ADDRESS=0xb8307e5842B9aeE75C704183F0355076aa74b4e2 @@ -14,3 +11,38 @@ RELAY_SUGAR_ADDRESS=0xb8307e5842B9aeE75C704183F0355076aa74b4e2 TEST_FACTORY_ADDRESS=0xCc0bDDB707055e04e497aB22a59c2aF4391cd12F TEST_ADDRESS=0xEeE7FB850D28f5cabd5f1EDF540646b5bEA17CE5 TEST_ALM_ADDRESS=0x892Ff98a46e5bd141E2D12618f4B2Fe6284debac + +CHAIN=optimism +CONTRACT='lp' + +#OPTIMISM +OPTIMISM_REGISTRY=0xF4c67CdEAaB8360370F41514d06e32CcD8aA1d7B +OPTIMISM_VOTER=0x41C914ee0c7E1A5edCD0295623e6dC557B5aBf3C +OPTIMISM_FACTORIES=0xF1046053aa5682b4F9a81b5481394DA16BE5FF5a,0xCc0bDDB707055e04e497aB22a59c2aF4391cd12F +OPTIMISM_CONVERTOR=0x585Af0b397AC42dbeF7f18395426BF878634f18D +OPTIMISM_SLIPSTREAM_HELPER=0x5Bd7E2221C2d59c99e6A9Cd18D80A5F4257D0f32 +OPTIMISM_ALM_FACTORY=0xeD8b81E3fF6c54951621715F5992CA52007D88bA + +#BASE +BASE_REGISTRY=0x5C3F18F06CC09CA1910767A34a20F771039E37C0 +BASE_VOTER=0x16613524e02ad97eDfeF371bC883F2F5d6C480A5 +BASE_FACTORIES=0x420DD381b31aEf6683db6B902084cB0FFECe40Da,0x5e7BB104d84c7CB9B682AaC2F3d509f5F406809A +BASE_CONVERTOR=0x1111111111111111111111111111111111111111 +BASE_SLIPSTREAM_HELPER=0x6d2D739bf37dFd93D804523c2dfA948EAf32f8E1 +BASE_ALM_FACTORY=0x5B1b1aaC71bDca9Ed1dCb2AA357f678584db4029 + +#MODE +MODE_REGISTRY=0x0000000000000000000000000000000000000000 +MODE_VOTER=0x0000000000000000000000000000000000000000 +MODE_FACTORIES=0x31832f2a97Fd20664D76Cc421207669b55CE4BC0 +MODE_CONVERTOR=0x1111111111111111111111111111111111111111 +MODE_SLIPSTREAM_HELPER=0x0000000000000000000000000000000000000000 +MODE_ALM_FACTORY=0x0000000000000000000000000000000000000000 + +#BOB +BOB_REGISTRY=0x0000000000000000000000000000000000000000 +BOB_VOTER=0x0000000000000000000000000000000000000000 +BOB_FACTORIES=0x31832f2a97Fd20664D76Cc421207669b55CE4BC0 +BOB_CONVERTOR=0x1111111111111111111111111111111111111111 +BOB_SLIPSTREAM_HELPER=0x0000000000000000000000000000000000000000 +BOB_ALM_FACTORY=0x0000000000000000000000000000000000000000 diff --git a/scripts/deploy.py b/scripts/deploy.py index 0f00feb..113b601 100644 --- a/scripts/deploy.py +++ b/scripts/deploy.py @@ -6,6 +6,7 @@ def main(): contract_name = str(os.getenv('CONTRACT')).lower() + chain_name = str(os.getenv('CHAIN')).upper() if os.getenv('PROD'): account = accounts.load('sugar') @@ -14,11 +15,12 @@ def main(): if 'lp' in contract_name: LpSugar.deploy( - os.getenv('VOTER_ADDRESS'), - os.getenv('REGISTRY_ADDRESS'), - os.getenv('CONVERTOR_ADDRESS'), - os.getenv('SLIPSTREAM_HELPER_ADDRESS'), - os.getenv('ALM_FACTORY_ADDRESS'), + os.getenv(chain_name + '_REGISTRY'), + os.getenv(chain_name + '_VOTER'), + str(os.getenv(chain_name + '_FACTORIES')).split(','), + os.getenv(chain_name + '_CONVERTOR'), + os.getenv(chain_name + '_SLIPSTREAM_HELPER'), + os.getenv(chain_name + '_ALM_FACTORY'), {'from': account} )