exchange.IO("lp.select", ...)
Automatically selects an LP pool by rule: chooses the pool with the highest 24h trading volume among pools with sufficient liquidity, or the pool with a specified fee tier.
exchange.IO(k, token, budget)
exchange.IO(k, token, budget, options)Examples
Select an ETH/USDC pool, then separately select one among V4 pools.
javascript
function main() {
var p = exchange.IO("lp.select", "ETH", 1000, {quote: "USDC"})
if (!p) {
Log("Pool selection failed:", GetLastError())
return
}
Log("Selected:", p.protocol, p.id, "Fee rate:", p.feeRate, "Reason:", p.reason)
// Select only among V4 pools (use infinity for PancakeSwap, slipstream etc. for Aerodrome and Velodrome)
var v4 = exchange.IO("lp.select", "ETH", 1000, {quote: "USDC", protocol: "v4"})
Log("V4 pool:", v4 ? v4.id : GetLastError())
}Returns
| Type | Description |
object / null value | The selected pool: one entry from the |
Arguments
| Name | Type | Required | Description |
k | string | Yes | Fixed as |
token | string | Yes | Token name or contract address, e.g. |
budget | number | Yes | Budget, denominated in the quote currency, used to set the liquidity threshold: the pool's TVL must be at least the greater of 5,000 USD and the budget. |
options | object | No | Pool selection criteria |
See Also
Uniswap / PancakeSwap Aerodrome / Velodrome exchange.IO exchange.IO("lp.pools") exchange.IO("lp.plan") exchange.IO("lp.pool")
Remarks
Fields of options:
| Key | Description |
|---|---|
quote | Quote currency, e.g. USDC; if omitted, pools pairing the token with the chain's wrapped native token, USDC or USDT are all compared |
fee | Preferred fee tier, in millionths, e.g. 500 |
exact | When true, only the fee tier given by fee is used |
protocol | Pool type, a string or an array: v3 or v4 for Uniswap; v3 or infinity for PancakeSwap; slipstream, slipstream2, volatile or stable for Aerodrome and Velodrome |
tickSpacing | Only selects pools with this tick spacing (mainly for Slipstream, whose pools are distinguished by tick spacing) |
Selection rules: first, empty pools and pools that do not match protocol or tickSpacing are excluded. If fee is specified, the pool with that fee tier is selected if it meets the liquidity threshold (reason is fee tier 500 requested); with exact set to true it is selected even if it does not meet the threshold; if no pool with that fee tier exists, an error is reported. Otherwise, among pools whose TVL is at least the greater of 5,000 USD and the budget, the one with the highest 24h trading volume is selected (largest 24h volume among pools with enough liquidity); if there is no volume data, the pool with the highest TVL is selected. If no pool meets the threshold, the pool with the highest TVL is selected and this is stated in reason.
The candidate pools are the pools listed by lp.pools (see the lp.pools page for where Uniswap V4 pools come from and when some may be missing). To use a pool not on that list, pass its PoolId directly as the pool of lp.plan.
When exchange.IO("lp.plan", ...) is called without pool, it selects a pool by the same rules (fee and tickSpacing are taken from the plan parameters; for Aerodrome and Velodrome, if range is specified, only Slipstream pools are considered). To open a position in a V4/Infinity CL pool on Uniswap or PancakeSwap, first select the pool with protocol, then pass its id as the plan's pool.