Research/Education/AMMs Explained: The Simple Math Behind DEX Prices and Slippage
# Trading

AMMs Explained: The Simple Math Behind DEX Prices and Slippage

BloFin Academy04/13/2026

An Automated Market Maker (AMM) is a smart-contract system that prices trades from a liquidity pool using a mathematical rule, most commonly x * y = k, where the product of two token reserves stays constant before fees. Every swap changes the pool's token ratio, which mechanically shifts the quoted price and produces slippage proportional to trade size relative to pool depth. This section explains how constant-product pricing works, why execution price diverges from spot price, what causes bad fills, and how AMM variants like stable-swap curves and concentrated liquidity change the experience for traders.


How an AMM Prices a Trade

An AMM replaces the order book with a mathematical formula applied to pooled token reserves inside a smart contract, where the ratio of those reserves determines the current price, and every swap shifts that ratio to produce a new price automatically.

In a traditional order book, price emerges from matching discrete buy and sell limit orders placed by humans and bots. On an AMM, price emerges from a curve defined by pooled capital. Liquidity providers deposit paired tokens (e.g., ETH and USDC) into a contract. Traders swap against the pool rather than matching with a counterparty. The pool charges a fee on each swap (typically 0.05% to 1%), which accrues to liquidity providers.

Three properties define every constant-product AMM:

  • x = Token A reserves (e.g., 10,000 ETH)

  • y = Token B reserves (e.g., 20,000,000 USDC)

  • k = x * y, held constant before fees

The spot price at any moment equals y / x. A pool with 10,000 ETH and 20,000,000 USDC implies a spot price of 2,000 USDC per ETH. This differs from an order book because there is no bid-ask spread in the traditional sense, only the fee and the curve's response to trade size.

When you buy ETH with USDC, you add USDC and remove ETH. The new reserve ratio creates a new, higher ETH price. Larger trades consume more of the scarce token, walking further along the curve and paying progressively worse rates per unit. This is price impact, and it is the single most important cost in AMM trading beyond the base fee.


Worked Example: Why Large Trades Get Worse Rates

Start with a pool holding 10,000 ETH and 20,000,000 USDC. The constant k = 200,000,000,000. Spot price: 2,000 USDC/ETH.

Across our user base, traders who understand how AMM pricing works tend to choose execution venues more deliberately, routing large orders through order books for better depth and using AMMs only for pairs with sufficient on-chain liquidity.

Small swap (10 ETH in):

  • New ETH reserves: 10,010

  • New USDC reserves: k / 10,010 = 19,980,019

  • USDC received: 20,000,000 - 19,980,019 = 19,981

  • Average execution price: 1,998 USDC/ETH

  • Price impact: 0.1%

Large swap (1,000 ETH in):

  • New ETH reserves: 11,000

  • New USDC reserves: k / 11,000 = 18,181,818

  • USDC received: 20,000,000 - 18,181,818 = 1,818,182

  • Average execution price: 1,818 USDC/ETH

  • Price impact: 9.1%

The large trade pays 9% more per ETH than the small trade. This is not a fee. It is the mathematical consequence of walking along a hyperbolic curve. The same logic applies in reverse: buying a token that represents a large fraction of pool reserves will cost disproportionately more per unit.

I ran both of these calculations manually the first time I tried a five-figure swap on Uniswap and watched the preview show exactly this curve-walking behavior in real time. The numbers are unforgiving at scale.


Spot Price vs Execution Price: Where Slippage Originates

The price shown on a DEX interface is the spot price derived from the current reserve ratio before your trade. Your actual execution price is the average rate across every marginal unit of your swap as it walks the curve.

Spot price = y / x at the instant you view the pool. It represents the theoretical rate for an infinitely small trade.

Execution price = total output tokens / total input tokens for your actual trade size. Because each marginal unit shifts the ratio, you pay a range of prices averaged together.

Price impact = the mechanical difference between spot price and execution price caused solely by your trade size on the curve.

Realized crypto slippage = the total deviation between your expected output and actual output, including price impact plus any market movement during confirmation plus fees.

Slippage tolerance = a user-set parameter that reverts the transaction if execution deviates beyond your threshold. Setting 1% tolerance means the contract rejects the swap if you would receive more than 1% less than quoted.

The distinction matters because price impact is predictable from pool math before you submit, while market-movement slippage depends on what happens during the confirmation window. You control the first through trade sizing; you mitigate the second through tolerance settings and confirmation speed.


Four Causes of Bad Fills on AMMs

When a swap returns fewer tokens than expected, one of four factors is responsible.

1. Shallow Liquidity

Pool reserves determine how far your trade moves the curve. A 10,000 USDC swap in a pool with $10 million total value locked (TVL) represents 0.1% of reserves and barely moves the price. The same swap in a pool with $50,000 TVL represents 20% of reserves and creates catastrophic price impact.

