AMMs on XRPL - Automated Market Making | DeFi Fundamentals on XRPL | XRP Academy - XRP Academy
3 free lessons remaining this month

Free preview access resets monthly

Upgrade for Unlimited
Skip to main content
beginner60 min

AMMs on XRPL - Automated Market Making

Learning Objectives

Explain how the XRPL AMM works including the constant product formula and protocol-level implementation

Understand the continuous auction mechanism and how it differs from Ethereum AMMs

Evaluate liquidity provision opportunities including expected returns and impermanent loss scenarios

Choose between AMM and order book DEX for different trading scenarios

Assess AMM pool health before committing capital

For over a decade, XRPL had only an order book DEX. In 2024, the AMM amendment (XLS-30) passed, adding automated market maker functionality directly to the protocol.

  • Protocol-native (not a smart contract)
  • Continuous auction mechanism to reduce MEV
  • Integration with existing order book
  • Same security model as core XRPL

The result: XRPL now has both order book and AMM trading, giving users and liquidity providers more options.


XRPL AMM BASICS

Core concept (same as Uniswap v2):
├── Pool holds two assets
├── Constant product formula: x × y = k
├── Price determined by ratio
├── Trades change ratio → change price
└── Liquidity providers earn fees

XRPL-specific:
├── Native to protocol (not smart contract)
├── AMM account holds pool assets
├── LP tokens are issued currencies
├── Integrates with order book DEX
└── Continuous auction mechanism
```

CONSTANT PRODUCT MECHANICS

Formula: x × y = k

Example pool:
├── Asset X: 100,000 XRP
├── Asset Y: 250,000 RLUSD
├── k = 100,000 × 250,000 = 25,000,000,000
├── Implied price: 250,000/100,000 = 2.50 RLUSD/XRP

Trade: Buy 1,000 XRP
├── New X balance: 100,000 - 1,000 = 99,000 XRP
├── Required Y to maintain k: 25B / 99,000 = 252,525 RLUSD
├── Cost: 252,525 - 250,000 = 2,525 RLUSD
├── Effective price: 2,525/1,000 = 2.525 RLUSD/XRP
├── Price impact: (2.525 - 2.50) / 2.50 = 1%
└── Slippage increases with trade size

After trade:
├── Pool: 99,000 XRP + 252,525 RLUSD
├── New price: 252,525/99,000 = 2.55 RLUSD/XRP
├── Price moved up (fewer XRP in pool)
└── Arbitrageurs will rebalance
```

XRPL AMM vs ETHEREUM AMM

XRPL AMM Uniswap
─────────────────────────────────────────────────────────
Implementation Protocol-native Smart contract
Smart contract risk None Yes
Upgrade mechanism XRPL amendments Contract upgrade
Gas costs ~$0.0002 $5-50+
MEV protection Continuous auction Flashbots, etc.
Composability Limited Extensive
Ecosystem Small Massive

Why protocol-native matters:
├── No smart contract vulnerabilities
├── Same security as XRPL itself
├── Upgrades via consensus
├── Simpler audit surface
└── But: Less flexible than contracts
```


CONTINUOUS AUCTION EXPLAINED

Problem with standard AMMs:
├── Fixed 0.3% fee for everyone
├── Arbitrageurs profit at LP expense
├── MEV extractors front-run trades
├── LPs lose to informed traders
└── Adverse selection problem

XRPL's solution: Auction for better rates
├── Traders bid for discounted trades
├── Higher bid = better rate
├── Auction proceeds go to LPs
├── Reduces arbitrageur profits
└── Value stays with liquidity providers

How it works:
├── Base trading fee: 0.5% (example)
├── Auction slot available
├── Bid for slot: Pay premium to pool
├── Win slot: Trade at 0% fee for period
├── LPs get bid payment
└── Continuous process
```

AUCTION SLOT DETAILS

Slot duration: 24 hours
├── Winner gets discounted trading
├── Fee goes to 0% for slot holder
├── Must outbid current holder
├── Minimum bid increment required
└── Creates ongoing competition

Bidding:
├── Bid with LP tokens
├── Minimum: Function of pool size
├── Higher bid wins immediately
├── Old holder gets partial refund
└── Complex game theory

Benefits:
├── Arbitrage profits → LP profits
├── Reduced MEV extraction
├── More LP-friendly
├── Novel mechanism
└── Aligns incentives better

