diff --git a/contracts/LpSugar.vy b/contracts/LpSugar.vy index 9ba3999..83a88d3 100644 --- a/contracts/LpSugar.vy +++ b/contracts/LpSugar.vy @@ -293,9 +293,11 @@ def toMigrate(_account: address) -> DynArray[Lp, MAX_POOLS]: @external @view -def forSwaps() -> DynArray[SwapLp, MAX_POOLS]: +def forSwaps(_limit: uint256, _offset: uint256) -> DynArray[SwapLp, MAX_POOLS]: """ @notice Returns a compiled list of pools for swaps from all pool factories + @param _limit The max amount of tokens to return + @param _offset The amount of pools to skip @return `SwapLp` structs """ factories_count: uint256 = self.registry.poolFactoriesLength() @@ -317,8 +319,8 @@ def forSwaps() -> DynArray[SwapLp, MAX_POOLS]: else: pools_count = factory.allPoolsLength() - for pindex in range(0, MAX_POOLS): - if pindex >= pools_count: + for pindex in range(_offset, _offset + MAX_POOLS): + if len(pools) >= _limit or pindex >= pools_count: break pool_addr: address = empty(address) @@ -330,10 +332,7 @@ def forSwaps() -> DynArray[SwapLp, MAX_POOLS]: pool: IPool = IPool(pool_addr) - reserve0: uint256 = pool.reserve0() - reserve1: uint256 = pool.reserve1() - - if (reserve0 > 0 and reserve1 > 0) or pool_addr == self.convertor: + if pool.reserve0() > 0 or pool_addr == self.convertor: pools.append(SwapLp({ lp: pool_addr, stable: pool.stable(), diff --git a/readme.md b/readme.md index 0f85484..611f28e 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 `0x7F45F1eA57E9231f846B2b4f5F8138F94295A726` +`LpSugar.vy` is deployed at `0x4D996E294B00cE8287C16A2b9A4e637ecA5c939f` It allows fetching on-chain pools data. The returned data/struct of type `Lp` values represent: