跳转到主要内容

Documentation Index

Fetch the complete documentation index at: https://docs.chainstream.io/llms.txt

Use this file to discover all available pages before exploring further.

DEXTrades Cube 包含逐笔 DEX 兑换事件,是粒度最细的成交数据。可用于查询单笔交易、分析钱包行为、跟踪代币价格以及查找头部交易者。
以下示例均使用 network: sol(Solana)。其他支持的链可改为 ethbscpolygon

如何获取最新的 DEX 成交?

获取 Solana 上最近 10 笔 DEX 成交,包含区块信息、交易哈希、买卖明细及 DEX 协议。
query {
  Solana {
    DEXTrades(
      limit: {count: 10}
      orderBy: {descending: Block_Time}
    ) {
      Block { Time, Slot }
      Transaction { Hash }
      Trade {
        Buy {
          Currency { MintAddress }
          Amount
          PriceInUSD
          Account { Owner }
        }
        Sell {
          Currency { MintAddress }
          Amount
          Account { Owner }
        }
        Dex { ProgramAddress, ProtocolName }
      }
      Pool { Address }
    }
  }
}
在 GraphQL IDE 中打开 — 将上方查询粘贴进去即可交互运行,并享受自动补全与 schema 浏览。
字段说明
Block.Time区块时间戳(ISO 8601)
Block.SlotSolana slot 编号(Solana 特有)
Transaction.Hash链上交易哈希 — 可在浏览器中用其查询该笔交易
Trade.Buy.Currency.MintAddress买入资产的代币地址
Trade.Buy.PriceInUSD成交时买入代币的 USD 价格
Trade.Buy.Account.Owner买方钱包地址
Trade.Dex.ProtocolNameDEX 名称(如 Raydium、Orca、Jupiter)
Pool.Address成交所在的流动性池地址
  • 切换链:将 network: sol 改为 network: ethnetwork: bscnetwork: polygon
  • 增加条数:将 count: 10 提高到最多 10000
  • 增加时间过滤:添加 where: {Block: {Time: {after: "2025-03-01T00:00:00Z"}}} 限定时间范围
  • 按 DEX 过滤:添加 where: {Trade: {Dex: {ProtocolName: {is: "Raydium"}}}} 限定为某协议

如何获取某个代币的成交?

通过 tokenAddress 选择器传入代币地址,即可查询该代币相关成交。
query {
  Solana {
    DEXTrades(
      limit: {count: 10}
      tokenAddress: {is: "TOKEN_ADDRESS"}
      orderBy: {descending: Block_Time}
    ) {
      Block { Time }
      Trade {
        Buy { Amount, PriceInUSD, Account { Owner } }
        Sell { Currency { MintAddress }, Amount }
        Dex { ProtocolName }
      }
      Pool { Address }
    }
  }
}
TOKEN_ADDRESS 替换为实际代币 mint 地址(例如 Solana 上 USDC 为 EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v)。按名称查地址见 代币元数据
字段说明
Trade.Buy.Amount买入代币数量
Trade.Buy.PriceInUSD成交时的单价(USD)
Trade.Buy.Account.Owner执行买入的钱包
Trade.Sell.Currency.MintAddress卖出资产的代币地址(交易对的另一侧)
Trade.Dex.ProtocolNameDEX 协议名称
  • 按最小数量过滤:添加 where: {Trade: {Buy: {Amount: {gt: 1000}}}} 仅看大额成交
  • 按价格区间过滤:添加 where: {Trade: {Buy: {PriceInUSD: {gte: 0.001, lte: 1.0}}}} 限定价格带
  • 排除可疑成交:默认已应用 IsSuspect = false 过滤 — 机器人/MEV 类成交已排除

如何获取某个钱包的全部成交?

