AMMs and DEXs (Uniswap, Curve)

AMMs & DEXs: Uniswap & Curve Explained

Constant-product markets, concentrated liquidity, stable-swap curves, slippage, fees, and MEV. everything you need to trade or provide liquidity with confidence.

TL;DR: AMMs price assets via math, not order books. Uniswap uses constant-product (x·y=k) and now concentrated liquidity; Curve optimizes for stable pairs with a low-slippage “stable-swap” curve. Mind slippage, fees, and MEV.

1) Constant-Product AMM (Uniswap)

x * y = k
• x, y = token reserves; k = constant (pool invariant)
• Spot price ≈ y / x (ignoring fees)

Traditional exchanges use an order book: bids and asks meet, and the best match becomes the trade price.
Automated Market Makers (AMMs) replace the order book with a pool of two assets and a simple rule:
the product of the reserves must stay constant (x·y=k). If you add one token to the pool
to buy the other, the ratio y/x changes; this automatically updates the price.

This curve has two immediate implications. First, the larger your trade relative to the pool, the more the price moves during execution, this is slippage. Second, deeper liquidity (larger x and y) reduces slippage for the same trade size.
Fees (e.g., 0.05%, 0.3%, 1%) are taken from each swap and left in the pool for Liquidity Providers (LPs), so LPs earn from volume.

Worked example. Imagine a USDC/ETH pool with 100 ETH and 200,000 USDC (implied mid ≈ 2,000 USDC/ETH). A trader swaps 20,000 USDC into a 0.3% fee pool. Only 99.7% (= 19,940 USDC) enters the reserves; the rest is fees for LPs. New USDC = 219,940. The invariant k was 100 × 200,000 = 20,000,000. The new ETH reserve must be k / 219,940 ≈ 90.934 ETH, so the trader receives ≈ 9.066 ETH. Their average fill is ≈ 2,206 USDC/ETH—worse than 2,000 due to price impact.

Conceptually, the curve is “flat” near the current price and “steep” as you push farther, so aggregators often split large trades
across multiple pools to reduce impact. As an LP, more volume means more fees, but price volatility changes the value of your position (we’ll cover this under impermanent loss).

2) Concentrated Liquidity (Uniswap v3-style)

In older constant-product pools, your liquidity is spread across all prices from zero to infinity capital-inefficient because most prices never happen. Uniswap v3 introduced concentrated liquidity: LPs choose a specific price band (e.g., 1,800–2,200 USDC/ETH) where their capital is active. Inside the band, they earn fees and provide depth; if price exits the band, they hold a single asset and earn no fees until price returns.

This design massively increases capital efficiency within your band, traders get lower slippage with far less total capital.
The trade-off is management: as markets move, LPs often rebalance their bands to stay active. Narrow bands can earn more (because they’re hit often) but go out-of-range quickly; wide bands earn more consistently but with lower return on capital. Different fee tiers (e.g., 0.01%, 0.05%, 0.3%, 1%) suit different volatility profiles. stable pairs favor lower fee tiers; volatile pairs often need higher tiers to compensate for risk.

Put simply: v3 turns passive LPing into a light market-making strategy. Success depends on choosing sensible ranges, fee tiers,
and a rebalancing cadence that justifies gas costs and minimizes the risk of sitting idle.

3) Curve’s Stable-Swap

Curve specializes in assets that should trade at (or very near) 1:1 classic examples are USDC/DAI/USDT and stETH/ETH.
A pure constant-product curve is good generally, but it still introduces noticeable slippage even for tiny deviations around 1:1.
Curve blends constant-sum (flat near the peg, ultra-low slippage) with constant-product (prevents pool depletion away from the peg) to get the best of both. The result is a curve that’s extremely cheap to trade near parity and gets steeper as imbalance grows.

The key tuning knob is the amplification parameter (often written as A). Higher A makes the curve flatter near the peg,
lowering slippage for small imbalances. Curve also uses meta-pools to stack assets on top of deep base pools (like “3pool”), enabling efficient routing while preserving low slippage. This is excellent for stablecoins and closely-pegged staking derivatives, but it’s not the right tool for volatile assets where price can drift far from 1:1.

4) Trading UX: Slippage, Fees, Routing

