Uniswap Guide

AMM Pricing Formula Intuition: How Constant Product Markets Really Set Token Prices

The intuition behind the AMM pricing formula is that it doesn't "price" an asset at all—it derives a price from the ratio of two token reserves in a liquidity pool, and that ratio shifts automatically as trades occur. In a standard constant product market like Uniswap V2, the core invariant is `x * y = k`, where `x` and `y` are the reserves of two tokens. The instantaneous price of token X in terms of token Y is simply `y / x`. That single ratio, and the way it bends as you trade against it, is the entire engine of automated market making.

Why the Price Is Just a Ratio, Not a Quote

In traditional order-book exchanges, a price is set by the last matched bid and ask. In an AMM, there is no order book. Instead, the pool holds both tokens, and the price is a direct consequence of how much of each token is currently in the pool. If a pool has 100 Token A and 200 Token B, the price of 1 A is 2 B (because `200 / 100 = 2`). This is not a prediction or a valuation—it is a mechanical relationship.

The Constant Product Constraint

The product `x * y` must always equal the same constant `k` after any trade. When you buy Token A, you add Token B to the pool and remove Token A. The pool's reserves change, but `x * y` stays the same. This constraint is what forces the price to move: because the product is fixed, any change in one reserve forces an inverse change in the other, which alters the ratio.

Why This Creates a Curve, Not a Line

If the price were linear, buying 10% of a token would cost exactly 10% of the pool's value. But because the product is constant, the price increases non-linearly as you buy more. The first small trade is cheap; the next one is slightly more expensive. This is the "slippage" you often hear about—it is not a bug, but the mathematical consequence of the constant product rule.

Marginal Price vs. Execution Price

A common confusion is between the spot price (the ratio `y / x` before your trade) and the average price you actually pay. The AMM formula gives you the marginal price for an infinitesimally small trade. For any real trade of size `Δx`, you must solve for the new reserves that keep `k` constant, and your average cost is the total `Δy` you paid divided by the `Δx` you received.

Deriving the Output Amount

If you put `Δx` tokens into the pool, the new reserve of X is `x + Δx`. To keep the product constant, the new reserve of Y must be `k / (x + Δx)`. So the Y you receive is: `Δy = y - (k / (x + Δx))` This is the exact output formula. Notice that the larger `Δx` is relative to `x`, the larger the denominator shrinks, and the more Y you lose per unit of X. That is the entire intuition of price impact.

Why Big Pools Have Lower Slippage

If `x` is huge (a deep pool), then adding a small `Δx` barely changes the denominator `x + Δx`. The ratio `y / x` stays almost the same, so the price impact is tiny. If `x` is small (a shallow pool), the same `Δx` represents a large percentage change, and the price moves sharply. This is why liquidity depth matters more than the raw token count.

How the Formula Rebalances the Pool

The constant product formula is not just a pricing rule; it is a self-correcting mechanism. After a trade, the pool holds more of the token you sold and less of the token you bought. That new reserve ratio means the price has shifted against the direction of your trade. This discourages one-sided trading and encourages arbitrageurs to step in.

The Arbitrage Loop

If the AMM price of Token A rises well above the price on a centralized exchange, an arbitrageur will buy Token A from the cheaper venue and sell it into the AMM. That sale pushes the AMM price back down. Conversely, if the AMM price is too low, arbitrageurs buy from the AMM and sell elsewhere, pushing the AMM price up. The formula ensures that the pool always returns to a state where the AMM price roughly matches external markets.

Impermanent Loss as a Side Effect

Because the pool's composition changes with every trade, liquidity providers do not simply hold a static 50/50 portfolio. If one token's external price rises, arbitrageurs drain that token from the pool, leaving you with more of the cheaper token. When you withdraw, the dollar value of your position may be lower than if you had just held the two tokens. This is not a fee or a loss in the traditional sense—it is the cost of providing liquidity in a formula-driven market.

Visualizing the Price Impact with a Simple Table

To build intuition, consider a pool with 100 X and 100 Y (`k = 10,000`). The table below shows how the price of X changes as you buy increasing amounts. | X bought (Δx) | New X reserve | New Y reserve | Price per X (Δy / Δx) | |---------------|---------------|---------------|------------------------| | 1 | 101 | 99.01 | 0.99 | | 5 | 105 | 95.24 | 0.95 | | 10 | 110 | 90.91 | 0.91 | | 25 | 125 | 80.00 | 0.80 | Notice that the price per token drops as you buy more. This is not a discount—it is the average cost of each unit, which rises with size. The marginal price after buying 25 X would be even lower than 0.80, illustrating the accelerating slippage.

The Bottom Line: The Formula Is a Rule, Not a Prediction

The AMM pricing formula does not ask "what is this token worth?" It asks "what ratio of reserves keeps this pool balanced?" The answer is always `y / x`, and every trade is a forced rebalancing along the constant product curve. Once you internalize that price is a derivative of pool composition—and that every trade changes the composition—you understand the core of Uniswap and every constant product AMM built after it. The formula is simple, but its consequences (slippage, arbitrage, impermanent loss) ripple through the entire DeFi ecosystem.