Skip to main content

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.

orderBy InputObject

Each Cube generates an {Cube}OrderBy input object with ascending and descending fields. Each field accepts a CompareFields enum value that follows the dimension path joined by underscores:
{DimensionGroup}_{DimensionField}
For nested dimensions, each level is joined:
Block_Time
Trade_Buy_Amount
Trade_Buy_PriceInUSD
Usage:
orderBy: {descending: Block_Time}      # newest first
orderBy: {ascending: Trade_Buy_Amount}  # smallest amount first

Common CompareFields Values

CompareFields ValueExample UsageCube(s)Description
Block_TimeorderBy: {descending: Block_Time}DEXTrades, Transfers, BalanceUpdates, DEXPools, TokenSupplyUpdates, Pairs, TokensNewest first
Block_TimeorderBy: {ascending: Block_Time}DEXTrades, Transfers, BalanceUpdates, DEXPools, TokenSupplyUpdates, Pairs, TokensOldest first
Interval_Time_StartorderBy: {ascending: Interval_Time_Start}Pairs, TokensOldest first (interval start time)
Trade_Buy_AmountorderBy: {descending: Trade_Buy_Amount}DEXTradesLargest buy amount first
Trade_Buy_PriceInUSDorderBy: {descending: Trade_Buy_PriceInUSD}DEXTradesHighest USD price first
Transfer_AmountInUSDorderBy: {descending: Transfer_AmountInUSD}TransfersLargest USD transfer first
LatestBalanceUSDorderBy: {descending: LatestBalanceUSD}TokenHoldersLargest holder first
BuyVolumeUSDStateorderBy: {descending: BuyVolumeUSDState}WalletTokenPnLHighest buy volume first
Use the GraphQL IDE auto-complete to discover all available CompareFields values for a Cube — type orderBy: {descending: and the IDE will show available fields.

Usage

Pass an orderBy input object with either descending or ascending set to a CompareFields value:
query {
  Solana {
    DEXTrades(
      orderBy: {descending: Block_Time}
      limit: { count: 10 }
    ) {
      Block { Time }
      Trade { Buy { Amount PriceInUSD } }
    }
  }
}
orderBy accepts a single direction/field pair. Multi-column sorting is not supported — the query is sorted by one dimension at a time.

limit Argument

The limit argument controls how many rows are returned and supports offset-based pagination:
input LimitInput {
  count: Int   # Number of rows to return
  offset: Int  # Number of rows to skip
}

Default and Maximum Limits

Each Cube has a default limit applied when you omit the limit argument, and a maximum cap:
CubeDefault countMaximum count
DEXTrades2510,000
Transfers2510,000
BalanceUpdates2510,000
DEXPools2510,000
TokenSupplyUpdates2510,000
Pairs2510,000
Tokens2510,000
DEXPoolEvents2510,000
TokenHolders2510,000
WalletTokenPnL2510,000
If you request a count exceeding the maximum, the server silently caps it at the maximum value.

Offset-Based Pagination

Use offset to page through result sets. The pattern is straightforward:
  • Page 1: limit: { count: 50, offset: 0 }
  • Page 2: limit: { count: 50, offset: 50 }
  • Page 3: limit: { count: 50, offset: 100 }

Example: Paginated Token Holders

query {
  Solana {
    TokenHolders(
      tokenAddress: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
      orderBy: {descending: LatestBalanceUSD}
      limit: { count: 20, offset: 0 }
    ) {
      Holder { Address }
      LatestBalance
      LatestBalanceUSD
    }
  }
}

Pagination Tips

Without a stable sort order, rows may shift between pages. Always pair limit with an orderBy that produces a deterministic order.
Large offset values (e.g., 50,000+) may degrade performance since the database must scan and skip rows. For very large datasets, narrow your query with where filters instead of paginating deeply.
If a page returns fewer rows than the requested count, you’ve reached the end of the dataset. Alternatively, use the count metric field to get total row count upfront.

Practical Examples

Latest Large Trades

Fetch the 10 most recent DEX trades on Solana with a buy value over $10,000:
query {
  Solana {
    DEXTrades(
      where: {
        Trade: { Buy: { PriceInUSD: { gt: 10000 } } }
      }
      orderBy: {descending: Block_Time}
      limit: { count: 10 }
    ) {
      Block { Time }
      Trade {
        Buy {
          Currency { MintAddress }
          Amount
          PriceInUSD
        }
        Dex { ProtocolName }
      }
    }
  }
}

OHLC Candles — Last 60 Minutes

Fetch 1-minute candles for a token, sorted chronologically:
query {
  Trading {
    Pairs(
      where: {
        Token: { Address: { is: "So11111111111111111111111111111111111111112" } }
        Market: { Network: { is: "sol" } }
        Block: { Time: { after: "2025-03-27T09:00:00Z" } }
      }
      orderBy: {ascending: Block_Time}
      limit: { count: 60 }
    ) {
      Block { Time }
      Price {
        Ohlc { Open High Low Close }
      }
      Volume { Usd }
      Stats { TradeCount }
    }
  }
}

Top 50 Token Holders

Fetch the top 50 holders sorted by USD balance:
query {
  Solana {
    TokenHolders(
      tokenAddress: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263"
      orderBy: {descending: LatestBalanceUSD}
      limit: { count: 50 }
    ) {
      Holder { Address }
      LatestBalance
      LatestBalanceUSD
      FirstSeen
      LastSeen
    }
  }
}

Next Steps

Filtering

Combine ordering with filters to build precise analytical queries.

Metrics & Aggregation

Aggregate ordered data with count, sum, avg, min, max, uniq.