Page cover

What is an Automated Market Maker? Introduction to XRPL’s super DEX

The paradigm is gradually shifting in favor of decentralized protocols, with more people realizing the value of decentralization.

Centralized Exchanges Vs Decentralized Exchanges

With your typical crypto exchange, such as Coinbase or Binance, you deposit your money using a bank transfer, credit/debit card, or crypto you already own. But here’s the catch: once you deposit your crypto, you don’t really control it anymore. Sure, you can still trade or withdraw it, but technically, the exchange holds the private keys, not you. That means the exchange has to approve any withdrawals, and your trades happen off-chain, just in the exchange’s own system.

Now, a decentralized exchange (DEX) works totally differently. Instead of relying on a company to handle your money, DEXs use smart contracts, self-executing code on the blockchain, to let people trade directly from their own wallets. Think of it like a peer-to-peer (P2P) marketplace where buyers and sellers connect without a middleman.

The best part? You keep full control of your funds because you never hand over your private keys.

The biggest difference between CEXs and DEXs is simple: who holds your money? With a CEX, the exchange does. With a DEX, you do.

Fun fact: The XRP Ledger (XRPL) introduced the first DEX in history, built way back in 2012! It uses an onchain order book system, also known as central limit order book (CLOB), letting people trade XRP and other tokens directly on the ledger. Users can interact with the XRPL DEX through different platforms and interfaces such as https://dex.anodos.finance/ and the Xaman Wallet.

What is an Automated Market Maker?

An Automated Market Maker is a type of decentralized exchange (DEX) that uses math (algorithms) to set prices and lets people trade crypto without needing a buyer and seller to match up at the exact same time. Instead of waiting for someone to take your trade, you swap tokens directly with a liquidity pool: a big pile of crypto that other users have deposited.

AMMs vs. Order Book Exchanges

There are two main ways DEXs work:

Order Book (CLOB): Like a stock market, where buyers and sellers place orders at different prices. The system matches them up.

AMM (Liquidity Pools): Instead of waiting for a match, you trade against a pool of funds. The price adjusts automatically based on supply and demand.

AMMs are a big deal because they let people trade even rare tokens that wouldn’t have enough buyers or sellers in an order book.

The introduction of liquidity pools was a game-changer for the entire decentralized finance market. These pools seek to address the issue by incentivizing users to provide liquidity in exchange for a share of the trading fees. Anyone can be a liquidity provider (LP) in an AMM.

How Do Liquidity Pools Work?

Imagine a self-running stall at a market that always has items to trade. The price of items isn't set by any one person but is determined by how much of each item is available. If lots of people want to buy a particular item and start trading their items for it, the AMM adjusts the price so that item becomes more expensive. If people want to get rid of an item and it starts piling up, the AMM makes it cheaper. This way, the AMM keeps the trading going by balancing supply and demand automatically, without anyone having to manually set the prices.

Liquidity Providers (LPs)

Users called liquidity providers add an equal value of two tokens in a pool to create a market. In exchange for providing their funds, they earn trading fees from the trades that happen in their pool, proportional to their share of the total liquidity. So AMMs make market making more accessible.

LP Tokens

When funds are deposited into a liquidity pool, the AMM automatically generates a new token that represents the share the depositor owns of that pool. This is called a liquidity provider (LP) token, and it is the receipt (proof) that you have deposited liquidity and you own a share of that pool. LP tokens allow AMMs to be non-custodial, meaning they do not hold on to your tokens, but instead operate via automated functions that promote decentralization and fairness.

Key Things to Know

When you deposit to a pool, you are not locking the assets you are providing. You are essentially selling them for a share of the liquidity pool. When you buy a share of a mutual fund, you don’t lock in USD for a mutual fund share. You buy shares of a mutual fund. In either case you are buying shares (LP Tokens) of a liquidity pool.

Advantages of AMMs:

  • Always Open for Business: Liquidity pools are available 24/7, making it possible for users to trade at any time, even during periods of low trading activity.

  • Lower Entry Barriers: AMMs are often more user-friendly than traditional order book exchanges. Users don't need to place specific buy or sell orders. They simply swap one asset for another at the current price.

  • Decentralization: AMMs operate without middlemen, which aligns with the principles of blockchain technology.

  • Liquidity Provision Rewards: Users who provide liquidity to these pools earn a portion of the trading fees. This provides a financial incentive for liquidity providers.

  • Predictable Fees: AMMs often feature predictable fee structures, making it easier for traders to understand their costs.

Challenges in AMMs and Impermanent Loss

AMMs are great, but they come with one big challenge: impermanent loss (IL). This sounds scary, but it’s not as bad as it seems if you understand how it works.

What Is Impermanent Loss (IL)?

Impermanent loss occurs when the prices of the assets in the pool change compared to when they were initially provided. It’s the result of token rebalancing by the AMM as prices of the tokens in an LP position diverge from their starting ratio to each other. Liquidity providers may find themselves with fewer assets than if they had held them outside the pool.

