Functions we've written so you don't have to
Exports Helpers
Exporting empty TVL - if your project has filtered TVL only, here's an easy way to export core TVL as empty.
Token balance queries
if you have a known set of tokens and contract addresses, there are few ways to fetch and export it as tvl using sumTokensExport
if single contract and multiple tokens
if there are multiple contracts to look up:
if all contracts dont share same set of tokens:
if any of these tokens are LP tokens, set resolveLP: true
to resolve them into underlying tokens
Solana Helpers
getTokenBalance is used for getting a solana account's balance of a particular token.
Transforming Tokens That Aren't On CoinGecko
DefiLlama uses a wide variety of sources to price tokens, such as CoinGecko and chain calls to price exotic tokens such as Curve and uniswap LPs. If you find that a token is missing and it's not getting priced in your adapter, just let us know in our discord!
To count the TVL of LP token balances, the positions must be unwrapped into their underlying tokens.
Getting Block Heights
For lesser known EVM chains sometimes the block height wont be available in the third parameter passed to the adapter's TVL function. In this case you can use getBlock to fetch the block height.
Last updated