
What Is an Automated Market Maker and How Do AMMs Work in DeFi?
An automated market maker lets tokens be swapped on a decentralised exchange without a buyer and a seller being matched. Prices are set by a formula and a pool of tokens rather than by an order book.
What Is an Automated Market Maker?
An automated market maker (AMM) is a trading protocol used in decentralised finance, the part of crypto where financial services run on public blockchains without a central operator. Instead of matching individual buy and sell orders, an AMM holds reserves of two or more tokens in a liquidity pool, and traders swap against that pool. The price of each token swap is calculated automatically from the pool reserves.
Because the rules run as code on a blockchain, the pool is open around the clock and no counterparty needs to be online for a trade to go through. How that shared ledger records every swap is explained in this guide to how blockchain works.
How Do AMMs Work on Decentralised Exchanges?
Three parts work together: the pool, the code that runs it and the people who supply the tokens.
Liquidity Pools and Token Reserves
A liquidity pool is a set of tokens locked in a smart contract. A simple pool holds two tokens, for example ETH and the USDC stablecoin. The amounts held, known as the pool reserves, change with every trade and determine the price the pool quotes.
Smart Contracts and Token Swaps
Smart contracts are self-executing programs stored on a blockchain. In an AMM, they accept a trader's tokens, calculate how much of the other token is owed and send it back in the same transaction, with no exchange staff approving the trade. More detail on how smart contracts power DeFi is available in a separate guide.
Liquidity Providers and Trading Fees
A liquidity provider is anyone who deposits tokens into the pool, usually in equal value of both assets. In return, the provider receives a share of the pool, often represented by LP tokens, and a portion of the fee charged on each swap. Providing liquidity carries risks, however:
Impermanent loss: if the two token prices move apart, a provider can end up with less value than if the tokens had simply been held.
Smart contract risk: a bug or exploit in the code can lead to lost funds.
Variable income: fees depend on trading volume and are not guaranteed.
How AMMs Determine Token Prices

Many AMMs use the constant product formula, x × y = k, popularised by Uniswap. Here x and y are the reserves of the two tokens, and k is a constant that must stay the same after each trade. Fees are left out of the example below for simplicity.
Take a pool holding 100 ETH and 200,000 USDC. Then k = 100 × 200,000 = 20,000,000, and the pool's starting price is 2,000 USDC per ETH.
A trader sends 10,000 USDC to the pool, raising the USDC reserve to 210,000.
To keep k unchanged, the ETH reserve must fall to 20,000,000 ÷ 210,000 ≈ 95.24 ETH.
The trader receives the difference, about 4.76 ETH, at an average price of roughly 2,100 USDC per ETH.
The pool now quotes about 210,000 ÷ 95.24 ≈ 2,205 USDC per ETH.
The price moved because the trade was large relative to the pool. This effect is called price impact, and it becomes smaller as pool reserves grow.
If ETH still trades at 2,000 USDC elsewhere, the pool is now overpriced. Arbitrage traders can sell ETH into the pool and buy it back on other exchanges, adding ETH to the reserves and pushing the pool price back towards 2,000 USDC. This activity keeps AMM prices broadly in line with external markets.
The constant product formula is one model rather than a universal rule. Other AMMs use stable swap curves for assets expected to trade near the same price, weighted pools holding more than two tokens, or concentrated liquidity, where providers choose the price range for their funds.
AMMs vs Order Book Exchanges
Feature | Automated market maker | Order book exchange |
|---|---|---|
How trades are filled | Against a liquidity pool | A buyer is matched with a seller |
How price is set | Formula based on pool reserves | Highest bid and lowest ask |
Who provides liquidity | Anyone depositing into the pool | Market makers and traders placing limit orders |
Large trades | Price impact grows with trade size relative to the pool | Execution depends on order book depth |
Neither design removes market risk. Crypto prices can move sharply on any venue, so position sizing and loss limits matter however an exchange is built. This guide to crypto risk management sets out practical ways to control exposure.
Conclusion
An automated market maker replaces the order book with a pool of tokens and a pricing formula. Liquidity providers supply the reserves, smart contracts execute each token swap, and arbitrage helps keep pool prices aligned with the wider market.
Try your ideas on demo first.
Get StartedUnderstanding these mechanics makes the risks of trading and providing liquidity in decentralised finance easier to judge.
Disclaimer: This article is for informational purposes only and does not constitute investment advice. Cryptocurrency trading and liquidity provision involve a high risk of loss.
See more:Glossary