Skip to content
Learn the Ledger poster: Two Ways to Find a Trade. Kev and two koala friends at a table where glowing order book and AMM pool screens feed into one trade, with the line XRPL trades can use order books, AMM pools, or both in one transaction.

Lesson 3

Two ways to find a trade

XRPL trades can use order books, AMM pools, or both in one transaction. Built-in liquidity tools help connect buyers and sellers.

Say Kev wants to swap some XRP for $XYZ. One trader has $XYZ up for sale, and an on-ledger pool holds $XYZ too. If the trader’s offer only covers part of Kev’s swap, the XRP Ledger’s built-in decentralised exchange (DEX) can fill the rest from the pool in the same transaction, provided the trade stays within the terms Kev set.

How does an order book work?

An order book lists offers from people willing to buy or sell an asset at a set price. If someone is offering 1,000 $XYZ at a rate Kev is happy with, his trade can match that offer. If he wants more than 1,000, the next seller might ask for more XRP per token. The best price on the screen only applies to the amount available at that price.

How does an AMM pool work?

An automated market maker (AMM) holds two assets in a pool. When Kev swaps XRP for $XYZ, XRP goes into the pool and $XYZ comes out. A formula uses the pool’s balances to set the exchange rate, and the pool can charge a trading fee. As the swap changes those balances, the rate moves. A large swap relative to the size of the pool will generally move it more. That’s price impact.

How can one trade use both?

Imagine the order book has the better rate for Kev’s first 1,000 $XYZ, and the pool has a better rate than the next seller. The DEX can take the first offer and get some or all of the remaining tokens from the pool. Which source it uses depends on the prices and amounts available when the transaction executes.

People who deposit assets into an AMM receive LP tokens representing a share of the pool. They can benefit from trading fees, but if the price of one asset moves sharply relative to the other, their share can be worth less than if they’d simply held both assets.

Kev’s tip: Check the estimated amount you’ll receive for your whole swap. The best displayed rate might only cover the first part.

Sources

#XRPLEducationMonth

XRPL Foundation