Decoded Intelligence Signal

Constant Product Formula

intermediate
fundamentals
3 min read
412 words

Published Last updated

Key Takeaway

The constant product formula is the mathematical rule used by most AMMs to price tokens, maintaining the product of two pool token quantities as a fixed constant across every trade.

Learn These First

What Is Constant Product Formula?

The constant product formula is the mathematical rule used by most AMMs to price tokens, maintaining the product of two pool token quantities as a fixed constant across every trade.

How Constant Product Formula Works

The constant product formula, expressed as x multiplied by y equals k, is the pricing mechanism that governs most automated market maker protocols, most famously Uniswap. In this formula, x and y represent the current quantities of two tokens held in a liquidity pool, and k is a constant value that must remain unchanged after every trade. When a trader buys token X from the pool, they add token Y to the pool in exchange. The quantities of x and y shift, but their product must remain equal to k. Because k is fixed, any increase in one token's quantity forces a decrease in the other's quantity, which automatically recalculates the exchange rate between them. The more of a token a trader removes from the pool, the more of the other token they must provide to keep the product constant, which means prices move progressively against the buyer as trade size increases. This behavior produces the characteristic price impact curve of AMMs: small trades experience modest price movement, while large trades shift prices dramatically. The curve is hyperbolic, meaning prices theoretically approach infinity before any pool can be completely drained of a token — ensuring the pool always retains some of both assets. The constant product formula has significant advantages: it is simple to implement in a smart contract, requires no external price feeds, and ensures pools can never run completely out of either token. Its limitations include poor capital efficiency for stable asset pairs and high price impact for large trades, which is why newer AMM designs such as Curve's stableswap formula and Uniswap V3's concentrated liquidity model have emerged as refinements.

Frequently Asked Questions

What is the constant product formula in crypto AMMs?

The constant product formula — x multiplied by y equals k — is the mathematical rule that governs token pricing in most automated market maker liquidity pools. In this formula, x and y represent the current quantities of two tokens in the pool, and k is a fixed constant that cannot change after a trade. When you buy token X, you add token Y to the pool, shifting the ratio between them. The formula recalculates the new price automatically based on the updated ratio, without requiring any external price data or human input to set or adjust prices.

Why do large trades on AMMs get such bad prices?

Large trades receive worse prices on AMMs because of how the constant product formula works. Each unit of a token you remove from the pool requires you to add progressively more of the other token to keep the product constant. This means the effective exchange rate worsens continuously as trade size grows — the larger the trade relative to pool size, the more the ratio shifts against you during execution. This worsening is called price impact. Smaller pools amplify this effect because a given trade size represents a larger fraction of total pool liquidity, shifting the ratio more dramatically.

How is the constant product formula different from newer AMM designs?

The original constant product formula spreads liquidity evenly across all possible prices from zero to infinity, making it capital-inefficient — most of the deposited liquidity sits idle at prices far from the current market rate. Newer AMM designs address this. Uniswap V3 introduced concentrated liquidity, allowing providers to allocate capital within a specific price range, dramatically improving capital efficiency near the current price. Curve Finance uses a modified stableswap formula optimized for assets that should trade near a 1:1 ratio, such as stablecoins, producing much lower price impact for large stable asset swaps than the constant product model would allow.

Common Misconceptions About Constant Product Formula

Common Misconception

The constant product formula keeps token prices stable inside a pool.

Technical Reality

The constant product formula does not stabilize prices — it determines how prices change in response to trades. Every trade that shifts the pool's token ratio produces a new price, and the formula provides no floor or ceiling on how far prices can move. Large trades or sustained one-directional buying can shift pool prices dramatically away from market consensus prices on other exchanges. Arbitrageurs help realign pool prices with external markets by exploiting these gaps, but the formula itself has no price stabilization mechanism built into it.

Common Misconception

The k value in x times y equals k can change when fees are added.

Technical Reality

In the basic constant product model, k is fixed for the duration of a trade — the trade must preserve the product exactly. However, in practice most AMM protocols extract a small fee from each trade before applying the formula, which slightly increases k over time as fee income accumulates in the pool. This fee accumulation is how liquidity providers earn returns. The important distinction is that k does not change during a trade's execution; it only grows incrementally between trades as fees are collected, which increases total pool value over time.

Common Misconception

All decentralized exchanges use the constant product formula.

Technical Reality

The constant product formula is the most widely adopted AMM pricing model but it is not universal. Curve Finance uses a hybrid stableswap formula that combines constant product and constant sum mechanics, specifically designed to minimize price impact for stablecoin and pegged-asset swaps. Balancer uses a generalized constant product formula extended to pools with more than two tokens and customizable weightings. DODO and other DEXs use proactive market maker models that incorporate external price oracles. AMM design is an active area of innovation, and multiple competing formulas coexist across the DeFi ecosystem.

Related Terms

Compare Adjacent Terms

Access Pro Research Infrastructure

Deciphering Constant Product Formula is just the first step. Apply for the Q3 2026 Beta to gain direct access to our 8-agent intelligence pipeline.