跳轉到主要內容

什麼是 Cube?

Cube 是一種分析型資料模型,對映到一個或多個 OLAP 資料庫表。每個 Cube 定義:
  • Dimensions — 可查詢欄位,組織為巢狀層級(例如 Block.TimeTrade.Buy.Currency.MintAddress
  • Selectors — 頂層的快捷篩選引數(例如 tokenAddress),用於簡化常見篩選模式
  • Metrics — Record 型別上可用的聚合函式(countsum 等)
  • Defaults — 自動應用的預設篩選與分頁 limit
查詢 Cube 時,activecube-rs 會將 GraphQL 查詢編譯為針對該 Cube 底層表的最佳化 SQL;表名遵循 {chain}_{table_name} 模式(例如 sol_dex_tradeseth_transfers)。

Cube 概覽

25 個 Cube 分為三個 Chain Group。每個 Cube 屬於某一資料倉儲層級:
  • DWD(明細層)— 逐事件原始資料,粒度最高
  • DWM(聚合層)— 預計算彙總(例如按分鐘)
  • DWS(彙總層)— 高度聚合的快照
  • DIM(維度層)— 參考 / 查詢表
CubeChain Group層級用途
DEXTradesEVM, SolanaDWD逐筆 DEX swap 事件
DEXTradeByTokensEVM, SolanaDWD按代幣索引的 DEX 成交(買/賣側)
TransfersEVM, SolanaDWD代幣轉賬事件
BalanceUpdatesEVM, SolanaDWD錢包餘額變動事件
DEXPoolEventsEVM, SolanaDWD流動性新增/移除事件
TokenSupplyUpdatesEVM, SolanaDWD代幣 mint/burn 事件
BlocksEVM, SolanaDWD區塊級資料
TransactionsEVM, SolanaDWD交易級資料
TransactionBalancesEVM, SolanaDWD單筆交易內的餘額變動
InstructionsSolanaDWDSolana instruction 資料
InstructionBalanceUpdatesSolanaDWDinstruction 級餘額變動
RewardsSolanaDWD驗證者 / staking 獎勵
DEXOrdersSolanaDWDDEX 訂單事件(限價單等)
EventsEVMDWD智慧合約 event log
CallsEVMDWD內部 call trace
MinerRewardsEVMDWD礦工 / 驗證者獎勵
DEXPoolSlippagesEVMDWD池子滑點資料
UnclesEVMDWDUncle 區塊資料
PairsTradingDWMOHLC K 線(跨鏈)
TokensTradingDWM按代幣的成交統計(跨鏈)
DEXPoolsEVM, SolanaDWS含當前儲備的池子快照
TokenHoldersEVM, SolanaDWS代幣持有者餘額
WalletTokenPnLEVM, SolanaDWS按錢包-代幣的 PnL
PredictionTradesEVM (Polygon)DWD預測市場成交
PredictionManagementsEVM (Polygon)DWD預測市場管理事件
PredictionSettlementsEVM (Polygon)DWD預測市場結算

EVM + Solana 共享 Cube

以下 Cube 在 EVMSolana Chain Group 中均可用。
表: {chain}_dex_trades 預設 limit: 25(最大 10,000) 預設 filter: IsSuspect = false(預設排除 bot/MEV 成交) Selectors: tokenAddresswalletAddresspoolAddressdexProgramdate Metrics: countsumavgminmaxuniq關鍵欄位:
DEXTradesRecord {
  Block { Time, Slot, Height }
  Transaction { Hash, FeeInNative }
  Trade {
    Buy { Currency { MintAddress }, Amount, PriceInUSD, Account { Owner } }
    Sell { Currency { MintAddress }, Amount, Account { Owner } }
    Dex { ProgramAddress, ProtocolName }
  }
  Pool { Address }
  IsSuspect
}
適用場景: 成交歷史、錢包成交分析、DEX 成交量拆解、大額成交檢測。
表: {chain}_dex_trades_enriched(UNION 子查詢 — 每筆成交一側一行) Selectors: tokenAddresssideTypepoolAddressdexProgramdate Metrics: countsumavgminmaxuniq關鍵欄位:
DEXTradeByTokensRecord {
  Block { Time, Slot, Height }
  Transaction { Signature, Fee, FeeInUSD }
  Trade {
    Currency { MintAddress, Symbol, Name }
    Amount, AmountInUSD, PriceInUSD, PriceInNative
    Side { Type, Currency { MintAddress }, Amount }
    Account { Owner }
    Dex { ProgramAddress, ProtocolName }
    Market { PoolAddress }
  }
}
適用場景: 按代幣查詢成交(買賣兩側)、代幣成交量分析、單代幣高效篩選。
表: {chain}_transfers Selectors: tokenAddresssenderAddressreceiverAddressdate Metrics: countsumavguniq關鍵欄位:
TransfersRecord {
  Block { Time, Slot }
  Transaction { Hash, Signer }
  Transfer {
    Currency { MintAddress }
    Sender { Address, TokenAccount }
    Receiver { Address, TokenAccount }
    Amount, AmountInUSD, PriceInUSD
  }
}
適用場景: 錢包轉賬歷史、巨鯨監控、交易所充提追蹤。
表: {chain}_balance_updates Selectors: ownerAddresstokenAddressdate Metrics: countsumavgminmaxuniq關鍵欄位:
BalanceUpdatesRecord {
  Block { Time, Slot }
  Transaction { Hash }
  BalanceUpdate {
    Currency { MintAddress, Decimals }
    Account { Address, Owner }
    PreBalance, PostBalance
    PreBalanceInUSD, PostBalanceInUSD
  }
}
適用場景: 餘額變動追蹤、倉位監控、吸籌/派發識別。
表: {chain}_dex_pool_events_enriched Selectors: poolAddresstokenAddressdate Metrics: countsumavgmax關鍵欄位:
DEXPoolEventsRecord {
  Block { Time }
  Transaction { Signature }
  Pool {
    Market { Address, BaseCurrency { ... }, QuoteCurrency { ... } }
    Dex { ProgramAddress, ProtocolName }
    Base { PostAmount, ChangeAmount, PriceInUSD }
    Quote { PostAmount, ChangeAmount }
    LiquidityInUSD
  }
}
適用場景: 流動性增減監控、池子 TVL 追蹤、新池發現。
表: {chain}_token_supplies Selectors: tokenAddress關鍵欄位:
TokenSupplyUpdatesRecord {
  Block { Time }
  TokenSupplyUpdate {
    Currency { MintAddress, Decimals }
    PostBalance, MarketCapInUSD, PriceInUSD, FDVInUSD, TotalSupply
  }
}
適用場景: mint/burn 事件追蹤、供應變動告警、市值歷史。
表: {chain}_blocks Selectors: date Metrics: countsumavgminmax關鍵欄位:
BlocksRecord {
  Block {
    Time, Date, Height, Hash, ParentHash, TxCount
    # Solana-specific
    Slot, ParentSlot, RewardsCount
    # EVM-specific
    Number, Coinbase, GasLimit, GasUsed, BaseFee, Difficulty
  }
}
適用場景: 出塊監控、gas 分析(EVM)、slot 追蹤(Solana)。
表: {chain}_transactions Selectors: datetxHash/txSignaturefromAddresstoAddressfeePayersigner Metrics: countsumavgminmax關鍵欄位:
TransactionsRecord {
  Block { Time, Slot, Height }
  Transaction {
    # Solana: Signature, Fee, FeePayer, Signer, Result { Success }
    # EVM: Hash, From, To, Value, Gas, GasPrice, Nonce, Type
  }
  Fee { ... }     # EVM EIP-1559 fee breakdown
  Receipt { ... } # EVM receipt fields
}
適用場景: 交易查詢、gas/fee 分析、活躍度監控。
表: {chain}_transaction_balances Selectors: dateaddresscurrency Metrics: countsumavgminmax關鍵欄位:
TransactionBalancesRecord {
  Block { Time }
  Transaction { Hash, Index }
  TokenBalance {
    Address, TokenAccount
    Currency { SmartContract, Symbol, Name, Decimals }
    PreBalance, PostBalance, Change
    PreBalanceInUSD, PostBalanceInUSD, ChangeInUSD
    UpdateType
  }
}
適用場景: 單筆交易對餘額的影響分析、代幣流向追蹤。
該 Cube 不支援 dataset 切換(無 _realtime / _archive 等表變體)。

Solana 專屬 Cube

以下 Cube 僅在 Solana Chain Group 中可用。
表: sol_instructions_enriched Selectors: dateprogramIdtxSignature Metrics: countuniq關鍵欄位:
InstructionsRecord {
  Block { Time, Slot }
  Transaction { Signature }
  Instruction {
    Index, Depth, InternalSeqNumber
    Program { Address, Name, Method }
    Accounts       # Array of account addresses
    Data           # Raw instruction data
    CallPath, Logs
  }
}
適用場景: 程式互動分析、instruction 級除錯、協議使用追蹤。
表: sol_balance_updates_enriched Selectors: datetokenAddressownerAddressprogramId Metrics: countsumavgminmaxuniq關鍵欄位:
InstructionBalanceUpdatesRecord {
  Block { Time, Slot }
  Transaction { Signature }
  Instruction { Index, Program { Address } }
  BalanceUpdate {
    Currency { MintAddress, Decimals }
    Account { Address, Owner }
    Amount, AmountInUSD
    PreBalance, PostBalance
  }
}
適用場景: instruction 級餘額影響分析、程式手續費追蹤。
該 Cube 不支援 dataset 切換。
表: sol_rewards Selectors: dateaddress Metrics: countsumavg關鍵欄位:
RewardsRecord {
  Block { Time, Slot }
  Reward {
    Address          # Validator/staker address
    Amount           # Reward amount in SOL
    AmountInUSD      # Reward value in USD
    PostBalance      # Balance after reward
    RewardType       # Type: voting, staking, etc.
    Commission       # Validator commission
  }
}
適用場景: staking 獎勵追蹤、驗證者表現、獎勵歷史。
表: sol_dex_orders Selectors: datemarketAddressorderTypeownerAddress Metrics: countsumavguniq關鍵欄位:
DEXOrdersRecord {
  Block { Time, Slot }
  Transaction { Signature }
  OrderEvent {
    Type             # Order type (place, cancel, fill, etc.)
    Market { Address }
    Order { Id, BuySide, LimitPrice, Mint, Owner }
    Dex { ProgramAddress, ProtocolName }
  }
}
適用場景: 訂單簿分析、限價單追蹤、市場微觀結構研究。

EVM 專屬 Cube

以下 Cube 僅在 EVM Chain Group(ethbscpolygon)中可用。
表: {chain}_logs_enriched Selectors: datecontractAddresstxHashtopic0 Metrics: countuniq關鍵欄位:
EventsRecord {
  Block { Time, Number }
  Transaction { Hash, From, To }
  Log {
    SmartContract    # Contract emitting the event
    Index            # Log index in transaction
    Signature { Name, Signature }
    Topics           # Event topics array
    Data             # ABI-encoded event data
  }
}
適用場景: 智慧合約 event 監控、協議活動追蹤、自定義 event 篩選。
表: {chain}_traces_enriched Selectors: datetxHashtoAddress Metrics: countsumuniq關鍵欄位:
CallsRecord {
  Block { Time, Number }
  Transaction { Hash }
  Call {
    Index, Depth
    From, To
    Opcode          # CALL, DELEGATECALL, STATICCALL, CREATE, etc.
    Gas, GasUsed
    Input, Output
    Value           # ETH/BNB transferred
    Signature { Name, Signature }
  }
}
適用場景: 內部交易 trace、合約互動分析、MEV 檢測。
表: {chain}_miner_rewards Selectors: dateminer Metrics: countsumavgminmax關鍵欄位:
MinerRewardsRecord {
  Block { Time, Number, Hash }
  Reward {
    Miner
    TotalReward, TotalRewardInUSD
    BurntFees, DynamicReward, StaticReward
    TxFees, UncleReward
  }
}
適用場景: 驗證者/礦工獎勵分析、區塊獎勵趨勢、MEV 收入追蹤。
表: {chain}_dex_pool_slippages Selectors: datepoolAddress Metrics: countavgminmax關鍵欄位:
DEXPoolSlippagesRecord {
  Block { Time }
  Price {
    Pool { SmartContract, CurrencyA { ... }, CurrencyB { ... } }
    AtoB, BtoA             # Current prices
    AtoBMin, AtoBMax       # Price range
    SlippageBasisPoints    # Slippage in basis points
    Dex { ProtocolName }
  }
}
適用場景: 滑點監控、池子深度分析、執行質量評估。
表: {chain}_uncles Selectors: dateminer Metrics: count關鍵欄位:
UnclesRecord {
  Block { Time, Number }
  Uncle {
    Index, Hash, ParentHash
    Miner, Difficulty, Number
    GasLimit, GasUsed, Timestamp
  }
}
適用場景: Uncle 區塊分析、網路健康監控(主要為 Ethereum PoW 歷史資料)。

Trading Cube(跨鏈)

以下 Cube 屬於 Trading Chain Group,在全部支援的鏈(solethbsc)上彙總資料,幷包含用於篩選的 chain dimension。
表: 跨鏈物化檢視({chain}_ohlc_mvSelectors: tokenAddresschaindate Metrics: countsumavgminmax關鍵欄位:
PairsRecord {
  Token { Address }
  Market { Network }       # Chain identifier (sol, eth, bsc)
  Block { Time }
  Interval { Time }        # Minute-bucket timestamp
  Price {
    Ohlc { Open, High, Low, Close }
  }
  Volume { Usd, Native }
  Stats { TradeCount, BuyCount, SellCount }
}
適用場景: K 線圖、價格歷史、成交量分析、跨鏈價格對比。
表: 跨鏈物化檢視({chain}_token_trade_stats_mvSelectors: tokenAddresschaindate Metrics: countsumavgminmax關鍵欄位:
TokensRecord {
  Token { Address }
  Market { Network }           # Chain identifier
  Block { Time }
  Interval { Time }            # Minute-bucket timestamp
  Volume { Usd, BuyVolumeUSD, SellVolumeUSD, Base }
  Stats {
    TradeCount, BuyCount, SellCount
    UniqueBuyers, UniqueSellers
  }
}
適用場景: 買賣壓力分析、獨立交易者數量、成交量趨勢、跨鏈代幣對比。

彙總 Cube(DWS)

彙總 Cube 提供高度聚合、快照式資料,便於快速查詢。
表: {chain}_dex_pools(DWS 層) Selectors: poolAddresstokenAtokenB Metrics: count關鍵欄位:
DEXPoolsRecord {
  Pool {
    Address
    TokenAAddress, TokenBAddress
    ProgramAddress
    LiquidityUSD
    PriceAtoB, PriceBtoA
    LastUpdated
  }
}
適用場景: 池子發現、當前流動性排名、池子後設資料查詢。
該 Cube 不支援 dataset 切換或基於時間的篩選;表示池子狀態的最新快照。
表: {chain}_token_holders Selectors: tokenAddress關鍵欄位:
TokenHoldersRecord {
  Token { Address }
  Holder { Address }
  LatestBalance
  LatestBalanceUSD
  FirstSeen
  LastSeen
}
適用場景: 大戶列表、持有者分佈、巨鯨追蹤。
該 Cube 不支援 dataset 切換。
表: {chain}_wallet_token_pnl Selectors: walletAddress關鍵欄位:
WalletTokenPnLRecord {
  Wallet { Address }
  Token { Address }
  BuyVolumeUSDState, SellVolumeUSDState
  BuyCountState, SellCountState
  FirstTradeState, LastTradeState
}
適用場景: 按代幣的錢包 PnL、交易表現排行榜、組合分析。
該 Cube 不支援 dataset 切換。

預測市場 Cube

以下 Cube 在 EVM Chain Group 中可用,主要用於 Polygon 上的預測市場協議。
表: {chain}_prediction_trades Selectors: dateconditionIdquestionIdmarketplace Metrics: countsumavgminmaxuniq關鍵欄位:
PredictionTradesRecord {
  Block { Time }
  Transaction { Hash }
  Trade { Buyer, Seller, Amount, Price, Fee }
  Prediction {
    Condition { Id, Outcomes }
    Question { Id }
    Outcome, OutcomeToken
    Marketplace { ProtocolName }
    CollateralToken { SmartContract }
  }
}
適用場景: 預測市場成交歷史、結果定價、marketplace 成交量。
預測市場 Cube 不支援 dataset 切換。
表: {chain}_prediction_managements Selectors: dateeventTypeconditionIdquestionId Metrics: countsumavgminmaxuniq關鍵欄位:
PredictionManagementsRecord {
  Block { Time }
  Transaction { Hash }
  Management {
    EventType, Description, Group
    Prediction { Condition { ... }, Question { ... }, Marketplace { ... } }
  }
}
適用場景: 市場建立/結算追蹤、condition 管理事件。
表: {chain}_prediction_settlements Selectors: dateeventTypeconditionIdholder Metrics: countsumavgminmaxuniq關鍵欄位:
PredictionSettlementsRecord {
  Block { Time }
  Transaction { Hash }
  Settlement {
    EventType, Holder
    OutcomeTokenIds, Amounts
    Prediction { Condition { ... }, CollateralToken { ... }, Marketplace { ... } }
  }
}
適用場景: 結算追蹤、派息分析、頭寸贖回監控。

選擇合適的 Cube

在滿足需求的前提下,優先選擇聚合度最高的 Cube。對時間序列與摘要類資料,DWM/DWS Cube 通常比 DWD Cube 快幾個數量級。
需求推薦 Cube層級
單筆成交事件DEXTradesDWD
按代幣的成交查詢DEXTradeByTokensDWD
代幣轉賬歷史TransfersDWD
K 線 / 價格圖PairsDWM
隨時間變化的成交量TokensDWM
當前大戶列表TokenHoldersDWS
錢包 PnL 拆解WalletTokenPnLDWS
池子當前狀態DEXPoolsDWS
流動性事件DEXPoolEventsDWD
智慧合約 event(EVM)EventsDWD
內部 trace(EVM)CallsDWD
Solana instructionInstructionsDWD
預測市場成交PredictionTradesDWD

Dataset 相容性

並非所有 Cube 都支援 dataset 引數(realtime/archive/combined)。以下 Cube 無論 dataset 取何值,都會查詢全表:
  • TokenHoldersWalletTokenPnLDEXPools(DWS 層 — 始終為最新快照)
  • TransactionBalances
  • PredictionTradesPredictionManagementsPredictionSettlements
詳見 Dataset 與 Aggregates

下一步

Chain Groups

瞭解 EVM、Solana 與 Trading Chain Group。

篩選

使用 where 與 selector 快捷方式篩選。

指標與聚合

使用 count、sum、avg、min、max、uniq 聚合資料。