General EVM contract calls

Balance Calls

use sumTokens2 method from helper to return token balances

For example, you have a vault with USDC and ETH tokens in it in arbitrum



const { sumTokensExport, sumTokens } = require('./helper/unwrapLPs')

const owner = '0x...' // vault address
const tokens = [
  '0xff970a61a04b1ca14834a43f5de4533ebddb5cc8', // USDC
  '0x0000000000000000000000000000000000000000', // ETH
]

module.exports = {
  arbitrum: {
    tvl: sumTokensExport({ owner, tokens })
  }
}

// or 

module.exports = {
  arbitrum: {
    tvl: async (api) => {
      return sumTokens2({ owner, tokens, api, })
    }
  }
}
Example ERC20 Token Balance Adapter

Custom Contract Calls

Contract calls are the most common ways of recording TVL.

Often after a single contract call you'll also want to add the balance to your balances object, which can be easily done with sumSingleBalance.

When you have lots of calls to functions with the same ABI, it's easier to use multiCall and sumMultiBalanceOf.

Example MultiCall Adapter

Last updated

Was this helpful?