Skip to Content
GlossaryCConstant Product Formula x*y=k

Constant Product Formula x*y=k

The constant product formula, typically x * y = k, is the mathematical equation used by decentralized exchanges (DEXs) to set token prices and balance liquidity pools for automated trading.

What is Constant Product Formula x*y=k?

The constant product formula is the cornerstone of most AMM-based DEXs, such as Uniswap V2, Uniswap V3, and Sushiswap, primarily on Ethereum and layer-2 networks like Arbitrum. It ensures that the product of the quantities of two tokens in a liquidity pool (x and y) remains constant (k) after a trade, automatically adjusting prices based on supply and demand. For example, in an ETH/USDC pool with 10 ETH (x) and 30,000 USDC (y), k = 10 * 30,000 = 300,000. A trader buying 1 ETH reduces x to 9, increasing y to 33,333.33 USDC (300,000 ÷ 9), setting the new price at ~3,333 USDC per ETH, per the formula. As of September 2025, Uniswap V3, with $4 billion in total value locked (TVL), uses this formula across 70% of its $1 trillion annual trading volume, per DeFiLlama data.

The formula enables permissionless trading without order books but introduces slippage for large trades in low-liquidity pools. For instance, a $100,000 trade in a pool with $1 million TVL might incur 1% slippage, while a $10 million TVL pool might see 0.1%, per Uniswap analytics. Variants like Curve’s StableSwap formula (for stablecoin pairs) or Balancer’s weighted pools adjust the constant product model for specific use cases, but x * y = k remains dominant. Risks include price manipulation via large trades, as seen in a 2023 low-liquidity pool exploit causing $5 million in losses. The formula’s simplicity drives DeFi’s $75 billion ecosystem, with gas costs for trades averaging $2-$10 on Ethereum or $0.10-$1 on layer-2, making it efficient for high-volume pools.

Last updated on