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

Pick a concentrated-liquidity pool for a token automatically, by a TVL floor and the 24h volume.

exchange.IO(k, token, budget)
exchange.IO(k, token, budget, options)

Examples

  • Pick a SOL/USDC pool for a budget of 100 USDC.

    javascript
    function main() { var pool = exchange.IO("lp.select", "SOL", 100, {quote: "USDC"}) if (!pool) { Log("Selection failed:", GetLastError()) return } Log("Picked:", pool.dex, pool.id, "fee", pool.fee / 1e4 + "%", "reason:", pool.reason) }
  • Pick only among Raydium and Orca pools.

    javascript
    function main() { var pool = exchange.IO("lp.select", "SOL", 100, {quote: "USDC", protocol: ["raydium", "orca"]}) if (!pool) { Log("Selection failed:", GetLastError()) return } Log(pool.dex, pool.id, "tickSpacing", pool.tickSpacing, "24h volume", Math.round(pool.volume24hUsd)) }

Returns

TypeDescription

object / null value

The chosen pool: one lp.pools row with an extra reason (the reason for the choice, in English). A null value is returned when no pool matches the filters, the token cannot be recognized or a request fails.

Arguments

NameTypeRequiredDescription

k

string

Yes

Set to lp.select to pick a pool.

token

string

Yes

The token, written as the token of lp.pools; it is the base token.

budget

number

Yes

The amount to invest, in the quote token; it sets the TVL floor.

options

object

No

Filters {quote, protocol, fee, binStep, tickSpacing}, all optional, see the remarks.

See Also

Remarks

Filters
KeyDescription
quoteThe quote token; without it, pools against SOL, USDC and USDT are considered
protocolThe protocol: meteora, raydium, orca, or an array of them
feeThe base fee in the unit of lp.pools' fee (millionths), such as 400
binStepOnly Meteora pools with this bin step
tickSpacingOnly Raydium and Orca pools with this tick spacing

Selection rule
  1. The lp.pools rows are filtered; nothing left is an error.
  2. The floor is the larger of $5000 and budget in USD, with budget valued at the USD price of the first pool's quote token.
  3. Among pools whose USD TVL reaches the floor, the one with the largest 24h volume wins; if none of them has volume data, the largest TVL; if no pool reaches the floor, the largest TVL of all.

reason names the case, as in highest 24h volume among pools with TVL >= $5000, largest TVL among pools with TVL >= $5000 (no volume data) and no pool reaches $5000 TVL; picked the largest.

exchange.IO("lp.plan") picks the pool by the same rule when pool is not given (taking fee, protocol, binStep and tickSpacing from the plan parameters). The busiest pool is not necessarily the best for a position: the fee and the price grid (binStep, tickSpacing) decide the fee income and how precise the range can be.