
Deposits and withdrawals
4 minDifficulty Checked 2026-11-10- Depositing both assets in the pool's ratio carries no fee.
- Depositing or withdrawing one asset pays the trading fee on the part that must be swapped.
- Creating a pool destroys 0.2 XRP instead of the normal transaction cost.
There are two ways into a pool.
Both assets. You add XRP and FOO in the same ratio the pool already holds. The pool gets bigger and its price does not move. No fee.
One asset. You add only XRP. That would tip the balance, so the pool treats part of your deposit as a swap into FOO. You pay the trading fee on that part. You get slightly fewer LP tokens than with a balanced deposit.
Leaving works the same way. Take both assets in the pool's ratio and there is no fee. Take only one and you pay the fee on the part that had to be swapped.
LP tokens arrive on a trust line to the pool's account. The ledger opens that line for you. It locks 0.2 XRP of reserve like any other trust line.
Anyone can start a pool for a pair that has none. The creator supplies both assets and picks the starting fee. The starting ratio sets the starting price, so a wrong ratio gives traders a cheap deal at the creator's expense.
A pool ends when the last LP tokens are redeemed and it holds nothing. The ledger then deletes it.
AMMCreate takes Amount, Amount2 and TradingFee (0 to 1000, in units of 1/100,000, so 1000 is 1%).
- Cost: at least one owner reserve, 0.2 XRP, destroyed. This replaces the standard minimum cost.
- Token issuers must have Default Ripple on, or the result is
terNO_RIPPLE. - Not allowed as pool assets: another AMM's LP tokens, or Single Asset Vault shares.
tecDUPLICATEif the pair already has an AMM.tecFROZENif either asset is frozen.tecNO_AUTHif the sender is not authorized to hold an asset that uses authorized trust lines.
AMMDeposit needs Asset, Asset2 and exactly one mode flag.
| Flag | Fields | Kind |
|---|---|---|
tfLPToken | LPTokenOut | Both assets, for an exact LP amount |
tfTwoAsset | Amount, Amount2 | Both assets, up to these amounts |
tfSingleAsset | Amount | One asset, exact amount |
tfOneAssetLPToken | Amount, LPTokenOut | One asset, for an exact LP amount |
tfLimitLPToken | Amount, EPrice | One asset, capped price per LP token |
tfTwoAssetIfEmpty | Amount, Amount2 | Refill an empty AMM |
A deposit fails with tecFROZEN if either pooled asset is frozen, and with tecNO_AUTH if the sender is not authorized for either one. If the sender lacks XRP for the LP token trust line, the result is tecINSUF_RESERVE_LINE.
AMMWithdraw mirrors this with LPTokenIn. Extra modes: tfWithdrawAll returns all your LP tokens for both assets. tfOneAssetWithdrawAll returns all of them for one asset.
Single-asset fee. A single-asset deposit is priced as if you swapped part of it for the other asset, then made a balanced deposit. The trading fee applies only to the swapped part. Single-asset withdrawals work the same way in reverse.
Deletion. When AMMWithdraw takes the last assets, the ledger deletes the AMM, its account and its trust lines. If more than 512 trust lines are attached, the AMM stays in the ledger, empty. Anyone can then send AMMDelete, which removes up to 512 lines per transaction, or refill it with tfTwoAssetIfEmpty. No refund or reward exists for deleting an empty AMM.
Related: Pools and LP tokens, Owner reserve.
- AMMCreateRead 2026-11-10
- AMMDepositRead 2026-11-10
- AMMWithdrawRead 2026-11-10
- AMMDeleteRead 2026-11-10
- Automated Market MakersRead 2026-11-10
