How-to for developers · Trading and DeFi

Use the AMM Auction Slot for Lower Fees

In plain words

This tutorial shows how to use the auction slot of an Automated Market Maker, or AMM, to pay lower fees when you trade against it. An AMM is a pool that swaps two assets, and whoever wins its auction slot trades at a discounted fee for a time.

Written by zerps in plain words, from the source linked below.
Section
Tutorials

What you will do

You estimate what an AMM would charge in trading fees for one trade, estimate what it costs to win the auction slot, and compare the two. If the slot is cheaper, you win it and then make the trade at the discount. The tutorial keeps things simple: you hold XRP, you want a fixed amount of one token in a single trade, and the whole trade runs through the AMM.

What you need

You need a basic understanding of the XRP Ledger and a client library such as xrpl.js. The AMM you want to trade against must already exist. For practice, the page offers an AMM set up on the XRP Ledger Testnet, where XRP holds no real-world value. You also need a high-precision number library such as Bignumber.js, and the AMM formulas from the appendix, which match the calculations the ledger uses.

Working out the numbers

Look up the AMM with the amm_info method on the current ledger. Run the SwapOut formula twice, once with the full fee and once with the discounted fee. The difference is the most you can save. The slot is always paid for in LP Tokens, the tokens that stand for a share of the pool. The AuctionDeposit formula tells you how many you need, and AssetIn tells you how much XRP to deposit to get them. Add an allowance for slippage, the change in rates before your transaction runs, and the cost of two transactions. If the total is higher than the savings, stop.

The three transactions

Send an AMMDeposit transaction to get the LP Tokens. Send an AMMBid transaction with your bid in the BidMax field. If you do not want to keep LP Tokens afterwards, set BidMin to the same value. Then make the trade with an OfferCreate transaction.

Good to know

You hold the slot until you are outbid or 24 hours have passed, whichever comes first. If you are outbid early, part of your LP Tokens is refunded, and an AMMWithdraw transaction turns them back into assets. The cost of outbidding a current holder falls over 24 hours, so you can also wait and try later.

Source: xrpl.org. Read 6 December 2026.

Zerpedia states what the source says, in plain words, and gives no opinion. How Zerpedia is made

zerps Trading tokens on the XRP Ledger carries risk, including total loss. zerps is a self-custodial interface; it does not hold funds, give advice, or execute trades on your behalf.