exchange.IO("lp.decrease", ...)
Withdraws a ratio of a position's liquidity and collects all its fees; the position stays (a ratio of 1 empties it without burning the NFT).
exchange.IO(k, positionId, ratio)
exchange.IO(k, positionId, ratio, options)Examples
Withdraw half of the liquidity and sell the returned ETH for USDC.
javascript
function main() {
var id = "1381183" // position ID from lp.add or lp.positions
var r = exchange.IO("lp.decrease", id, 0.5, {sell: true})
if (!r) {
Log("Decrease failed:", GetLastError())
return
}
var p = r.positions[0]
Log("Principal:", p.principalBase, "ETH +", p.principalQuote, "USDC")
Log("Fees:", p.feesBase, "ETH +", p.feesQuote, "USDC")
Log("Sold:", r.sells)
}Returns
| Type | Description |
object / null value |
|
Arguments
| Name | Type | Required | Description |
k | string | Yes | Set to |
positionId | string / number | Yes | Position ID. |
ratio | number | Yes | Ratio to withdraw, above 0 and at most 1. |
options | object | No |
|
See Also
Uniswap / PancakeSwap Aerodrome / Velodrome exchange.IO exchange.IO("lp.remove") exchange.IO("lp.collect") exchange.IO("lp.increase") exchange.IO("lp.positions")
Remarks
Fields: txHash is the transaction; positions gives, per position, the withdrawn principal principalBase and principalQuote, the collected fees feesBase and feesQuote, and what actually arrived, receivedBase and receivedQuote (principal plus fees); sells lists the market orders selling back to the quote token, [{symbol, qty, txHash}], with {symbol, qty, error} for a sale that failed without affecting the others, and is empty without selling. Amounts are in token units, oriented by the position's pair (the stablecoin is the quote by default).
Compared with exchange.IO("lp.remove", ...): lp.decrease handles one position with price protection and always keeps the NFT; lp.remove takes several positions at once and burns the NFT on a full withdrawal. To collect fees without touching the principal use lp.collect.
In V3 and Slipstream pools the native coin takes part as its wrapped token, so it comes back wrapped (such as WETH); use exchange.IO("unwrap", ...) for the native coin. Aerodrome and Velodrome: a staked position must first be taken out with exchange.IO("lp.unstake") (a basic pool only needs enough unstaked LP tokens in the wallet); basic pools redeem the tokens behind that share of the LP tokens.