Deciphr Academy
Track 4 · Module 17 · Lesson 4 of 7 · 8 min read

How does an automated market maker (AMM) pool set a price?

Short answer

An AMM pool holds two tokens and prices every trade with a formula; in Uniswap v2 the product of the two reserves, x × y = k, must not fall after a trade.1,2 The price is one reserve divided by the other, so every swap moves it, and v2 takes a 0.30% fee from the amount paid in.2,3

BRDL in the pool (x)USDC in the pool (y)A: before, price 0.20B: after Maya sells BRDLmore BRDL, less USDC, lower pricex × y = kthe pool stays on this curveprice = USDC ÷ BRDL
Fig. 4. The pool stays on the curve x × y = k. Selling BRDL into it moves the pool along the curve, so BRDL's price falls.

A pool instead of an order book

The Uniswap v3 whitepaper describes automated market makers (AMMs) as systems that pool liquidity and offer it to traders according to an algorithm.4 Uniswap's documentation says an AMM replaces buy and sell orders with a pool of two assets, each priced against the other. A trader deals with the pool directly, not with another person's order.1

Each Uniswap pool is a trading venue for one pair of tokens.5 People who deposit tokens into it are called liquidity providers. The first one sets the pool's starting price.5 Lesson 5 covers them. On an order book, by contrast, whoever makes a market must keep updating their own orders as others trade.5 Module 19 covers the firms that do this, called market makers.

The constant product rule

Uniswap prices trades with what it calls the constant product formula, x × y = k.1 Here x and y are the pool's reserves of the two tokens. k is a number that must stay the same, or grow, after every trade.1

So when a trader takes some of one token out, they must put in enough of the other to keep the product the same.6 The Uniswap v2 whitepaper puts the rule simply: the product of the reserves cannot decrease.2

How the pool sets a price

The pool's current price, before fees, is one reserve divided by the other.2 A pool with 1,000,000 of token A and 200,000 USDC prices token A at 200,000 ÷ 1,000,000 = 0.20 USDC.2

Every trade changes the reserves, so every trade moves the price.1 Uniswap's documentation says larger trades, compared with the size of the pool, move the price more. This is called price impact. Small trades happen close to the current price.1 Module 18 looks at price impact and slippage in more detail.

What stops a pool's price drifting away from the rest of the market? The v2 whitepaper says arbitrage traders will trade with the pool whenever its price is wrong by more than the fee, so the pool's price tends to track the market.2 Module 15 explains why a smart contract should not trust a pool's live price as an oracle.

The 0.30% fee

The v2 whitepaper explains that, as in v1, the fee is taken by reducing the amount paid in by 0.3% before the constant-product rule is checked.2 Uniswap's documentation says every v2 pool charges a flat 0.30%, which is added to the pool's reserves.3

Uniswap's own code shows the sum. It multiplies the amount in by 997, multiplies that by the reserve of the token going out, and divides by the reserve of the token coming in times 1,000, plus the amount in times 997.7 The result is the most the pool will pay out.7 Solidity, the language the code is written in, rounds integer division towards zero, so any fraction of the smallest unit is dropped.8

Fees differ between versions.3,4

  • v3 pools have fee tiers. The standard ones are 0.05%, 0.30% and 1%.3,4
  • v4 has no fixed tiers. Pool creators can set any fee from 0% to 100%.3
  • Protocol fee. As of October 2026, Uniswap's documentation says a protocol fee is active on all v2 pools.3 It was first switched on for Ethereum in December 2025, then for more chains in 2026.9,10 It takes 0.05% of the 0.30%, so liquidity providers get 0.25%.3
How we work out a swap

Output = (amount in × 997 × reserve out) ÷ (reserve in × 1,000 + amount in × 997). This is the method in Uniswap v2's code.7 We round the result down to the cent. The contract itself works in each token's smallest unit and drops any fraction of that.8,7

Sell 5,000 tokens into a pool with 1,000,000 tokens and 200,000 USDC: 5,000 × 997 = 4,985,000. Then 4,985,000 × 200,000 ÷ (1,000,000,000 + 4,985,000) = 992.05 USDC, rounded down. Afterwards the pool holds 1,005,000 tokens and 199,007.95 USDC, so its price is 199,007.95 ÷ 1,005,000 = 0.1980 USDC. The quizzes use this method.

Different curves for different tokens

The constant product rule spreads a pool's money across every possible price, from zero to infinity.11 The v3 whitepaper says only a fraction of it is used at any one price, which is wasteful for tokens that should trade close to one price.4 Lesson 5 shows Uniswap's answer.

Other designs use a different formula. Curve's 2019 StableSwap paper describes a pool for stablecoins that it calls "Uniswap with leverage", with much less price slippage for coins that should be worth the same.12,4

Our viewAn AMM is a simple machine. It never runs out of prices, but it charges more and more the bigger your trade is compared with the pool.
WatchExchanges, DEXs and how a pool sets a price, in about two minutes. Captions are built in. Sources are listed at the end.
Sources
  1. How Uniswap Works. Uniswap Developers documentation (read 22 October 2026).
  2. Uniswap v2 Core (whitepaper). Hayden Adams, Noah Zinsmeister and Dan Robinson, March 2020.
  3. Fees. Uniswap Developers documentation (read 22 October 2026).
  4. Uniswap v3 Core (whitepaper). Hayden Adams, Noah Zinsmeister, Moody Salem, River Keefer and Dan Robinson, March 2021.
  5. Pools (Uniswap v2). Uniswap Developers documentation (read 22 October 2026).
  6. Uniswap v2 Swaps. Uniswap Developers documentation (read 22 October 2026).
  7. UniswapV2Library.sol (getAmountOut). Uniswap v2-periphery source code on GitHub.
  8. Types: Division. Solidity documentation (read 22 October 2026).
  9. UNIfication (onchain proposal 93). Uniswap governance vote page on Agora (read 22 October 2026; rechecked 24 October 2026).
  10. Protocol Fee Expansion: Vote 3 (onchain proposal 96). Uniswap governance vote page on Agora (read 24 October 2026).
  11. Concentrated Liquidity. Uniswap Developers documentation (read 22 October 2026).
  12. StableSwap: efficient mechanism for Stablecoin liquidity. Michael Egorov (Curve), 10 November 2019.

General education built from the publicly available sources listed above. Not financial, legal, tax or investment advice. Naming a company, project or regulator is not an endorsement either way. Last checked 2026-10-24. Terms and disclaimer.