Back to Guides

XRPL AMM Guide

The XRP Ledger has native Automated Market Maker pools built directly into the protocol. No smart contracts, no third-party risk. Here is how they work and how to interact with them.

What is the XRPL AMM

An Automated Market Maker (AMM) is a liquidity pool that allows token swaps without a traditional order book. Instead of matching buyers with sellers, an AMM uses a mathematical formula to price trades based on the ratio of two assets in a pool. The XRPL AMM was activated through the AMM amendment and runs at the protocol level alongside the existing order book DEX.

This means the XRPL has both an order book DEX and AMM pools operating simultaneously. When you make a trade, the protocol automatically finds the best price across both the order book and AMM pools.

How it works

The XRPL AMM uses a constant product formula (similar to Uniswap v2). Each pool holds two assets and prices them according to the formula: x * y = k, where x and y are the quantities of each asset and k is a constant.

  • Liquidity providers deposit equal value of two assets into a pool and receive LP (Liquidity Provider) tokens representing their share
  • Traders swap one asset for another, paying a fee that goes to liquidity providers
  • The protocol automatically adjusts prices based on supply and demand within the pool

Providing liquidity

Anyone can provide liquidity to an XRPL AMM pool by depositing tokens. In return, you receive LP tokens that represent your proportional share of the pool. As trades occur, fees accumulate in the pool, increasing the value of your LP tokens over time.

To provide liquidity, you need:

  • Equal value of both assets in the pool pair
  • Trust lines to both token issuers (if not XRP)
  • A standard XRPL transaction fee (about 0.00001 XRP)

You can withdraw your liquidity at any time by redeeming your LP tokens for the underlying assets.

Trading fees

XRPL AMM pools charge a trading fee on each swap. The fee is set by a governance mechanism where LP token holders can vote on the fee percentage. Fees are distributed proportionally to all liquidity providers based on their share of the pool.

The fee structure incentivizes liquidity provision -- the more trading volume a pool has, the more fees it generates for providers.

AMM vs order book

The XRPL is unique in having both systems running natively:

  • Order book DEX: Better for large trades (less slippage), professional trading, and precise limit orders
  • AMM pools: Better for long-tail token pairs with less liquidity, passive income for LPs, and guaranteed execution
  • Combined: The protocol routes trades through whichever gives the better price, maximizing efficiency

Impermanent loss

Like all AMMs, XRPL pools carry impermanent loss risk. If one asset's price changes significantly relative to the other, liquidity providers may end up with less value than if they had simply held both assets. Trading fees can offset this loss, but it is an important risk to understand before providing liquidity.

Querying AMM data via API

XRPL Stream provides full API access to AMM pool data:

  • amm_info: Query any AMM pool's current state including reserves, LP token supply, and trading fee
  • account_lines: Check LP token balances for any account
  • book_offers: See order book liquidity alongside AMM pricing
  • subscribe: Stream real-time AMM trades and liquidity changes via WebSocket
  • account_tx: Full history of AMM deposits, withdrawals, and swaps

All AMM data is available from the moment the pools were first created, through XRPL Stream's full history access.

Get API Access XRPL API Guide