Markets

How automated market makers work

An automated market maker prices trades with a formula over a pooled reserve instead of an order book. Learn the constant-product model and where price comes from.

How automated market makers work

Mechanics, not signals. This explains how a market feature works. It is not a trading strategy, entry, target, or recommendation to buy or sell anything.

Quick answer

An automated market maker is a smart contract that prices trades using a formula over a pooled reserve of two assets instead of an order book. The common constant-product design keeps x times y constant, so the reserve ratio sets the price, and arbitrage keeps that price aligned with the wider market.

Key points

  • An AMM prices trades with a formula, not an order book
  • The constant-product rule keeps x times y equal to k
  • The pool price is simply the ratio of its two reserves
  • Slippage grows with trade size relative to pool size
  • Arbitrage keeps the pool price aligned with the market

An automated market maker (AMM) is a smart contract that lets people trade one asset for another against a shared pool of funds, with the price set by a formula instead of an order book. There is no counterparty posting quotes — you trade against the pool, and the maths decides the price.

AMMs are the engine behind most decentralised exchanges. They replaced the traditional order book with something that can run entirely on-chain, permissionlessly, without anyone actively managing quotes. This article explains the mechanism — how the pool prices trades, where the liquidity comes from, and what the design costs — using the standard constant-product model. It describes mechanics only, not how to trade.

The pool replaces the order book

Instead of matching buyers to sellers, an AMM holds a reserve of two assets in a liquidity pool. Anyone can swap one for the other. When you buy asset X, you add asset Y to the pool and remove X from it; the pool’s changing balances are what move the price. There is no waiting for a matching order — as long as the pool has reserves, a trade can happen instantly.

The funds in the pool are supplied by liquidity providers (LPs), who deposit both assets and, in return, receive tokens representing their share. They earn a cut of every swap’s trading fee. In effect the crowd of LPs collectively plays the role that a market maker plays on a traditional venue — hence the name.

The constant-product formula

The most widely used design, popularised by Uniswap, is the constant-product market maker. It keeps the product of the two reserves constant across every trade:

x × y = k

Here x is the amount of one asset in the pool, y is the amount of the other, and k is a constant that only the trading fee and LP deposits/withdrawals change. Every swap must leave the product x × y equal to k. The current price the pool offers is simply the ratio of the reserves, y / x.

Because the product is fixed, taking a lot of X out of the pool forces you to put in a disproportionately large amount of Y — the price you pay rises the more you buy. This built-in curve is what makes the pool self-pricing. The Uniswap v2 documentation describes the same mechanism in detail.

A worked swap

Suppose a pool holds 10 ETH and 10,000 USDC. Then:

  • k = 10 × 10,000 = 100,000
  • Current price = 10,000 / 10 = 1,000 USDC per ETH

Now someone wants to buy 1 ETH. After the trade the pool must hold 9 ETH, and the product must still be 100,000, so the USDC reserve becomes:

  • New USDC = k / new ETH = 100,000 / 9 = 11,111.11
  • USDC the buyer must add = 11,111.11 − 10,000 = 1,111.11 USDC

So buying 1 ETH costs about 1,111 USDC, an effective price of roughly 1,111 per ETH — noticeably above the 1,000 quoted before the trade. That gap between the pre-trade price and your actual average price is slippage, and in an AMM it is a direct, predictable function of your trade size relative to the pool. (We ignore fees here to isolate the pricing maths.)

The larger the pool relative to your trade, the smaller the slippage. A 1 ETH buy against a 10,000 ETH pool would barely move the price. This is the AMM version of market depth: pool size is depth.

How the price stays honest: arbitrage

Nothing inside the formula knows the “real” market price of ETH. The pool only knows its own reserves. So what keeps an AMM’s price aligned with the wider market? Arbitrage.

If ETH trades at 1,050 elsewhere while the pool still offers it near 1,000, arbitrageurs buy from the cheap pool and sell where it is dearer, adding USDC and removing ETH until the pool’s ratio matches the outside price. Their profit is the mechanism that drags the pool back into line. AMMs are therefore designed to rely on self-interested arbitrage to stay accurate — a point analysed formally in academic work such as “An analysis of Uniswap markets” (Angeris et al.).

