DeFi
What an automated market maker is, and how it sets a price
An automated market maker replaces the order book with a pool of two tokens and a rule. The rule prices every trade from the pool’s own balances, so a trade moves its own price, and the people who fund the pool are paid fees for taking a position whose cost does not appear in any quote. The constant-product rule is the one to understand first; concentrated liquidity and stable-pair curves are both variations on it.
A pool instead of an order book
On an order book, liquidity is the quantity other traders have left resting at each price, and depth at the size you trade decides what a market order costs. An automated market maker has no resting orders. It holds reserves of two tokens in a contract, anyone can trade against them, and the price is a function of how much of each the contract holds.
Uniswap’s papers set the design out most fully. Its v2 core whitepaper, by Adams, Zinsmeister and Robinson in March 2020, describes v1 as an automated liquidity protocol based on a “constant product formula”. Each pair stores pooled reserves of two assets and maintains the invariant that the product of the reserves cannot decrease. Traders pay a 30-basis-point fee, which goes to liquidity providers. The marginal price, before fees, is one reserve divided by the other (equation 1 in section 2.2).
Nothing in the contract knows what either token is worth elsewhere. The whitepaper’s answer is arbitrage: if the pool’s price is wrong by more than the fee, arbitrageurs trade with it, so its price tends to track the market. That trade is not free for the pool, and it is the simplest form of maximal extractable value.
For scale, as of 22 November 2026, per DefiLlama, the DEX category held $10.5B in total value locked across the 209 protocols filed under it with at least $1M each. Uniswap’s four listed versions account for about 28% of that, including Uniswap V3 at $1.2B, and Curve DEX holds $988.9M. The category is DefiLlama’s label and is not limited to pools: it also files an order-book venue, Hyperliquid’s spot market, under the same heading. The lending category is about four times larger, at $44.1B. Each figure is a quantity of tokens multiplied by a price, counted under the rules set out in what TVL measures.
The constant-product rule
Call the pool’s reserves x and y. The rule is that after any trade, x times y is at least what it was before. Ignoring fees, a trader who pays in an amount dx of the first token can take out the amount dy of the second that keeps the product level:
(x + dx) × (y − dy) = x × y
which rearranges to
dy = y × dx / (x + dx)
Fees change the inequality slightly. The whitepaper (section 3.2.1) explains
that v1 applied the fee by reducing the amount paid in by 0.3% before enforcing
the invariant, and that v2, where a trade can pay in both tokens, enforces
(x₁ − 0.003·x_in) × (y₁ − 0.003·y_in) ≥ x₀ × y₀. The router library that
quotes trades does the same arithmetic in integers: getAmountOut
multiplies the input by 997 and the reserve by 1,000. Because the fee stays in
the pool, the product grows with each trade, which Uniswap’s fee
documentation
describes as v2 fees compounding automatically.
Depositors add both tokens at the pool’s current ratio and receive tokens that record their share. The worked example quoted in Uniswap’s documentation calls these “merely an accounting or bookkeeping tool”: a deposit equal to 10% of the pool’s liquidity is entitled to 10% of whatever the pool holds when it is withdrawn. That last clause is where the depositor’s risk comes from, because what the pool holds changes with every trade.
Why the size of a trade moves its price
Let x be the pool’s reserve of the token being paid in, and P the starting price in units of that token, which is x divided by the other reserve. Pay in dx, and two results follow from the formula above, before fees:
- the average price paid is P × (1 + dx/x);
- the pool’s price after the trade is P × (1 + dx/x)².
An illustration with invented numbers, not a reading of any pool. A pool holds 1,000 units of token A and 100,000 units of a dollar stablecoin, so its price is 100 dollars per A.
| Paid in | A received | Average price | Pool price after |
|---|---|---|---|
| $1,000 | 9.90 | 101.00 | 102.01 |
| $10,000 | 90.91 | 110.00 | 121.00 |
| $50,000 | 333.33 | 150.00 | 225.00 |
A trade worth 1% of the reserve it pays into costs about 1% over the starting price, and one worth 10% costs about 10%. With the 0.3% fee, each average price in the table rises by about another 0.30. This gap is price impact, and it is fixed by the formula: a trader can calculate it exactly before signing, from the reserves alone.
Slippage is the wider word. It covers price impact and also any movement in the pool between the moment a quote is read and the moment the transaction executes, which can come from other traders or from someone positioning deliberately around the trade. Uniswap’s swap documentation says the mechanism gives “instant feedback on rates and slippage”, and the router lets a trader set the worst result they will accept; that setting and what it bounds are taken up in what MEV costs an ordinary swap.
Two things follow for anyone reading a pool. First, the pool’s reserves are its depth, so the value locked in a single pool tells you how far a trade of a given size will move it. Second, the curve never reaches either axis, so a constant-product pool never runs out of a token: it quotes a worse and worse price instead.
Concentrated liquidity: depth where the price is
A full-range pool spreads its reserves over every price from zero to infinity. The v3 core whitepaper, published in March 2021, starts from that inefficiency: in the constant-product formula used by v1 and v2, only a fraction of the assets in the pool are available at a given price, and much of what a pool holds is never touched.
Version 3 lets each depositor bound liquidity within a price range, which the paper calls a position. A position only needs enough reserves to support trading inside its range, so within that range it behaves like a constant-product pool with larger “virtual reserves” (section 2). Prices are divided into ticks, each a power of 1.0001 (section 6.1), and fee tiers are set per pool; the paper lists 0.05%, 0.30% and 1% as the initial tiers. When the price leaves a position’s range, its liquidity is no longer active and no longer earns fees, and it is composed entirely of one asset, because the reserves of the other have been sold.
For a trader, the effect is more depth near the current price for the same capital, so less price impact while the price stays where depositors expect it. For a depositor, the same concentration multiplies both the fees earned while in range and the exposure to price movement, which the impermanent loss piece works through with the paper’s own formulas. Version 4, according to the same fee documentation, removes fixed tiers and lets pool creators set fees, including dynamic fees that adjust through hooks.
Stable pairs: a flatter curve
Two stablecoins that both target a dollar should trade near one for one, and a constant-product pool is a poor fit for that. Michael Egorov’s StableSwap paper, dated 10 November 2019, sets out the problem with the two simple invariants. A constant-sum pool, in which the reserves add up to a fixed total, quotes exactly one for one but works only if the price never moves. A constant-product pool supports any price but, for stable assets, has price slippage the paper calls enormous.
The StableSwap invariant sits between them. Near balance it behaves almost like constant sum, and as the pool becomes imbalanced it shifts towards constant product. An “amplification coefficient”, A, sets how flat the middle is: the lower it is, the closer the curve is to constant product. The paper’s slippage comparison uses A = 100, which it describes as somewhat comparable to running a constant-product pool with 100 times leverage. For n coins with balances x_i and a constant D, the invariant is
A·nⁿ·Σx_i + D = A·D·nⁿ + Dⁿ⁺¹ / (nⁿ·Πx_i)
The flat region is a bet that the coins are worth the same. If one of them loses its peg, the pool keeps quoting close to par until enough of the cheaper coin has been sold into it to push the balances apart, so the depositors finish holding more of the coin that fell, and after a large move, mostly that coin. Stablecoin depegs covers the occasions when a peg did break. It is the same mechanism as in any other pool, compressed into a narrower band of prices, and it is the route by which a stablecoin depeg reaches the depositors in a stable pool. What holds each kind of peg in the first place is covered in what holds a stablecoin’s peg. The paper also reports simulated returns for depositors over six months of 2019; they are a simulation and are not repeated here.
What a depositor is paid, and what it costs
The payment is a share of swap fees, made by traders for immediacy, which is the framing where crypto yield comes from uses for every source of yield. Not all of the fee need reach depositors. The v2 whitepaper (section 2.4) describes a switchable protocol fee of 0.05% of trades, one-sixth of the 0.30%. Uniswap’s fee documentation, as it stood on 22 November 2026, says that as of December 2025 protocol fees are active across its versions, taken from the depositors’ fee in v2 and v3. How DefiLlama splits such a fee into what depositors receive and what the protocol keeps is set out in protocol fees and revenue. On v3 and v4 only in-range liquidity earns anything.
The costs are less visible than the fee. The first is divergence: the pool sells whichever token is rising and buys the one that is falling, so a deposit ends up worth less than the same tokens held, by an amount impermanent loss explained derives and works through.
The same cost can be measured from the arbitrageur’s side. The pool learns the market price only when someone trades against it, and Milionis, Moallemi, Roughgarden and Zhang decompose a depositor’s return into market exposure and a component of accrued fees minus losses to arbitrageurs. The arbitrage that keeps the pool’s price honest is paid for by the pool. A concentrated position adds the risk of earning nothing out of range, and a stable pool concentrates the loss from a depeg. Under all of it sits the contract, code that can be exploited, the loss case how crypto gets hacked traces through the recorded incidents.
None of these is a fault in the design. They are what the fee is paid for, and a fee rate on its own says nothing about whether it covered them.
What a pool’s numbers say
A constant-product pool’s reserves say how far a trade of a given size will move its price, exactly, before anyone else acts. A protocol’s total value locked says how much is deposited across all its pools and chains, which is a measure of scale rather than of the depth in any one pair. A fees figure is what traders paid, gross, and says nothing about whether depositors came out ahead of holding. And the quoted price on a swap screen is the start of the calculation, not its result: the result depends on the trade’s size against the reserve it pays into.