diff --git a/contracts/LpSugar.vy b/contracts/LpSugar.vy index e2e3391..776dbd6 100644 --- a/contracts/LpSugar.vy +++ b/contracts/LpSugar.vy @@ -281,7 +281,7 @@ def _pools(_limit: uint256, _offset: uint256)\ nfpm: address = self._fetch_nfpm(factory.address) for pindex in range(0, MAX_ITERATIONS): - if pindex >= pools_count or visited >= _limit + _offset: + if pindex >= pools_count or visited >= _limit + _offset or len(pools) >= MAX_POOLS: break # Since the convertor pool, first pool on one of the factories... @@ -327,7 +327,7 @@ def forSwaps(_limit: uint256, _offset: uint256) -> DynArray[SwapLp, MAX_POOLS]: pools_count: uint256 = factory.allPoolsLength() for pindex in range(0, MAX_ITERATIONS): - if pindex >= pools_count: + if pindex >= pools_count or len(pools) >= MAX_POOLS: break # If no pools to process are left... @@ -396,7 +396,7 @@ def tokens(_limit: uint256, _offset: uint256, _account: address, \ col.append(self._token(_addresses[index], _account)) seen.append(_addresses[index]) - for index in range(0, MAX_TOKENS): + for index in range(0, MAX_POOLS): if len(col) >= _limit or index >= pools_count: break diff --git a/env.example b/env.example index 81665a2..9fdc4dd 100644 --- a/env.example +++ b/env.example @@ -5,7 +5,7 @@ CONVERTOR_ADDRESS=0x1111111111111111111111111111111111111111 RELAY_REGISTRY_ADDRESSES=0x05e41604B9463e2224227053980dfF3f57fb6dB5,0xD308aBCe663302d3b86b36d332CEFd8A4F62C5Ed SLIPSTREAM_HELPER_ADDRESS=0x6d2D739bf37dFd93D804523c2dfA948EAf32f8E1 GOVERNOR_ADDRESS=0x94C012A23A8A65A6f40608dA30534a46a433F410 -LP_SUGAR_ADDRESS=0x08483151e59375a03E82C180BBc4c79E5CB8C60D +LP_SUGAR_ADDRESS=0xcDF4AA33Bafba3e5dc5B3ae54ab67324Ef956ABD VE_SUGAR_ADDRESS=0x4c5d3925fe65DFeB5A079485136e4De09cb664A5 RELAY_SUGAR_ADDRESS=0x8932B5FE23C07Df06533F8f09E43e7cca6a24143 diff --git a/readme.md b/readme.md index 615df5a..9194cb0 100644 --- a/readme.md +++ b/readme.md @@ -35,7 +35,7 @@ Below is the list of datasets we support. ### Liquidity Pools Data -`LpSugar.vy` is deployed at `0x08483151e59375a03E82C180BBc4c79E5CB8C60D` +`LpSugar.vy` is deployed at `0xcDF4AA33Bafba3e5dc5B3ae54ab67324Ef956ABD` It allows fetching on-chain pools data. The returned data/struct of type `Lp` values represent: diff --git a/tests/test_lp_sugar.py b/tests/test_lp_sugar.py index 73d2f3a..c96136a 100644 --- a/tests/test_lp_sugar.py +++ b/tests/test_lp_sugar.py @@ -119,6 +119,21 @@ def test_tokens(sugar_contract, TokenStruct, LpStruct): assert token1.token_address == first_lp.token1 +def test_tokens_large_limit(sugar_contract, TokenStruct): + many_tokens = list(map( + lambda _p: TokenStruct(*_p), + sugar_contract.tokens(2000, 1000, ADDRESS_ZERO, []) + )) + + assert many_tokens is not None + assert len(many_tokens) > 100 + + token0 = many_tokens[0] + + assert token0.symbol is not None + assert token0.decimals > 0 + + def test_all(sugar_contract, LpStruct): first_lp = LpStruct(*sugar_contract.byIndex(0)) second_lp = LpStruct(*sugar_contract.byIndex(1))