AMMs and DEXs Explained: How Uniswap, Curve, Slippage, Fees, MEV, and Impermanent Loss Work

AMMs and DEXs changed how crypto markets trade by replacing traditional order books with smart contract liquidity pools. Instead of waiting for buyers and sellers to match, users swap against pooled assets priced by algorithms. Uniswap popularized constant-product AMMs and later concentrated liquidity, while Curve optimized stable and pegged swaps with low-slippage stable-swap curves. These systems are powerful, but traders and liquidity providers must understand slippage, fees, routing, MEV, sandwich attacks, approvals, and impermanent loss before interacting with them.

TL;DR

  • AMMs price assets with math and pool reserves instead of traditional order books.
  • Uniswap-style constant-product pools use the reserve rule x multiplied by y equals k to keep markets liquid across a wide price range.
  • Large trades create slippage because they change the pool’s reserve ratio during execution.
  • Uniswap v3-style concentrated liquidity lets LPs choose price ranges, improving capital efficiency but requiring more management.
  • Curve-style stable-swap pools are designed for assets that should trade close to 1:1, such as stablecoins or liquid staking pairs.
  • MEV and sandwich attacks can worsen trade execution, especially when slippage tolerance is too loose or liquidity is thin.
  • LPs earn fees, but impermanent loss can make providing liquidity worse than simply holding the tokens.
