Skip to content

Commit

Permalink
feat: add external tokensByAddress function
Browse files Browse the repository at this point in the history
  • Loading branch information
ethzoomer committed Dec 21, 2023
1 parent 686bfb1 commit 908f286
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions contracts/LpSugar.vy
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,27 @@ def tokens(_limit: uint256, _offset: uint256, _account: address)\

return col

@external
@view
def tokensByAddress(_addresses: DynArray[address, MAX_TOKENS], _account: address)\
-> DynArray[Token, MAX_TOKENS]:
"""
@notice Returns a collection of tokens data based on given addresses
@param _addresses The tokens to return data of
@param _account The account to check the balances
@return Array for Token structs
"""
tokens_count: uint256 = len(_addresses)
col: DynArray[Token, MAX_TOKENS] = empty(DynArray[Token, MAX_TOKENS])

for index in range(0, MAX_TOKENS):
if index == MAX_TOKENS or index >= tokens_count:
break

col.append(self._token(_addresses[index], _account))

return col

@internal
@view
def _token(_address: address, _account: address) -> Token:
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Below is the list of datasets we support.

### Liquidity Pools Data

`LpSugar.vy` is deployed at `0xc8EA305A43CB85866d1a2f60552DBe14f2aA191d`
`LpSugar.vy` is deployed at `0x211D33f1ccfb8128aB9FAF1f502531c1De31d997`

It allows fetching on-chain pools data.
The returned data/struct of type `Lp` values represent:
Expand Down

0 comments on commit 908f286

Please sign in to comment.