Automated Market Maker (AMM)AMM

An automated market maker is a smart contract that prices trades from a formula instead of an order book. In the common constant-product design, a pool holds two tokens whose quantities multiply to a constant (x × y = k), so buying one token makes it progressively more expensive.

On a traditional exchange, buyers and sellers meet in an order book. On many decentralised exchanges there is no order book at all. Instead, you trade against a pool of tokens, and a formula decides the price. Understanding that formula explains why big trades get worse prices, why pool depth matters and what liquidity providers actually earn and risk.

Category
Cryptocurrency and Blockchain
Reading time
5 min
Also called
Liquidity pool, Constant product market maker, AMM pool
Updated

AMMs in plain words

An AMM replaces the Order Book with smart contracts that let anyone swap tokens or provide liquidity onchain.1 A smart contract is code and data deployed on a blockchain.2

In the constant-product design, the pool keeps x × y = k, where x and y are the two token balances.1 When you take tokens out of one side, you must add enough to the other to keep k constant.

Pools are funded by liquidity providers, who deposit token pairs in exchange for rewards.3 See Liquidity and Slippage.

How an AMM trade works, step by step

  1. Pick a pool

    Choose the Trading Pair pool, for example ETH/USDC.

  2. Read the reserves

    The pool holds x of one token and y of the other; k = x × y.1

  3. Calculate the output

    New reserve of the token you buy = k ÷ new reserve of the token you sell.

  4. Account for the fee

    A fee, often a fraction of a percent, is taken from the input and goes to liquidity providers.

  5. Check price impact

    The bigger your trade compared with the pool, the further it pushes the price.1

  6. Set a slippage limit

    Set a maximum acceptable price before confirming, in case the pool changes first.

Worked examples

Example 1 — A small trade

3,030.30 USDC

A pool holds 100 ETH and 300,000 USDC, so the spot price is 3,000 USDC. You buy 1 ETH (fees ignored).

Example 1 — A small trade — calculation
k100 × 300,000 = 30,000,000
New USDC reserve30,000,000 ÷ 99 = 303,030.30
You pay303,030.30 − 300,000 = 3,030.30 USDC (≈1.01% above spot)

The formula keeps x × y constant, so even a small purchase costs a little more than spot.1

Example 2 — A large trade

≈11.1% worse than spot

Same pool. You buy 10 ETH.

Example 2 — A large trade — calculation
New USDC reserve30,000,000 ÷ 90 = 333,333.33
You pay33,333.33 USDC → 3,333.33 per ETH
Versus spot≈11.1% above 3,000; pool price after ≈3,703.70

The trade was large for this pool, so it shifted the price noticeably — that shift is price impact.1

Example 3 — Adding the fee

≈3,039.42 USDC

Same pool, buy 1 ETH, with a 0.3% fee taken from the input.

Example 3 — Adding the fee — calculation
Needed after fee3,030.30 USDC
Input including fee3,030.30 ÷ 0.997 ≈ 3,039.42 USDC
Fee≈ 9.12 USDC to liquidity providers

Fees reward the liquidity providers who deposit token pairs into the pool.1

AMM vs. order book

AspectAMMOrder book
Price set byA formula and pool reservesBids and asks from traders
CounterpartyThe poolAnother trader
Liquidity fromLiquidity providers’ depositsMarket makers and limit orders
Large-trade costPrice impact along the curveWalking through the book

Where AMMs are used

  • Token swaps

    Swapping tokens directly from a wallet.

  • Long-tail tokens

    Trading tokens with no order-book market.

  • Providing liquidity

    Earning fees by depositing token pairs.

  • Price reference

    Other smart contracts read pool prices.

Advantages and disadvantages

Advantages

  • Always available while the pool has liquidity.
  • Anyone can trade or provide liquidity.
  • Prices are transparent and set by a known formula.
  • No need for a matching counterparty.

Disadvantages

  • Large trades suffer price impact in shallow pools.
  • Smart contract bugs can lose funds.
  • Liquidity providers face losses when prices move (impermanent loss).
  • Transactions can be front-run or fail when prices change.

Going deeper

Read as far as you need. Each level builds on the one before it.

Trade against a pool

Beginner

An AMM is a set of smart contracts that lets you swap tokens without an order book.1

The constant product

Intermediate

x × y = k means every purchase shifts the balance and the price.1 Deeper pools mean smaller price impact for the same trade size.1

Liquidity providers and risk

Advanced

Liquidity providers deposit pairs and earn fees.1 If the price of one token moves a lot, arbitrageurs rebalance the pool and the provider can end up worse off than simply holding — impermanent loss. Smart contracts are code on a blockchain, so bugs are a real risk.2

Common mistakes

  1. Ignoring pool depth

    Making a large trade in a small pool.

  2. Setting no slippage limit

    Accepting any price if the pool moves before execution.

  3. Confusing fee with impact

    Thinking the fee is the only cost of a large trade.

  4. Ignoring impermanent loss

    Providing liquidity without understanding the price risk.

Check your understanding

Test yourself before moving on. Each answer comes with an explanation.

Q1A pool has 50 ETH and 150,000 USDC. How much USDC does buying 5 ETH cost (no fees)?
Q2Why do larger trades get worse prices in an AMM?

Key points to remember

  1. An AMM prices trades from a formula, not an order book.
  2. Constant-product pools keep x × y = k.
  3. Price impact grows with trade size relative to pool depth.
  4. Fees go to liquidity providers.
  5. Smart contract and impermanent-loss risks apply.

Frequently asked questions

Is an AMM the same as a DEX?

Not exactly. An AMM is a pricing mechanism; many DEXs use AMMs, but some use order books.

Who sets the price in an AMM?

The formula and the pool’s reserves. Arbitrage traders keep it near prices elsewhere.

Is providing liquidity risk-free income?

No. Price moves, smart contract bugs and low fees can all lead to losses.

Further learning

Sources

This article is written in our own words. The sources below support the specific facts, rules and figures marked with a number in the text. Links open the original publisher’s page.

  1. Uniswap Docs. How Uniswap works (opens in a new tab) Checked .
  2. NIST CSRC Glossary. Smart contract (opens in a new tab) Checked .
  3. ethereum.org. Ethereum Glossary (opens in a new tab) Checked .

Educational content, not financial advice. Examples use hypothetical prices and simplified costs; actual fees, margin rules and regulations vary by broker, market and country. We are not affiliated with any publisher linked above. Last reviewed . Report an error or request a source credit.