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

Add to an existing position: the budget is split into the two tokens by the position's range and the current price, swapping first for the one that is short.

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

Examples

Add 50 USDC to the first SOL/USDC position.

javascript
function main() { var list = exchange.IO("lp.positions", "SOL_USDC") if (!list || list.length == 0) { Log("No SOL/USDC position") return } var r = exchange.IO("lp.increase", list[0].id, 50, {symbol: "SOL_USDC"}) if (!r) { Log("Increase failed:", GetLastError()) return } Log(r.id, "added", r.amountBase, "SOL", r.amountQuote, "USDC", "transaction", r.txHash) }

Returns

TypeDescription

object / null value

{txHash, swapTxHash, id, symbol, amountBase, amountQuote, feeSol}: amountBase and amountQuote are the amounts actually deposited (from the balances before and after), and swapTxHash is the signature of the swap made first (null without one). A null value is returned when funds are short, the position does not belong to this wallet, or a simulation or transaction fails.

Arguments

NameTypeRequiredDescription

k

string

Yes

Set to lp.increase to add to a position.

positionId

string

Yes

A position ID (the id of lp.positions, such as meteora:position address, raydium:NFT mint or orca:NFT mint; a bare address is accepted too). The position must belong to this wallet.

budget

number

Yes

The amount to add, in the quote token.

options

object

No

{symbol, shape, slippage}: symbol is the pair, setting the orientation and the currency of budget (by default the stablecoin, then SOL, is the quote); shape is the DLMM shape (default spot); slippage the price protection, default 0.01.

See Also

Remarks

Planning, swapping and execution work as in lp.add: the position's range is planned at the latest pool price, a shortfall is an error, a Jupiter market order swaps first when needed and is waited for, then the plan is redone and one transaction is sent.

Differences between protocols
  • Meteora DLMM: distributed over the position's bins by shape; only positions of at most 70 bins (a wider one does not fit in one transaction and fails).
  • Raydium CLMM: uses increase_liquidity_v2. When both tokens are needed one token's amount is fixed (the SOL side first) and the other is capped at the most it can take while the price moves within slippage (at least the planned amount × (1 + slippage)); when only one is needed (the range lies on one side of the price) a fixed liquidity is added, the other token capped at what the price moving into the range would take.
  • Orca Whirlpools: no width limit; both token amounts go on chain as maxima, and the program adds the most liquidity they allow at the execution price.

Execution

Every transaction is simulated by the node before sending and is not sent when the simulation fails, with the reason reported (DLMM, Raydium CLMM and Orca Whirlpool error codes with their names); the compute-unit limit is the simulated usage plus headroom, and the priority fee is the 75th percentile of recent fees paid by transactions writing the same accounts, capped by exchange.IO("priorityFee"). The call returns after confirmation, with actual amounts from the balances before and after. When within 120 seconds the transaction is neither confirmed nor provably expired, the error says outcome is unknown with the signature: it may have landed, so check it with exchange.IO("receipt") before retrying.