export const prerender = true; Constant Product AMM — What It Is and How It Works

TL;DR

A constant product AMM is a decentralized exchange design where trades are priced by a simple rule: the product of two token reserves must stay constant (x * y = k). Instead of matching buyers with sellers, traders swap directly against a pool of tokens held in a smart contract. Uniswap v2-style pools are the most widely used implementation of this model.

How It Works

Think of a constant product AMM as a balancing scale with two buckets: one holding your token, the other holding a base asset like ETH or USDC. The rule is simple: the amount in bucket A multiplied by the amount in bucket B must always equal the same number (k). When someone takes tokens from one bucket, they have to add enough to the other bucket to keep that product constant.

Mechanically, the pool holds reserves of two tokens (x and y) in a smart contract. When a trader swaps token X for token Y, they deposit X into the pool (increasing x) and withdraw Y (decreasing y). The smart contract calculates exactly how much Y to give out so that x * y still equals k after the trade, minus a small fee (typically 0.3%).

This formula creates a hyperbolic pricing curve. For tiny trades, the price is approximately y/x (the ratio of the two reserves). But larger trades push further along this curve, meaning each additional unit costs more than the last. This is why big trades get worse rates than small ones.

One important nuance: the AMM doesn’t know or care what the “real” market price is. It only adjusts when someone trades. If ETH jumps 10% on Binance but nobody trades on the AMM, its price stays unchanged. Arbitrage traders, who buy cheap on the AMM and sell on the exchange where it’s higher, are what keep prices aligned across venues.

Try It Yourself

See constant product math in action: enter your token supply and budget in the calculator, and watch how the x * y = k formula determines your initial price, market cap, and price impact for different trade sizes. Try the Token Launch Simulator →

  • Liquidity Pool: The smart contract that holds the two token reserves the AMM trades against
  • Slippage: The difference between expected and actual trade price, partly caused by how far you move along the AMM curve
  • Impermanent Loss: The cost liquidity providers pay when the AMM rebalances their position as prices change
  • Spot Price: The current instantaneous price derived from the reserve ratio (y/x)
  • Constant Product Formula: The specific mathematical equation (x * y = k) that defines this AMM type

Frequently Asked Questions

What is a constant product AMM?

A constant product AMM is a type of decentralized exchange that prices trades using the formula x * y = k, where x and y are the reserves of two tokens in a pool. When someone buys one token, they add the other token to the pool, and the formula determines how many tokens they receive. This eliminates the need for traditional order books or counterparties.

How does a constant product AMM determine price?

The spot price in a constant product AMM is the ratio of the two reserves (y/x for the price of token X in terms of token Y). As trades change the reserve ratio, the price updates automatically. Larger trades move further along the pricing curve and receive progressively worse rates, which is what creates price impact.

Does a constant product AMM track the market price automatically?

No. A constant product AMM only updates its price when someone trades against it. If the external market price changes but nobody trades on the AMM, its price stays stale. Arbitrageurs are what keep AMM prices aligned with other exchanges: they profit by trading whenever the AMM price diverges from the broader market.

Are all AMMs constant product?

No. Constant product (x * y = k) is one of several AMM designs. Others include constant sum AMMs, Curve’s stableswap invariant (optimized for pegged assets), and concentrated liquidity designs like Uniswap v3. Each uses a different mathematical formula that creates different price curves and tradeoffs.

Read the Full Article

Enter your email for free access to this article and all simulation tools.

No spam. Unsubscribe anytime.

← Back to Learn

Get Token Launch Insights

Free AMM simulation tips, launch strategies, and tool updates. No spam.

Unsubscribe anytime.