For the complete documentation index, see llms.txt. This page is also available as Markdown.

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 account
const 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 account

To 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:

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}")
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.

The receiving account must hold a trustline for every classic asset the pool returns. Withdrawing a position you deposited from the same account always satisfies this; a missing trustline fails with a NoTrustlineError naming the fix.

Last updated