Skip to content

Commit

Permalink
chore: pass and use registry
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrovalido committed Oct 4, 2024
1 parent 214b372 commit d180c42
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
24 changes: 9 additions & 15 deletions contracts/LpSugar.vy
Original file line number Diff line number Diff line change
Expand Up @@ -258,24 +258,22 @@ interface IAlmLpWrapper:
def totalSupply() -> uint256: view

# Vars
registry: public(IFactoryRegistry)
voter: public(IVoter) # Voter on root , LeafVoter on leaf chain
factories: public(DynArray[address, MAX_FACTORIES])
registry: public(IFactoryRegistry)
convertor: public(address)
cl_helper: public(ISlipstreamHelper)
alm_factory: public(IAlmFactory)

# Methods

@external
def __init__(_registry: address, _voter: address, _factories: DynArray[address, MAX_FACTORIES], \
def __init__(_voter: address, _registry: address,\
_convertor: address, _slipstream_helper: address, _alm_factory: address):
"""
@dev Sets up our external contract addresses
"""
self.registry = IFactoryRegistry(_registry)
self.voter = IVoter(_voter)
self.factories = _factories
self.registry = IFactoryRegistry(_registry)
self.convertor = _convertor
self.cl_helper = ISlipstreamHelper(_slipstream_helper)
self.alm_factory = IAlmFactory(_alm_factory)
Expand All @@ -290,7 +288,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.factories
factories: DynArray[address, MAX_FACTORIES] = self.registry.poolFactories()
factories_count: uint256 = len(factories)

to_skip: uint256 = _offset
Expand Down Expand Up @@ -338,7 +336,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.factories
factories: DynArray[address, MAX_FACTORIES] = self.registry.poolFactories()
factories_count: uint256 = len(factories)

pools: DynArray[SwapLp, MAX_POOLS] = empty(DynArray[SwapLp, MAX_POOLS])
Expand Down Expand Up @@ -610,7 +608,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.factories
factories: DynArray[address, MAX_FACTORIES] = self.registry.poolFactories()

return self._positions(_limit, _offset, _account, factories)

Expand Down Expand Up @@ -1346,15 +1344,11 @@ def _fetch_nfpm(_factory: address) -> address:
@notice Returns the factory NFPM if available. CL pools should have one!
@param _factory The factory address
"""
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]
# Returns the votingRewardsFactory and the gaugeFactory
factory_data: address[2] = self.registry.factoriesToPoolFactory(_factory)

response: Bytes[32] = raw_call(
factory,
factory_data[1],
method_id("nft()"),
max_outsize=32,
is_delegate_call=False,
Expand Down
4 changes: 0 additions & 4 deletions env.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,27 @@ 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
3 changes: 1 addition & 2 deletions scripts/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ def main():

if 'lp' in contract_name:
LpSugar.deploy(
os.getenv(chain_name + '_REGISTRY'),
os.getenv(chain_name + '_VOTER'),
str(os.getenv(chain_name + '_FACTORIES')).split(','),
os.getenv(chain_name + '_REGISTRY'),
os.getenv(chain_name + '_CONVERTOR'),
os.getenv(chain_name + '_SLIPSTREAM_HELPER'),
os.getenv(chain_name + '_ALM_FACTORY'),
Expand Down

0 comments on commit d180c42

Please sign in to comment.