Skip to main content

Price Index Algorithm

What it is​

The Price Index is the engine behind the Crypto Price API. It turns DEX trades into one price per pool, blends the pools of a token into one token price per chain, and blends a currency's tokens across chains into one currency price. This page explains the three levels well enough to read the fields they produce. It does not describe the internal rules or their thresholds.

Three levels: trades make a pool price, pools blend into a token price, tokens blend into a currency price

How to get it​

The index is not a separate cube. Its outputs are the price and ranking fields on the Trading cubes, in queries, subscriptions and on the trading.prices Kafka topic.

LevelCubeOne row is
PoolTrading.Pairsone pool on one market, for one interval
TokenTrading.Tokensone token on one chain, all its pools blended
CurrencyTrading.Currenciesone asset across chains, all its tokens blended
GroupTradesPairsTokensCurrencies
Ranking { Position Weight }yesyesyes–
RankingDetail { Verdict StaleMultiplier }–yesyes–
Liquidity { Usd Source RealShare … }–yes (one pool)yes (summed)yes (summed)
LeadingPool { MarketId PoolAddress QuoteTokenId }––yes–

Pairs filtered to Ranking: { Position: { eq: 1 } } returns the pool that leads a token's blend. See Getting the Most Accurate Token Price.

How it is derived​

Pool: from trades to a price​

Trades in a pool become one pool price: drop bad prints, average by size, convert to USD
  • Orientation. One side of the pool is base, the other quote. Stablecoins and native tokens are preferred as quote, so a memecoin/WSOL pool prices the memecoin in WSOL. The rules are in Breaking Down Price Streams in Detail.
  • Bad prints are dropped. Zero-amount trades, trades below the token's precision, and legs of a self-sandwich do not count. Trades of negligible USD value count toward volume but not price.
  • The price is the pool's spot. Each trade is priced at what the pool's curve moved to, with the pool fee excluded where the venue reports it inside the input. Chart sites show the price the trader paid, fee included, so on a pool with a 1 % fee the two differ by about 1 % in the direction of the last trade. The trader's price is still on every Trading.Trades row from its Amounts.
  • Trades are averaged by size into one pool price per block. The candle open, high, low and close come from the individual trades.
  • USD is the quote-denominated price times the quote currency's own index price. A pool whose quote has no USD price carries a price in quote tokens only.

Token: from pools to a price​

From pools to one token price: each pool's share of liquidity is its weight, pool prices are averaged by weight

Every pool where the token is base is a part of the token. Each part gets a weight, each part gets a verdict, and the token price is the average of the accepted parts' prices by weight.

  • Weight is the pool's share of the token's liquidity, discounted for staleness. Liquidity is the measured reserve where the index can read it and an estimate otherwise (Liquidity fields). A pool that stops trading keeps its liquidity but loses weight the longer it stays quiet. This is Ranking.Weight; Ranking.Position orders the pools by it.
  • Verdict says what the blend did with the pool's price. priced is accepted as is. clamped is accepted but pulled toward the other pools. outlier is rejected, price and volume. ineligible is a pool with too little money or history: its volume counts, its price does not. retired is a launch curve the token has left. no_price is a pool with nothing to price. This is RankingDetail.Verdict.
  • Launch curves. While a token trades only on its bonding curve, the curve is its price. Once it graduates to a real pool, the curve is retired for that token and never votes again, so its frozen price cannot drag the blend.
  • One pool. A token with one pool has nothing to blend: that pool's price is the token's, at Position 1 and Weight 1.

Currency: from tokens to a price​

The same blend one level up. A non-stablecoin currency such as bid:bitcoin is made of its token representations across chains (WBTC, cbBTC and so on), each weighted by that token's liquidity. Ranking is not exposed on Currencies.

Stablecoins skip the trade-based path: their price comes from an external spot source. At currency level they carry no Liquidity and no Supply.

Which price to read​

FieldWhat it isUse it for
Price.Ohlc.CloseThe last accepted trade of the interval.Candles, charts, last traded price.
Price.Average.EstimateThe valuation price: smoothed over recent short intervals, so one spike moves it a little and a sustained move captures it fully.Market cap, portfolio value. MarketCap is Estimate × supply.
Price.Average.MeanSize-weighted mean of the interval's trades.VWAP over the bar.
PriceInUsd on Trading.TradesThat trade's own price times the quote token's USD rate. Not the blended token price.Per-swap accounting, PnL.
PoolPrice on PairsThe pool curve's marginal quote after the last swap.Routing, slippage. See PoolPrice fields.

Fields​

Ranking is exposed on Trades, Pairs and Tokens.

FieldTypeMeaning
Ranking.PositionInt1-based priority among the parts of a blend: the pool among a token's pools, or the token among a currency's tokens. Lower is higher priority.
Ranking.WeightFloatThis part's share of the blend, in [0, 1]. Weights across a token's pools sum to 1.

RankingDetail { Verdict StaleMultiplier }, LeadingPool and every Liquidity field are documented in Liquidity, RankingDetail and LeadingPool fields.

Examples​

Which pools set a token's price?​

Filter Pairs on Ranking.Position to keep only the top contributors (positions 1, 2 and 3 here). Weight is normally read, not filtered.

{
Trading {
Pairs(
where: {
Ranking: { Position: { in: [1, 2, 3] } }
Interval: { Time: { Duration: { eq: 3600 } } }
Block: { Time: { since_relative: { hours_ago: 1 } } }
}
limit: { count: 10 }
) {
Block {
Time(maximum: Block_Time)
}
Currency {
Id
}
Token {
Id
}
QuoteToken {
Id
}
Market {
Id
Protocol
Address
}
Price {
Ohlc {
Close
}
}
Ranking {
Position
Weight
}
Interval {
Time {
Start
End
}
}
}
}
}
  • Position: 1 is the pool with the largest liquidity-weighted share, not the one with the most trades.
  • Add Token: { Id: { is: "bid:solana:So11111111111111111111111111111111111111112" } } to see one token's pools and check that their Weight values sum to about 1.
  • Add RankingDetail { Verdict StaleMultiplier } to see why each pool got its rank.

Pitfalls​

  • Our close is not DEX Screener's close on high-fee pools. We publish the pool's spot; chart sites publish the price the trader paid, fee included.
  • Estimate is not the close. It is smoothed. Use Ohlc.Close for the last trade and Estimate for valuation.
  • Rejected pools still have rows. An outlier or ineligible pool keeps its Pairs row and Position. Filter on RankingDetail.Verdict for the pools the price actually uses.
  • Do not apply StaleMultiplier again. Weight already includes it.
  • History before 2026-10-19 is volume-weighted. Liquidity fields are 0 on those rows and Weight follows traded volume. Do not compare weights across the cutover.
  • Volume.Quote is not USD. It is the sum of quote-token amounts. Use Volume.Usd.
Build with Bitquery

Ready to run this in production?

Get an API key and run these queries in minutes, or talk to us about plans and enterprise delivery.