Rule of thumb: keep your trade below 1% of pool reserves for minimal impact. Above 5%, expect double-digit percentage losses from impact alone (source: Uniswap Docs).

2. Fees (Single-Hop and Multi-Hop)

Every AMM pool charges a swap fee, typically 0.05% (stablecoin pairs), 0.3% (standard pairs), or 1% (exotic pairs). Multi-hop routes stack fees:

  • Direct ETH to USDC: one 0.3% fee

  • ETH to WBTC to USDC: two fees totaling roughly 0.6%

Aggregators like 1inch or CowSwap sometimes route through multiple pools to minimize total cost, even when individual legs carry fees, because accessing deeper market liquidity at each step reduces price impact enough to offset the extra fee.

3. Volatility During Confirmation

Blockchain transactions take 10 to 30 seconds for confirmation on Ethereum mainnet, longer on congested networks. During this window, other trades or market events can shift the pool's reserves, changing your execution from what the UI previewed.

You submit a swap when ETH is at 2,000 USDC. During the mempool wait, another large trade moves the pool. Your swap executes at the new, shifted reserves. If the shift exceeds your slippage tolerance, the transaction reverts and you pay only the network fee.

4. MEV Sandwich Attacks

In public mempools, bots monitor pending swaps. A sandwich attack works in three steps: the bot front-runs your trade (buying the same token, pushing price up), your trade executes at the worse price, and the bot back-runs (selling into your purchase for profit). You lose the difference.

Loose slippage tolerance is an invitation. Setting 5% tolerance on a visible mempool tells bots they can extract up to 5% from your trade. Private transaction routing (e.g., Flashbots Protect, MEV Blocker) hides your swap from the public mempool (source: Flashbots). For a comprehensive guide to shielding your trades, see MEV protection for traders.


AMM Variants: Stable-Swap and Concentrated Liquidity

Not all AMMs use the same curve. Different mathematical formulas serve different asset types.

Stable-Swap (Curve Finance)

Curve's StableSwap formula creates a hybrid curve that behaves like a constant-sum (flat) near the 1:1 peg and steepens toward constant-product at extremes. For pegged assets like USDC/USDT or stETH/ETH, this allows large swaps with negligible price impact while the pool is balanced.

A $100,000 USDC-to-USDT swap in a balanced Curve pool typically costs under 0.01% in slippage. The same swap in a constant-product pool would cost significantly more because the generic curve does not account for the assets being near-identical in value.

The tradeoff: during a depeg event, the curve steepens aggressively. A pool that becomes 95% USDC / 5% USDT suddenly behaves worse than constant-product for USDC sellers because the formula protects the scarce asset.

Concentrated Liquidity (Uniswap v3/v4)

Concentrated liquidity lets providers allocate capital within specific price ranges rather than across the entire zero-to-infinity curve. Within active ranges, effective depth can be 10x to 100x higher than equivalent TVL in a constant-product pool.

The benefit: dramatically better execution for trades within the concentrated range. An ETH/USDC pool with $50 million TVL concentrated between 1,800 and 2,200 USDC provides effective depth equivalent to a $500 million uniform pool at current prices.

The risk: at range boundaries, liquidity drops off sharply. If price moves outside where most LPs have positioned, the next marginal unit of your trade hits near-zero liquidity and price impact spikes instantly. This is why some tokens with apparently high TVL still produce terrible fills during volatile moves.

Uniswap v4 extends this model with programmable hooks that allow custom fee logic, time-weighted average pricing, and dynamic range adjustments (source: Uniswap).


How to Execute Safely on AMMs

Converting AMM knowledge into execution habits requires consistent pre-trade checks, not one-time understanding.

For traders who want price control on decentralized venues without accepting AMM slippage, DEX limit orders provide an alternative execution method.

Slippage tolerance defaults:

  • Major pairs (ETH, BTC): 0.5% to 1%

  • Stablecoin swaps: 0.1% to 0.3%

  • Low-liquidity or new tokens: 2% to 3% maximum

  • Never exceed 3% unless you deliberately accept MEV risk

Trade sizing relative to pool depth:

  • Below 1% of pool reserves: minimal impact, proceed normally

  • 1% to 5%: noticeable impact, compare aggregator routes

  • Above 5%: split into multiple transactions or use an aggregator that auto-splits

Route selection:

  • Check whether a direct single-pool route or a multi-hop aggregator path gives better net output after all fees

  • Aggregators (1inch, CowSwap, Paraswap) optimize across multiple venues simultaneously

  • For stablecoin swaps, Curve pools almost always beat generic constant-product pools

Confirmation risk:

  • Use adequate network fees for timely confirmation during volatile conditions

  • Consider private transaction submission to avoid sandwich attacks

  • Avoid swapping during extreme volatility unless urgency justifies the cost