```
Core idea AMMs are automated liquidity markets

A decentralized exchange does not need a centralized order book to execute swaps. An AMM uses pooled inventory and a pricing rule. Traders pay fees to swap against the pool. Liquidity providers earn those fees, but they also accept price risk, inventory changes, and impermanent loss.

What AMMs and DEXs are

A decentralized exchange, or DEX, lets users trade crypto assets through smart contracts. The user connects a wallet, selects a pair, approves the asset if needed, and submits a swap transaction. The trade settles on-chain without a centralized exchange account.

An Automated Market Maker, or AMM, is the pricing engine behind many DEXs. Instead of matching buyers and sellers directly, the AMM uses liquidity pools. A liquidity pool is a smart contract that holds token reserves. Traders swap against those reserves, and the pool updates prices based on its formula.

This model made DeFi trading accessible. Anyone can create a market by deploying a pool and depositing liquidity. Wallets and aggregators can route trades through pools. Developers can build strategies, dashboards, bots, and analytics around open on-chain liquidity.

The tradeoff is that AMMs expose users to risks that are not obvious from a simple swap button. The execution price can move during a trade. Bots can extract value from visible transactions. Tokens can have dangerous permissions. LPs can underperform holding because of impermanent loss.

Constant-product AMMs: how Uniswap-style pools work

The simplest Uniswap-style AMM uses a constant-product rule. The pool holds two assets. One reserve is called x, the other is called y, and their product is k. When a trader adds one token to the pool and removes the other, the formula adjusts the output so the reserve product remains balanced.

Formula x multiplied by y equals k

The spot price is roughly the ratio between the reserves. If the pool has more USDC relative to ETH, ETH becomes more expensive inside the pool. If the pool has more ETH relative to USDC, ETH becomes cheaper inside the pool.

Traditional exchanges use bids and asks. AMMs use inventory. If a trader buys ETH from a USDC/ETH pool, ETH leaves the pool and USDC enters it. Because the pool now has less ETH and more USDC, the implied ETH price rises.

This is why trade size matters. A small trade barely changes the reserve ratio. A large trade changes the reserve ratio sharply and produces worse execution. That execution difference is called slippage or price impact.

Worked example: USDC into ETH

Imagine a USDC/ETH pool with 100 ETH and 200,000 USDC. The implied price is about 2,000 USDC per ETH. A trader swaps 20,000 USDC into a pool with a 0.3 percent fee.

Because of the fee, only 19,940 USDC effectively enters the reserves. The USDC side becomes 219,940. The pool must keep the reserve product aligned, so the ETH reserve falls to about 90.934 ETH. The trader receives about 9.066 ETH.

The average fill is around 2,206 USDC per ETH, worse than the starting price of 2,000. That difference exists because the trade moved the pool along the curve. The larger the trade relative to pool depth, the worse the price impact becomes.

Constant-product AMM flow A trader adds one asset and removes another. The reserve ratio changes, so price changes. Trader Sends USDC AMM pool USDC reserve increases ETH reserve decreases ETH price rises inside pool Trader receives ETH after price impact Rule: Bigger trades move the reserve ratio more, which increases slippage.

Concentrated liquidity: Uniswap v3-style ranges

Older constant-product pools spread liquidity across every possible price from near zero to extremely high values. This makes liquidity always available, but it is capital-inefficient because most of that price range may never be used.

Concentrated liquidity lets LPs choose a price band where their capital is active. For example, an ETH/USDC LP may choose to provide liquidity only between 1,800 and 2,200 USDC per ETH. While the market trades inside that band, the position earns fees and provides deeper liquidity.

If the price leaves the selected band, the position becomes inactive and stops earning fees. Depending on which side the price exits, the LP may end up holding mostly one asset. This turns passive LPing into a lighter form of active market making.

Narrow ranges can generate higher fee efficiency, but they go out of range faster. Wide ranges earn more consistently but usually generate lower returns per dollar. The right range depends on volatility, gas cost, fee tier, trading volume, and how actively the LP can manage the position.

LP warning Concentrated liquidity is not passive if the range is tight

A tight range can look attractive because the fee APR appears high while in range. But if price trends away, the position can stop earning fees and become heavily exposed to one asset.

Curve stable-swap: why stable pairs trade differently

Curve specializes in assets that should trade near the same value. Common examples include USDC, DAI, USDT, ETH, stETH, and other closely pegged or correlated assets.

A normal constant-product curve works for many assets, but it can still create unnecessary slippage around a 1:1 peg. Stable-swap curves are designed to be flatter near parity. This allows larger trades with lower slippage when assets remain close to their expected relationship.

Curve-style pools blend constant-sum behavior near the peg with constant-product protection when the pool becomes imbalanced. The result is efficient trading around parity and stronger protection when one asset moves too far away.

The key tuning variable is often called the amplification parameter. A higher amplification setting makes the curve flatter near the peg, reducing slippage for stable or correlated assets. But stable-swap is not suitable for highly volatile assets that are not expected to remain close in price.

Stable-swap pools are powerful, but they are not risk-free. If a stablecoin depegs, a bridge asset fails, or a liquid staking token trades at a discount, LPs can be left holding more of the weaker asset as traders exit into the stronger one.

AMM design Best fit Main advantage Main risk
Constant-product General volatile pairs Always-on liquidity across a wide price range Slippage and impermanent loss during large moves
Concentrated liquidity Active LPs choosing price ranges Higher capital efficiency inside selected ranges Out-of-range exposure and active management burden
Stable-swap Stablecoins and correlated assets Very low slippage near the peg Depeg or imbalance can leave LPs with weaker assets
Aggregated routing Large or complex trades Can split orders across pools for better execution Approval, route, MEV, and smart contract risk

Trading UX: slippage, fees and routing

A good swap is not only about choosing the token pair. Execution quality depends on slippage tolerance, liquidity depth, fees, route selection, gas conditions, and whether the transaction is exposed to public mempool searchers.

Slippage tolerance is the maximum price movement a user accepts between quote and execution. If slippage tolerance is too tight, the transaction may revert when the market moves slightly. If it is too loose, the user may receive a much worse price, especially in thin pools or during volatile conditions.

Fees also matter. Uniswap v3-style pools can have different fee tiers for the same pair. Stable pairs usually work better in lower fee tiers because volatility is lower and volume is high. Volatile pairs often need higher fees to compensate LPs for risk.

Routing matters because the best route is not always the direct route. A smart router may split a trade across multiple pools or use a multi-hop path such as TOKEN to WETH to USDC. What matters is the final effective price after fees, slippage, gas, and execution risk.

Token approvals are another part of the trading experience. ERC-20 tokens usually require approval before the first swap. Users should avoid approving suspicious contracts, review unlimited approvals, and revoke unused approvals when they are no longer needed.

Better swap execution checklist

  • Check pool depth before making a large swap.
  • Use realistic but tight slippage settings.
  • Avoid huge single swaps in thin pools.
  • Use reputable routers or aggregators where appropriate.
  • Compare direct and multi-hop routes based on final received amount.
  • Watch gas conditions before submitting time-sensitive swaps.
  • Review token approvals and revoke unused permissions.
  • Avoid swapping through suspicious links or fake DEX front ends.

MEV and sandwich attacks

MEV, or maximal extractable value, is profit that can be captured by ordering, inserting, or routing transactions in a block. In DEX trading, one of the most common MEV patterns is the sandwich attack.

A sandwich happens when a bot sees a pending swap, buys before it to move the price, lets the user’s trade execute at a worse price, and then sells after it. The user receives worse execution, while the bot captures the difference.

Sandwich risk is higher when a trade is large relative to pool depth, slippage tolerance is loose, the pool is thin, or the transaction is broadcast publicly during volatile conditions.

Tight slippage settings do not remove MEV completely, but they limit how much value can be extracted. Private or protected routing can also reduce exposure where available. Large trades should often be split, routed through deeper liquidity, or executed with more care.

Execution risk Loose slippage can become an invitation to MEV

Slippage tolerance is not just a convenience setting. It tells the market how much price movement you are willing to accept. If it is too loose, bots may have more room to extract value from your swap.

Impermanent loss for LPs

Providing liquidity is not the same as holding tokens in a wallet. As prices move, the AMM automatically changes the LP’s asset mix. Compared with simply holding the original assets, the LP position can be worth less. That difference is called impermanent loss.

In a 50/50 constant-product pool, if one asset doubles in price, the LP ends up with less of the asset that went up and more of the other asset. The position may still be profitable in dollar terms, but it can underperform a simple hold strategy.

A common simplified estimate says a 2x price move creates about 5.7 percent impermanent loss versus holding, before fees. If the LP’s share of fees exceeds that loss after gas and other costs, LPing can still be profitable. If fees do not cover the gap, holding was better.

Curve-style stable pools usually have lower impermanent loss near the peg, which is one reason they are popular for stablecoins and closely correlated assets. But lower IL does not mean zero risk. Depegs, smart contract failures, bridge issues, and liquidity shocks can still create losses.

In concentrated liquidity pools, tighter ranges can increase fee income while active, but they also increase out-of-range risk. If price trends away, the LP may stop earning fees and become heavily exposed to one side.

Liquidity provider checklist

Before providing liquidity

  • Choose pairs whose behavior you understand.
  • Separate stable, correlated, and volatile pairs in your risk model.
  • Pick fee tiers that match volatility and expected volume.
  • Simulate price moves of 20 percent, 50 percent, or more before depositing.
  • Estimate whether fees can realistically offset impermanent loss.
  • Account for gas costs when rebalancing, claiming, or withdrawing.
  • For concentrated liquidity, define your price range and rebalancing rule before entering.
  • Avoid pools involving tokens with dangerous permissions, thin liquidity, or unclear ownership.

Wallet security and approvals

DEX trading requires signatures. Some transactions approve tokens, some execute swaps, and some interact with routers or liquidity positions. Users should always confirm the chain, contract, token, amount, and approval scope before signing.

For larger positions, a hardware wallet such as Ledger can help reduce private key exposure. This does not replace transaction review, but it adds a stronger custody layer than keeping everything in a hot wallet.

Users should also review old approvals after trading or providing liquidity. Leaving unlimited approvals open forever increases risk if a router, fake front end, or approval target is later abused.

Using on-chain analytics before trading or LPing

AMM and DEX risk is easier to understand with data. Before trading a token or providing liquidity, users should review pool depth, holder concentration, token transfers, smart money activity, liquidity movements, deployer behavior, and historical volume quality.

On-chain analytics platforms such as Nansen can help users research wallets, token flows, and DeFi activity before interacting with unfamiliar markets. This does not guarantee safety, but it can reduce blind decision-making.

Developers, analysts, and advanced users who need direct chain data for DEX analytics, pool monitoring, or custom dashboards can use infrastructure providers such as Chainstack for RPC and data access workflows.

Quick check

Use these questions to confirm the main concepts before trading or providing liquidity.

What does the constant-product rule represent?

It represents the relationship between the two token reserves in a basic AMM pool. Trades move the reserves along the curve, which changes price and creates slippage.

How does concentrated liquidity improve capital efficiency?

It lets LPs focus liquidity inside selected price bands instead of spreading capital across all possible prices. The tradeoff is active management and out-of-range risk.

Why is Curve useful for stable pairs?

Curve-style stable-swap curves are flatter near 1:1 parity, which allows low-slippage swaps between stable or closely correlated assets.

How can traders improve execution on volatile days?

Use tighter slippage settings, avoid large swaps in thin pools, route through deeper liquidity, split large orders when needed, and use protected routing where available.

How do fees and impermanent loss interact?

Fees add value to an LP position, while impermanent loss subtracts value compared with holding. LPing works only when fees exceed IL, gas costs, and other risks.

Final recommendation

AMMs and DEXs are core DeFi infrastructure. They make permissionless trading possible, but they also introduce execution risk, MEV exposure, approval risk, and liquidity provider risk. A swap button hides a lot of mechanics.

Uniswap-style constant-product pools are simple and flexible, but large trades create slippage. Concentrated liquidity improves capital efficiency but requires more management. Curve-style stable-swap pools are excellent for pegged assets, but depeg events can still punish LPs.

For traders, the safer path is to check liquidity depth, slippage, route quality, token risk, and approvals before signing. For LPs, the safer path is to estimate impermanent loss, choose realistic fee tiers, understand range behavior, and avoid unknown tokens with weak liquidity or dangerous permissions.

The final rule is simple: AMMs are powerful because they automate markets, but they do not remove market risk. The more you understand the pool mechanics before interacting, the less likely you are to become exit liquidity for better-informed traders or bots.

Research before you swap, approve, or provide liquidity

Before using a DEX, check token permissions, approval exposure, pool depth, slippage settings, MEV risk, liquidity quality, and whether the token can be safely traded or provided as liquidity.

FAQs

What is an AMM?

An AMM is an Automated Market Maker. It is a smart contract system that prices swaps using liquidity pool reserves and a mathematical curve.

What is a DEX?

A DEX is a decentralized exchange that lets users trade crypto assets through smart contracts instead of a centralized exchange account.

How does Uniswap price swaps?

Basic Uniswap-style pools price swaps through a constant-product reserve rule. When one reserve increases and the other decreases, the price changes.

What is slippage?

Slippage is the difference between the expected price and the final execution price. It usually increases when a trade is large relative to pool depth.

What is concentrated liquidity?

Concentrated liquidity lets LPs place liquidity inside specific price ranges. It improves capital efficiency but creates out-of-range risk.

What is Curve used for?

Curve is commonly used for stablecoins and closely correlated assets because its stable-swap curve offers low slippage near parity.

What is MEV?

MEV is value extracted through transaction ordering, insertion, or routing. In DEX trading, sandwich attacks are a common MEV risk.

What is impermanent loss?

Impermanent loss is the underperformance of a liquidity provider position compared with simply holding the deposited assets.

Can LP fees beat impermanent loss?

Yes, but not always. LPing is profitable only when earned fees exceed impermanent loss, gas costs, out-of-range time, and other risks.

How can I reduce swap risk?

Use reputable interfaces, check token risk, keep slippage realistic but tight, avoid thin pools, review routes, and revoke unused approvals.

References

Official documentation and reputable sources for deeper reading:


This guide is for educational DeFi research only and is not financial, investment, legal, tax, or security advice. AMM and DEX activity can result in loss of funds due to slippage, MEV, sandwich attacks, malicious token contracts, smart contract exploits, bad approvals, impermanent loss, depegs, bridge failures, or protocol failure. Always verify current protocol documentation and assess your own risk before swapping tokens or providing liquidity.

```
Reader Supported Research

Support Independent Web3 Research

TokenToolHub publishes free Web3 security guides, smart contract risk explainers, and on-chain research resources for traders, builders, and investors. If this article helped you, you can optionally support the platform and help keep these resources free.

Network USDC on Base
Optional
0xBFCD4b0F3c307D235E540A9116A9f38cE65E666A

Support is completely optional. Please only send USDC on the Base network to this address. TokenToolHub will continue publishing free educational resources for the Web3 community.

TH

Add TokenToolHub shortcut

Keep scanners, research tools, guides, and the community one tap away on this device.

On iPhone, open TokenToolHub in Safari, tap the Share icon, then choose Add to Home Screen.