Fees and what liquidity providers earn

Every swap pays a trading fee that is added to the pool, increasing the reserves and the value of each LP share. This is how LPs are compensated for supplying capital. In broad terms:

  • More trading volume through the pool means more fee income for LPs.
  • A larger pool spreads that fee income across more capital, so each unit earns less.
  • Fee income is not the whole story of LP returns, because providing liquidity carries a specific offsetting cost.

That cost is impermanent loss: when the price of the pooled assets diverges, an LP ends up worse off than if they had simply held the two assets. It is fundamental to the constant-product design and deserves its own careful treatment, which we give — with the exact arithmetic — in impermanent loss, explained arithmetically.

Slippage and price impact, made concrete

Because the constant-product curve is fully deterministic, an AMM’s price impact is not a matter of sentiment — it is fixed by the maths of your trade size relative to the reserves. Returning to the 10 ETH / 10,000 USDC pool, compare buying different amounts of ETH:

ETH bought USDC paid Effective price
0.1 101.01 1,010.1
1 1,111.11 1,111.1
2 2,500.00 1,250.0

Each figure comes straight from keeping the product at 100,000: buy 2 ETH and the pool drops to 8 ETH, so USDC must rise to 100,000 / 8 = 12,500, a payment of 2,500 at an effective 1,250 per ETH. The price impact climbs steeply as the trade grows relative to the pool — which is exactly why deep pools quote better prices for large trades, and why splitting or sizing trades against pool depth is the central practical fact of trading on an AMM. (These are illustrative calculations, not market data.)

It also clarifies what “liquidity” means on a decentralised exchange. There is no book to read; the pool’s reserves are the liquidity, and their size alone tells you how much a trade will move the price. A pool ten times larger produces roughly ten times less impact for the same order.

Variations on the theme

The constant-product formula is the classic, but not the only, design:

  • Stable-asset AMMs use a flatter curve tuned for assets meant to trade near parity, giving far lower slippage in the normal range.
  • Concentrated liquidity lets LPs commit their capital to a chosen price range rather than the whole curve, making their funds deeper where trading actually happens.
  • Weighted pools hold more than two assets in fixed proportions other than 50/50.

All of them share the same core idea: replace human quoting with a deterministic formula over pooled reserves, and let arbitrage keep the price honest.

What this means

An AMM turns market making into a public utility: a formula prices trades, a pool supplies the funds, fees pay the providers, and arbitrage keeps the quote aligned with the outside world. The trade-offs are explicit rather than hidden — slippage grows with trade size relative to the pool, and liquidity providers accept impermanent loss in exchange for fees. Understand x × y = k and where the price comes from, and the behaviour of almost every decentralised exchange becomes legible. For the other half of the LP’s economics, read the companion piece on impermanent loss.

Sources

  1. Uniswap Docs, How Uniswap works
  2. An analysis of Uniswap markets (Angeris et al.)

Frequently asked questions

What does x times y equals k mean?

It is the constant-product rule: the product of a pool's two reserves stays constant across trades. Removing one asset forces you to add a disproportionately larger amount of the other, which is what sets and moves the price.

How does an AMM know the correct market price?

It does not. The pool only knows its own reserves. Arbitrageurs profit by trading whenever the pool's price drifts from the wider market, and that activity pushes the pool's ratio back into line.

Who provides the money in an AMM pool?

Liquidity providers deposit both assets and receive share tokens in return. They earn a portion of every swap's trading fee, but also bear impermanent loss when the pooled assets' prices diverge.

Last reviewed: 26 Aug 2026 Next review: 26 Feb 2027 Section: Markets
Marcus Reed
Market structure writer · Order books, liquidity, derivatives mechanics

Marcus Reed explains how crypto markets function mechanically — order books, liquidity, spreads and exchange mechanics. He describes how markets work, never what to trade.

More by Marcus Reed

Related

Markets

What is a flash loan?

A flash loan is an uncollateralised loan borrowed and repaid in one transaction. Learn how atomicity makes it possible and…

Marcus Reed · Aug 26, 2026 · 6 min