All scripts have a ton of legacy code / debt as needs have evolved over time.
We currently use Defillama TVL scripts to:
1) Get the total TVL of all chains (chain level API) - We want to use Defillama's double counting filters, so we use the chain-level API, rather than summing up the breakdown API (which would lead to double counting)
2) Breakdown TVL by app, category, token, token type, etc
Future State
We should migrate these scripts to the new subcommands structure & simplify the data pulls, where we're not doing any calculations at the ingestion level, just pulling data and storing it.
Store results
Note: This creates huge datasets, so we may need to push to BQ by protocol? We've also observed some larger protocols not return data (i.e. uniswap-v3), ~possibly because of github actions memory limits. So tbd if we'll need to figure out other utilities/solutions.
Note - take 00:00:00 timestamps to reduce dupes
Metadata
Scrape it
Store results
Next steps
Once we have the raw data, we can build charts like "net flows" versus "token price movement" to indicate higher signal TVL movements due to actual transfers.
We can also build dashboards to evaluate raw TVL and/or flows at the category level, using Defillama's categories and/or building our own.
We can also categorize tokens (i.e. liquid staking, wrapped bitcoin, gas tokens) to track TVL metrics by these token categories
Other considerations
These endpoints give us token symbol, but not contract address. So we may need to eventually request or map these tokens to contract addresses, for future metrics such as "TVL of interoperable assets"
Current State Defillama API pulls live in two places:
Note that we also scrape Defillama's normalizeChain file to get chain metadata (i.e. chainId, tags) for segmenting and joining with other data sources: https://github.com/DefiLlama/defillama-server/blob/master/defi/src/utils/normalizeChain.ts
All scripts have a ton of legacy code / debt as needs have evolved over time.
We currently use Defillama TVL scripts to: 1) Get the total TVL of all chains (chain level API) - We want to use Defillama's double counting filters, so we use the chain-level API, rather than summing up the breakdown API (which would lead to double counting) 2) Breakdown TVL by app, category, token, token type, etc
Future State We should migrate these scripts to the new subcommands structure & simplify the data pulls, where we're not doing any calculations at the ingestion level, just pulling data and storing it.
Steps: Chain-Level
Full breakdown
Metadata
Next steps Once we have the raw data, we can build charts like "net flows" versus "token price movement" to indicate higher signal TVL movements due to actual transfers.
We can also build dashboards to evaluate raw TVL and/or flows at the category level, using Defillama's categories and/or building our own.
We can also categorize tokens (i.e. liquid staking, wrapped bitcoin, gas tokens) to track TVL metrics by these token categories
Other considerations These endpoints give us token symbol, but not contract address. So we may need to eventually request or map these tokens to contract addresses, for future metrics such as "TVL of interoperable assets"