Markets

Constant-product pricing

Short answer Constant-product pricing keeps the product of two reserves from falling when a swap pays its fee. The spot price is the reserve ratio. The rule is uniform across all prices in v2, only inside a tick range in v3 and v4, and only the outer region of a Curve StableSwap pool.

Written by
Published
Updated
What changed
Last verified
What this date means
Reading time
About 4 min

Constant product means the pool agrees to any trade that does not shrink x * y after fees. x and y are the two reserves. Their product is k. The trader who wants more of y must leave more of x, and the last unit of y costs more than the first because the reserve of y is shrinking while the reserve of x is growing.

The spot price of y in units of x is x / y only as a marginal price, before a finite trade and before the fee. A real trade moves the reserves. The execution price is worse than the spot price by the impact along the curve, then worse again by the fee. Uniswap’s overview states the qualitative part: larger trades relative to the pool move the price more.

The fee is inside the product check

The v2 flash-swap guide puts the fee at 0.30 percent on the input. The familiar quote multiplies the input by 997 and the reserve by 1000 so that only 99.7 percent of the input counts toward the product. The pool can therefore increase k slightly. It must not decrease k using the post-fee balances. That increase is the fee, left in the reserves so that each LP token claims a larger inventory. All of it was LP income while the protocol fee was off. Uniswap’s UNIfication proposal turns the fee on by splitting the 0.30 percent into 0.25 for LPs and 0.05 for the protocol, and a later proposal says protocol fees are now live on all v2 pools on 11 chains. The trader’s quote is the same either way.

A sketch of the quote, with the rounding made obvious, is on the Uniswap page. The deployed pair does not trust the caller’s arithmetic. It measures token balances. If the product check fails, the swap reverts. There is no partial fill.

A worked swap

Take a v2 pool that holds 100 ETH and 300,000 USDC, and ignore token decimals. The spot price is 300,000 / 100 = 3,000 USDC per ETH. A trader sends 1 ETH. getAmountOut in the v2 periphery library (UniswapV2Library.sol at 87edfdca, last read on 1 December 2026) multiplies the input by 997 and the reserve by 1,000:

Worked arithmetic for the example above, not contract code.

amountInWithFee = 1 × 997                               = 997
amountOut       = 997 × 300,000 / (100 × 1,000 + 997)
                = 299,100,000 / 100,997                 ≈ 2,961.47 USDC

The trader pays an average of 2,961.47 USDC per ETH, 1.28 percent below the 3,000 spot price. Without the fee the same trade would return 2,970.30 USDC, so about 0.99 percentage points of the gap is the curve and the rest is the fee. After the trade the pool holds 101 ETH and 297,038.53 USDC. The new spot price is 2,940.98, and the next buyer of ETH starts from there.

The product moved from 30,000,000 to about 30,000,891, up 0.003 percent. That growth is the 0.003 ETH of fee that the formula did not count toward the trade. It stays in the reserves. Where the protocol fee is on, one sixth of that fee accrues to the protocol and the rest to the LPs.

Size is what changes the picture. A 10 ETH input into the same pool returns 27,198.33 USDC, an average of 2,719.83: 9.34 percent below spot, of which the fee is still only a small part. The trade is a tenth of the ETH reserve, and the curve charges for that.

Calculator Try a constant-product swap
Amount out
2,961.47
Average price paid
2,961.47
Spot price before
3,000.00
Spot price after
2,940.98
Average price below spot
1.28%
Growth of x · y
0.0030%

Uses the v2 getAmountOut formula with real numbers instead of integer division, so the last digits can differ from a pair. Prices are in units of the output token per unit of the input token. With JavaScript off, the values shown are the worked example above.

Where the rule is local

v3 and v4 do not keep one k for the entire price line. The v3 whitepaper gives each range a liquidity L that acts like a product curve between two prices. Outside the range the position has no active liquidity. Talking about “the pool’s k” as a single number is a v2 habit.

Curve’s derivation mixes a constant-sum term with a product term. Near equal balances and with a high amplification coefficient, trades barely move the price, which is the constant-sum end. Far from balance, the product term is what still offers a price instead of letting the pool sell the last coin at one-for-one until it is gone. StableSwap is not “constant product with a different fee.” The fee is separate. The invariant is different. The picture on the Curve page is only a sketch of that bend.

Rounding and the empty pool

Integer reserves round in favor of the pool when the implementation is careful. A quote that uses floating point will not match. A pool with zero of one reserve cannot sell that reserve at any finite price, because the product would require infinite input. v2’s library rejects empty reserves. A concentrated position that has been traded entirely into one asset is the same fact inside its range: there is nothing of the other asset left to buy until the price re-enters and the liquidity is active again.

Common questions

What does x · y = k mean in a Uniswap v2 pool?

x and y are the two reserves and their product is k. The pool agrees to any trade that does not shrink x * y after fees. The last unit of y costs more than the first because the reserve of y is shrinking while the reserve of x is growing.

Where does the Uniswap v2 swap fee go?

The v2 flash-swap guide puts the fee at 0.30 percent on the input, implemented by counting only 99.7 percent of the input toward the product check. The pool can therefore increase k slightly, and the fee stays in the reserves. All of it went to LPs while the protocol fee was off. Where governance has turned it on, since December 2025, LPs earn 0.25 percent and 0.05 percent goes to the protocol.

Does constant-product pricing hold in Uniswap v3 and Curve?

Not uniformly. The rule is uniform across all prices in v2, only inside a tick range in v3 and v4, and only the outer region of a Curve StableSwap pool.

Sources

Check the claims yourself: each group below is a different kind of evidence. Code and specifications show what the contracts do. Documentation shows what the protocol says they do.

Source code

Documentation

Whitepaper

Governance

Changes

  • : Noted the Uniswap v2 protocol fee: where it is on, LPs earn 0.25 of the 0.30 percent.
  • : Added a worked v2 swap with the fee split out, from getAmountOut in UniswapV2Library.sol, and a swap calculator.

Every change to the publication is listed on What changed.

Keep reading

See something wrong or missing? Propose a change via pull request (src/content/concepts/constant-product.md) or report a correction. See how to contribute.