exchange.IO("lp.positions", ...)
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
| Type | Description |
array / null value | An array of positions |
Arguments
| Name | Type | Required | Description |
k | string | Yes | Set to |
filter | string | No | A pair (such as |
wallet | string | No | Another wallet's address, to view its positions read-only; this exchange object's wallet when omitted. |
See Also
Uniswap / PancakeSwap Aerodrome / Velodrome exchange.IO exchange.IO("lp.add") exchange.IO("lp.collect") exchange.IO("lp.remove") exchange.IO("lp.track") exchange.IO("lp.history")
Remarks
Fields of each position:
| Field | Description |
|---|---|
id, pool, protocol, symbol, fee | Position ID, pool ID, pool type, pair and fee (millionths) |
tickLower, tickUpper, priceLower, priceUpper | The position's range in ticks and prices (quote per base) |
price, tick, inRange | The pool's current price and tick, and whether the price is inside the range (no fees are earned outside it) |
liquidity | The position's liquidity (decimal string) |
amountBase, amountQuote, value | Current token amounts and their value in the quote token |
feesBase, feesQuote, feesValue | Uncollected fees and their value in the quote token |
closed | true 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.