🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
💼 Servicesℹ️ About✉️ ContactView Pricing Plansfrom $10

AMM Mechanisms

Blockchain Financial Systems🟢 Free Lesson

AMM Mechanisms

Automated Market Makers (AMMs) are decentralized exchange protocols that use algorithmic pricing functions instead of traditional order books. They enable permissionless token swaps by maintaining liquidity pools governed by mathematical curves.

Constant Product Formula (x × y = k)

The foundational AMM model, pioneered by Uniswap, uses the constant product invariant:

Where:

  • = Reserve of token X in the pool
  • = Reserve of token Y in the pool
  • = Constant that remains fixed during trades

Price Determination

The marginal price is derived from the invariant:

Trade Execution

When a trader swaps of token X for of token Y:

Price Impact

The price impact of a trade of size :

Constant Product Curve (x × y = k)Token X ReserveToken Y ReserveTrade Point ATrade Point BSelling X → YPrice decreases

Concentrated Liquidity (Uniswap v3)

Uniswap v3 introduced concentrated liquidity, allowing LPs to allocate capital within specific price ranges.

Capital Efficiency Formula

The effective liquidity at a given price range :

Price Range Selection

LPs choose a price range where :

  • Within range: Full capital utilization
  • Outside range: Position composed entirely of one asset
  • At price : Position value is

Fee Tiers

Fee TierUse CaseTick Spacing
0.01%Stable pairs (USDC/USDT)1
0.05%Correlated pairs (ETH/stETH)10
0.30%Standard pairs (ETH/USDC)60
1.00%Exotic/volatile pairs200

Concentrated Liquidity Visual

Concentrated Liquidity RangesPriceLiquidityLP Position 1LP Position 2LP Position 3

Stable Swap (Curve Finance)

Curve Finance uses a hybrid invariant optimized for pegged assets:

Where:

  • = Amplification coefficient (controls curve flatness)
  • = Number of tokens in the pool
  • = Total pool value (sum of all at equilibrium)

Amplification Coefficient Impact

A ValueCurve BehaviorBest For
Low (1-50)More volatile, like constant productVolatile pairs
Medium (100-500)Balanced curveModerately correlated
High (1000+)Very flat, like constant sumStablecoins

Stable Swap Curve Shape

Stable Swap Curve vs Constant ProductToken X ReserveConstant ProductCurve Stable SwapConstant Sum

Weighted Pools (Balancer)

Balancer generalizes the constant product formula to weighted multi-token pools:

Where:

  • = Reserve of token
  • = Weight of token (must sum to 1)
  • = Number of tokens (typically 2-8)

Price Formula in Weighted Pools

The price of token in terms of token :

Swap Calculation

Pool TypeWeightsUse Case
50/50EqualStandard trading pairs
80/20ImbalancedETH/stablecoin
WeightedCustomIndex funds
StablePeggedStablecoin pairs

Flash Swaps

Flash swaps allow users to receive tokens before paying for them, enabling arbitrage within a single transaction:

  1. Receive token Y from pool
  2. Execute arbitrary operations (arbitrage, liquidation, etc.)
  3. Return token X to pool (or revert)

Flash Swap Fee

Where is typically 0.25% on Uniswap v2.

Impermanent Loss Mathematics

Impermanent loss occurs when the price ratio of pooled tokens changes from the entry point.

Impermanent Loss Formula

For a 50/50 pool, impermanent loss as a function of price ratio change :

Where (price ratio change).

Impermanent Loss Table

Price Change ()Impermanent Loss
1.25x (25% increase)-0.6%
1.50x (50% increase)-2.0%
2.00x (100% increase)-5.7%
3.00x (200% increase)-13.4%
5.00x (400% increase)-25.5%
0.50x (50% decrease)-5.7%

Generalized Impermanent Loss

For weighted pools with weight for the base asset:

Break-Even Fee Formula

To offset impermanent loss, the required fee APR:

Where is the time period in years.

Real-World Example: Uniswap v3 LP Position

An LP provides $100,000 in ETH/USDC with:

  • Entry price: ETH = $2,000
  • Range: 2,400
  • Fee tier: 0.30%

Scenario 1: ETH stays in range

  • Earns ~25% APR from fees
  • Impermanent loss: minimal
  • Net profit: ~25% minus gas costs

Scenario 2: ETH rises to $3,000

  • Position converts entirely to USDC
  • Impermanent loss: ~15%
  • Net result: Underperforms simple HODL

LP Position Calculations

Position Value at Different Prices:

Where:

  • = Liquidity depth
  • = Current price
  • = Lower bound price

Fee Earnings Formula

Gas Cost Considerations

ActionGas UnitsCost at 30 gwei
Add Liquidity200,000~0.006 ETH
Remove Liquidity150,000~0.0045 ETH
Collect Fees100,000~0.003 ETH
Swap150,000~0.0045 ETH

Break-Even Analysis:

AMM Risk Assessment

Risk Matrix

RiskConstant ProductConcentratedStable Swap
Impermanent LossMediumHighVery Low
Smart ContractLowMediumLow
Oracle DependencyLowLowLow
Gas CostsMediumHighLow
ComplexityLowHighMedium

