Skip to content

Commit

Permalink
chore: root/leaf diff with bridge variable
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrovalido committed Oct 14, 2024
1 parent 8f8febd commit e56fc5b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
31 changes: 22 additions & 9 deletions contracts/LpSugar.vy
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,12 @@ registry: public(IFactoryRegistry)
convertor: public(address)
cl_helper: public(ISlipstreamHelper)
alm_factory: public(IAlmFactory)
root_pool_factory: public(address)
root_pool_factory_slipstream: public(address)

# Methods

@external
def __init__(_voter: address, _registry: address,\
_convertor: address, _slipstream_helper: address,\
_alm_factory: address, _root_pool_factory: address, _root_pool_factory_slipstream: address):
_convertor: address, _slipstream_helper: address, _alm_factory: address):
"""
@dev Sets up our external contract addresses
"""
Expand All @@ -280,8 +277,6 @@ def __init__(_voter: address, _registry: address,\
self.convertor = _convertor
self.cl_helper = ISlipstreamHelper(_slipstream_helper)
self.alm_factory = IAlmFactory(_alm_factory)
self.root_pool_factory = _root_pool_factory
self.root_pool_factory_slipstream = _root_pool_factory_slipstream

@internal
@view
Expand All @@ -307,7 +302,7 @@ def _pools(_limit: uint256, _offset: uint256)\
break

factory: IPoolFactory = IPoolFactory(factories[index])
if factory.address == self.root_pool_factory or factory.address == self.root_pool_factory_slipstream:
if self._is_root_factory(factory.address):
continue

pools_count: uint256 = factory.allPoolsLength()
Expand Down Expand Up @@ -356,7 +351,7 @@ def forSwaps(_limit: uint256, _offset: uint256) -> DynArray[SwapLp, MAX_POOLS]:
break

factory: IPoolFactory = IPoolFactory(factories[index])
if factory.address == self.root_pool_factory or factory.address == self.root_pool_factory_slipstream:
if self._is_root_factory(factory.address):
continue

nfpm: address = self._fetch_nfpm(factory.address)
Expand Down Expand Up @@ -677,7 +672,7 @@ def _positions(
break

factory: IPoolFactory = IPoolFactory(_factories[index])
if factory.address == self.root_pool_factory or factory.address == self.root_pool_factory_slipstream:
if self._is_root_factory(factory.address):
continue

nfpm: INFPositionManager = \
Expand Down Expand Up @@ -1446,3 +1441,21 @@ def _safe_symbol(_token: address) -> String[100]:
return IERC20(_token).symbol()

return "-NA-"

@internal
@view
def _is_root_factory(_factory: address) -> bool:
"""
@notice Returns true if the factory is a root pool factory and false if it is a leaf pool factory.
@param _factory The factory address
"""
success: bool = raw_call(
_factory,
method_id("bridge()"),
max_outsize=32,
is_delegate_call=False,
is_static_call=True,
revert_on_failure=False
)[0]

return success
8 changes: 0 additions & 8 deletions env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ ALM_FACTORY_10=0xeD8b81E3fF6c54951621715F5992CA52007D88bA
DIST_10=0x9D4736EC60715e71aFe72973f7885DCBC21EA99b
RELAY_REGISTRY_ADDRESSES_10=0xe9F00f2e61CB0c6fb00A2e457546aCbF0fC303C2,0x6b1253B116B5919932399295C75116d33F8EfF96
GOVERNOR_10=0x1F82e10D58aEf03DeA2e478029fB0387A1cbE989
ROOT_POOL_FACTORY_10=0x1111111111111111111111111111111111111111
ROOT_POOL_FACTORY_SLIPSTREAM_10=0x1111111111111111111111111111111111111111

TEST_FACTORY_ADDRESS_10=0xCc0bDDB707055e04e497aB22a59c2aF4391cd12F
TEST_ADDRESS_10=0xEeE7FB850D28f5cabd5f1EDF540646b5bEA17CE5
Expand All @@ -30,8 +28,6 @@ ALM_FACTORY_8453=0x5B1b1aaC71bDca9Ed1dCb2AA357f678584db4029
DIST_8453=0x227f65131A261548b057215bB1D5Ab2997964C7d
RELAY_REGISTRY_ADDRESSES_8453=0x05e41604B9463e2224227053980dfF3f57fb6dB5,0xD308aBCe663302d3b86b36d332CEFd8A4F62C5Ed
GOVERNOR_8453=0x94C012A23A8A65A6f40608dA30534a46a433F410
ROOT_POOL_FACTORY_8453=0x1111111111111111111111111111111111111111
ROOT_POOL_FACTORY_SLIPSTREAM_8453=0x1111111111111111111111111111111111111111

TEST_FACTORY_ADDRESS_8453=0x5e7BB104d84c7CB9B682AaC2F3d509f5F406809A
TEST_ADDRESS_8453=0xEeE7FB850D28f5cabd5f1EDF540646b5bEA17CE5
Expand All @@ -50,8 +46,6 @@ ALM_FACTORY_34443=0x0000000000000000000000000000000000000000
DIST_34443=0x0000000000000000000000000000000000000000
RELAY_REGISTRY_ADDRESSES_34443=
GOVERNOR_34443=0x1111111111111111111111111111111111111111
ROOT_POOL_FACTORY_34443=0x1111111111111111111111111111111111111111
ROOT_POOL_FACTORY_SLIPSTREAM_34443=0x1111111111111111111111111111111111111111

LP_SUGAR_ADDRESS_34443=
VE_SUGAR_ADDRESS_34443=
Expand All @@ -66,8 +60,6 @@ ALM_FACTORY_60808=0x0000000000000000000000000000000000000000
DIST_60808=0x0000000000000000000000000000000000000000
RELAY_REGISTRY_ADDRESSES_60808=
GOVERNOR_60808=0x1111111111111111111111111111111111111111
ROOT_POOL_FACTORY_60808=0x1111111111111111111111111111111111111111
ROOT_POOL_FACTORY_SLIPSTREAM_60808=0x1111111111111111111111111111111111111111

LP_SUGAR_ADDRESS_60808=
VE_SUGAR_ADDRESS_60808=
Expand Down
2 changes: 0 additions & 2 deletions scripts/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ def main():
os.getenv(f'CONVERTOR_{chain_id}'),
os.getenv(f'SLIPSTREAM_HELPER_{chain_id}'),
os.getenv(f'ALM_FACTORY_{chain_id}'),
os.getenv(f'ROOT_POOL_FACTORY_{chain_id}'),
os.getenv(f'ROOT_POOL_FACTORY_SLIPSTREAM_{chain_id}'),
{'from': account}
)

Expand Down

0 comments on commit e56fc5b

Please sign in to comment.