defi-data

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

DefiLlama MCP Data Reference

DefiLlama MCP 数据参考文档

Tool Quick Reference

工具快速参考

QuestionToolKey Params
Total DeFi TVL, global volumes
defillama:get_market_totals
metrics
(tvl_base, volume_dexs_1d, etc.)
Protocol TVL, fees, revenue
defillama:get_protocol_metrics
protocol
,
metrics
Chain TVL, gas fees, REV
defillama:get_chain_metrics
chain
,
metrics
Token price, mcap, ATH
defillama:get_token_prices
token
Category rankings
defillama:get_category_metrics
category
Pool APY, lending rates
defillama:get_yield_pools
token
,
chain
,
category
Stablecoin supply
defillama:get_stablecoin_supply
stablecoin
,
chain
ETF inflows/outflows
defillama:get_etf_flows
token
(bitcoin/ethereum)
Bridge volume
defillama:get_bridge_flows
bridge
,
chain
CEX volume
defillama:get_cex_volumes
cex
Open interest
defillama:get_open_interest
protocol
,
chain
Hacks/exploits
defillama:get_events
event_type: "hacks"
Fundraising
defillama:get_events
event_type: "raises"
Protocol events
defillama:get_events
event_type: "protocol_events"
Protocol treasury
defillama:get_treasury
treasury
Institutional holdings
defillama:get_dat_holdings
institution
,
token
Token unlocks
defillama:get_token_unlocks
token
,
query_type
(chart, window, day, window_all, ratio, market_window)
Token TVL in protocols
defillama:get_token_tvl
token
,
protocol
Oracle coverage
defillama:get_oracle_metrics
oracle
User activity
defillama:get_user_activity
protocol
,
chain
Income statement
defillama:get_income_statement
protocol
Protocol metadata, URLs, audit
defillama:get_protocol_info
protocol
,
category
,
tag
,
has_token
,
chain
Chain metadata, type, L2 parent
defillama:get_chain_info
chain
,
chain_type
List valid categories
defillama:list_categories
type
(protocol, token, chain)
Unknown entity slug
defillama:resolve_entity
name
问题工具关键参数
DeFi总TVL、全球交易量
defillama:get_market_totals
metrics
(tvl_base、volume_dexs_1d等)
协议TVL、手续费、收入
defillama:get_protocol_metrics
protocol
metrics
链上TVL、gas手续费、收入
defillama:get_chain_metrics
chain
metrics
代币价格、市值、历史最高价
defillama:get_token_prices
token
类别排名
defillama:get_category_metrics
category
池子年化收益率、借贷利率
defillama:get_yield_pools
token
chain
category
稳定币供应量
defillama:get_stablecoin_supply
stablecoin
chain
ETF资金流入/流出
defillama:get_etf_flows
token
(bitcoin/ethereum)
跨链桥交易量
defillama:get_bridge_flows
bridge
chain
中心化交易所交易量
defillama:get_cex_volumes
cex
持仓量
defillama:get_open_interest
protocol
chain
黑客攻击/漏洞利用
defillama:get_events
event_type: "hacks"
融资事件
defillama:get_events
event_type: "raises"
协议事件
defillama:get_events
event_type: "protocol_events"
协议国库
defillama:get_treasury
treasury
机构持仓
defillama:get_dat_holdings
institution
token
代币解锁
defillama:get_token_unlocks
token
query_type
(chart、window、day、window_all、ratio、market_window)
协议中的代币TVL
defillama:get_token_tvl
token
protocol
预言机覆盖范围
defillama:get_oracle_metrics
oracle
用户活跃度
defillama:get_user_activity
protocol
chain
利润表
defillama:get_income_statement
protocol
协议元数据、网址、审计信息
defillama:get_protocol_info
protocol
category
tag
has_token
chain
链上元数据、类型、Layer2母链
defillama:get_chain_info
chain
chain_type
列出有效类别
defillama:list_categories
type
(protocol、token、chain)
未知实体别名
defillama:resolve_entity
name

Entity Conventions

