Sub topic 9
What TVL measures and what it leaves out
This chapter assumes you know what an ERC-20 token is, how a lending pool or automated market maker (AMM) holds user deposits, and what a smart contract balance is. It also assumes you have seen the DefiLlama site from the previous chapter. By the end you should be able to say exactly what a TVL number counts. You should also be able to say where it misleads, and which DefiLlama settings change it.
The definition
Total value locked (TVL) is the USD value of the tokens held by a protocol's smart contracts. The calculation has two steps:
- Read the token balances that the protocol's contracts hold.
- Multiply each balance by a USD price and add the results.
TVL is therefore a stock, not a flow. It is a snapshot of what sits in contracts at one moment, not what was traded, earned or borrowed during a period. Trading volume and fees are flows. Chapter-level mistakes often come from comparing a stock with a flow, such as asking why a protocol has high TVL but low fees.
How DefiLlama computes it
DefiLlama does not take TVL from the protocols. Each protocol has an adapter, a small piece of open-source code in the DefiLlama-Adapters repository on GitHub. The adapter lists the contracts to read and the tokens to count. DefiLlama runs the adapters on a schedule, then prices the balances.
Two properties follow from this design:
- The number is only as good as the adapter. If an adapter misses a contract or a token, TVL is understated. If it counts something it should not, TVL is overstated. Anyone can read the adapter, so you can audit a figure.
- The price source matters as much as the balance. A token with no reliable price is usually left out or valued at zero.
Price moves change TVL without any deposit or withdrawal
Most TVL swings in volatile markets come from prices, not from users moving funds. The script below uses invented numbers, no network access, and shows the effect.
balances = {"ETH": 10_000, "USDC": 5_000_000}
def tvl(prices):
return sum(amount * prices[token] for token, amount in balances.items())
before = tvl({"ETH": 3000, "USDC": 1})
after = tvl({"ETH": 2400, "USDC": 1})
print(f"TVL at ETH=$3000: ${before:,.0f}")
print(f"TVL at ETH=$2400: ${after:,.0f}")
print(f"Change: {(after / before - 1):.1%} with zero deposits or withdrawals")Running it prints a drop of 17.1%, from $35,000,000 to $29,000,000, while the token amounts never changed. When a protocol's TVL falls, check the token-denominated view before concluding that users left. DefiLlama's charts let you switch the display to token amounts for a protocol.
A protocol that holds mostly volatile assets will show larger TVL swings than one holding stablecoins, even if user behaviour is identical.
What is counted by default, and what is split out
DefiLlama separates several categories of value, and the headline TVL does not include all of them. The dashboard settings let you toggle them. Exact defaults can change, so check the settings panel rather than relying on memory.
| Category | What it is | Why it is separated |
|---|---|---|
| Borrowed | Tokens that users have borrowed out of lending markets | The tokens already left the contract. Counting them would count the same value as both deposit and loan. |
| Staking | A protocol's own governance token locked in its staking contract | The value depends on the token's own price, which the protocol can create at will. |
| Pool2 | Liquidity pool positions that pair the protocol's own token with another asset | The same own-token price problem applies. |
| Liquid staking | Protocols that issue a receipt token for staked assets | Receipt tokens are often deposited again elsewhere, which causes double counting. |
| Double counted | Value that is already counted in another protocol's TVL | Summing across protocols would otherwise count it twice. |
The own-token rule deserves attention. If a protocol mints a billion tokens, stakes half of them, and the market prices them at $1, it could show $500 million of "locked" value that no outside user ever paid for. Separating own-token value keeps the headline figure closer to external capital.
Double counting in practice
Double counting happens because DeFi positions stack. You deposit ETH into Protocol A and receive a receipt token. You then deposit that receipt token into Protocol B. Both protocols hold something worth the same underlying ETH, and each reports it as TVL. Adding the two TVLs counts the same ETH twice.
The next script shows the arithmetic, using the earlier price of $3000 per ETH.
eth_price = 3000
protocol_a_tvl = 10_000 * eth_price + 5_000_000 # ETH plus USDC held by A
receipts_in_b = 4_000 # A's receipt tokens, redeemable 1:1 for ETH
protocol_b_tvl = receipts_in_b * eth_price
naive_total = protocol_a_tvl + protocol_b_tvl
deduplicated = protocol_a_tvl # B's holdings are already inside A
print(f"Naive sum: ${naive_total:,.0f}")
print(f"Deduplicated: ${deduplicated:,.0f}")
print(f"Overstatement: ${naive_total - deduplicated:,.0f}")The naive sum is $47,000,000 against a true $35,000,000 of distinct assets. The gap is the $12,000,000 that Protocol B holds as receipts. At the scale of the whole ecosystem, stacked positions such as liquid staking tokens used as collateral can inflate a sum-of-protocols figure by a large margin.
Chain TVL and bridged assets
Chain TVL is the sum of protocol TVL on that chain. It does not measure how many assets exist on the chain. Two effects matter:
- Assets that arrive through a bridge are counted where they are deposited into a protocol, not where they were issued. A token locked on Ethereum and represented on another chain can show up in protocol TVL on the second chain while the original also sits in a bridge contract.
- A chain with many protocols that wrap each other will rank higher than a chain with fewer, simpler protocols holding the same real capital.
For this reason, use chain TVL for rough ranking and trend, not for precise comparisons between chains with very different structures.
What TVL leaves out
TVL says nothing about several things people often read into it:
- Usage. A lending pool can hold $1 billion that nobody trades against. Volume and fees measure activity, and the next chapter covers them.
- Revenue and profitability. Two protocols with equal TVL can earn very different fees. Dividing fees by TVL gives a capital-efficiency view, not TVL alone.
- Risk. TVL does not show smart contract risk, oracle risk, or how concentrated deposits are among a few wallets.
- User count. One whale can account for most of a protocol's TVL.
- Incentives. Token rewards can attract deposits that leave as soon as the rewards stop. High TVL during a rewards campaign may not last.
- Non-custodial positions. Value that never enters a protocol contract, such as tokens in a user's own wallet, is not counted by design.
Reading a TVL claim critically
When you see a TVL figure in a report or chart, ask these questions in order:
- Which date, and which price source?
- Were borrowed, staking, pool2 and double-counted values included or excluded?
- Is the change driven by token prices or by token amounts?
- Is the figure for one protocol, one chain, or an aggregate that may double count?
- Is the number in USD, or in the chain's native token?
If a claim does not answer these, treat it as approximate.
Where Dune fits
You can recompute a simple TVL on Dune by summing token balances held by a contract address and multiplying by a price. Doing so shows you how many choices the calculation hides, such as which contracts to include and which price table to use. The final chapters use that exercise to cross-check Dune against DefiLlama and to explain gaps.
Exercise
A lending protocol's TVL falls 20% in a week. The amount of every token it holds is unchanged, and ETH, its main asset, fell 20% in price. Did users withdraw funds? Name two other things you would check before reporting its health.
Show answer
No. With unchanged token amounts, the whole drop comes from the lower ETH price, so users did not withdraw. Before reporting health, check the token-denominated balance to confirm that amounts were flat, and check borrowed value and fees. A drop in borrows or fees would show falling usage even when deposits stayed in place. Checking whether deposits are concentrated in a few wallets would also help.
Exercise
Protocol X holds 2,000 ETH and issues a receipt token for each. Protocol Y holds 500 of those receipt tokens. ETH costs $2,000. What is the naive combined TVL of X and Y, and what is the deduplicated figure?
Show answer
X holds 2,000 × $2,000 = $4,000,000. Y holds 500 receipts worth 500 × $2,000 = $1,000,000. The naive sum is $5,000,000. The deduplicated figure is $4,000,000, because Y's receipts are claims on ETH that X already counts.