A good trade is more than “click swap.” You’re optimizing execution under uncertainty. Here are the levers that matter:

  • Slippage tolerance. This is the maximum price movement you’ll accept between quote and execution. Too tight and the transaction reverts when price nudges; too loose and you open the door to predatory orderflow like sandwiches. Set it as low as possible while still
    clearing in current conditions raise it temporarily in highly volatile windows or thin liquidity, then reduce it again.
  • Fees and fee tiers. Uniswap v3 pools come in multiple fee tiers. Aggregators often split orders across tiers and across different pools
    to beat any single route’s price. Curve frequently wins on stable swaps even when headline fees look similar because the stable-swap curve reduces price impact.
  • Routing and multi-hop. Don’t fear multi-hop paths (e.g., TOKEN → WETH → USDC); if they’re chosen by a smart router, total impact can be lower than a direct pool with poor depth. What matters is effective price after fees and impact.
  • Token approvals. ERC-20 tokens require an approval before the first swap. Prefer exact approvals or review them periodically and revoke unused approvals to reduce risk exposure.
  • Gas and failure modes. On busy networks, mempool competition can reorder or delay inclusion. Avoid repeatedly resubmitting the same swap with tiny gas bumps; instead, submit one confident transaction via a reputable router or, where available, a protected/private route (see “Risks” below).

5) Risks: MEV & Sandwiches

Because transactions are visible before they’re confirmed, specialized searchers simulate your trade and sometimes insert their own around it.
A classic sandwich attack buys ahead of your swap to push the price up and sells after your trade for profit, leaving you with worse execution.
This behavior falls under MEV (Maximal Extractable Value).

  • Keep slippage tight (but realistic for your trade size and liquidity).
  • Avoid single, huge market orders in thin pools; split the trade or route via deeper liquidity.
  • Use reputable frontends or aggregators that offer private or MEV-protected routing where possible.

Note: reducing slippage tolerance doesn’t eliminate MEV entirely, but it limits how much can be extracted and increases the chance a harmful route fails to execute.

6) Impermanent Loss for LPs

Providing liquidity is not the same as holding tokens in your wallet. As price moves, the AMM automatically rebalances you into a different mix
of the two assets. Compared to simply holding, your position value can be lower, this difference is called impermanent loss (IL).
It becomes “permanent” when you withdraw at the new price. Fees you earn can offset IL; whether LPing is profitable depends on volume × fee tier
versus the price path.

In a 50/50 constant-product pool, if price doubles, a simple approximation says IL ≈ 5.7% versus holding. If the pool generated more than ~5.7% in net fees for your share over that move, you could still come out ahead. Curve-style stable pools keep IL very small near 1:1 one reason they’re popular for stablecoin LPs. In Uniswap v3, tighter ranges concentrate fee earnings but can increase the risk of going out-of-range (earning zero) or ending up heavily exposed to one asset if price trends.

Practical LP checklist:

  • Choose pairs whose behavior you understand (stable vs. volatile).
  • Pick a fee tier that matches expected volatility (higher for choppier pairs).
  • Simulate “what if price trends +/−20%, +/−50%?” and check if expected fees plausibly compensate.
  • Account for gas costs to rebalance and claim fees.

Quick check

  1. What does x·y=k represent and why does it cause slippage?
  2. How does Uniswap v3 increase capital efficiency, and what’s the trade-off?
  3. Why is Curve’s stable-swap ideal near 1:1 pegs?
  4. List two tactics to improve execution quality on volatile days.
  5. How do fees and impermanent loss interact for LP profitability?
Show answers
  • It’s the constant-product invariant; trades must move along the curve, changing the price as reserves change larger trades move price more (slippage).
  • By concentrating liquidity in chosen price bands; the trade-off is active management and risk of going out-of-range.
  • It blends constant-sum and constant-product so slippage is very low near the peg but grows as imbalance increases.
  • Keep slippage tight and route across deeper pools/aggregators; consider breaking large orders; use protected/private routing where available.
  • Fees add value to your position; IL subtracts compared to holding. LPing is profitable only if accumulated fees exceed IL (and gas costs).

Go deeper

Tip: After experimenting, revisit this lesson and map your results to each concept, slippage, routing, fee tier choice, and LP outcomes.

Next: provide liquidity and understand yield vs. risk.

Next: Yield Farming & LPs →