Type/to search
Built-in Functions
Structures
Built-in Variables and Constants
Conventions
Exchanges
Capability Matrix
Centralized Exchanges
Decentralized Exchanges (DEX)
Prediction Markets
Securities and Futures
On-chain & Custom

View a pool's liquidity distribution over a range, with both token amounts per bin or tick segment.

exchange.IO(k, poolId)
exchange.IO(k, poolId, lower, upper)
exchange.IO(k, poolId, lower, upper, step)

Examples

  • Find the thickest bin near the price of a Meteora pool.

    javascript
    function main() { var pool = exchange.IO("lp.select", "SOL", 100, {quote: "USDC", protocol: "meteora"}) if (!pool) { Log("Selection failed:", GetLastError()) return } var d = exchange.IO("lp.ticks", pool.id) if (!d) { Log("Query failed:", GetLastError()) return } var ranked = d.segments.map(function(s) { return {seg: s, value: s.amountX * d.price + s.amountY} }) ranked.sort(function(a, b) { return b.value - a.value }) var best = ranked[0] Log("active bin", d.activeId, "price", d.price, "bins", d.segments.length) Log("thickest bin", best.seg.binLower, "price", best.seg.priceLower, "about", Math.round(best.value), d.symbolY) }
  • Summarize about 10% on each side of a Raydium pool's price in segments of 100 ticks (about 1%).

    javascript
    function main() { var pool = exchange.IO("lp.select", "SOL", 100, {quote: "USDC", protocol: "raydium"}) if (!pool) { Log("Selection failed:", GetLastError()) return } var d = exchange.IO("lp.ticks", "raydium:" + pool.id, pool.tick - 1000, pool.tick + 1000, 100) if (!d) { Log("Query failed:", GetLastError()) return } d.segments.forEach(function(s) { Log(s.current ? "*" : " ", s.priceLower.toFixed(2), "-", s.priceUpper.toFixed(2), s.amountX.toFixed(2), d.symbolX, s.amountY.toFixed(2), d.symbolY) }) }

Returns

TypeDescription

object / null value

For a DLMM pool {pool, activeId, binStep, price, tokenX, tokenY, symbolX, symbolY, segments}; for Raydium {pool, tick, tickSpacing, price, tokenX, tokenY, symbolX, symbolY, segments}, and Orca adds liquidity (the liquidity at the price). segments lists the segments, see the remarks for their fields. A null value is returned when a request fails or the range exceeds the limit.

Arguments

NameTypeRequiredDescription

k

string

Yes

Set to lp.ticks to view the liquidity distribution.

poolId

string

Yes

The pool address, written as the poolId of lp.pool.

lower

number

No

Lower end of the range: a bin ID on DLMM, a tick on Raydium and Orca. Without lower and upper a default range around the price is used, see the remarks.

upper

number

No

Upper end of the range, in the unit of lower.

step

number

No

Width of each segment: in bins on DLMM (default 1), in ticks on Raydium and Orca (default one tick spacing).

See Also

Remarks

Ranges and segments by protocol
ProtocolWithout a rangeLimitEach item of segments
Meteora DLMM35 bins on each side of the active bin1400 bins per call{binLower, binUpper, priceLower, priceUpper, amountX, amountY, current}
Raydium CLMMabout 10% on each side of the price200 TickArrays (including the current one) and 2000 segments per call{tickLower, tickUpper, priceLower, priceUpper, liquidity, amountX, amountY, current}
Orca Whirlpools35 tick spacings on each side of the current tick2000 tick spacings per callas Raydium

  • Prices are Y per X (the pool's own order, as in lp.pool); amountX and amountY are in readable units; the segment with current true holds the price.
  • DLMM: the active bin holds both tokens, bins above it only X and bins below only Y; the amounts per segment are the actual balances of those bins.
  • Raydium: both ends are aligned outward to the tick spacing, and each segment's liquidity and token amounts are derived from the current liquidity through the initialized ticks in the TickArrays; liquidity is the largest liquidity inside the segment. A pool with tick spacing 1 has nearly 2000 segments in the default range; merge them with step.
  • Orca: both ends are aligned outward to the tick spacing and step is rounded up to it; each segment gives the active liquidity of its first cell and both token amounts that liquidity represents over the segment.