What Is an AMM (Automated Market Maker)?
An automated market maker (AMM) is the engine behind most decentralized exchanges. Instead of matching buyers and sellers through an order book, it uses pools of tokens and a fixed math formula to set prices and settle trades automatically.
What an AMM actually is
An automated market maker (AMM) is a piece of code — a smart contract — that lets people trade one token for another without a traditional middleman. On a regular exchange, your order is matched against someone else's opposite order in an order book. An AMM works differently: it holds a shared pot of tokens called a liquidity pool and uses a formula to decide the price of every swap.
AMMs are the core of most DeFi applications and power the DEX (decentralized exchange) you may have heard of. Because everything runs on-chain, you trade directly from your own crypto wallet — there is no company holding your coins while you trade.
How liquidity pools and the x*y=k formula work
A liquidity pool is just two (or more) tokens locked in a contract — for example, ETH paired with a stablecoin like USDC. People called liquidity providers (LPs) deposit both tokens and, in return, earn a share of the trading fees.
The most common pricing rule is the constant product formula, written as x * y = k. Here x is the amount of one token in the pool, y is the amount of the other, and k is a number that must stay constant. When you swap, you add to one side and remove from the other — but the product of the two sides has to remain equal to k. That constraint is what sets the price.
This is the key insight: the price is not fixed. The larger your trade is relative to the pool, the more the price moves against you. A deep pool with lots of liquidity barely moves; a shallow pool moves a lot.
AMMs vs. order book exchanges
| Feature | AMM (DEX) | Order book exchange |
|---|---|---|
| Price set by | A formula and pool balances | Buyers and sellers placing orders |
| Counterparty | The liquidity pool | Another trader |
| Custody | You hold your own keys | Often the exchange holds funds |
| Who earns fees | Liquidity providers | The exchange / market makers |
| Works without active traders? | Yes, as long as the pool has tokens | No, needs matching orders |
AMMs made it possible to trade tokens that no professional market maker had ever touched. Anyone can create a pool, and anyone can supply liquidity — which is powerful, but also means quality varies wildly.
Slippage and impermanent loss: the two costs to understand
Two concepts trip up almost every beginner. Learn both before you trade or provide liquidity.
- Slippage — the gap between the price you expected and the price you actually got. It happens because your trade moves the pool (as in the example above) and because the price can shift between when you submit and when the transaction confirms. Most DEX interfaces let you set a slippage tolerance; a trade that would exceed it is canceled to protect you.
- Impermanent loss (IL) — a risk for liquidity providers, not swappers. If the price of the pooled tokens changes a lot after you deposit, you can end up with less value than if you had simply held the two tokens in your wallet. It is called "impermanent" because the loss shrinks if prices return to where they started — but it becomes permanent the moment you withdraw at a different price.
- Decide whether you are swapping (worry about slippage and fees) or providing liquidity (worry about impermanent loss and fees).
- Check pool depth — thin pools mean high slippage and easy price manipulation.
- Confirm you understand the token contract; scam and "honeypot" tokens often live on AMMs because listing is permissionless.
- Start small while you learn how a specific DEX behaves.
Why AMMs matter — and a word of caution
AMMs turned exchanges into open infrastructure. They run 24/7, require no account approval, and let assets from Bitcoin wrappers to obscure altcoins trade with whatever liquidity the community supplies. Many also run on faster, cheaper Layer-2 networks to reduce fees.
That openness cuts both ways. Smart-contract bugs, low-liquidity pools, malicious tokens, and front-running are real risks, and providing liquidity is not a guaranteed yield — fees can be smaller than impermanent loss. Nothing here is a promise of profit.
This article is educational and not investment advice. Crypto assets are volatile and you can lose money. Do your own research, understand each protocol's risks, and never commit funds you cannot afford to lose.
NOONOO TRADING — join the free chat and watch live trading together.
Join free chat →📈 Sign up on OKX for a trading fee discount
Get OKX fee discount →