Complexity:
├── More complicated than simple AMM
├── Optimal bidding is non-trivial
├── May favor sophisticated actors
├── Still being battle-tested
└── Unique to XRPL
```

CONTINUOUS AUCTION EFFECTS

For traders:
├── Standard trades: Normal fee
├── Arbitrageurs: Must bid for slots
├── Regular users: Similar experience
├── Large traders: May bid for slots
└── More fair overall (in theory)

For LPs:
├── Trading fees (standard)
├── Plus: Auction bid payments
├── Reduced loss to arbitrageurs
├── Potentially higher returns
└── But: Need more data to confirm

Current reality:
├── Mechanism is new
├── Limited track record
├── Theoretical benefits plausible
├── Actual results TBD
└── Monitor as ecosystem matures
```


LP PROCESS ON XRPL

Step 1: Choose a pool
├── Existing pool or create new
├── Consider liquidity and volume
├── Assess impermanent loss risk
├── Check current fee tier
└── Understand both assets

Step 2: Deposit assets
├── Equal value of both assets
├── Pool calculates your share
├── Receive LP tokens
├── LP tokens are issued currency
└── Requires trust line for LP token

Step 3: Earn fees
├── Trading fees accrue to pool
├── Auction bids accrue to pool
├── Your share proportional to LP tokens
├── Withdraw anytime to realize
└── Subject to impermanent loss

Step 4: Withdraw
├── Return LP tokens
├── Receive share of pool
├── May be different ratio than deposit
├── Impermanent loss realized
└── Calculate net return
```

IMPERMANENT LOSS REVIEW

What is impermanent loss?
├── Loss vs just holding assets
├── Caused by price changes
├── Greater price move = greater IL
├── "Impermanent" only if price returns
└── Permanent if you exit

XRPL example:
├── Deposit: 10,000 XRP + 25,000 RLUSD
├── Initial price: 2.50 RLUSD/XRP
├── Total value: $50,000

XRP rises to $5.00:
├── Pool rebalances via arbitrage
├── Your share: ~7,071 XRP + 35,355 RLUSD
├── Pool value: ~$70,710
├── Held separately: 10,000 XRP ($50,000) + 25,000 RLUSD = $75,000
├── IL: $4,290 (5.7%)
└── You still gained, but less than holding

XRP drops to $1.25:
├── Your share: ~14,142 XRP + 17,678 RLUSD
├── Pool value: ~$35,355
├── Held separately: 10,000 XRP ($12,500) + 25,000 RLUSD = $37,500
├── IL: $2,145 (5.7%)
└── You lost, but less than holding (DCA effect)

Key insight:
├── IL exists in both directions
├── Same % IL for same % price change
├── Fees must exceed IL for profit
└── Calculate scenarios before committing
```

LP OPPORTUNITY ASSESSMENT

Calculate expected return:
├── Estimate trading volume
├── Calculate fee income
├── Project IL based on volatility
├── Net: Fees - IL - opportunity cost
└── Compare to alternatives

Key factors:
├── Pool volume (higher = more fees)
├── Asset volatility (higher = more IL)
├── Fee tier (higher = more fees but less volume)
├── Competition (more LPs = smaller share)
└── Time horizon (longer may average better)

Example calculation:
├── Pool TVL: $100,000
├── Your deposit: $10,000 (10% share)
├── Daily volume: $50,000
├── Fee: 0.5%
├── Daily fees: $250
├── Your share: $25/day
├── Monthly: ~$750 (9% monthly)
├── BUT: Subject to IL
├── If XRP moves 25%: IL ~6%
├── Net: 9% fees - 6% IL = 3% (maybe)
└── Highly dependent on assumptions
```


AMM ADVANTAGES

Better for:
├── Small trades: Always available liquidity
├── Market orders: Guaranteed execution
├── Thin order books: AMM may have better rate
├── Passive trading: No order management
└── Price discovery: Continuous pricing

AMM shines when:
├── Order book is thin/wide spread
├── You want immediate execution
├── Trade size is moderate
├── Price precision less important
└── Convenience matters most

Example scenario:
├── XRP/NewToken pair
├── Order book: $2.00 bid / $2.20 ask (10% spread)
├── AMM: Continuous curve, ~2% slippage for your size
├── AMM wins for small/medium trades
└── Order book wins if patient (limit order)
```

ORDER BOOK ADVANTAGES

Better for:
├── Large trades: May have better depth
├── Price-sensitive trades: Set your price
├── Professional trading: More control
├── Making markets: Provide liquidity strategically
└── Patient traders: Wait for your price