实体约定

  • Protocols: lowercase-hyphenated slugs (
    aave
    ,
    uniswap
    ,
    compound-v3
    )
  • Chains: lowercase (
    ethereum
    ,
    solana
    ,
    arbitrum
    )
  • Tokens:
    coingecko:
    prefix (
    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.,
    aave
    ) — used in
    get_protocol_metrics
    , aggregates all versions
  • Sub-protocol (e.g.,
    aave-v3
    ) — individual versions, used in sub_protocol views
resolve_entity
returns both
slug
(sub-protocol) and
parent_protocol
. Use
parent_protocol
for
get_protocol_metrics
. Use
slug
when you need a specific version.
Example: resolve_entity({name: "compound"}) returns:
  • slug: compound-v2, parent_protocol: compound
  • slug: compound-v3, parent_protocol: compound → Use
    protocol: "compound"
    in get_protocol_metrics for the aggregate.
许多协议有多个版本,数据库同时跟踪两者:
  • 父协议(例如
    aave
    )——用于
    get_protocol_metrics
    ,汇总所有版本的数据
  • 子协议(例如
    aave-v3
    )——单个版本,用于子协议视图
resolve_entity
会返回
slug
(子协议)和
parent_protocol
(父协议)。调用
get_protocol_metrics
时使用
parent_protocol
。需要特定版本时使用
slug
示例: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:
  • protocol: "aave"
    or
    protocol: ["aave", "lido", "compound"]
  • chain: "ethereum"
    or
    chain: ["ethereum", "solana"]
  • token: "coingecko:ethereum"
    or
    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
defillama:resolve_entity
only when:
  • 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
period
(NOT
time_range
):
  • current
    (default) -- latest snapshot
  • 7d
    ,
    30d
    ,
    90d
    ,
    180d
    ,
    365d
    -- rolling windows
For custom date ranges, use
start_date
and
end_date
(YYYY-MM-DD format) instead of
period
. If
start_date
is set without
end_date
, it defaults to today.
所有工具接受
period
参数(不支持
time_range
):
  • current
    (默认值)——最新快照数据
  • 7d
    30d
    90d
    180d
    365d
    ——滚动时间窗口
如需自定义日期范围,请使用
start_date
end_date
(格式为YYYY-MM-DD)替代
period
。如果仅设置
start_date
未设置
end_date
,默认结束日期为今日。

Critical Conventions

关键约定

Stock vs Flow

存量与流量

Different aggregation rules -- getting this wrong produces nonsensical results:
  • Stock (point-in-time snapshots):
    tvl
    ,
    price
    ,
    mcap
    -- NEVER sum across dates
  • Flow (cumulative over period):
    fees_1d
    ,
    revenue_1d
    ,
    volume
    -- CAN sum across dates
不同的聚合规则——如果搞错会产生无意义的结果:
  • 存量(时点快照):
    tvl
    price
    mcap
    ——绝不能跨日期求和
  • 流量(周期累计值):
    fees_1d
    revenue_1d
    volume
    ——可以跨日期求和

Percentage Formatting

百分比格式

Two different conventions in the data:
  • *_pct_change
    columns = decimals (e.g., -0.13 = -13%, 0.35 = +35%). Multiply by 100 for display.
  • apy
    columns = already percentages (e.g., 2.32 = 2.32%). Do NOT multiply by 100.
数据中有两种不同的格式约定:
  • *_pct_change
    列 = 小数形式(例如-0.13 = -13%,0.35 = +35%)。展示时需乘以100。
  • apy
    列 = 已为百分比形式(例如2.32 = 2.32%)。不要乘以100。

TVL Components

TVL组成部分

Components are mutually exclusive -- never double-add:
  • tvl_base
    = default TVL (excludes liquid staking and double-counted)
  • tvl_ls_only
    = liquid staking portion not in tvl_base
  • tvl_dc_only
    = double-counted portion not in tvl_base
  • tvl_ls_and_dc
    = both LS and DC
  • Total with LS+DC =
    tvl_base + tvl_ls_only + tvl_dc_only + tvl_ls_and_dc
各组成部分互斥——切勿重复累加:
  • tvl_base
    = 默认TVL(不含流动性质押和重复统计部分)
  • tvl_ls_only
    = 未包含在tvl_base中的流动性质押部分
  • tvl_dc_only
    = 未包含在tvl_base中的重复统计部分
  • tvl_ls_and_dc
    = 同时包含流动性质押和重复统计的部分
  • 包含流动性质押+重复统计的总TVL =
    tvl_base + tvl_ls_only + tvl_dc_only + tvl_ls_and_dc

