跳轉到主要內容

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 線、成交統計、市值與代幣後設資料。