Skip to main content
CoinPulse
DeFi 6 min read

Automated Market Makers (AMMs), Explained

An AMM is a smart contract that prices and settles token swaps against a pooled reserve using a formula, replacing the traditional order book.

Mia Chen
Ethereum & Layer-2 Editor
Published
Written by our team and checked against our editorial policy. Informational only, not financial advice.
Automated Market Makers (AMMs), Explained
In this article6
  1. 1Key takeaways
  2. 2The problem AMMs solve
  3. 3The constant product formula
  4. 4How liquidity providers earn
  5. 5Common variations
  6. 6Risks to understand

An automated market maker (AMM) is a smart contract that prices and settles token trades against a shared pool of reserves, using a mathematical formula instead of matching individual buyers and sellers. It is the engine behind most decentralized exchanges: rather than waiting for someone to take the other side of your trade, you swap against the pool, and the formula decides the price based on how much of each token the pool holds.

Key takeaways

  • An AMM replaces the buyer-and-seller order book with a pooled reserve and a pricing formula.
  • The most common design, the constant product formula, keeps the product of the two token balances constant during a trade.
  • Liquidity providers deposit token pairs into the pool and earn a share of trading fees.
  • Price impact grows as a trade gets larger relative to the pool, which is the source of slippage.
  • Liquidity providers face impermanent loss, and users face smart-contract and oracle risks.

The problem AMMs solve

A traditional exchange uses an order book: buyers post bids, sellers post asks, and the exchange matches them. That works well when there are many active traders, but on a blockchain it is slow and expensive, and thinly traded tokens can sit with no counterparty at all. AMMs sidestep the problem entirely. Anyone can trade at any time because they trade against a pool of funds rather than another person. The result is continuous, permissionless liquidity, which is why AMMs became the default design for on-chain trading. For the wider context, see our guide to what a DEX is.

The constant product formula

The best-known AMM design uses the constant product formula, often written as x times y equals k. Here x and y are the amounts of the two tokens in the pool, and k is a constant that the trade must preserve. When you buy one token, you add to one side of the pool and remove from the other, so the ratio shifts and the price changes to keep the product constant.

A simple example makes it clear. Imagine a pool with 10 of token A and 1,000 of token B, so k equals 10,000. If you want to buy some of token A, you add token B and remove token A while keeping the product at 10,000. The more of token A you try to buy, the more scarce it becomes in the pool, and the price you pay per unit rises. This built-in curve is why a large trade moves the price more than a small one.

Price impact and slippage

That price movement during your own trade is called price impact, and the gap between the quoted and executed price is slippage. In a deep pool, a normal-sized trade barely moves the price; in a shallow pool, the same trade can be costly. Our explainer on slippage and liquidity covers how to measure it and set a sensible tolerance so a trade fails rather than filling at a bad price.

How liquidity providers earn

An AMM only works if the pool has funds, and those come from liquidity providers (LPs). An LP deposits an equal value of both tokens in a pair and receives LP tokens representing their share of the pool. Every swap charges a small fee that is added to the reserves, so an LP's share slowly grows in value as trading volume accrues. In effect, LPs are paid for supplying the inventory that makes trading possible.

The catch is that providing liquidity is not risk-free. When the two tokens' prices diverge, the pool automatically rebalances toward the token that is falling, which can leave an LP worse off than if they had simply held the tokens. This effect is called impermanent loss, and it is the single most misunderstood part of being an LP.

The role of arbitrage

An AMM does not know the outside market price on its own; its price comes purely from the ratio of tokens in the pool. So how does it stay in line with the wider market? The answer is arbitrage. When the pool price drifts away from prices elsewhere, traders profit by buying the underpriced side and selling it where it is dearer, and that activity pushes the pool back toward the market rate. Arbitrage is therefore essential to how AMMs function, but it is also the mechanism that transfers value away from liquidity providers when prices move, which is precisely why impermanent loss exists. Understanding that link makes the whole design click into place.

Common variations

Not every AMM uses the plain constant product curve. Several variants tune the formula for specific needs:

  • Stable-pair AMMs: designed for tokens meant to trade near the same value, such as two dollar-pegged stablecoins, using a flatter curve that reduces slippage around the peg.
  • Concentrated liquidity: lets providers focus their capital within a chosen price range, improving efficiency but requiring more active management.
  • Weighted pools: hold more than two tokens or unequal weightings, useful for index-style baskets.

Each variation trades simplicity for a specific benefit, but all share the same core idea: a formula plus a pool replaces the order book.

Risks to understand

AMMs carry risks for both traders and liquidity providers. Before using one, weigh the following:

  • Impermanent loss: LPs can end up with less value than simply holding the two tokens, especially in volatile pairs.
  • Smart-contract risk: the pool is a program, and a bug or exploit can drain it. Favor audited, well-established contracts.
  • Oracle and manipulation risk: because an AMM price is set by pool balances, an attacker with enough capital can distort it temporarily, which is dangerous when other protocols read that price as an oracle.
  • Low-liquidity and scam tokens: anyone can create a pool, so shallow pools and malicious tokens are common; verify tokens before trading.

To go deeper on the surrounding topics, browse our guides or start with the broad picture of what DeFi is. Understanding the constant product formula is the key that unlocks how nearly all on-chain trading actually works.

Frequently asked questions

What does an automated market maker do?+

An AMM prices and settles token swaps against a pooled reserve using a formula, rather than matching individual buy and sell orders. This lets people trade at any time without needing a counterparty on the other side.

What is the constant product formula?+

It is the pricing rule used by many AMMs, written as x times y equals k. The product of the two token balances stays constant during a trade, so buying more of a token makes it scarcer in the pool and raises its price.

How do liquidity providers make money from an AMM?+

Liquidity providers deposit a pair of tokens into the pool and earn a share of the trading fees charged on every swap. Their earnings depend on trading volume, offset by any impermanent loss.

Why does a big trade get a worse price on an AMM?+

Because the formula raises the price as you buy more of a token from the pool. This price impact, and the resulting slippage, grows with trade size relative to the depth of the pool.

What next

About the author
Mia Chen
Ethereum & Layer-2 Editor

Mia Chen is an Ethereum & Layer-2 Editor at CoinPulse, where she specializes in the Ethereum ecosystem, staking, Layer-2 networks, rollups, protocol upgrades, and smart contract technologies.

Full profile and all articles

This article is for information only and is not financial, investment or tax advice. Crypto assets are volatile; do your own research. See our editorial policy and how we are funded.