Research note · 2026-11-06 · Primary sources: Uniswap v2 Core whitepaper (March 2020), Uniswap developer docs

An order book needs someone willing to quote both sides at all times. On a blockchain where every quote update costs gas and blocks arrive every few seconds, that is expensive to run on-chain. Automated market makers solve the problem by removing the quoting: a contract holds reserves of two tokens and prices every trade from a formula over those reserves. Liquidity providers deposit tokens and accept whatever the formula does with them, in exchange for fees.

The constant product rule

The Uniswap v2 Core whitepaper describes the design inherited from v1: each pair stores pooled reserves of two assets and maintains “the invariant that the product of the reserves cannot decrease.” Written out:

x × y = k

where x and y are the pool’s reserves of the two tokens and k is a constant between liquidity changes. A trade adds some amount of one token and removes some of the other, and the amount removed is whatever keeps the product at k (after fees). The spot price is the ratio of reserves, y / x.

Two properties follow directly:

  • The pool never runs out. As one reserve shrinks, its price rises without limit, so the pool always quotes a price, however bad.
  • Price impact is a function of trade size relative to reserves. Small trades barely move the ratio; large ones move it a lot.

Worked example

All numbers are hypothetical.

Say a pool holds 1,000 TKN and 100,000 USDC. Then:

  • k = 1,000 × 100,000 = 100,000,000
  • Spot price = 100,000 / 1,000 = 100 USDC per TKN

A trader sends 10,000 USDC to buy TKN. Uniswap v2 charges 0.30%, taken from the input, so 9,970 USDC counts toward the curve.

  1. USDC side after the trade (for the invariant): 100,000 + 9,970 = 109,970
  2. TKN side required to hold k: 100,000,000 / 109,970 ≈ 909.34
  3. TKN paid out: 1,000 − 909.34 ≈ 90.66 TKN
  4. Average execution price: 10,000 / 90.66 ≈ 110.30 USDC per TKN

The pool now holds about 909.34 TKN and 110,000 USDC (the full input, fee included, stays in reserves in v2). The new spot price is 110,000 / 909.34 ≈ 120.97 USDC. The trade paid an average price about 10.3% above the starting spot and left the spot about 21% higher.

The same pool at four trade sizes:

USDC in TKN out Average price (USDC) Premium over 100 spot
100 0.996 100.40 0.4%
1,000 9.872 101.30 1.3%
10,000 90.661 110.30 10.3%
50,000 332.666 150.30 50.3%

The 0.4% at the smallest size is almost entirely the 0.30% fee. At larger sizes the curve dominates. This is why depth relative to trade size, not the headline TVL of a protocol, is what matters for execution.

Adding and removing liquidity

Deposits must match the current reserve ratio. In the example pool, a new provider adding 10 TKN would also add 1,000 USDC, and would receive LP tokens representing 1% of the enlarged pool. Withdrawing burns the LP tokens and returns the same percentage of whatever the reserves hold at that moment, which after trading will be a different mix than the one deposited. An LP share is a claim on a fraction of the pool, not a claim on the specific tokens put in. The liquidity pool explainer walks through the share accounting.

Depositing at the wrong ratio is not rejected outright in every implementation; in Uniswap v2 the excess on one side is effectively donated to existing LPs, which is why routers calculate the matching amount before submitting.

How the price returns to market

Nothing in the pool knows the outside price. After the trade above, TKN costs about 121 USDC in this pool. If TKN trades at 100 elsewhere, an arbitrageur can sell TKN into the pool until its ratio is back near 100, pocketing the difference minus fees and gas. AMMs depend on arbitrage to stay in line with other markets, and that arbitrage profit comes out of the pool. The cost to depositors is what is usually called impermanent loss.

Fees and where they go

In v2, the fee is added to reserves, so k grows slightly with every trade and each LP share becomes redeemable for a bit more of both tokens. Uniswap’s fee docs note this compounding happens automatically in v2, while v3 and v4 positions accrue fees as separate claimable balances.

The whitepaper also describes a protocol fee switch: if turned on, LPs receive 0.25% and the protocol 0.05% of the amount traded. According to Uniswap’s docs, protocol fees were activated on all v2 pools and select v3 pools after the UNIfication governance proposal passed in December 2025.

Variants on the curve

The constant product is the reference design. Others change the curve or the distribution of liquidity:

  • Concentrated liquidity (Uniswap v3 and v4). LPs choose a price range. Uniswap’s concentrated liquidity page notes that a v2 DAI/USDC pair used only about 0.50% of its capital between $0.99 and $1.01. Concentrating capital deepens the market near the current price, but a position earns nothing once the price leaves its range and ends up holding only one of the two tokens.
  • Stable-swap curves. Designs for assets expected to trade near parity (two dollar stablecoins, ETH and a liquid staking token) flatten the curve near 1:1, so large trades move the price less, and steepen it further out. They work well until one asset depegs, at which point the pool fills up with the weaker asset.
  • Weighted pools. Pools with more than two tokens or unequal weights (80/20 instead of 50/50) generalize the product rule.
  • Hooks and dynamic fees (Uniswap v4). Uniswap’s hooks docs describe external contracts attached to a pool at creation that can run logic around swaps and liquidity changes, including fees that adjust per swap.

AMMs as price oracles

Because a pool always has a price, protocols are tempted to read it. A spot price from one pool can be pushed within a single transaction, especially with flash-borrowed capital. The v2 whitepaper addressed this with a time-weighted average price accumulator: the contract records the price at the start of each block and sums it over time, so a caller can compute an average over any interval. Pushing an average for a meaningful window requires holding the price away from market for many blocks, which arbitrageurs make expensive. ethereum.org’s oracles page lists Uniswap TWAPs among common DeFi price sources. Thin pools remain easy to move even on a TWAP basis.

Failure modes

  • Price manipulation of thin pools for use as collateral pricing elsewhere.
  • MEV. Pending swaps are visible to block builders and searchers, who can sandwich trades with loose slippage settings. See how decentralized exchanges work.
  • Asset risk. A pool holds both tokens. If one fails (a depeg, an exploit of its issuer, a malicious mint function), arbitrageurs drain the good token out of the pool in exchange for the bad one.
  • Contract risk. Custom curves, hooks and routers add code. Each addition is a separate surface. The DeFi risk checklist covers how to assess it.

This explains the mechanism only; it is not a suggestion to provide liquidity to, or trade on, any pool.

Summary formulas for reference

  • Output for an input Δx with fee f: Δy = y × Δx(1 − f) / (x + Δx(1 − f))
  • Spot price: y / x
  • New spot after trade: (y − Δy) / (x + Δx), with v2 fees retained in reserves