Withdraw liquidity
Withdraw liquidity from an Aquarius pool with the official SDK — burn pool shares for the underlying tokens, guarded by per-token minimums.
Burn pool share tokens and receive the underlying tokens back. The SDK reads your share balance, derives per-token minimums from a simulation of your exact withdrawal, and returns the amounts you received.
This page continues from the client setup in Deposit liquidity. For the raw router signature — withdraw(user, tokens, pool_index, share_amount, min_amounts) — see Router & pool contracts.
1. Read your share balance
pool = next(p for p in aqua.pools_for_pair(XLM, AQUA) if p.type == "volatile" and p.fee_bps == 30)
shares = pool.share_balance() # the signer's shares; pass an address to check another accountconst pool = (await aqua.pools.forPair(XLM, AQUA)).find(p => p.type === "volatile" && p.feeBps === 30);
const shares = await pool.shareBalance(); // the signer's shares; pass an address to check another accountTo find every pool where an account holds shares, use positions() — see Get pools info.
2. Withdraw
Pass the share amount to burn — all of it, or any part. A withdrawal right after a deposit into a pool with rewards first waits for the next ledger: simulation runs on the latest ledger's state, and a withdrawal simulated on the ledger that applied the deposit fails on-chain once rewards accrue. wait_for_next_ledger() returns once the RPC reports a ledger after the one that applied the client's last transaction:
aqua.wait_for_next_ledger() # past the ledger that applied the deposit
result = pool.withdraw(shares, slippage=0.01)
print(f"received: {result.amounts}") # base units returned, in sorted-token order
print(f"transaction: {result.tx_hash}")await aqua.waitForNextLedger(); // past the ledger that applied the deposit
const result = await pool.withdraw({ shares, slippage: 0.01 });
console.log(`received: ${result.amounts}`); // base units returned, in sorted-token order
console.log(`transaction: ${result.txHash}`);The slippage guard mirrors the deposit's: the SDK simulates the exact withdrawal, takes the estimated per-token amounts, and submits with minimums reduced by slippage (default 1%). Withdrawing does not claim accrued rewards — that is a separate call, and the rewards keep waiting for you either way: Claim LP rewards.
Last updated