
Order books and offers
4 minDifficulty Checked 2026-11-10- The DEX is part of the ledger and has run since 2012.
- A trade is an offer: a limit order for one asset against another.
- Matching offers fill best rate first. The unfilled rest waits in the order book.
Most crypto exchanges are companies. You send them your coins, and they keep the list of who wants to buy and sell.
The XRP Ledger has that list built in. It is called the decentralized exchange, or DEX. It has run since the ledger started in 2012. No company holds your coins while you trade. They stay in your account until a trade happens.
A trade is called an offer. An offer says two things: what you want, and the most you will give for it. For example: "I want 100 FOO. I will pay up to 1,000 XRP."
The ledger looks for people offering the other side of that trade. It takes the best deals first. Three things can happen:
- Full fill. Enough matching offers exist. You get your 100 FOO at once.
- Partial fill. Only 22 FOO are for sale at your rate. You get 22 now. The rest of your offer waits in line.
- No fill. Nothing matches. Your whole offer waits in line.
The line is called an order book. There is one for each pair of assets. Anyone can read it.
A waiting offer can be filled later by someone else's trade. You can cancel it at any time.
Anyone can make a token with any name and sell it on the DEX. Two tokens can share the code "USD" and come from different issuers. Check the issuer before you buy.
An offer is created with an OfferCreate transaction. Two fields set the trade:
TakerPays: the amount the offer's owner wants to receive.TakerGets: the amount the owner will give.
The names describe the trade from the side of whoever takes the offer.
Processing an OfferCreate:
- The ledger computes the offer's exchange rate from the two amounts.
- It finds the order book for the reverse direction.
- The new offer consumes matching offers, best rate first. Offers at the same rate are taken oldest first.
- Bought tokens go to the owner's trust line. If the line does not exist, the ledger creates it with a limit of 0.
- Any remainder becomes an
Offerledger entry at the original rate.
An offer can fill at a better rate than requested when it is first placed. Once it rests in the book, it fills at exactly its stated rate, apart from rounding.
Pairs are not listed or approved. A pair exists when someone trades it. A token is identified by issuer plus currency code, so same-code tokens from two issuers are two different assets with their own books.
Trades execute only when a ledger closes, about every 3 to 5 seconds. The order of transactions inside one ledger is deterministic but designed to be hard to predict, which discourages front-running. The ledger has no native market orders, stop orders or leverage.
The network charges only the normal transaction cost, which is destroyed and paid to no one. A token issuer can set a transfer fee on its own token. That fee applies when the token moves between two accounts that are not the issuer.
Cross-currency payments consume offers too, but never leave an Offer entry behind. Offers and payments can also trade against AMM pools when that gives a better rate.
Related: Trust lines and issued tokens, Placing an offer.
- Decentralized Exchange (DEX)Read 2026-11-10
- OffersRead 2026-11-10
- Transfer FeesRead 2026-11-10
- Automated Market MakersRead 2026-11-10
- OfferCreateRead 2026-11-10
