defi-data
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDefiLlama MCP Data Reference
DefiLlama MCP 数据参考文档
Tool Quick Reference
工具快速参考
| Question | Tool | Key Params |
|---|---|---|
| Total DeFi TVL, global volumes | | |
| Protocol TVL, fees, revenue | | |
| Chain TVL, gas fees, REV | | |
| Token price, mcap, ATH | | |
| Category rankings | | |
| Pool APY, lending rates | | |
| Stablecoin supply | | |
| ETF inflows/outflows | | |
| Bridge volume | | |
| CEX volume | | |
| Open interest | | |
| Hacks/exploits | | |
| Fundraising | | |
| Protocol events | | |
| Protocol treasury | | |
| Institutional holdings | | |
| Token unlocks | | |
| Token TVL in protocols | | |
| Oracle coverage | | |
| User activity | | |
| Income statement | | |
| Protocol metadata, URLs, audit | | |
| Chain metadata, type, L2 parent | | |
| List valid categories | | |
| Unknown entity slug | | |
| 问题 | 工具 | 关键参数 |
|---|---|---|
| DeFi总TVL、全球交易量 | | |
| 协议TVL、手续费、收入 | | |
| 链上TVL、gas手续费、收入 | | |
| 代币价格、市值、历史最高价 | | |
| 类别排名 | | |
| 池子年化收益率、借贷利率 | | |
| 稳定币供应量 | | |
| ETF资金流入/流出 | | |
| 跨链桥交易量 | | |
| 中心化交易所交易量 | | |
| 持仓量 | | |
| 黑客攻击/漏洞利用 | | |
| 融资事件 | | |
| 协议事件 | | |
| 协议国库 | | |
| 机构持仓 | | |
| 代币解锁 | | |
| 协议中的代币TVL | | |
| 预言机覆盖范围 | | |
| 用户活跃度 | | |
| 利润表 | | |
| 协议元数据、网址、审计信息 | | |
| 链上元数据、类型、Layer2母链 | | |
| 列出有效类别 | | |
| 未知实体别名 | | |
Entity Conventions
实体约定
- Protocols: lowercase-hyphenated slugs (,
aave,uniswap)compound-v3 - Chains: lowercase (,
ethereum,solana)arbitrum - Tokens: prefix (
coingecko:,coingecko:ethereum,coingecko:bitcoin)coingecko:usd-coin - CEX: slug includes suffix (,
binance-cex,coinbase-cex,htx)gate-io - Categories: Title case (,
Lending,DEX)Derivatives
- 协议:小写连字符格式的别名(、
aave、uniswap)compound-v3 - 链:小写格式(、
ethereum、solana)arbitrum - 代币:带有前缀(
coingecko:、coingecko:ethereum、coingecko:bitcoin)coingecko:usd-coin - 中心化交易所(CEX):别名包含后缀(、
binance-cex、coinbase-cex、htx)gate-io - 类别:标题大小写格式(、
Lending、DEX)Derivatives
Protocol vs Sub-Protocol
协议与子协议
Many protocols have multiple versions. The database tracks both:
- Parent protocol (e.g., ) — used in
aave, aggregates all versionsget_protocol_metrics - Sub-protocol (e.g., ) — individual versions, used in sub_protocol views
aave-v3
resolve_entityslugparent_protocolparent_protocolget_protocol_metricsslugExample: resolve_entity({name: "compound"}) returns:
- slug: compound-v2, parent_protocol: compound
- slug: compound-v3, parent_protocol: compound
→ Use in get_protocol_metrics for the aggregate.
protocol: "compound"
许多协议有多个版本,数据库同时跟踪两者:
- 父协议(例如)——用于
aave,汇总所有版本的数据get_protocol_metrics - 子协议(例如)——单个版本,用于子协议视图
aave-v3
resolve_entityslugparent_protocolget_protocol_metricsparent_protocolslug示例:resolve_entity({name: "compound"})返回:
- slug: compound-v2, parent_protocol: compound
- slug: compound-v3, parent_protocol: compound
→ 在get_protocol_metrics中使用获取汇总数据。
protocol: "compound"
Array Support
数组支持
All entity params accept single values or arrays for comparison:
- or
protocol: "aave"protocol: ["aave", "lido", "compound"] - or
chain: "ethereum"chain: ["ethereum", "solana"] - or
token: "coingecko:ethereum"token: ["coingecko:ethereum", "coingecko:bitcoin"]
所有实体参数接受单个值或数组用于对比:
- 或
protocol: "aave"protocol: ["aave", "lido", "compound"] - 或
chain: "ethereum"chain: ["ethereum", "solana"] - 或
token: "coingecko:ethereum"token: ["coingecko:ethereum", "coingecko:bitcoin"]
Entity Resolution
实体解析
Try tools directly for well-known entities — works 80%+ of the time. Use only when:
defillama:resolve_entity- Unsure of exact slug
- Tool returns 0 rows
- Need to disambiguate (e.g., "compound" → compound-v2, compound-v3)
- Need to find the parent_protocol slug
对于知名实体可直接调用工具——成功率达80%以上。仅在以下情况使用:
defillama:resolve_entity- 不确定确切的别名
- 工具返回0行数据
- 需要消除歧义(例如"compound" → compound-v2、compound-v3)
- 需要查找父协议的别名
Period Parameter
周期参数
All tools accept (NOT ):
periodtime_range- (default) -- latest snapshot
current - ,
7d,30d,90d,180d-- rolling windows365d
For custom date ranges, use and (YYYY-MM-DD format) instead of . If is set without , it defaults to today.
start_dateend_dateperiodstart_dateend_date所有工具接受参数(不支持):
periodtime_range- (默认值)——最新快照数据
current - 、
7d、30d、90d、180d——滚动时间窗口365d
如需自定义日期范围,请使用和(格式为YYYY-MM-DD)替代。如果仅设置未设置,默认结束日期为今日。
start_dateend_dateperiodstart_dateend_dateCritical Conventions
关键约定
Stock vs Flow
存量与流量
Different aggregation rules -- getting this wrong produces nonsensical results:
- Stock (point-in-time snapshots): ,
tvl,price-- NEVER sum across datesmcap - Flow (cumulative over period): ,
fees_1d,revenue_1d-- CAN sum across datesvolume
不同的聚合规则——如果搞错会产生无意义的结果:
- 存量(时点快照):、
tvl、price——绝不能跨日期求和mcap - 流量(周期累计值):、
fees_1d、revenue_1d——可以跨日期求和volume
Percentage Formatting
百分比格式
Two different conventions in the data:
- columns = decimals (e.g., -0.13 = -13%, 0.35 = +35%). Multiply by 100 for display.
*_pct_change - columns = already percentages (e.g., 2.32 = 2.32%). Do NOT multiply by 100.
apy
数据中有两种不同的格式约定:
- 列 = 小数形式(例如-0.13 = -13%,0.35 = +35%)。展示时需乘以100。
*_pct_change - 列 = 已为百分比形式(例如2.32 = 2.32%)。不要乘以100。
apy
TVL Components
TVL组成部分
Components are mutually exclusive -- never double-add:
- = default TVL (excludes liquid staking and double-counted)
tvl_base - = liquid staking portion not in tvl_base
tvl_ls_only - = double-counted portion not in tvl_base
tvl_dc_only - = both LS and DC
tvl_ls_and_dc - Total with LS+DC =
tvl_base + tvl_ls_only + tvl_dc_only + tvl_ls_and_dc
各组成部分互斥——切勿重复累加:
- = 默认TVL(不含流动性质押和重复统计部分)
tvl_base - = 未包含在tvl_base中的流动性质押部分
tvl_ls_only - = 未包含在tvl_base中的重复统计部分
tvl_dc_only - = 同时包含流动性质押和重复统计的部分
tvl_ls_and_dc - 包含流动性质押+重复统计的总TVL =
tvl_base + tvl_ls_only + tvl_dc_only + tvl_ls_and_dc
Fee and Revenue
手续费与收入
- = gross payments by users
fees - = protocol's cut (fees - payments to LPs/stakers)
revenue - = buybacks + dividends to token holders
holder_revenue - Chain-level: (gas),
chain_fees,chain_revenue,chain_mev(protocol fees on chain),app_feesapp_revenue
- = 用户支付的总费用
fees - = 协议留存部分(手续费 - 支付给流动性提供者/质押者的费用)
revenue - = 回购+分配给代币持有者的分红
holder_revenue - 链上层面:(gas费)、
chain_fees、chain_revenue、chain_mev(链上协议手续费)、app_feesapp_revenue
Metric Name Patterns
指标名称模式
Protocol metrics follow these patterns:
- TVL: ,
tvl_base,tvl_staking,tvl_borrowed,tvl_pool2,tvl_treasurytvl_vesting - Flows (with suffixes ):
_1d/_7d/_30d/_90d/_180d/_365d/_ytd/_alltime/_annualised,fees,revenue,holder_revenueincentive - Volume (same suffixes): ,
volume_dexs,volume_aggregators,volume_derivatives,volume_aggr_derivativesvolume_options - Market: ,
price,mcap,fdv,fdv_outstanding,token_volume,ps_ratiopf_ratio - pct_change variants only available on views
_current
Chain metrics use , , , , instead of , .
chain_feeschain_revenuechain_mevapp_feesapp_revenuefeesrevenueDaily views only have the suffix for flows/volumes.
_1d协议指标遵循以下模式:
- TVL:、
tvl_base、tvl_staking、tvl_borrowed、tvl_pool2、tvl_treasurytvl_vesting - 流量(带有后缀):
_1d/_7d/_30d/_90d/_180d/_365d/_ytd/_alltime/_annualised、fees、revenue、holder_revenueincentive - 交易量(相同后缀):、
volume_dexs、volume_aggregators、volume_derivatives、volume_aggr_derivativesvolume_options - 市场指标:、
price、mcap、fdv、fdv_outstanding、token_volume、ps_ratiopf_ratio - 变体仅在
pct_change视图中可用_current
链上指标使用、、、、替代、。
chain_feeschain_revenuechain_mevapp_feesapp_revenuefeesrevenue每日视图中的流量/交易量仅带有后缀。
_1dImportant Gotchas
重要注意事项
- Category column: has NO category column. Use
get_protocol_metricsfor category-level data.get_category_metrics - FDV: Never sort by FDV -- unreliable data produces junk rankings. Sort by
total_supplyinstead.mcap - Valuation: = mcap / annualised revenue.
ps_ratio= mcap / annualised fees. Lower = potentially undervalued.pf_ratio - Metric validation: Protocol/chain/category metrics are validated against actual DB columns. Invalid metrics return a suggestion for the closest match.
- NULL values: NULL means data unavailable, NOT $0. Do not report NULL as zero.
- Params accept string or array: or
protocol: "aave". Param names are singular (protocol: ["aave", "lido"]notprotocol).protocols - sort_by format: String like or
"tvl_base desc"."fees_1d desc"
- 类别列:没有类别列。如需类别层面的数据,请使用
get_protocol_metrics。get_category_metrics - FDV:切勿按FDV排序——不可靠的数据会产生无效排名。请改用
total_supply排序。mcap - 估值:= 市值 / 年化收入。
ps_ratio= 市值 / 年化手续费。数值越低,可能被低估。pf_ratio - 指标验证:协议/链/类别指标会与实际数据库列进行验证。无效指标会返回最接近的匹配建议。
- NULL值:NULL表示数据不可用,不是0。请勿将NULL报告为0。
- 参数接受字符串或数组:或
protocol: "aave"。参数名称为单数形式(protocol: ["aave", "lido"]而非protocol)。protocols - sort_by格式:字符串格式,例如或
"tvl_base desc"。"fees_1d desc"
Examples
示例
Example 1:
User: "What is Aave's TVL?"
Tool call:
defillama:get_protocol_metrics(protocol: "aave", metrics: ["tvl_base"])Example 2:
User: "Top 5 chains by fees"
Tool call:
defillama:get_chain_metrics(sort_by: "chain_fees_1d desc", limit: 5)Example 3:
User: "ETH price history over 90 days"
Tool call:
defillama:get_token_prices(token: "coingecko:ethereum", period: "90d")Example 4:
User: "Compare ETH price and Ethereum chain TVL"
Tool calls in parallel:
defillama:get_token_prices(token: "coingecko:ethereum")defillama:get_chain_metrics(chain: "ethereum")
Example 5:
User: "Biggest DeFi hacks this year"
Tool call:
defillama:get_events(event_type: "hacks", sort_by: "amount desc", limit: 10, period: "365d")Example 6:
User: "Aave TVL from Jan to Mar 2025"
Tool call:
defillama:get_protocol_metrics(protocol: "aave", metrics: ["tvl_base"], start_date: "2025-01-01", end_date: "2025-03-31")示例1:
用户:“Aave的TVL是多少?”
工具调用:
defillama:get_protocol_metrics(protocol: "aave", metrics: ["tvl_base"])示例2:
用户:“手续费最高的5条链”
工具调用:
defillama:get_chain_metrics(sort_by: "chain_fees_1d desc", limit: 5)示例3:
用户:“过去90天ETH的价格历史”
工具调用:
defillama:get_token_prices(token: "coingecko:ethereum", period: "90d")示例4:
用户:“对比ETH价格和以太坊链的TVL”
并行调用工具:
defillama:get_token_prices(token: "coingecko:ethereum")defillama:get_chain_metrics(chain: "ethereum")
示例5:
用户:“今年最大的DeFi黑客攻击事件”
工具调用:
defillama:get_events(event_type: "hacks", sort_by: "amount desc", limit: 10, period: "365d")示例6:
用户:“2025年1月至3月Aave的TVL”
工具调用:
defillama:get_protocol_metrics(protocol: "aave", metrics: ["tvl_base"], start_date: "2025-01-01", end_date: "2025-03-31")Error Recovery
错误恢复
- 0 rows returned -> call -> retry with the correct slug
defillama:resolve_entity(name: "...") - Wrong data -> verify you're using the right tool (protocol vs chain vs category)
- Ambiguous entity -> call to see all matching slugs, then pick the right one
resolve_entity
- 返回0行数据 -> 调用-> 使用正确的别名重试
defillama:resolve_entity(name: "...") - 数据错误 -> 验证是否使用了正确的工具(协议/链/类别)
- 实体歧义 -> 调用查看所有匹配的别名,然后选择正确的一个
resolve_entity