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

Lists a wallet's LP positions with range, in-range flag, liquidity, current amounts and value, and uncollected fees.

exchange.IO(k)
exchange.IO(k, filter)
exchange.IO(k, filter, wallet)

Examples

View any wallet's ETH/USDC positions read-only: in range or not, value and uncollected fees.

javascript
function main() { // omit the third argument to view this exchange object's wallet var wallet = "0xc1906cb9b3e7ab44dec8b0ab6894f8ccbbe40a72" var ps = exchange.IO("lp.positions", "ETH_USDC", wallet) if (!ps) { Log("Query failed:", GetLastError()) return } ps.filter(function (p) { return !p.closed }).forEach(function (p) { Log(p.id, p.protocol, "range", p.priceLower, "~", p.priceUpper, p.inRange ? "in range" : "out of range", "value:", p.value, "fees:", p.feesValue) }) }

Returns

TypeDescription

array / null value

An array of positions [{id, pool, protocol, symbol, fee, tickLower, tickUpper, priceLower, priceUpper, price, tick, inRange, liquidity, amountBase, amountQuote, value, feesBase, feesQuote, feesValue, closed}]; see the remarks. Null when the node fails.

Arguments

NameTypeRequiredDescription

k

string

Yes

Set to lp.positions to list positions.

filter

string

No

A pair (such as ETH_USDC, which also sets the price orientation) or a token (such as ETH, only positions containing it); * or nothing lists all positions.

wallet

string

No

Another wallet's address, to view its positions read-only; this exchange object's wallet when omitted.

See Also

Remarks

Fields of each position:

FieldDescription
id, pool, protocol, symbol, feePosition ID, pool ID, pool type, pair and fee (millionths)
tickLower, tickUpper, priceLower, priceUpperThe position's range in ticks and prices (quote per base)
price, tick, inRangeThe pool's current price and tick, and whether the price is inside the range (no fees are earned outside it)
liquidityThe position's liquidity (decimal string)
amountBase, amountQuote, valueCurrent token amounts and their value in the quote token
feesBase, feesQuote, feesValueUncollected fees and their value in the quote token
closedtrue for a position with no liquidity and no uncollected fees (emptied, NFT still there)

Orientation: a pair given as filter sets it; otherwise the stablecoin is the quote, so without a pair V3 positions show the wrapped spelling such as WETH_USDC.

How positions are found: V3 positions are listed by the PositionManager per wallet (only the latest 2000 when the wallet holds very many NFTs). The V4/Infinity CL PositionManager cannot list a wallet's positions, so they are found from the logs of NFTs sent to the wallet: a node that serves the full log history finds all of them, while public nodes usually serve only recent blocks, so register older positions with exchange.IO("lp.track", ids) (positions created by lp.add in this process are remembered automatically); their IDs look like v4:123456 or inf:123456.

Aerodrome and Velodrome: Slipstream positions in the wallet are listed directly; staked position NFTs are owned by the gauge, so the gauges staked into by this process, found in the logs, holding positions registered with lp.track or matching filter are checked; basic pools are checked when added to by this process, registered with lp.track, matching filter, or on the common pairs of the token table. Each row also has staked, gauge, rewardToken (the reward token), rewards (claimable reward tokens) and rewardsValue (in the quote token); basic pools also have fullRange, lpTokens and stakedLpTokens and no ticks.