Sub topic 10
Volume, fees, yields and stablecoin dashboards
This chapter assumes you can read a JSON response in Python and that you know what TVL is from the previous chapter. It also assumes you know what an automated market maker (AMM) is and how an ERC-20 token works. The chapter covers four DefiLlama dashboard families that answer questions TVL can't: how much trading happens, how much money protocols earn, what depositors can earn, and how much stablecoin supply exists.
Why TVL is not enough
TVL is a stock, a balance measured at one moment. The four metrics here are mostly flows (volume, fees) or rates (yields), plus one stock for stablecoins (supply). Two protocols can both hold $1B in TVL while one processes $5M of trades a day and the other $500M. TVL alone can't tell them apart.
| Metric | Type | Question it answers | Typical unit |
|---|---|---|---|
| DEX volume | Flow | How much was traded in a period? | USD per day |
| Fees | Flow | How much did users pay to use the protocol? | USD per day |
| Revenue | Flow | How much of those fees does the protocol keep? | USD per day |
| Yield (APY) | Rate | What does a depositor earn per year? | Percent |
| Stablecoin supply | Stock | How much of each stablecoin is circulating? | USD |
DEX volume
DefiLlama's DEX volume pages sum the value of swaps executed by each protocol. The numbers come from per-protocol adapters. Each adapter is a small piece of code that reads swap events, or a protocol's own API, and converts amounts to USD. Windows are reported as 24-hour, 7-day and 30-day totals, plus a daily history you can chart.
Related dashboards use the same approach for other activity: perpetuals volume, derivatives, aggregators and options. Keep them separate. An aggregator routes trades through other DEXs, so adding aggregator volume to DEX volume counts the same trade twice. This is the double counting problem from the pitfalls chapter, and it shows up in dashboards you build yourself as well.
Volume has limits as a signal:
- Wash trading. A trader who swaps back and forth with themselves inflates volume while paying only fees. This is most visible on chains or venues with trading rewards.
- Routing. One user swap can touch several pools. If you count every pool hop, you count the same value more than once. Dune's
dex.tradestable has the same issue with multi-hop routes, so check how your table treats them. - Price conversion. Volume in USD depends on the token prices used. A thin, manipulated token price distorts the USD figure.
Fees and revenue
Fees and revenue are not the same thing, and mixing them up is the most common error on these dashboards. DefiLlama separates them:
- Fees are everything users pay: swap fees, borrowing interest, liquidation penalties, and so on.
- Supply-side revenue is the portion paid to liquidity providers or lenders.
- Protocol revenue is the portion kept by the protocol or its treasury.
- Holders revenue is the portion distributed to token holders, through buybacks, burns or dividends.
A concrete case: a DEX charges 0.3% per swap on $100M of volume, so fees are $300,000. If the protocol takes one sixth of that, protocol revenue is $50,000 and supply-side revenue is $250,000. A protocol with high fees and low revenue is paying most of the value to LPs, which is not a defect. It is a different design.
Yields
The yields dashboard lists individual pools, each with a chain, a project, a token symbol, TVL and an APY. APY is the annual percentage yield, which assumes earnings compound. Two fields matter most:
apyBaseis the yield from real activity such as swap fees or borrow interest.apyRewardis the yield from token incentives that the protocol emits to attract deposits.
The total apy is their sum. Treat the two parts differently. Base yield comes from users paying for a service. Reward yield is paid in the protocol's own token, whose price can fall, so a 40% reward APY can be worth much less by the time you sell the token.
Other fields to read before trusting a number:
tvlUsd: a pool with $20,000 of TVL can show 900% APY because one trade moved the ratio. Filter small pools out.ilRiskandexposure: they flag impermanent loss risk and whether the pool holds one asset or several. Impermanent loss is the value you lose compared with simply holding the tokens when prices diverge.stablecoin: a boolean that marks pools made only of stablecoins.apyMean30d: a 30-day average that smooths out one-day spikes.
Yields are a snapshot of current conditions, not a forecast. They change hourly as deposits and trading volume change.
Stablecoin dashboards
The stablecoins section tracks the circulating supply of each stablecoin, broken out by chain. Several fields shape how you read it:
- Circulating supply is the amount issued and not burned. For a USD-pegged coin, supply in tokens roughly equals supply in dollars.
- Peg mechanism groups coins as fiat-backed (reserves held by an issuer), crypto-backed (overcollateralized on-chain) or algorithmic. The groups carry different failure modes.
- Peg type says what the coin tracks, for example USD or EUR. Don't sum coins with different peg types as if they were all dollars.
- Price shows how far the coin trades from its target. A coin at $0.97 has lost its peg even if its supply looks stable.
Chain breakdowns can double count. When a stablecoin is bridged from Ethereum to another chain, the tokens locked on Ethereum and the wrapped copies on the destination can both appear in supply figures if you add chains together without checking how the dashboard treats bridged amounts. Use the dashboard's own totals instead of rebuilding them from chain rows.
Supply is also not activity. A coin can have $30B in circulation and few transfers, while a smaller coin moves more value each day. The USDC transfer query from the Dune chapters measures activity. DefiLlama's stablecoin pages measure supply. They answer different questions.
Pulling the data with the API
All of these dashboards are backed by public endpoints. The yields endpoint lives on its own host, yields.llama.fi. This script finds the highest-APY stablecoin pools with meaningful TVL and splits their base and reward yield.
import requests
resp = requests.get("https://yields.llama.fi/pools", timeout=60)
resp.raise_for_status()
pools = resp.json()["data"]
MIN_TVL = 10_000_000 # ignore small pools whose APY is noise
candidates = [
p for p in pools
if p.get("stablecoin")
and (p.get("tvlUsd") or 0) >= MIN_TVL
and p.get("apy") is not None
]
candidates.sort(key=lambda p: p["apy"], reverse=True)
print(f"{'project':<22}{'chain':<12}{'symbol':<18}{'TVL $M':>8}{'base %':>8}{'reward %':>10}")
for p in candidates[:10]:
base = p.get("apyBase") or 0.0
reward = p.get("apyReward") or 0.0
print(
f"{p['project']:<22}{p['chain']:<12}{p['symbol'][:17]:<18}"
f"{p['tvlUsd'] / 1e6:>8,.1f}{base:>8.2f}{reward:>10.2f}"
)Note the or 0.0 guards. Pools often return null for apyBase or apyReward, and arithmetic on None raises a TypeError. The same habit helps with volume and fees. The overview endpoints return a total24h and a list of protocols, and either may be missing for protocols that failed an update.
import requests
BASE = "https://api.llama.fi/overview"
def top_by_24h(kind, n=5):
resp = requests.get(f"{BASE}/{kind}", timeout=60)
resp.raise_for_status()
data = resp.json()
rows = [p for p in data["protocols"] if p.get("total24h")]
rows.sort(key=lambda p: p["total24h"], reverse=True)
return data.get("total24h"), rows[:n]
for kind in ("dexs", "fees"):
total, rows = top_by_24h(kind)
print(f"\n{kind}: total 24h = ${(total or 0) / 1e6:,.0f}M")
for p in rows:
print(f" {p['name']:<25} ${p['total24h'] / 1e6:>8,.1f}M")Reading these dashboards well
Keep this checklist in mind when you read or build any of these views:
- Confirm the unit and window: USD or native token, 24 hours or 30 days, daily or cumulative.
- Separate fees from revenue before comparing two protocols.
- Split yield into base and reward, and filter by TVL.
- Check whether a chain or category total already includes routed or bridged amounts.
- Compare against a second source. The next chapters show how to check DefiLlama volume against Dune's
dex.trades.
Exercise
A DEX processed $200M of volume yesterday with a 0.25% swap fee. The protocol keeps 20% of fees and the rest goes to liquidity providers. What are the fees, protocol revenue and supply-side revenue? Then explain why a pool showing 120% APY with $15,000 TVL should not drive a decision.
Show answer
Fees are 0.25% of $200M, which is $500,000. Protocol revenue is 20% of that, $100,000. Supply-side revenue is the remaining 80%, $400,000. The 120% APY pool has too little TVL for the figure to be stable, because a single trade or deposit can shift the ratio sharply. Part of the yield may also be token rewards that lose value. Filter by a TVL minimum and split base from reward yield before comparing.
Exercise
You add the "DEX volume" and "aggregator volume" dashboards together to estimate total trading on a chain. What is wrong with this, and what does the stablecoin equivalent of this mistake look like?
Show answer
Aggregators route trades through DEXs, so the same trade appears in both figures and the sum counts it twice. The stablecoin version is summing a coin's supply across chains without checking for bridged copies, which counts the same tokens once on the origin chain and again on the destination chain.