跳轉到主要內容
DEXTrades Cube 包含逐筆 DEX 兌換事件,是粒度最細的交易資料。可用它查詢單筆交易、分析錢包活動、追蹤代幣價格並找出頭部交易者。
以下示例均使用 network: sol(Solana)。其他受支援的鏈請改為 ethbscpolygon

How do I get the latest DEX trades?

獲取 Solana 上最近 10 筆 DEX 交易,包含區塊資訊、交易雜湊、買賣明細及 DEX 協議。
query {
  DEXTrades(
    network: sol
    limit: {count: 10}
    orderBy: Block_Time_DESC
  ) {
    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 中開啟 — 將上方查詢貼上到 IDE 中即可互動式執行,享受自動補全和 Schema 探索。
FieldDescription
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"}}}} 限定協議

How do I get trades for a specific token?

透過 tokenAddress 選擇器傳入地址,獲取某一代幣的交易。
query {
  DEXTrades(
    network: sol
    limit: {count: 10}
    tokenAddress: {is: "TOKEN_ADDRESS"}
    orderBy: Block_Time_DESC
  ) {
    Block { Time }
    Trade {
      Buy { Amount, PriceInUSD, Account { Owner } }
      Sell { Currency { MintAddress }, Amount }
      Dex { ProtocolName }
    }
    Pool { Address }
  }
}
TOKEN_ADDRESS 替換為實際代幣 mint 地址(例如 Solana 上 USDC 為 EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v)。可按名稱查地址時參見 代幣後設資料
FieldDescription
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 過濾 — bot/MEV 交易已排除

How do I get all trades by a wallet?

獲取某錢包地址的全部交易。
query {
  DEXTrades(
    network: sol
    limit: {count: 20}
    walletAddress: {is: "WALLET_ADDRESS"}
    orderBy: Block_Time_DESC
  ) {
    Block { Time }
    Trade {
      Buy { Currency { MintAddress }, Amount, PriceInUSD }
      Sell { Currency { MintAddress }, Amount }
      Dex { ProtocolName }
    }
    Transaction { Hash, FeeInNative }
  }
}
walletAddress 選擇器會匹配該錢包作為買方或賣方的交易。
FieldDescription
Trade.Buy.Currency.MintAddress買入的代幣
Trade.Sell.Currency.MintAddress賣出的代幣
Transaction.FeeInNative原生代幣支付的手續費(Solana 上為 SOL)
  • 單一代幣:與 tokenAddress: {is: "TOKEN_ADDRESS"} 組合,只看該錢包對某代幣的交易
  • 時間視窗:增加 where: {Block: {Time: {after: "2025-03-01T00:00:00Z"}}} 限定近期
  • 提高 limit:設 count: 100 拉取更多歷史(最大 10,000)

How do I get a token’s current price?

從最近一筆非可疑交易獲取代幣最新價格。
query {
  DEXTrades(
    network: sol
    limit: {count: 1}
    tokenAddress: {is: "TOKEN_ADDRESS"}
    where: {IsSuspect: {eq: false}}
    orderBy: Block_Time_DESC
  ) {
    Trade {
      Buy { PriceInUSD, PriceInNative }
    }
    Block { Time }
  }
}
FieldDescription
Trade.Buy.PriceInUSD最近一筆成交的 USD 價格
Trade.Buy.PriceInNative以鏈原生代幣(SOL、ETH、BNB)計價的價格
Block.Time成交時間戳 — 表示價格有多新
  • 多條價格:提高 count 獲取多筆近期價格用於平均
  • 跨鏈:使用 network: eth 獲取該鏈上同一代幣價格(若存在)
若需要可靠的代幣價格時間序列,可考慮改用 Pairs Cube — 提供預計算的 K 線資料,含每分鐘 open/high/low/close。

How do I find the top traders for a token?

透過聚合找出某代幣的頭部交易者。本查詢按買方錢包分組,返回總買入筆數與成交量。
query {
  DEXTrades(
    network: sol
    limit: {count: 100}
    tokenAddress: {is: "TOKEN_ADDRESS"}
    where: {IsSuspect: {eq: false}}
  ) {
    Trade {
      Buy {
        Account { Owner }
        Amount
        PriceInUSD
      }
    }
    count
    sum(of: Trade_Buy_Amount)
  }
}
FieldDescription
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 會按所選維度自動分組。詳見 Metrics & Aggregation

多鏈示例

以下查詢在所有支援鏈上同樣適用 — 只需修改 network 引數。
query {
  DEXTrades(
    network: sol
    limit: {count: 5}
    orderBy: Block_Time_DESC
  ) {
    Block { Time, Slot }
    Trade {
      Buy { Currency { MintAddress }, PriceInUSD }
      Dex { ProtocolName }
    }
  }
}

下一步

Transfers

查詢鏈上代幣轉賬資料。

Balances & Holders

查詢錢包餘額、餘額歷史與頭部持有者。

Pools & Liquidity

探索 DEX 池與流動性資料。

OHLC & Statistics

獲取 K 線、成交統計、市值與代幣後設資料。