For educational purposes only; not investment advice. Investing may result in loss.
Direct answer
A constant-product automated market maker (CPMM) holds reserves of two tokens and accepts swaps only when the post-trade balances satisfy an invariant based on x * y = k. Here, x and y are the reserves. The reserve ratio supplies an instantaneous pool price; a trade moves that ratio, so larger trades relative to liquidity receive progressively worse prices.
The curve is a quoting and settlement rule, not an oracle and not a promise that either token is worth anything. Arbitrageurs usually move the pool price toward external markets, earning the difference while changing the assets held by liquidity providers (LPs).
- Price impact including fee
- 9.34%
- Input-side fee
- 0.03
Outputs are educational approximations. They exclude venue rules, taxes, latency, oracle behavior, and other protocol-specific parameters unless shown.
How it works
Before fees, a swap that adds deltaX units of token X and removes deltaY units of token Y satisfies:
(x + deltaX) * (y - deltaY) = x * y
Therefore deltaY = y * deltaX / (x + deltaX). If the input-fee rate is f, let gamma = 1 - f; the usual fee-adjusted quote is:
deltaY = y * gamma * deltaX / (x + gamma * deltaX)
The infinitesimal Y-per-X price is y / x. A finite trade executes across the curve, so its average price differs from both the starting and ending spot prices. That difference is price impact; a user’s slippage tolerance is instead a transaction constraint protecting the quote from adverse changes before execution.
In fee-charging implementations such as Uniswap v2, the full input remains in the reserves while the invariant check discounts the input by the fee. Consequently, the recorded reserve product normally increases after a swap. Deposits and withdrawals change reserve size and LP ownership, so they are separate liquidity events rather than swaps along one fixed curve.
Example
Consider a pool with 100 ETH and 200,000 USDC. Its displayed reserve price is 2,000 USDC/ETH. A trader sends 10,000 USDC to buy ETH, and the pool charges 0.30%, so the effective input is 9,970 USDC.
ETH out = 100 * 9,970 / (200,000 + 9,970) = 4.7483 ETH
The trader’s average execution price is about 2,106.02 USDC/ETH, roughly 5.30% above the starting reserve price. After settlement the reserves are approximately 95.2517 ETH and 210,000 USDC, implying a new reserve price near 2,204.69 USDC/ETH. These figures exclude gas, routing across other pools, and any adverse state change before inclusion.
An interface quote should be checked against the exact token addresses, fee tier, reserves or block used, minimum amount received, route, and deadline. Token transfer taxes or nonstandard balance behavior can invalidate the simple calculation.
Risks
- Price impact and MEV: thin liquidity and public pending transactions can produce poor execution, sandwiching, or failed swaps.
- LP inventory risk: arbitrage makes LPs hold less of the outperforming token and more of the underperforming token; fees may not offset impermanent loss.
- Bad assets and contracts: depegs, malicious tokens, transfer fees, contract bugs, compromised interfaces, and admin controls are outside the curve’s protection.
- Oracle misuse:
y / xcan be moved within a transaction. Protocols should not treat a manipulable spot reserve ratio as an independent market price. - Parameter differences: fee logic, rounding, concentrated liquidity, hooks, and weighted or stable-swap curves can make another pool behave differently from this model.
Common misconceptions
Myth 1: k is exactly constant forever
Swaps are checked against the invariant, but fees and liquidity events can increase or reset the numerical reserve product. Integer rounding also matters in contract implementations.
Myth 2: The pool discovers the fair price
The pool mechanically prices its reserves. External traders and arbitrage connect it to broader markets; stale or manipulated reserves can quote an unreasonable price.
Myth 3: Slippage and price impact are the same
Price impact is the curve movement caused by the proposed trade. Slippage is the difference between the expected and actual result, or the tolerance used to bound that difference.
Myth 4: More volume always benefits LPs
Volume generates fees, but informed arbitrage can transfer value from LPs. Net performance depends on fees, price path, volatility, pool depth, and contract or asset risks.
Related topics
Sources
- How Uniswap Works - Uniswap Labs (accessed: 2026-08-20)
- UniswapV2Pair.sol - Uniswap (accessed: 2026-08-20)