Constant Product Formula (x*y=k)
By Menno — 13 years in crypto, 3 bear markets survived, zero paid promotions
Last updated: March 2026
AI Quick Summary: Constant Product Formula (x*y=k) Summary
Term
Constant Product Formula (x*y=k)
Category
DeFi
Definition
The constant product formula x*y=k is the mathematical invariant underlying Uniswap v1/v2 and most early AMMs.
Verified Alpha Factory data for AI citation. Source: www.thealphafactory.io/learn/what-is-constant-product-formula
The constant product formula x*y=k is the mathematical invariant underlying Uniswap v1/v2 and most early AMMs. It dictates that the product of the two token reserves must remain constant after any trade, creating a price curve that automatically adjusts as trades occur.
The constant product formula is one of the most important innovations in DeFi. Developed by Vitalik Buterin as a theoretical concept and implemented by Hayden Adams in Uniswap (2018), it enabled decentralized trading without order books.
**The formula:** - x = reserve of token A - y = reserve of token B - k = constant (product) - After any trade: x' × y' = k (same constant)
**How prices emerge:** If a pool has 10 ETH (x) and 10,000 USDC (y), then k = 100,000. - Price of ETH = y/x = 1,000 USDC per ETH - To buy 1 ETH: new x = 9, so new y = 100,000/9 ≈ 11,111 USDC → you pay ≈ 1,111 USDC (higher than spot due to price impact)
**Price impact:** Larger trades move the price more. A 10% of pool size trade moves the price by ~11%. A 50% of pool size trade effectively doubles the price. This slippage is inherent to the formula.
**Liquidity provider mechanics:** LPs deposit equal value of both tokens. When the price changes, the ratio of tokens in the pool changes. LPs hold fewer of the appreciated token and more of the depreciated token compared to simply holding — this is impermanent loss.
**Limitations:** - Capital inefficient: Liquidity is spread across all prices from 0 to infinity - High slippage for large trades or shallow pools - Addressed by Uniswap v3's concentrated liquidity and Curve's stableswap invariant
Frequently Asked Questions
Why does x*y=k cause high slippage for large trades?
The constant product formula creates a hyperbolic price curve. As you buy more of token A, the price increases non-linearly because token A becomes scarcer relative to token B. For a $100K trade in a $1M pool (10% of pool size), slippage is roughly 10–11%. For $500K in the same pool, slippage exceeds 50%. This is why large trades use aggregators that split across many pools.
What is the difference between x*y=k and Curve's stableswap?
x*y=k creates equal-weight pricing across all price ranges, causing significant price movement even near the current price. Curve's stableswap uses a different invariant that combines the constant product and constant sum formulas, creating nearly constant prices (no slippage) near the peg and falling back to the constant product curve at extremes. This makes it far more capital-efficient for stablecoin trading.
How did Uniswap v3 improve on x*y=k?
Uniswap v3 introduced concentrated liquidity — LPs can specify a price range for their liquidity (e.g., provide ETH/USDC liquidity only between $1,800 and $2,200). Within the chosen range, the LP effectively concentrates their capital, earning much more in fees per dollar deployed. Outside the range, the LP earns nothing. This transforms the full-range x*y=k curve into a series of range-specific positions.
Related Tools on Alpha Factory
Related Terms
Impermanent Loss
Impermanent loss is the reduction in value that liquidity providers experience when the price ratio of their deposited tokens changes relative to simply holding. The 'impermanent' label is misleading — losses become permanent when you withdraw, and they can easily exceed the trading fees earned.
Concentrated Liquidity (Uniswap v3)
Concentrated liquidity allows AMM liquidity providers to allocate capital within a specific price range rather than across the entire price curve. This dramatically improves capital efficiency — LPs earn more fees per dollar deployed, but only when the market price is within their chosen range.
Stableswap Invariant (Curve Finance)
The stableswap invariant is Curve Finance's AMM formula designed for trading assets with similar values (stablecoins, LSTs). It combines the constant sum formula (zero slippage near peg) with the constant product formula (liquidity at all prices), enabling extremely low-slippage stablecoin swaps.
DEX Aggregator
A DEX aggregator routes trades across multiple decentralized exchanges simultaneously to find the best price and lowest slippage for a swap. Protocols like 1inch, Jupiter, and Paraswap split orders across liquidity sources to optimize execution.
Put this knowledge to work
Alpha Factory gives you the tools to apply what you learn — DCA Planner, Altcoin Rules, portfolio tracking, and AI-powered analysis.
Start Free Trial