Skip to main content

orderBy Enum

Each Cube generates an {Cube}OrderBy enum with ASC and DESC variants for every sortable dimension. The naming convention follows the dimension path joined by underscores:
{DimensionGroup}_{DimensionField}_ASC
{DimensionGroup}_{DimensionField}_DESC
For nested dimensions, each level is joined:
Trade_Buy_Amount_ASC
Trade_Buy_PriceInUSD_DESC
Block_Time_ASC

Common orderBy Values

Enum ValueCube(s)Description
Block_Time_ASCDEXTrades, Transfers, BalanceUpdates, DEXPools, TokenSupplyUpdates, Pairs, TokensOldest first
Block_Time_DESCDEXTrades, Transfers, BalanceUpdates, DEXPools, TokenSupplyUpdates, Pairs, TokensNewest first
Interval_Time_Start_ASCPairs, TokensOldest first (interval start time)
Interval_Time_Start_DESCPairs, TokensNewest first (interval start time)
Trade_Buy_Amount_DESCDEXTradesLargest buy amount first
Trade_Buy_PriceInUSD_DESCDEXTradesHighest USD price first
Transfer_AmountInUSD_DESCTransfersLargest USD transfer first
LatestBalanceUSD_DESCTokenHoldersLargest holder first
BuyVolumeUSDState_DESCWalletTokenPnLHighest buy volume first
Use the GraphQL IDE auto-complete to discover all available orderBy values for a Cube — type orderBy: and the IDE will show the full enum.

Usage

Pass a single enum value to the orderBy argument:
query {
  DEXTrades(
    network: sol
    orderBy: Block_Time_DESC
    limit: { count: 10 }
  ) {
    Block { Time }
    Trade { Buy { Amount PriceInUSD } }
  }
}
orderBy accepts a single enum value. 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 {
  TokenHolders(
    network: sol
    tokenAddress: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
    orderBy: LatestBalanceUSD_DESC
    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 {
  DEXTrades(
    network: sol
    where: {
      Trade: { Buy: { PriceInUSD: { gt: 10000 } } }
    }
    orderBy: Block_Time_DESC
    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: Block_Time_ASC
      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 {
  TokenHolders(
    network: sol
    tokenAddress: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263"
    orderBy: LatestBalanceUSD_DESC
    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.