# What is an Automated Market Maker?

<mark style="color:$info;">The paradigm is gradually shifting in favor of decentralized protocols, with more people realizing the value of decentralization.</mark>

<figure><img src="https://2773531205-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwPYQpCxrPJoaRvqUIVza%2Fuploads%2F8KVPZIRP2R2ce3N9rVhy%2FWhat%20is%20an%20Automated%20Market%20Maker_%20Introduction%20to%20XRPL%E2%80%99s%20super%20DEX.png?alt=media&#x26;token=6f1d0eea-491d-47fc-85ba-44865e122640" alt=""><figcaption></figcaption></figure>

## 🔄 Centralized Exchanges Vs Decentralized Exchanges

{% tabs %}
{% tab title="In a nutshell" %} <mark style="color:$info;">With your typical crypto exchange, such as</mark> <mark style="color:$info;"></mark><mark style="color:$info;">**Coinbase**</mark> <mark style="color:$info;"></mark><mark style="color:$info;">or</mark> <mark style="color:$info;"></mark><mark style="color:$info;">**Binance**</mark><mark style="color:$info;">, you deposit your money using a bank transfer, credit/debit card, or crypto you already own.</mark>

{% hint style="warning" %} <mark style="color:$warning;">Once you deposit your crypto,</mark> <mark style="color:$warning;"></mark><mark style="color:$warning;">**you don’t control it anymore**</mark><mark style="color:$warning;">. The exchange holds the</mark> <mark style="color:$warning;"></mark><mark style="color:$warning;">**private keys**</mark><mark style="color:$warning;">, not you.</mark>
{% endhint %}

<mark style="color:$info;">You can still trade or withdraw, but:</mark>

* <mark style="color:$info;">The</mark> <mark style="color:$info;"></mark><mark style="color:$info;">**exchange must approve**</mark> <mark style="color:$info;"></mark><mark style="color:$info;">your withdrawals</mark>
* <mark style="color:$info;">Trades happen</mark> <mark style="color:$info;"></mark><mark style="color:$info;">**off-chain**</mark><mark style="color:$info;">, inside the exchange’s own system</mark>

***

### 🧩 What Is a DEX (Decentralized Exchange)?

<mark style="color:$info;">A</mark> <mark style="color:$info;"></mark><mark style="color:$info;">**DEX**</mark> <mark style="color:$info;"></mark><mark style="color:$info;">works completely differently:</mark>

* <mark style="color:$info;">Uses</mark> <mark style="color:$info;"></mark><mark style="color:$info;">**smart contracts**</mark> <mark style="color:$info;"></mark><mark style="color:$info;">to execute trades onchain</mark>
* <mark style="color:$info;">Trades happen</mark> <mark style="color:$info;"></mark><mark style="color:$info;">**directly from your wallet**</mark>
* <mark style="color:$info;">Works like a</mark> <mark style="color:$info;"></mark><mark style="color:$info;">**P2P marketplace**</mark>
* <mark style="color:$info;">**No middlemen or banks**</mark> <mark style="color:$info;"></mark><mark style="color:$info;">involved</mark>

✅ You keep **full control of your funds** because **you never hand over your private keys**

***

### 🔑 The Core Difference

**Who holds your money?**

* **CEX:** The exchange
* **DEX:** You
  {% endtab %}

{% tab title="Extensive" %} <mark style="color:$info;">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.</mark>

<mark style="color:$info;">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.</mark>

<mark style="color:$info;">The best part? You keep full control of your funds because you never hand over your private keys.</mark>

<mark style="color:$info;">The biggest difference between CEXs and DEXs is simple: who holds your money? With a CEX, the exchange does. With a DEX, you do.</mark>
{% endtab %}
{% endtabs %}

