Constant Product Formula
The mathematical formula (x · y = k) that governs automated market makers, maintaining a constant product of token reserves.
The constant product formula, expressed as $x \cdot y = k$, is the foundational mathematical principle behind Automated Market Makers (AMMs) like Uniswap v1. This formula defines the relationship between the reserves of two assets in a liquidity pool.
How It Works
In this model:
- x represents the quantity of one asset in the pool (e.g., ETH)
- y represents the quantity of the other asset (an ERC20 token)
- k is the "constant product" or invariant, which must remain constant during a trade (before fees)
Price Curve
The formula creates a hyperbolic bonding curve for asset prices. When a trader swaps an amount Δx of asset X for an amount Δy of asset Y, the new reserves must satisfy:
$(x + \Delta x) \cdot (y - \Delta y) = k$
Key Implications
Infinite Liquidity: The curve asymptotically approaches the axes but never touches them, meaning a pool can theoretically never be fully depleted of one asset through trading alone.
Price Impact: Larger trades have increasingly worse prices due to the hyperbolic curve, creating natural slippage.
Fee Accumulation: A trading fee (e.g., 0.30%) is added back to the reserves after each trade, causing k to increase over time, which rewards liquidity providers.
Security Considerations
The constant product formula is deterministic and can be manipulated within a single transaction, making it unsuitable as a price oracle without additional safeguards like time-weighted average prices (TWAP).
Articles Using This Term
Learn more about Constant Product Formula in these articles:
Need expert guidance on Constant Product Formula?
Our team at Zealynx has deep expertise in blockchain security and DeFi protocols. Whether you need an audit or consultation, we're here to help.
Get a Quote

