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

Queries the real-time state of a single pool, including its two tokens, fee tier, tick spacing, current tick, price and liquidity.

exchange.IO(k, poolId)

Examples

Inspect the token order and price of the selected pool.

javascript
function main() { var p = exchange.IO("lp.select", "ETH", 1000, {quote: "USDC"}) var pool = exchange.IO("lp.pool", p.id) if (!pool) { Log("Query failed:", GetLastError()) return } Log(pool.token0.symbol, "/", pool.token1.symbol, "tick:", pool.tick, "tick spacing:", pool.tickSpacing) Log("1", pool.token0.symbol, "=", pool.price0, pool.token1.symbol) }

Returns

TypeDescription

object / null value

{id, protocol, currency0, currency1, token0, token1, fee, tickSpacing, tick, sqrtPriceX96, price0, price1, liquidity}; see the remarks for a description of each field. If the pool does not exist, a null value is returned and an error is reported.

Arguments

NameTypeRequiredDescription

k

string

Yes

Fixed as lp.pool, indicating a pool query.

poolId

string

Yes

Pool ID: for V3, Slipstream and basic pools it is the pool contract address; for V4/Infinity CL it is the PoolId (0x followed by 64 hexadecimal characters). It can be taken from the id field in the results returned by lp.pools or lp.select.

See Also

Remarks

Pools are ordered by token0 and token1 as defined in the contract (the token with the smaller address is token0), which does not necessarily match the base currency and quote currency of the trading pair: token0 and token1 are {address, decimals, symbol}, while currency0 and currency1 are the addresses of the two tokens (in V4/Infinity CL pools, the native coin is the zero address); price0 is the amount of token1 that 1 token0 can be swapped for, and price1 is the amount of token0 that 1 token1 can be swapped for; sqrtPriceX96 and liquidity are decimal strings of the pool's raw values.

Uniswap, PancakeSwap: V3 only supports pools created by this exchange's factory contract; if no pool exists at the address, pool … not found is reported. V4/Infinity CL only supports pools without hooks.

Uniswap V4: the pool does not need to appear in lp.pools. Since V4's PoolManager does not store the PoolKey, a query by PoolId performs a reverse lookup through the PositionManager's poolKeys, so pools that have had positions on the PositionManager or that were once listed by lp.pools can be found; pools in which no one has ever opened a position through the PositionManager cannot be found, and pool … not found is reported. There is no cap on the fee (V4 static fees can be as high as 100%), so high-fee pools such as 2% can likewise be queried and have positions opened in them.

PancakeSwap Infinity CL: any initialized pool can be found by PoolId, but only pools with a fee of no more than 1% are supported; if the fee exceeds this, is not initialized or its fee is above 1% is reported.

Aerodrome, Velodrome: the result additionally includes gauge information (same as lp.pools: gauge, gaugeAlive, stakedShare, rewardsPerDay, rewardsPerDayUsd, rewardAprPct; rewardAprPct uses the same TVL calculation as lp.pools and is likewise an instantaneous value that may fluctuate significantly; see the lp.pools page for details); basic pools additionally include the reserves reserve0 and reserve1 and the total LP token supply lpSupply.