🛠ī¸Useful functions

Few things that can help you fasten your integration.

After doing over 100+ integration across multiple chains, we realized some protocols use very similar logic and therefore we've created few functions that can help you during your integration.

You can find the full list of all Utils here.

Here are some common functions that can be used for all networks.

This function is mostly used for Lending and Leverage protocols, by providing a list of SuppliedAssets, BorrowedAssets, RewardsAssets along with their respective Yields (optional) it returns all necessary values to return a PortfolioElementBorrowLend.

You can find an example here with Solend

getLpUnderlyingTokenSource()

We recommend to use this function whenever you are integrating liquidity protocols, this allow to quickly price new tokens listed on your protocol, by checking multiple conditions :

If this function returns a TokenPriceSource, you can store it in the cache.

This function will give you a formatted TokenPriceSource depending on the different information of the liquidity pool (supply, tokens, prices etc..).

You can then store this source inside our Cache by using cache.setTokenPriceSource()

This applies mostly to non-EVM chains where the representation of the LP is inside the wallet.

For each Fetcher (and even for some Jobs), you will need to know the price of some tokens that compose the position.

To avoid having the same redundant lines in each fetcher, this function will return a Map<string,TokenPrice> based on the array provided to the function.

This is very useful when you have a TokenPrice and need to generate an Asset.

The plural version is useful to convert underlyings tokens of a TokenPrice into an array of Assets.

Last updated