Automated market maker
An automated market maker is a trading mechanism that accepts or rejects exchanges according to a programmed rule over market state and liquidity.
Category: TradingOpposed arrows category cue
System record
Start with the economic purpose, participants, resources, and entitlements before studying implementation detail.
Why it exists
Automated market makers provide deterministic on-chain quotes and settlement without requiring every trade to match a newly posted opposing order.
Traditional-finance analogy
Automated dealer or market-making rule is the closest comparison recorded for this concept.
Where the analogy stops
- An AMM exposes pooled inventory through a public state-transition rule instead of letting a dealer choose each quote using private inventory and risk limits.
- Different AMMs use different curves, ranges, oracles, auctions, hooks, and fee rules; constant product is one model rather than the definition of every AMM.
Main actors
- ActorTrader
- ActorLiquidity provider
- ActorPool and pricing contracts
- ActorArbitrageur
- ActorGovernance, hook, or fee administrator
Assets and claims
Assets — controlled or transformed resources
Assets are resources the mechanism moves, holds, values, or transforms.
- AssetInput and output assets
- AssetPool reserves
Claims — entitlements and corresponding dependencies
Claims are rights to value, repayment, redemption, control, or another party's performance; each depends on an obligation or system that must honor it.
- ClaimLiquidity position or pool-share claim
An automated market maker, or AMM, accepts or rejects proposed trades using a programmed rule over liquidity and market state.
Why it exists
Section titled “Why it exists”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.
Traditional-finance analogy
Section titled “Traditional-finance analogy”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.
Constant-product example
Section titled “Constant-product example”For reserves x units of token X and y units of token Y, the simplified
zero-fee rule is:
x × y = kspot price of X in Y = y / xIf 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.
| AMM family | Main pricing state | Important difference |
|---|---|---|
| Constant product | Reserve product | Full-range two-asset baseline |
| Stable-swap curve | Reserves plus amplification-like parameters | Lower impact near a target region |
| Weighted pool | Reserves and weights | Multi-asset and unequal-weight exposure |
| Concentrated liquidity | Price, ticks, and active range liquidity | Depth changes across price intervals |
| Oracle or auction assisted | Pool state plus external information or bids | Adds information and timing dependencies |
Actors, assets, and claims
Section titled “Actors, assets, and claims”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”- Read reserves, active liquidity, fees, and relevant parameters.
- Calculate or propose input and output amounts.
- Transfer or account for the input.
- Transfer the output.
- Enforce the invariant, fee, price-limit, and callback conditions.
- Record new reserves, price state, liquidity state, and fees.
| State transition | Reserve X | Reserve Y | LP claim and fee state |
|---|---|---|---|
| Add liquidity | Rises by accepted X | Rises by accepted Y | Share or range-specific claim is created |
| Swap X for Y | Rises by settled X input | Falls by settled Y output | Retained fee follows the pool’s accounting |
| Remove liquidity | Falls by the provider’s X amount | Falls by the provider’s Y amount | Burned or collected claim is reduced |
| Failed trade | Reverts to its pre-trade state | Reverts to its pre-trade state | No successful trade or fee claim is recognized |
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.
Return source and loss allocation
Section titled “Return source and loss allocation”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.
Engineer or auditor lens
Section titled “Engineer or auditor lens”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.
Common misunderstandings
Section titled “Common misunderstandings”- “The AMM reports the fair price.” It reports a price implied by its current state and rule.
- “
x × y = kdefines 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.
Equation 1 Plain-text equation:
x * y = kVariables and units for equation 1 Symbol Meaning Unit xRecorded token X reserve amount token X reserve units yRecorded token Y reserve amount token Y reserve units kConstant-product reserve invariant token X units multiplied by token Y units Equation 2 Plain-text equation:
spotPriceXInY = y / xVariables and units for equation 2 Symbol Meaning Unit spotPriceXInYSpot price of token X quoted in token Y token Y units per token X unit yRecorded token Y reserve amount token Y reserve units xRecorded token X reserve amount token X reserve units
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 pageReserve geometry
Constant-product price curve
- Before trade
- After trade
The pool moves from 10,000.000000 X and 20,000.000000 Y to 11,500.000000 X and 17,398.112305 Y along the constant-product reserve curve.
Inspect all curve data points
| Point | X reserve | Y reserve |
|---|---|---|
| 1 | 4,500.000000 X | 44,444.444444 Y |
| 2 | 4,833.125000 X | 41,381.094013 Y |
| 3 | 5,166.250000 X | 38,712.799419 Y |
| 4 | 5,499.375000 X | 36,367.769065 Y |
| 5 | 5,832.500000 X | 34,290.612945 Y |
| 6 | 6,165.625000 X | 32,437.911809 Y |
| 7 | 6,498.750000 X | 30,775.149067 Y |
| 8 | 6,831.875000 X | 29,274.540298 Y |
| 9 | 7,165.000000 X | 27,913.468248 Y |
| 10 | 7,498.125000 X | 26,673.335000 Y |
| 11 | 7,831.250000 X | 25,538.707103 Y |
| 12 | 8,164.375000 X | 24,496.669984 Y |
| 13 | 8,497.500000 X | 23,536.334216 Y |
| 14 | 8,830.625000 X | 22,648.453535 Y |
| 15 | 9,163.750000 X | 21,825.126177 Y |
| 16 | 9,496.875000 X | 21,059.559065 Y |
| 17 | 9,830.000000 X | 20,345.879959 Y |
| 18 | 10,163.125000 X | 19,678.986532 Y |
| 19 | 10,496.250000 X | 19,054.424199 Y |
| 20 | 10,829.375000 X | 18,468.286489 Y |
| 21 | 11,162.500000 X | 17,917.133259 Y |
| 22 | 11,495.625000 X | 17,397.923123 Y |
| 23 | 11,828.750000 X | 16,907.957307 Y |
| 24 | 12,161.875000 X | 16,444.832725 Y |
| 25 | 12,495.000000 X | 16,006.402561 Y |
| 26 | 12,828.125000 X | 15,590.742996 Y |
| 27 | 13,161.250000 X | 15,196.124988 Y |
| 28 | 13,494.375000 X | 14,820.990227 Y |
| 29 | 13,827.500000 X | 14,463.930573 Y |
| 30 | 14,160.625000 X | 14,123.670389 Y |
| 31 | 14,493.750000 X | 13,799.051315 Y |
| 32 | 14,826.875000 X | 13,489.019095 Y |
| 33 | 15,160.000000 X | 13,192.612137 Y |
| 34 | 15,493.125000 X | 12,908.951551 Y |
| 35 | 15,826.250000 X | 12,637.232446 Y |
| 36 | 16,159.375000 X | 12,376.716302 Y |
| 37 | 16,492.500000 X | 12,126.724269 Y |
| 38 | 16,825.625000 X | 11,886.631254 Y |
| 39 | 17,158.750000 X | 11,655.860712 Y |
| 40 | 17,491.875000 X | 11,433.880016 Y |
| 41 | 17,825.000000 X | 11,220.196353 Y |
Scenario explanation
What is happening
You send 1,500.000000 X to the pool and receive 2,601.887695 Y. That adds X and removes Y, moving the pool price from 2.000000 to 1.512879 Y per X. The average execution price is 1.734592 Y per X, with 13.2704% price impact. The 4.500000 X fee remains in pool inventory for LP claim holders.
- Capital flow
- Claim flow
- Return flow
- Risk flow
Deterministic output
Results
| Metric | Value | Unit | Meaning |
|---|---|---|---|
| Spot price before | 2.000000 | Y per X | Y reserve ÷ X reserve |
| Quoted output | 2,601.887695 | Y | Amount sent from the pool |
| Average execution price | 1.734592 | Y per X | Gross-input execution price |
| Price impact | 13.2704% | percent | Deterioration from spot |
| Fee paid | 4.500000 | X | Retained in the pool |
| X reserve after | 11,500.000000 | X | Post-trade pool inventory |
| Y reserve after | 17,398.112305 | Y | Post-trade pool inventory |
| Invariant before | 200,000,000.000000 | X·Y | x × y before |
| Invariant after | 200,078,291.505372 | X·Y | Includes retained fee |
| Pool price after | 1.512879 | Y per X | Post-trade Y ÷ X |
| Arbitrage direction | Sell Y, receive X | trade direction | Moves pool toward market |
| LP inventory change | +1,500.000000 X; -2,601.887695 Y | token amounts | Capital flow, not LP profit |
Balance-sheet view
Pool state transition
| Pool account | Before trade | Trader flow | Fee attribution | After trade |
|---|---|---|---|---|
| Token X asset | 10,000.000000 X | +1,500.000000 X | 4.500000 X retained | 11,500.000000 X |
| Token Y asset | 20,000.000000 Y | -2,601.887695 Y | — | 17,398.112305 Y |
| LP share claims | Pro-rata claim on pool assets | No shares minted or burned | Fee accrues inside pool assets | Supply unchanged; asset mix changed |
| Invariant (x × y) | 200,000,000.000000 X·Y | Pricing curve applied | Retained input fee can increase k | 200,078,291.505372 X·Y |
| Pool price | 2.000000 Y per X | Moves against the trade | Fee included in execution | 1.512879 Y per X |
Guided comparison
Guided scenarios
Load a scenario, then compare its execution price, reserve movement, and invariant.
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.
Every accepted trade satisfies the selected invariant and fee rule under explicit rounding
No accepted trade can produce output without accountable input or make reserves negative
Reserve, liquidity, and fee state remain reconciled after swaps, deposits, and withdrawals
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.