exchange.IO("lp.pool", ...)
Read the live state and statistics of a concentrated-liquidity pool.
exchange.IO(k, poolId)Examples
Read a pool and derive the price from the current bin or tick.
javascript
function main() {
var sel = exchange.IO("lp.select", "SOL", 100, {quote: "USDC"})
if (!sel) {
Log("Selection failed:", GetLastError())
return
}
var p = exchange.IO("lp.pool", sel.protocol + ":" + sel.id)
if (!p) {
Log("Read failed:", GetLastError())
return
}
var scale = Math.pow(10, p.decimalsX - p.decimalsY)
var calc = p.protocol == "meteora"
? Math.pow(1 + p.binStep / 10000, p.activeId) * scale
: Math.pow(1.0001, p.tick) * scale
Log(p.dex, p.symbolX + "/" + p.symbolY, "price", p.price, "derived", calc)
Log("reserves", p.reserveX, p.symbolX, p.reserveY, p.symbolY, "24h fees", p.fees24hUsd)
}Returns
| Type | Description |
object / null value | The common fields |
Arguments
| Name | Type | Required | Description |
k | string | Yes | Set to |
poolId | string | Yes | The pool address (a DLMM LbPair account, a Raydium CLMM PoolState account or an Orca Whirlpool account), optionally written |
See Also
Remarks
X and Y follow the pool's own token order: price is the Y value of one X, and reserveX and reserveY are the pool's balances of the two tokens. lp.pools converts to base and quote tokens around the token queried, lp.pool does not; for a quote-per-base price, check the orientation with symbolX and symbolY. An empty pool has price 0.
Fields by protocol
protocol | Extra fields |
|---|---|
meteora | binStep, activeId, feeRateNow, enabled |
raydium | tickSpacing, tick, liquidity, sqrtPriceX64, enabled |
orca | tickSpacing, tick, liquidity, sqrtPriceX64, adaptiveFee, fullRangeOnly |
See exchange.IO("lp.pools") for their meaning and the form of rewards.
Price and index: the price of DLMM bin i is (1 + binStep/10000)^i, that of Raydium or Orca tick i is 1.0001^i, both multiplied by 10^(decimalsX − decimalsY) for readable units.