Fee and Revenue

手续费与收入

  • fees
    = gross payments by users
  • revenue
    = protocol's cut (fees - payments to LPs/stakers)
  • holder_revenue
    = buybacks + dividends to token holders
  • Chain-level:
    chain_fees
    (gas),
    chain_revenue
    ,
    chain_mev
    ,
    app_fees
    (protocol fees on chain),
    app_revenue
  • fees
    = 用户支付的总费用
  • revenue
    = 协议留存部分(手续费 - 支付给流动性提供者/质押者的费用)
  • holder_revenue
    = 回购+分配给代币持有者的分红
  • 链上层面:
    chain_fees
    (gas费)、
    chain_revenue
    chain_mev
    app_fees
    (链上协议手续费)、
    app_revenue

Metric Name Patterns

指标名称模式

Protocol metrics follow these patterns:
  • TVL:
    tvl_base
    ,
    tvl_staking
    ,
    tvl_borrowed
    ,
    tvl_pool2
    ,
    tvl_treasury
    ,
    tvl_vesting
  • Flows (with suffixes
    _1d/_7d/_30d/_90d/_180d/_365d/_ytd/_alltime/_annualised
    ):
    fees
    ,
    revenue
    ,
    holder_revenue
    ,
    incentive
  • Volume (same suffixes):
    volume_dexs
    ,
    volume_aggregators
    ,
    volume_derivatives
    ,
    volume_aggr_derivatives
    ,
    volume_options
  • Market:
    price
    ,
    mcap
    ,
    fdv
    ,
    fdv_outstanding
    ,
    token_volume
    ,
    ps_ratio
    ,
    pf_ratio
  • pct_change variants only available on
    _current
    views
Chain metrics use
chain_fees
,
chain_revenue
,
chain_mev
,
app_fees
,
app_revenue
instead of
fees
,
revenue
.
Daily views only have the
_1d
suffix for flows/volumes.
协议指标遵循以下模式:
  • TVL
    tvl_base
    tvl_staking
    tvl_borrowed
    tvl_pool2
    tvl_treasury
    tvl_vesting
  • 流量(带有后缀
    _1d/_7d/_30d/_90d/_180d/_365d/_ytd/_alltime/_annualised
    ):
    fees
    revenue
    holder_revenue
    incentive
  • 交易量(相同后缀):
    volume_dexs
    volume_aggregators
    volume_derivatives
    volume_aggr_derivatives
    volume_options
  • 市场指标
    price
    mcap
    fdv
    fdv_outstanding
    token_volume
    ps_ratio
    pf_ratio
  • pct_change
    变体仅在
    _current
    视图中可用
链上指标使用
chain_fees
chain_revenue
chain_mev
app_fees
app_revenue
替代
fees
revenue
每日视图中的流量/交易量仅带有
_1d
后缀。

Important Gotchas

重要注意事项

  • Category column:
    get_protocol_metrics
    has NO category column. Use
    get_category_metrics
    for category-level data.
  • FDV: Never sort by FDV -- unreliable
    total_supply
    data produces junk rankings. Sort by
    mcap
    instead.
  • Valuation:
    ps_ratio
    = mcap / annualised revenue.
    pf_ratio
    = mcap / annualised fees. Lower = potentially undervalued.
  • 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:
    protocol: "aave"
    or
    protocol: ["aave", "lido"]
    . Param names are singular (
    protocol
    not
    protocols
    ).
  • sort_by format: String like
    "tvl_base desc"
    or
    "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

错误恢复

  1. 0 rows returned -> call
    defillama:resolve_entity(name: "...")
    -> retry with the correct slug
  2. Wrong data -> verify you're using the right tool (protocol vs chain vs category)
  3. Ambiguous entity -> call
    resolve_entity
    to see all matching slugs, then pick the right one
  1. 返回0行数据 -> 调用
    defillama:resolve_entity(name: "...")
    -> 使用正确的别名重试
  2. 数据错误 -> 验证是否使用了正确的工具(协议/链/类别)
  3. 实体歧义 -> 调用
    resolve_entity
    查看所有匹配的别名,然后选择正确的一个