Ιmpermanent loss isn’t actually a great term. It’s called impermanent loss because the losses only become realized once you withdraw your tokens from the liquidity pool. At that point, however, the losses very much become permanent. The fees you earn may be able to compensate for those losses, but it’s still a slightly misleading name. Impermanent loss is basically opportunity cost on what would happen if you just held the assets in your wallet instead of adding them to the liquidity pool.

Fees can make up for it. The more people trade in your pool, the more fees you earn.

Small price changes = Small Impermanent Loss. If the tokens stay within 50% of their original price ratio, IL is usually less than 2%.

Most fear a breakout of the assets they provide, but even in the unfavorable scenario of a breakout happening in a short time, the IL is not as big as imagined even if the assets go up by 200-600%.

In other words, IL is actually not a big factor in the short-term, or even medium-term with less volatile tokens. It’s something to be aware of, but not necessarily something to be feared.

How to Reduce Risk

Impermanent loss is not something to be afraid of and can be mitigated by fees earned. Your goal as a LP should be to provide assets you don't intend to hold, but use specifically on the AMM to earn income from the fees and trading activity.

It's also very important to note that not all pools are created equal, and not all pools have the same IL risk. In the case your provide liquidity into a stablecoin pair such as USD/EUR there is usually 0 to minimal IL. Same if you provide liquidity to 2 crypto assets with high correlation such as XRP/XLM.

Providing liquidity to an XRP/stablecoin pair gives you less exposure to XRP's upside, but also less exposure to XRP's downside.

The XRPL AMM's novel Continuous Auction mechanism will compensate LPs through the distribution of winning bid amounts for each AMM pool, mitigating, even further, impermanent loss exposure.

Overall, impermanent loss is not something that should keep you away from participating in the AMM as a liquidity provider. But keep in this mind, this is not a risk-free procedure.

Key Features of XRPL’s super DEX (XLS-30)

XRPL’s super DEX comes with several unique features that set it apart in the world of AMMs:

  • Fee Voting: Unlike AMMs and platforms with fixed trading fees, XLS-30 allows liquidity providers to vote on the trading fees of the pool they are participating in. This democratic approach ensures that fees align with the interests of the community.

  • Continuous Auction Mechanism: To address impermanent loss and enhance liquidity provider rewards, XLS-30 introduces a continuous auction mechanism. Impermanent loss is a common concern for liquidity providers in AMMs as discussed in the previous lessons. XLS-30's continuous auction mechanism directly addresses this issue. It auctions off trading advantages for a 24-hour slot with zero trading fees. By participating in these auctions, liquidity providers can effectively minimize their exposure to impermanent loss by offering their assets for trading advantages. This innovation aligns the interests of liquidity providers and traders.

  • Two-Way Interoperability: One of the standout features of XLS-30 is its seamless interoperability. It allows for the coexistence of AMM-based trading with the existing Central Limit Order Book (CLOB) DEX. This means that users can access both liquidity sources, benefiting from competitive pricing and a wider selection of assets.

The XRPL's AMM benefits both liquidity providers and traders in many ways:

Liquidity Providers: These are users who contribute their assets to liquidity pools. In return, they receive LP tokens representing their share of the pool. With XLS-30, liquidity providers enjoy an array of benefits, including predictable fee voting, the continuous auction mechanism, and protection against impermanent loss.

Traders: Traders on the XRP Ledger benefit from improved liquidity thanks to the AMM-based system. They can swap assets seamlessly and access a wide range of trading pairs without having to worry about the current liquidity and depth like in the CLOB-based DEX.

Liquidity Provision ≠ Staking

It's very important to mention that there is no staking or earning with your XRP. You give assets to the AMM so others can trade them and you get paid a fee for that. The income comes from the trading fee that traders pay. If someone swaps $100 worth of assets and the fee in that pool is 1% then the trader pays $1 which goes to the pool and is distributed to LPs based on the share of the pool they own.

Single-sided Liquidity

When you deposit single-sided liquidity there isn’t actually a swap or conversion involved. Only one asset is actually added to the pool which changes the asset ratio. Something that can be dangerous when pool's liquidity is low because it will cause big differences in prices and the share you receive.

The XRPL's AMM basically allows you to earn yield from market making, volatility, and the continuous auction mechanism.

Many decentralized exchanges have emerged over the years, each iterating on previous attempts to streamline the user experience and build more powerful trading venues. Ultimately, the idea seems heavily aligned with the ethos of self-sovereignty: users don’t need to trust a third party. Even though both centralized and decentralized crypto ecosystems work hand in hand, the paradigm is gradually shifting in favor of DEXs, with more people realizing the value of decentralization.

Use the XRPL’s super DEX with ANODEX: https://dex.anodos.finance

Last updated