Order book shines when:
├── Deep liquidity exists
├── You can wait for execution
├── Precise price matters
├── Large order would move AMM significantly
└── Making markets for spread income

Example scenario:
├── XRP/RLUSD pair
├── Order book: Deep, 0.5% spread
├── AMM: 1% slippage for 10,000 XRP
├── Order book wins for large trades
├── Use limit order at mid-price
└── Save on slippage
```

HOW XRPL INTEGRATES AMM AND ORDER BOOK

Automatic routing:
├── DEX clients can check both
├── Route to better price
├── May split across venues
├── User gets best execution
└── Competition benefits traders

For the same pair:
├── AMM provides baseline liquidity
├── Order book provides depth at specific prices
├── Arbitrageurs keep prices aligned
├── Both venues benefit from each other
└── Ecosystem effect

Practical approach:
├── Check both before large trades
├── Use aggregator interfaces
├── Compare effective prices
├── Consider slippage
└── Route accordingly
```


XRPL AMM POOLS (2025)

Major pools:
├── XRP/RLUSD: Growing, primary stable pair
├── XRP/USD variations: Various issuers
├── XRP/other stablecoins: Various
└── Token/XRP pairs: Varies widely

TVL reality:
├── Total AMM TVL: ~$20-50M (estimate)
├── Concentrated in top pools
├── Long tail has minimal liquidity
├── Growing but small vs Ethereum
└── ~0.5% of Uniswap TVL

Volume:
├── Lower than order book historically
├── Growing with adoption
├── Varies significantly by pool
├── Check current data before deciding
└── Volume determines fee income
```

POOL HEALTH METRICS

What to check:
├── TVL: How much liquidity?
├── Volume: How much trading?
├── Volume/TVL ratio: Capital efficiency
├── Price alignment: Is it at market price?
├── LP token holders: Concentrated or distributed?

Healthy pool signs:
├── TVL: Sufficient for your position size
├── Volume: Active trading
├── Ratio: Higher = better for LPs
├── Price: Within 1% of other venues
├── Distribution: Multiple LP providers

Warning signs:
├── Very low volume: No fee income
├── Price deviation: Arbitrage opportunity or problem
├── Single large LP: Concentration risk
├── New pool: Limited track record
└── Exotic pair: Higher IL risk

Due diligence:
├── Use XRPL explorers
├── Check pool statistics
├── Calculate historical returns
├── Assess both assets
└── Start small
```

LP TOKEN DETAILS

What LP tokens are:
├── Issued currency on XRPL
├── Represent your pool share
├── Can be traded on DEX
├── Can be transferred
└── Require trust line to hold

Managing LP tokens:
├── Hold in wallet: Accumulate fees
├── Trade: Exit without withdrawing
├── Transfer: Move between wallets
├── Withdraw: Redeem for pool assets
└── Track value over time

LP token value:
├── = Share of pool × Pool value
├── Changes with trading activity
├── Changes with price movements
├── May be worth more or less than deposit
└── Track for performance measurement

Tax consideration:
├── LP token receipt: Potential taxable event
├── Fee accumulation: Income?
├── Withdrawal: Taxable event
├── Complex tax treatment
└── Consult tax professional
```


CONSERVATIVE APPROACH

Best for:
├── New LPs learning
├── Risk-averse investors
├── Long-term holders
└── Those wanting stable pairs

Strategy:
├── Choose established pools
├── Stick to stable/stable or XRP/stable
├── Lower IL risk (correlated assets)
├── Accept lower fees
└── Prioritize safety

Example: RLUSD/USD pool
├── Both stablecoins
├── Near-zero IL risk
├── Lower trading volume
├── Modest but predictable returns
├── Minimal management needed
└── "Set and forget" possible

Expected returns:
├── Fee income: Low (less volume)
├── IL: Minimal (stable pair)
├── Net: Low single digits APY
├── But: Reliable
└── Compare to alternatives
```

ACTIVE APPROACH

Best for:
├── Experienced DeFi users
├── Higher risk tolerance
├── Time to monitor
└── Seeking higher returns

Strategy:
├── Choose volatile pairs
├── Monitor IL actively
├── Enter/exit based on conditions
├── Capture fee spikes
└── Accept higher risk

Example: XRP/NewToken pool
├── High volatility
├── Higher trading fees
├── Significant IL risk
├── Requires active management
├── Exit before major moves
└── Potentially higher returns

Expected returns:
├── Fee income: Higher (more volume)
├── IL: Significant (volatile pair)
├── Net: Highly variable
├── Could be very positive or negative
└── Depends on management skill
```

MANAGING IMPERMANENT LOSS

Strategy 1: Stable pairs
├── Pair correlated assets
├── RLUSD/USDC example
├── Minimal IL
├── Lower returns
└── Simplest approach

Strategy 2: Rebalancing
├── Monitor pool composition
├── Exit when IL high
├── Re-enter after price stabilizes
├── Requires active management
└── Can reduce net IL

Strategy 3: Hedging
├── Short the asset you're LPing
├── Complex to execute
├── Requires perpetuals/options
├── Not native to XRPL
└── Advanced technique

Strategy 4: Time selection
├── LP when volatility expected low
├── Exit before expected volatility
├── Event-based management
├── Requires market views
└── Difficult in practice

Reality:
├── IL is unavoidable cost
├── Fees must exceed IL for profit
├── No magic solution
├── Accept or avoid
└── Don't LP if IL unacceptable
```


The AMM works as designed. Protocol-native implementation functions correctly since launch.

Continuous auction is live. The novel MEV-reduction mechanism is operational (effectiveness TBD).

Integration with order book. Both venues operate and can be compared for best execution.

⚠️ Whether continuous auction materially helps LPs. Theoretical benefits need longer track record to verify.

⚠️ Whether AMM TVL will grow significantly. Currently small; depends on ecosystem growth.

⚠️ Long-term fee sustainability. Fee income depends on sustained trading volume.

📌 Assuming LP is passive income. Impermanent loss can exceed fees; it's not "free money."

📌 LPing with money you can't afford to lose. IL can be substantial in volatile markets.

📌 Ignoring opportunity cost. Compare LP returns to simply holding assets.

XRPL's AMM is a well-designed, protocol-native addition that provides Uniswap-style liquidity alongside the established order book DEX. The continuous auction mechanism is innovative but unproven. For LPs, the same fundamental math applies: fees must exceed impermanent loss for profitability. The ecosystem is small but functional. Use it for genuine diversification, not for unrealistic yield expectations.


Assignment: Analyze a specific AMM pool and create an LP business case.

Requirements:

Part 1: Pool Selection and Data

  • Pool assets
  • Current TVL
  • Recent volume (daily/weekly)
  • Fee tier
  • Number of LP token holders
  • Current asset ratio and price

Part 2: Return Calculation

  • Estimated daily/monthly fee income
  • Your share based on hypothetical deposit
  • Projected annual fee return (%)
  • Compare to alternatives (lending, holding)

Part 3: IL Scenario Analysis

  • Asset A rises 25%

  • Asset A rises 50%

  • Asset A falls 25%

  • Asset A falls 50%

  • IL percentage

  • IL in dollar terms

  • Net return (fees - IL)

  • Break-even fee requirement

Part 4: Investment Decision

  • Would you LP in this pool? Why/why not?
  • What position size would be appropriate?
  • What's your exit criteria?
  • What would change your decision?

Part 5: Monitoring Plan

  • What metrics will you track?

  • How often will you review?

  • What triggers would cause you to exit?

  • How will you calculate performance?

  • Data accuracy and completeness: 25%

  • Return calculation methodology: 25%

  • IL scenario analysis: 25%

  • Investment decision quality: 25%

Time investment: 2-3 hours


Knowledge Check

Question 1 of 3

In an AMM using the constant product formula (x × y = k), what happens when someone buys a large amount of Asset X?

  • XLS-30 specification
  • XRPL.org AMM documentation
  • Continuous auction mechanics
  • IL calculators
  • Pool analytics
  • XRPL explorers with AMM data
  • AMM research papers
  • MEV and LP dynamics
  • Optimal LP strategies

For Next Lesson:
Lesson 9 covers Trust Lines and Issued Currencies in depth—the foundation of all non-XRP assets on XRPL.


End of Lesson 8

Total words: ~4,900
Estimated completion time: 60 minutes reading + 2-3 hours for deliverable

Key Takeaways

1

XRPL AMM uses constant product formula.

Same core mechanics as Uniswap, but implemented at protocol level with no smart contract risk.

2

Continuous auction reduces MEV.

Traders bid for discounted rates, with proceeds going to LPs. Novel approach, results TBD.

3

Impermanent loss is real and unavoidable.

Calculate IL scenarios before committing capital. Fees must exceed IL for profit.

4

AMM and order book serve different needs.

AMM for guaranteed liquidity and convenience; order book for price control and large orders.

5

The ecosystem is small but functional.

~$20-50M TVL is real but modest. Size positions and expectations accordingly. ---