{% hint style="info" %}
**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 [<mark style="color:blue;">https://dex.anodos.finance</mark>](https://dex.anodos.finance/) and the [<mark style="color:blue;">Xaman Wallet</mark>](https://xaman.app/).
{% endhint %}

***

## 🤖 What Is an Automated Market Maker (AMM)?

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 assets that other users have deposited.

An **AMM** is a type of DEX that:

* Uses **algorithms** to set prices
* Trades against **liquidity pools**, not individual traders
* Works **instantly** without needing matched orders

### 🆚 AMMs vs. Order Book DEXs

{% tabs %}
{% tab title="In a nutshell" %}
There are two main types:

* **Order Book (CLOB):** Buyers & sellers place offers
* **AMM (Liquidity Pools):** Trades happen against a pool, prices auto-adjust
  {% endtab %}

{% tab title="Extensive" %} <mark style="color:$info;">**There are two main ways DEXs work:**</mark>

<mark style="color:$info;">**Order Book (CLOB)**</mark><mark style="color:$info;">: Like a stock market, where buyers and sellers place orders at different prices. The system matches them up.</mark>

<mark style="color:$info;">**AMM (Liquidity Pools)**</mark><mark style="color:$info;">: Instead of waiting for a match, you trade against a pool of funds. The price adjusts automatically based on supply and demand.</mark>

<mark style="color:$info;">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.</mark>

<mark style="color:$info;">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.</mark>
{% endtab %}
{% endtabs %}

|                                        | <mark style="color:green;">AMMs</mark> | <mark style="color:yellow;">CLOBs</mark> |
| -------------------------------------- | -------------------------------------- | ---------------------------------------- |
| Market price is determined by          | Liquidity pools                        | Lowest asking price                      |
| Limit orders                           | Mostly no                              | ✅ Yes                                    |
| Capital efficiency                     | Mostly no                              | ✅ Yes                                    |
| Impermanent loss                       | ✅ Yes                                  | ❌ No                                     |
| Price discovery at all possible ranges | ✅ Yes                                  | ❌ No                                     |
| Easy to become a market maker          | ✅ Yes                                  | ❌ No                                     |
| Easy to bootstrap liquidity for a pair | ✅ Yes                                  | ❌ No                                     |
| Good for fat/long tail assets          | Long-tail                              | Fat-tail                                 |
| Earning yield comes from               | LP incentives                          | Maker rewards                            |
| MEV Attacks                            | Mostly yes                             | Mostly yes                               |

✅ AMMs make it easy to trade even **rare tokens**

***

### 💧 How Do Liquidity Pools Work?

{% tabs %}
{% tab title="In a nutshell" %}
Imagine a market stall that never closes. Prices adjust based on:

* Supply and demand
* Token balances in the pool

{% hint style="info" %}
The more people buy a token → The price goes up The more people sell → The price goes down
{% endhint %}
{% endtab %}

{% tab title="Extensive" %} <mark style="color:$info;">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.</mark>
{% endtab %}
{% endtabs %}

***

### 👥 Liquidity Providers (LPs)

{% tabs %}
{% tab title="In a nutshell" %}

* LPs add **equal value** of two tokens to create a market
* They earn **trading fees** proportional to their pool share
  {% endtab %}

{% tab title="Extensive" %} <mark style="color:$info;">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.</mark>
{% endtab %}
{% endtabs %}

***

### 💳 LP Tokens

{% tabs %}
{% tab title="In a nutshell" %}

* When you deposit, you get an **LP token** — your proof of ownership
* LP tokens let AMMs be **non-custodial**
  {% endtab %}

{% tab title="Extensive" %} <mark style="color:$info;">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.</mark>
{% endtab %}
{% endtabs %}

***

### 🧠 Key Things to Know

{% tabs %}
{% tab title="In a nutshell" %}

* You’re **not locking assets** — you're exchanging them for **LP shares**
* Like buying **mutual fund shares**
  {% endtab %}

{% tab title="Extensive" %} <mark style="color:$info;">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.</mark>&#x20;
{% endtab %}
{% endtabs %}

***

### 👍 Advantages of AMMs

{% tabs %}
{% tab title="In a nutshell" %}

* **Always Open:** 24/7 liquidity
* **Lower Entry Barriers:** No need to place complex orders
* **Decentralized:** No middlemen
* **Rewards:** LPs earn fees
* **Predictable Fees:** Easier cost estimation
  {% endtab %}

{% tab title="Extensive" %}

* 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.
  {% endtab %}
  {% endtabs %}

***

### ⚠️ Impermanent Loss (IL)

{% tabs %}
{% tab title="In a nutshell" %}
What is IL?

* Happens when **token prices change** after you’ve deposited them
* Your LP value may be **less than if you held the tokens separately**

> 📉 IL becomes real **only when you withdraw** your tokens

* Small price change = **Low IL (<2%)**

<figure><img src="https://2773531205-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwPYQpCxrPJoaRvqUIVza%2Fuploads%2FXDmUNS2HHxtNBssBitz6%2FGraph%201.png?alt=media&#x26;token=c9f81485-939f-48e4-ac36-4eb8511de5f8" alt=""><figcaption></figcaption></figure>

* Large price swings (200–600%) = **Still manageable IL**

<figure><img src="https://2773531205-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwPYQpCxrPJoaRvqUIVza%2Fuploads%2F1hkI8E1m4fCXm2QgiMgN%2FGraph%202.png?alt=media&#x26;token=36e62c6e-7b06-447e-8d08-a841a39f0897" alt=""><figcaption></figcaption></figure>

> ✅ IL is an **opportunity cost**, not a total loss

#### How to Reduce IL Risk

* Provide **correlated pairs** (e.g. XRP/XLM or USD/EUR)
* Stablecoin pools = **Minimal IL**
* Focus on **fee income**, not speculation

> ⚙️ The **XRPL AMM’s Continuous Auction** feature helps offset IL
> {% endtab %}

{% tab title="Extensive" %}
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%.

<figure><img src="https://2773531205-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwPYQpCxrPJoaRvqUIVza%2Fuploads%2FvXQiNfLQY3lZWXcqdbWn%2FGraph%201.png?alt=media&#x26;token=9927de75-ff0f-40e3-b4dc-c7453a9befb2" alt=""><figcaption></figcaption></figure>

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%.

<figure><img src="https://2773531205-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwPYQpCxrPJoaRvqUIVza%2Fuploads%2F2WB8u4KnrqUcRWgx12CU%2FGraph%202.png?alt=media&#x26;token=41f36cd1-05cc-4594-8d96-c3a716116440" alt=""><figcaption></figcaption></figure>

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.&#x20;
{% endtab %}
{% endtabs %}

***

## 🧬 XRPL’s Super DEX (XLS-30)

<mark style="color:$info;">**XRPL’s super DEX comes with several unique features that set it apart in the world of AMMs:**</mark>

{% tabs %}
{% tab title="In a nutshell" %}

#### 🗳️ Fee Voting

* LPs **vote** on pool fees

#### 🔄 Continuous Auction Mechanism

* Auctions trading advantages to **offset impermanent loss**
* LPs earn from **winning bids**

#### 🔁 Two-Way Interoperability

* Seamless access to both:
  * **AMM-based liquidity**
  * **Order Book DEX (CLOB)**
    {% endtab %}

{% tab title="Extensive" %}

* **Fee Voting**: <mark style="color:$info;">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.</mark>
* **Continuous Auction Mechanism**: <mark style="color:$info;">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.</mark>
* **Two-Way Interoperability**: <mark style="color:$info;">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.</mark>
  {% endtab %}
  {% endtabs %}

### 🌟 Benefits

<mark style="color:$info;">The XRPL's AMM benefits both liquidity providers and traders in many ways:</mark>

{% tabs %}
{% tab title="In a nutshell" %}

* LPs: Predictable rewards, auction income, IL protection
* Traders: Deep liquidity, wide trading pairs, seamless UX
  {% endtab %}

{% tab title="Extensive" %}
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.
{% endtab %}
{% endtabs %}

{% hint style="info" %}
Use XRPL’s AMM DEX 👉 <https://dex.anodos.finance>
{% endhint %}

***

### 🪙 Liquidity Provision ≠ Staking

{% tabs %}
{% tab title="In a nutshell" %}

* No "staking" or passive earning with XRP
* You’re providing liquidity, **not locking** assets
* You get paid **fees from trader activity**

{% hint style="info" %}
Example: $100 trade with 1% fee → $1 goes to the pool
{% endhint %}
{% endtab %}

{% tab title="Extensive" %} <mark style="color:$info;">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.</mark>
{% endtab %}
{% endtabs %}

***

### 💰 Single-Sided Liquidity

{% tabs %}
{% tab title="In a nutshell" %}

* You can deposit **just one asset**
* No conversion needed
* ⚠️ Can cause price slippage if pool is small
  {% endtab %}

{% tab title="Extensive" %} <mark style="color:$info;">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.</mark>
{% endtab %}
{% endtabs %}

***

## 💬 Final Thoughts

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.

{% hint style="info" %}
🧭 The future is decentralized — and the XRPL is leading the way.
{% endhint %}

{% hint style="success" %}
**Use the XRPL’s super DEX with ANODEX:** [<mark style="color:blue;">https://dex.anodos.finance</mark>](https://dex.anodos.finance/)
{% endhint %}
