advanced 35 min

AMMs beyond pool creation

Interpret AMM reserves, LP-token ownership, fees, price impact, and the deposit and withdrawal modes used in production applications.

Prerequisites

Complete these before starting this module:

What you'll learn

  • Read reserves, fee, AMM account, and LP supply from amm_info.
  • Explain an LP token as a proportional claim.
  • Distinguish two-asset and single-asset operations.
  • Explain price impact and CLOB/AMM interaction.
Complete this module by a quiz. Jump to assessment

Read the pool before you change it

An AMM (Automated Market Maker) is a shared pool of two assets — say XRP and TST — that quotes a price from a formula instead of from an order book. Ask amm_info and you get the whole picture of a pool: its two balances (the reserves), its trading fee, its account, and the total supply of LP tokens.

An LP token is your receipt for adding liquidity, and it stands for a share of the pool. Hold 100 of a pool's 1,000 LP tokens and you own a tenth of it; what that tenth is worth rises and falls as people trade.

XRPL AMM deposit, swap, and withdrawal flow

Constant-product reserve curve and price movement

Treat the current price as a snapshot only. XRPL AMMs follow a constant-product curve, so a bigger trade earns a worse average price by pushing the two balances further apart. Fees stay in the pool and grow it. When you report a trade, compare your quote against the reserves in the validated result rather than trusting the price you started from.

Two ways to add or remove liquidity

  • A two-asset (proportional) deposit adds both assets at the pool's current ratio. If the pool holds 500 XRP against 1,000 TST (1:2), you add 5 XRP and 10 TST together. The price stays put, which makes this the clearest place to begin.
  • A single-asset deposit adds one asset only, tilts the ratio and the price, and pays a small fee.

Withdrawals mirror the same two modes, and a transaction flag picks which one you mean. Before you submit, call which way the balances and your LP-token count should move, then check the result against your call. Because AMM liquidity belongs to the same DEX, ordinary payments and offers tap it without any extra work.

Assignments

0 of 1 complete

Unlocks

Finishing this module opens up: