How-to for developers · Trading and DeFi

Create an Automated Market Maker

In plain words

This tutorial shows how to create an Automated Market Maker, or AMM, for a pair of assets on the XRP Ledger. An AMM is a pool that lets people swap between two assets, and the people who supply the pool can earn income from it.

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

What you will do

You connect to a test network, get the two assets, check that no AMM exists for the pair yet, look up the cost, and send one AMMCreate transaction. As the creator you are also the pool's first liquidity provider, which means you supply its starting assets. The AMM feature was added by the AMM amendment, enabled on 2024-03-22.

What you need

You need an XRP Ledger address and some XRP. For testing you can get both from a faucet. The examples use JavaScript with the xrpl.js library, version 2.11.0 or later. You must hold a balance of both assets, or be their issuer. Any pair of XRP or tokens works if it meets the restrictions on AMM assets. Choose the pair carefully, because you supply amounts of both for others to swap between.

The steps in short

Use the amm_info method to check the pair. There can be only one AMM per pair, and an actNotFound error means none exists yet. Then look up the current owner reserve with the server_state method, because AMMCreate burns at least that much XRP as its transaction cost. In the AMMCreate transaction you give Asset and Asset2, the two starting amounts, which should be about equal in total value. You also set TradingFee, where the maximum of 1000 means a 1% fee. Submit with fail_hard so that many kinds of failure do not cost you the high fee.

After the AMM exists

Call amm_info again to see the new AMM. Its lp_token field shows the issuer and currency code of the LP Tokens, which stand for a share of the pool. Their hex currency code always starts with 03, and their issuer is the AMM's own address. The account_lines method shows your token balances, now lower by what you deposited, plus your LP Tokens. Others can deposit at any time, so the total in amm_info is not always your own balance.

Good to know

The page gives the AMMCreate cost as 0.2 XRP at the time of writing, against 0.000010 XRP for a typical transaction. Ripple provides Testnet and Devnet for testing only and sometimes resets them, so do not use the same addresses there and on Mainnet.

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.