Helper functions
Last updated
Was this helpful?
Last updated
Was this helpful?
For situations where the fetch function can only return totalVolume
and can return in based on a timestamp you can use the customBackfill
function that can be found in volumes/helper/customBackfill
.
If the data is available in a subgraph and it follows a structure similar to uniswap, you can use the folling helper functions to easily query it. More docs about it to be added soon but for now... take a look at other implementations!
getChainVolume
from helpers/getUniSubgraphVolume
getDexChainFees
from helpers/getUniSubgraphFees
getDexChainBreakdownFees
from helpers/getUniSubgraphFees
Or simply use the function univ2Adapter
to create an adapter with a couple of lines of code. See an example .
If fees or revenue are directly sent to an address, you can calculate the fees by calculating the tokens received by that address in the following way (this is the adapter for basecamp, a pumpfun fork on base):
Some data sources are only able to return data given a 00:00:00 day timestamp. In that case you can use the parameter startOfDay
to get the timestamp of the specific day. For example passing 1663718399 (2022-09-20T23:59:59.000Z)
timestamp will return 1663632000000 (2022-09-20T00:00:00.000Z)