Monitoring Metrics

Track these metrics for LP positions:

  1. Capital Utilization: How much of your liquidity is earning fees
  2. Fee APR vs IL: Compare fee income to impermanent loss
  3. Range Utilization: Percentage of time price stays in range
  4. Gas Efficiency: Fees earned minus gas costs

Trade-Offs

AMM TypeProsCons
Constant ProductSimple, battle-testedHigh slippage, capital inefficient
Concentrated LiquidityCapital efficientActive management required
Stable SwapLow slippage for pegged assetsLimited to correlated assets
Weighted PoolsFlexible multi-assetMore complex math
Flash SwapsAtomic arbitrageComplex, requires capital

Key Trade-Offs

  • Passive vs Active: Simple AMMs are passive but less efficient; concentrated liquidity requires active management
  • Capital Efficiency vs Complexity: More capital-efficient designs are harder to understand and manage
  • Decentralization vs Speed: On-chain AMMs are slower than order books but more censorship-resistant
  • Fee Income vs Impermanent Loss: Higher fee tiers may attract less volume, reducing total income

AMM Design Evolution

Generation Comparison

GenerationModelYearInnovation
1stConstant Product (x×y=k)2020Basic AMM
2ndConcentrated Liquidity2021Capital efficiency
3rdStable Swap2020-2021Pegged asset optimization
4thHybrid2022+Order book + AMM
5thIntent-based2023+User intent matching

AMM Mathematics Summary

AMM Mathematical Models ComparisonConstant Productx × y = kPrice = y/xUniswap v2ConcentratedL = √(xy)/(√pb - √pa)Range-bound capitalUniswap v3Stable SwapAn^nΣx + D = ...Flat curve near 1:1Curve FinanceImpermanent Loss VisualizationPrice Change: 1.25x → 0.6% IL | 2x → 5.7% IL | 5x → 25.5% ILFee income must exceed IL for profitable LP positionBreak-even: ~10% APR fees for 2x price change over 1 year

AMM Selection Guide

Use CaseRecommended AMMReason
StablecoinsCurveMinimal slippage
Major pairsUniswap v3Capital efficiency
Long-tail assetsUniswap v2Simple, passive
Multi-assetBalancerWeighted pools
Leveraged tradingGMXDeep liquidity

AMM Fee Comparison

ProtocolFee RangeFee Distribution
Uniswap v20.30%100% to LPs
Uniswap v30.01-1%100% to LPs
Curve0.04%50% veCRV holders
SushiSwap0.30%81.5% LPs, 9% SUSHI stakers
Balancer0.001-10%87.5% LPs, 12.5% protocol

Advanced AMM Concepts

K-factor (Constant Sum):

This provides zero slippage but is unsustainable for volatile assets.

Geometric Mean:

Used in Balancer for equal-weight pools.

AMM Performance Metrics

Key Performance Indicators

MetricFormulaTarget
Capital UtilizationVolume / TVL> 1.0
Fee APRFees / TVL × 365> IL
SlippageΔP / P< 0.5%
Impermanent Loss(V_hold - V_lp) / V_holdMinimize
MEV ExtractedFront-run profitMinimize

AMM Efficiency Formula

Higher efficiency indicates better capital utilization relative to costs.

Pool Health Indicators

AMM Pool Health DashboardHealthy PoolVolume/TVL > 1.0Fee APR > ILLow slippageStressed PoolVolume/TVL < 0.5Fee APR ≈ ILMedium slippageUnhealthy PoolVolume/TVL < 0.1Fee APR << ILHigh slippageMonitoring Recommendations• Check pool health daily for active positions• Rebalance concentrated liquidity positions weekly• Monitor gas costs relative to fee earnings

Interview Questions

  1. Explain the constant product formula and how it determines token prices. What are the implications of this formula for large trades?

  2. How does concentrated liquidity in Uniswap v3 improve capital efficiency, and what additional risks does it introduce for liquidity providers?

  3. Calculate the impermanent loss for a 50/50 pool when the price ratio doubles. How would you structure fees to offset this loss?

Quiz Questions

  1. In the constant product formula x × y = k, what happens to the price of token X when a large amount of X is sold into the pool?

    • A) Price increases
    • B) Price decreases
    • C) Price stays the same
    • D) Price becomes undefined
  2. What is the primary benefit of concentrated liquidity over constant product AMMs?

    • A) Lower gas costs
    • B) Better capital efficiency within price ranges
    • C) No impermanent loss
    • D) Higher total value locked
  3. In Curve's stable swap invariant, what does the amplification coefficient A control?

    • A) Trading fees
    • B) The flatness of the curve near equilibrium
    • C) Number of tokens in the pool
    • D) Slippage tolerance
CW

ChatWhole Learn Editorial Team

Written by experienced data scientists, software engineers, and educators. All content is reviewed by industry professionals to ensure accuracy and relevance.

Last reviewed: 2026-09-22

—
☆☆☆☆☆
0 ratings

Rate & Feedback

Need Expert Blockchain Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement