Module 9: DeFi Deep Dive

AMMs and DEXs in Depth

Chapter 2 of 14 · about 6 minutes

2.1 Beyond x × y = k

In Module 1, Chapter 8, Mint learned the basic AMM formula and saw how pool size affects slippage. Now Mint noticed that swaps between two stablecoins had almost no slippage at all, even in large amounts, and that some pools showed liquidity concentrated in narrow price ranges.

"Not every DEX uses the same formula?" Mint asked.

"Far from it," said Hash. "The simple formula was the first design. Since then, DEXs have evolved to make liquidity more efficient. Understanding the main designs helps you trade better and, if you provide liquidity, understand your risks."

2.2 The constant product AMM, revisited

The constant product formula, x × y = k, keeps the product of the two token balances fixed (Module 1, Chapter 8). It has useful properties: it always has a price, it never runs out of either token, and it's simple and robust.

Its weakness is capital efficiency. Liquidity is spread evenly across every possible price, from near zero to near infinity. For an ETH/USDC pool where ETH trades around $3,000, most of the liquidity sits at prices like $10 or $1,000,000, where trades almost never happen. Only a small portion is actually used near the current price.

2.3 Concentrated liquidity

Concentrated liquidity lets liquidity providers choose a price range where their liquidity is active. If ETH trades around $3,000, a provider might place liquidity only between $2,700 and $3,300.

Within that range, the same capital provides much deeper liquidity, so traders get less slippage and providers earn more fees per dollar deposited. Outside the range, the position stops earning fees and is fully converted into one token.

Full-range liquidityConcentrated liquidity ($2,700 to $3,300)
Where liquidity is activeAll pricesOnly within the chosen range
Capital efficiencyLowMuch higher
Fees earned per dollar while in rangeLowerHigher
If price leaves the rangeStill earningEarns nothing; holds only one token
Management neededMinimalActive: ranges may need adjusting
Impermanent loss within rangeStandardAmplified (Chapter 4)

"So it's like a shop that only opens during the busiest hours," said Mint. "More customers per hour, but closed the rest of the time."

"And if the busy hours shift, you need to move your opening times," said Hash.

Chapter 2 · Concentrated liquidity

One curve shows constant-product liquidity thinly spread across every price. The other shows liquidity concentrated into a chosen band, making the pool far deeper within that range. When price moves outside the range, the position stops earning fees and sits in a single token.

A classic AMM spreads liquidity across all prices, most of it never used. Concentrated liquidity lets providers focus their capital in a chosen range, deepening it where trading happens — but earning nothing when price leaves the range.

2.4 Stable swap curves

For assets expected to trade near the same price, such as two dollar stablecoins, or ETH and a liquid staking token (Chapter 8), DEXs use stable swap curves. These behave almost like a fixed exchange rate near the expected price, giving very low slippage, but curve more steeply if the pool becomes heavily unbalanced.

Swap of $1,000,000 between two stablecoinsConstant product poolStable swap pool
Typical slippage, deep poolNoticeableVery small

The trade-off: if one asset in a stable pool loses its peg, the pool fills up with the depegged asset as traders swap it for the healthy one. Liquidity providers end up holding mostly the failing asset. This is exactly the pool imbalance signal from Module 6, Chapter 8.

2.5 Fees and fee tiers

DEX pools charge a fee on each swap, paid to liquidity providers and sometimes partly to the protocol. Many DEXs offer fee tiers:

Pair typeTypical fee tier (illustrative)Reason
Stablecoin pairs~0.01% to 0.05%Low volatility, low risk for providers
Major pairs, like ETH/USDC~0.05% to 0.30%Moderate volatility
Volatile or small tokens~0.30% to 1.00%Higher risk for providers

Higher fees compensate liquidity providers for higher risk, but push traders toward cheaper venues.

2.6 DEX aggregators

DEX aggregators search many DEXs and pools to find the best price for a trade, sometimes splitting it across several routes.

Example. Swapping $500,000 of USDC for ETH:

RouteShare of trade
Pool A, concentrated liquidity55%
Pool B, different fee tier30%
Pool C, another DEX15%

By splitting the order, the aggregator reduces total price impact compared with sending it all through one pool. Most users now swap through aggregators or wallets with built-in routing, often without realising it.

2.7 Intent-based trading

A newer approach is intent-based trading. Instead of specifying exactly which pools to trade through, the user signs an intent: "I want to sell 10 ETH for at least 29,800 USDC within the next two minutes."

Independent solvers compete to fill that intent at the best price, using any source of liquidity: DEX pools, their own inventory, or other users' opposite orders. The winning solver delivers the result.

Traditional DEX swapIntent-based trade
User specifiesThe exact routeThe desired outcome
Who finds the routeThe user or an aggregatorCompeting solvers
GasUsually paid by the userOften included in the price or paid by solvers
MEV exposureCan be sandwiched (Module 3, Chapter 11)Generally reduced, since orders aren't exposed as normal swaps in the public mempool
TrustThe pools' smart contractsThe settlement contract and solver competition

Intent-based designs also power some cross-chain bridges (Module 3, Chapter 10).

2.8 Order book DEXs

As Module 1, Chapter 8 and Module 7, Chapter 13 mentioned, some DEXs use on-chain order books instead of pools, usually on high-throughput chains. They work like centralised exchanges, with limit orders and market makers, but settle on-chain.

2.9 Choosing where to trade

TradeTypically best
Small swap of major tokensAggregator or intent-based swap
Large swapAggregator or intent-based swap, with careful slippage settings
Stablecoin to stablecoinStable swap pools, usually via an aggregator
New or small tokensThe specific pool where liquidity exists, with extra caution (Module 2, Chapter 11)

2.10 Try it yourself

Get quotes for swapping $1,000 and $100,000 of ETH to USDC from two different aggregators and one intent-based swap interface, without executing. Compare the output amounts, routes, and any fees. Then find a concentrated liquidity pool for ETH/USDC and look at how its liquidity is distributed around the current price.

Key takeaways from this chapter

  1. Constant product AMMs are simple and robust but spread liquidity inefficiently across all prices.
  2. Concentrated liquidity lets providers focus capital in price ranges, increasing efficiency but requiring active management.
  3. Stable swap curves give low slippage between assets expected to trade at similar prices, but fill with the weaker asset in a depeg.
  4. Fee tiers compensate liquidity providers according to the pair's risk.
  5. Aggregators split trades across pools for better prices.
  6. Intent-based trading lets solvers compete to fill a desired outcome, often reducing MEV exposure.
  7. Choose venues based on trade size, token type, and liquidity.