按钱包地址查询其参与的全部成交。
query {
  Solana {
    DEXTrades(
      limit: {count: 20}
      walletAddress: {is: "WALLET_ADDRESS"}
      orderBy: {descending: Block_Time}
    ) {
      Block { Time }
      Trade {
        Buy { Currency { MintAddress }, Amount, PriceInUSD }
        Sell { Currency { MintAddress }, Amount }
        Dex { ProtocolName }
      }
      Transaction { Hash, FeeInNative }
    }
  }
}
walletAddress 选择器会匹配该钱包作为买方或卖方的成交。
字段说明
Trade.Buy.Currency.MintAddress买入的代币
Trade.Sell.Currency.MintAddress卖出的代币
Transaction.FeeInNative以原生代币计价的 Gas 费(Solana 上为 SOL)
  • 限定单一代币:与 tokenAddress: {is: "TOKEN_ADDRESS"} 组合,只看该钱包对某代币的成交
  • 增加时间窗口:添加 where: {Block: {Time: {after: "2025-03-01T00:00:00Z"}}} 限定近期成交
  • 提高 limit:将 count 设为 100 以拉取更多历史(最大 10,000)

如何获取代币当前价格?

从最近一笔非可疑成交中获取代币最新价格。
query {
  Solana {
    DEXTrades(
      limit: {count: 1}
      tokenAddress: {is: "TOKEN_ADDRESS"}
      where: {IsSuspect: {eq: false}}
      orderBy: {descending: Block_Time}
    ) {
      Trade {
        Buy { PriceInUSD, PriceInNative }
      }
      Block { Time }
    }
  }
}
字段说明
Trade.Buy.PriceInUSD最近一笔成交的 USD 价格
Trade.Buy.PriceInNative以链原生代币(SOL、ETH、BNB)计价的价格
Block.Time成交时间戳 — 反映价格有多新
  • 多条价格:增大 count 可得到多笔近期价格用于平均等用途
  • 跨链:使用 network: eth 可在以太坊上查询同一代币价格(若该链存在该代币)
若需要更可靠的代币价格时间序列,可考虑使用 Pairs Cube — 其提供预计算的 K 线数据,含每分钟 open/high/low/close。

如何查找某代币的头部交易者?

通过聚合查找某代币的头部交易者。以下查询按买方钱包分组,返回总买入笔数与成交量。
query {
  Solana {
    DEXTrades(
      limit: {count: 100}
      tokenAddress: {is: "TOKEN_ADDRESS"}
      where: {IsSuspect: {eq: false}}
    ) {
      Trade {
        Buy {
          Account { Owner }
          Amount
          PriceInUSD
        }
      }
      count
      sum(of: Trade_Buy_Amount)
    }
  }
}
字段说明
Trade.Buy.Account.Owner钱包地址(分组键)
count该钱包的成交笔数
sum(of: Trade_Buy_Amount)该钱包买入的代币总量
  • 按成交量排序:结果会按维度字段分组 — 减少维度可得到更高层级的聚合
  • 限定时间段的排行榜:添加 where: {Block: {Time: {after: "2025-03-01T00:00:00Z"}}} 限定周期
  • 排除小额成交:在 where 中加入 Trade: {Buy: {Amount: {gt: 100}}}
当指标字段(countsum)与维度字段同时出现时,API 会按所选维度自动分组。完整说明见 指标与聚合

多链示例

以下查询在所有支持的链上结构相同 — 只需修改 network 参数。
query {
  Solana {
    DEXTrades(
      limit: {count: 5}
      orderBy: {descending: Block_Time}
    ) {
      Block { Time, Slot }
      Trade {
        Buy { Currency { MintAddress }, PriceInUSD }
        Dex { ProtocolName }
      }
    }
  }
}

后续步骤

转账

查询链上代币转账数据。

余额与持币者

查询钱包余额、余额历史与头部持币者。

池子与流动性

探索 DEX 池子与流动性数据。

OHLC 与统计

获取 K 线、成交统计、市值与代币元数据。