Common Mistakes and Correct Mental Models

From an exchange operator's perspective, the traders who consistently get the best fills are the ones who check pool depth before submitting and use aggregators for anything above a few thousand dollars in size.

"Higher slippage tolerance prevents failed transactions without costing anything." Wrong. Loose tolerance (above 3%) tells MEV bots how much they can extract from you. Use the minimum tolerance that executes reliably.

"The displayed price is what I will receive." Wrong. The UI shows spot price, not your execution price. Preview the full price impact before confirming. For an explanation of how displayed prices diverge from fills on centralized venues, see hidden fees in trading.

"If a token is listed on a DEX, it is safe to trade normal amounts." Wrong. Anyone can create a liquidity pool with minimal capital. A pool with $10,000 TVL cannot support a $5,000 trade without catastrophic impact. Always check reserves before swapping.

"My swap failed because the DEX is broken." Almost always wrong. Transaction reverts mean your slippage tolerance protected you from a worse fill. Raise tolerance by 0.5% increments rather than jumping to 10%.

"CEX vs DEX and DEX prices should be identical." They diverge constantly. Arbitrageurs work to close gaps, but latency, fees, and liquidity differences mean persistent small deviations. Large deviations signal thin AMM liquidity or a depeg event.


Execution Checklist

Before confirming any AMM swap:

  1. 1. Verify pool TVL is at least 20x your trade size

  2. 2. Preview price impact in the UI (abort if above 3%)

  3. 3. Set slippage tolerance to displayed impact plus 0.5% to 1% buffer

  4. 4. Compare direct route versus aggregator output

  5. 5. Confirm you are on the correct network and have sufficient tokens for gas

  6. 6. Check the "minimum received" figure and confirm it is acceptable

  7. 7. If impact exceeds 3%, split the trade or route through an aggregator

  8. 8. During high volatility, consider private transaction submission

For position sizing principles that apply to both CEX and DEX trading, including how to cap risk per trade regardless of venue, the position sizing guide covers the full framework. If you are new to DEX versus CEX mechanics broadly, the perpetuals vs futures guide covers how derivative pricing compares across venue types.


What is an AMM and how does it price trades?

An AMM is a smart-contract protocol that holds paired token reserves in a liquidity pool and uses a mathematical formula to determine swap prices. The most common formula, x * y = k, means the product of both token quantities stays constant. When you swap, you add one token and remove the other, changing the ratio and producing a new price. No order book or counterparty matching is needed. The formula itself enforces pricing.

Why does a large swap get a worse rate than a small one?

Because the constant-product curve is hyperbolic. Each unit you remove from the pool makes the next unit more expensive to extract. A trade representing 0.1% of reserves barely moves the curve. A trade representing 10% of reserves walks far along it, paying progressively higher marginal prices. The average across all those marginal prices is your execution rate, which is always worse than spot for meaningful trade sizes.

How do I reduce slippage when trading on a DEX?

Three practical approaches work consistently. First, trade in pools with high TVL relative to your size so your swap represents a small fraction of reserves. Second, use aggregators that split your order across multiple pools to reduce per-pool impact. Third, set tight slippage tolerance (0.5% to 1% for major pairs) which both protects you from unexpected movement and makes sandwich attacks unprofitable against your transaction.

What is the difference between price impact and slippage?

Price impact is the predictable, mathematical cost of your trade size on the pool curve. You can calculate it before submitting. Slippage is the total deviation from your expected output including price impact, swap fees, and any market movement that occurs during the confirmation window. Price impact is deterministic from pool math. The market-movement component of slippage is stochastic and depends on conditions during execution.

Are all AMM pools equally safe to trade?

No. Safety depends on pool TVL, the legitimacy of the tokens, smart contract audit status, and liquidity concentration. A pool with $100 million in reserves from a battle-tested protocol like Uniswap v3 provides reliable execution. A pool with $5,000 in reserves for an unaudited token can produce 50%+ slippage on modest trades and may carry impermanent loss risks or rug-pull exposure for liquidity providers.

 



Researched and written by the Blofin Academy editorial team with AI-assisted drafting. Primary sources include Uniswap v3 whitepaper (Uniswap, https://app.uniswap.org/whitepaper-v3.pdf); Curve Finance StableSwap paper (Curve Finance, https://classic.curve.fi/files/stableswap-paper.pdf); Uniswap blog on AMM mechanics Uniswap; DeFi Llama protocol TVL rankings (DefiLlama, https://defillama.com/). All facts independently verified against cited documentation current as of April 2026.

 

This article is for informational purposes only and does not constitute financial advice. Cryptocurrency trading involves substantial risk of loss. Past performance does not guarantee future results. Always conduct your own research and consider your financial situation before trading. BloFin does not guarantee the accuracy of third-party data referenced herein.