Automated Market Makers (AMMs)

In the last chapter, we learned that DeFi exchanges (DEXs) don’t usually use Order Books because they are too slow and expensive for the blockchain.

So, if there is no list of buyers and sellers, who are you trading with?

You are trading with a robot.

This robot is called an Automated Market Maker (AMM). It is a smart contract that sits there, holding a pile of assets, ready to trade with you 24/7 at a price determined by a simple mathematical formula.

1. The Constant Product Formula (x * y = k)

The most famous AMM model (used by Uniswap v2) relies on a surprisingly simple equation:

x * y = k

  • x: The amount of Token A in the pool (e.g., ETH).
  • y: The amount of Token B in the pool (e.g., USDC).
  • k: A fixed constant.

The Golden Rule: The pool must always maintain the same total value (k). It tries to keep the balance of the two assets roughly equal in value.

The “Banana & Apple” Analogy:

Imagine a vending machine containing 10 Bananas and 10 Apples.

  1. 10 X 10 = 100. So, our constant (k) is 100.
  2. You want to buy 5 Bananas. This would leave only 5 Bananas in the machine.
  3. The math says: 5 Bananas X (New Apples) = 100.
  4. Solving for Apples: 100 / 5 = 20.
  5. The machine must end up with 20 Apples. Since it started with 10, you must put in 10 Apples to get those 5 Bananas.

Result: The price of bananas just skyrocketed because they became scarce. The more you buy, the more expensive each subsequent banana becomes.

2. Liquidity Pools and LP Tokens

Where do the Bananas and Apples (or ETH and USDC) come from?

In traditional finance, banks or rich trading firms provide the money. In DeFi, you provide the money. This pile of money is called a Liquidity Pool. It is essentially a smart contract that holds user funds collectively while knowing how much funds belong to whom. 

Anyone can send funds to Liquidity Pools and become a “Liquidity Provider” (LP).

  1. You deposit an equal value of ETH and USDC into the smart contract.
  2. The contract gives you a receipt called an LP Token.
  3. This token represents your share of the pool. If you own 10% of the LP tokens, you own 10% of the liquidity in that pool.

Why would you do this? Fees. Every time a trader swaps tokens, they pay a small fee (usually 0.3%). This fee goes directly to the LPs.

3. Price Discovery in AMMs

If the AMM doesn’t look at the stock market or the news, how does it know the “real” price of Bitcoin?

It doesn’t. It relies on greed (Arbitrage).

Let’s say the price of ETH is $3,000 everywhere in the world (Coinbase, Binance, etc.), but in our specific AMM pool, the math says the price is only $2,900.

  1. The Opportunity: Traders (arbitrageurs) notice this discount.
  2. The Action: They rush to the AMM, buying the “cheap” ETH for $2,900.
  3. The Result: As they buy ETH, the pool’s supply of ETH (x) goes down. Remember the formula—as supply goes down, price goes up.
  4. The Balance: They keep buying until the price in the AMM rises to meet the global price of $3,000.

The AMM relies on an army of traders constantly keeping its prices in line with the rest of the world to make a quick profit.

Summary

The AMM is a zero-to-one innovation. It allows a market to function without a professional market maker. It guarantees that there is always liquidity. No matter how volatile the market is, you can always sell your tokens—as long as you are willing to accept the price the formula gives you.

However, providing liquidity isn’t free money. There is a hidden risk called “Impermanent Loss” that can wipe out your profits.

Coming Up Next:

We are going to switch sides. Instead of being a trader, we will look at what it takes to be the “Bank.” In Chapter 6, we will cover Liquidity Provision, how to earn fees, and the dangers of Impermanent Loss.

Disclaimer:

Some elements of this content may have been enhanced with the help of our artificial intelligence (AI) assistants for purposes such as basic refinement, review, image generation, and translation to deliver high-quality news in a shorter time frame. However, all AI-assisted content is reviewed and approved by our team to ensure accuracy, fairness, and editorial integrity.

Share This Article