exchange.IO("lp.ticks", ...)
Queries a pool's liquidity distribution over a tick range, giving the liquidity and both token amounts per segment.
exchange.IO(k, poolId, tickLower, tickUpper)
exchange.IO(k, poolId, tickLower, tickUpper, step)Examples
Look at the liquidity within 10 tick spacings on either side of the price.
javascript
function main() {
var p = exchange.IO("lp.select", "ETH", 1000, {quote: "USDC"})
var pool = exchange.IO("lp.pool", p.id)
var w = pool.tickSpacing * 10
var r = exchange.IO("lp.ticks", p.id, pool.tick - w, pool.tick + w, pool.tickSpacing * 2)
r.segments.forEach(function (s) {
Log(s.tickLower, s.tickUpper, s.current ? "<- price" : "",
pool.token0.symbol, s.amount0, pool.token1.symbol, s.amount1)
})
}Returns
| Type | Description |
object / null value |
|
Arguments
| Name | Type | Required | Description |
k | string | Yes | Set to |
poolId | string | Yes | Pool ID as in |
tickLower | number | Yes | Lower end of the range (tick). |
tickUpper | number | Yes | Upper end of the range (tick). |
step | number | No | Segment width in ticks; the pool's tick spacing by default. |
See Also
Uniswap / PancakeSwap Aerodrome / Velodrome exchange.IO exchange.IO("lp.pool") exchange.IO("lp.plan")
Remarks
Each segment's liquidity is the liquidity inside it and amount0 and amount1 the amounts of both tokens in it (summed over the initialized ticks, in token units); price0Lower and price0Upper give token1 per token0 at the two ends; the segment with current true contains the current tick and is the only one holding both tokens. The token order is that of lp.pool.
The range is read through the tick bitmap; spans of more than 120 bitmap words (each covering 256 tick spacings) fail, so narrow the range or query it in parts.