Skip to content
Reading depth

Each view includes the earlier layers; the complete engineer or auditor page is shown by default.

An automated market maker is a trading mechanism that accepts or rejects exchanges according to a programmed rule over market state and liquidity.

Opposed arrows category cue

An automated market maker, or AMM, accepts or rejects proposed trades using a programmed rule over liquidity and market state.

An AMM provides on-chain quotes and settlement without waiting for a newly posted opposing order for every trade. The rule makes execution predictable from contract state, but it does not know a universal fair price. External trading and arbitrage connect its state to other markets.

An automated dealer is a useful analogy. A dealer chooses quotes from inventory, information, and risk limits; an AMM exposes a public state-transition rule. Some AMMs use external information or auctions, so even this distinction is not absolute. Constant product is one AMM, not the definition of all AMMs.

For reserves x units of token X and y units of token Y, the simplified zero-fee rule is:

x × y = k
spot price of X in Y = y / x

If a trader adds X and removes Y, x rises, y falls, and the marginal price moves along the curve. With a fee retained in the pool, the post-trade product can increase. Exact formulas, rounding, protocol fees, and range behavior depend on the implementation.

Traders exchange reserve assets. Liquidity providers own pooled shares or range-specific pooled claims. Arbitrageurs trade discrepancies with external markets. Pool, hook, router, and position-manager contracts execute the rules. Governance or administrators may control fee, hook, pause, or upgrade parameters.

Step-by-step mechanism, state changes, and flows

Section titled “Step-by-step mechanism, state changes, and flows”
  1. Read reserves, active liquidity, fees, and relevant parameters.
  2. Calculate or propose input and output amounts.
  3. Transfer or account for the input.
  4. Transfer the output.
  5. Enforce the invariant, fee, price-limit, and callback conditions.
  6. Record new reserves, price state, liquidity state, and fees.

Capital flow follows trader input/output and provider reserves. Claim flow follows LP positions. Return flow is trader fees and any separate incentives. Risk flow includes stale pricing, adverse selection, manipulation, thin or inactive liquidity, faulty math, callbacks, hooks, and privileged control.

Traders pay fees allocated under the pool rules. LP inventory gains or loses value as prices and reserve composition change. Arbitrage profit is funded by the executable difference between the AMM and another venue, net of costs; part of that transfer can be an adverse-selection cost to LPs.

Specify units, domains, fee placement, and rounding for every formula. Test zero and near-zero liquidity, maximum inputs, exact input/output, reserve limits, overflow, callback payment, reentrancy, token behavior, tick crossings, inactive ranges, hooks, donations, and price limits. A manipulable instantaneous pool price is not automatically safe as an oracle for another protocol.

Uniswap’s cross-version overview and v2 pair implementation provide a constant-product lineage. Curve’s StableSwap paper shows a different curve objective. These are concrete mechanisms, not evidence that one curve dominates every market or that every implementation is safe. The living Uniswap references were reviewed 2026-08-10; the versioned contract and paper remain implementation artifacts rather than current parameter claims.

  • “The AMM reports the fair price.” It reports a price implied by its current state and rule.
  • x × y = k defines every AMM.” Curves, ranges, weights, oracles, auctions, hooks, and fees vary.
  • “The invariant alone proves safety.” Authorization, accounting, token behavior, callbacks, control, and integration still matter.

Next separate price impact from total execution slippage.

Machine-readable model

Key equations

Canonical expressions come from the structured concept record. KaTeX renders the notation, while the plain-text expression and variable table keep its meaning and units inspectable without JavaScript. Read the narrative above for the model's domain, assumptions, and rounding rules.

  1. Equation 1

    Plain-text equation: x * y = k

  2. Equation 2

    Plain-text equation: spotPriceXInY = y / x

Interactive module

Test the mechanism

Change reserves, trade size, fees, and the external market price; inspect execution, pool state, and arbitrage direction.

Open Constant-product AMM lab on its full lab page

Assurance contract

Security properties

These structured statements define desired behavior. Their stable IDs can bind tests, invariants, specifications, audit findings, or proof results without turning descriptive review advice into an assurance claim.

Desired · not evaluated: No test, audit, or proof result is implied until scoped evidence is linked to this property.

  1. Every accepted trade satisfies the selected invariant and fee rule under explicit rounding

  2. No accepted trade can produce output without accountable input or make reserves negative

  3. Reserve, liquidity, and fee state remain reconciled after swaps, deposits, and withdrawals

  4. Spot-state manipulation is not treated as an external fair-price oracle without an explicit defense

Knowledge check

Quiz

Answer in your own words, then open the model answer.

What problem does Automated market maker exist to address?

Model answer

Automated market makers provide deterministic on-chain quotes and settlement without requiring every trade to match a newly posted opposing order.