exchange.IO("lp.ticks", ...)
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.
javascriptfunction 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%).
javascriptfunction 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
| Type | Description |
object / null value | For a DLMM pool |
Arguments
| Name | Type | Required | Description |
k | string | Yes | Set to |
poolId | string | Yes | The pool address, written as the |
lower | number | No | Lower end of the range: a bin ID on DLMM, a tick on Raydium and Orca. Without |
upper | number | No | Upper end of the range, in the unit of |
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
| Protocol | Without a range | Limit | Each item of segments |
|---|---|---|---|
| Meteora DLMM | 35 bins on each side of the active bin | 1400 bins per call | {binLower, binUpper, priceLower, priceUpper, amountX, amountY, current} |
| Raydium CLMM | about 10% on each side of the price | 200 TickArrays (including the current one) and 2000 segments per call | {tickLower, tickUpper, priceLower, priceUpper, liquidity, amountX, amountY, current} |
| Orca Whirlpools | 35 tick spacings on each side of the current tick | 2000 tick spacings per call | as Raydium |
- Prices are Y per X (the pool's own order, as in
lp.pool);amountXandamountYare in readable units; the segment withcurrenttrueholds 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;
liquidityis the largest liquidity inside the segment. A pool with tick spacing 1 has nearly 2000 segments in the default range; merge them withstep. - Orca: both ends are aligned outward to the tick spacing and
stepis rounded up to it; each segment gives the active liquidity of its first cell and both token amounts that liquidity represents over the segment.