Guide 03 — The Swap

What if anyone could create a market for anything?

To list a new asset on the NYSE, you need an investment bank, a legal team, SEC approval, and 6 to 12 months of paperwork. To create a new market onchain, you need two tokens and one transaction. The pool is live in the next block.

Time to create a new market
Traditional
6–12 months
Onchain
~2 seconds

The machine that makes this possible is called an automated market maker — an AMM. No order book. No middleman. Just a mathematical formula that gives you a price for any trade, at any size, at any time.

This guide takes it apart.

Ch 01 — The Pool

Two tokens in a box. The ratio is the price.

An AMM pool holds two tokens — say ETH and USDC. The ratio between the two reserves determines the price. If the pool holds 100 ETH and 200,000 USDC, 1 ETH costs 2,000 USDC. No order book. No market maker. Just a ratio.

Buy or sell ETH. Watch the reserves shift and the price change. The curve on the right shows your position on the x · y = k invariant.

Reserve A: 100.0 ETH
Price: $2000
Reserve B: 200,000 USDC
x · y = k

The constant product formula. x and y are the reserves of each token. k is their product and must remain constant. Every trade changes x and y, but k stays the same. This single constraint is all you need to price any swap.

Price = ratio

Spot price is simply y / x. If the pool has 100 ETH and 200,000 USDC, 1 ETH = 200,000 / 100 = $2,000. Buy ETH? The pool has less ETH, more USDC — the price goes up. The formula enforces this automatically.

No oracle needed

Unlike perpetual futures or lending markets, a basic AMM doesn't need an external price feed. The price emerges from the reserves. This makes the system entirely self-contained — but it also means the pool doesn't know when it's mispriced.

Ch 02 — The Slide

The bigger your trade, the worse your price.

Price impact — or slippage — is the gap between the spot price and the price you actually get. On an order book exchange, it depends on the depth of resting orders. On an AMM, it's a mathematical certainty: the constant product curve gets steeper as you trade more.

Drag the slider. Watch how execution price drops as trade size increases. The shaded area is the cost of slippage — money left on the table.

Trade size: 50 ETH
Spot price
$2000
Exec. price
$0
Slippage
0.00%
Deep vs shallow pools

A $10K swap in a $1M pool barely moves the needle — maybe 1% slippage. The same swap in a $50K pool eats 20%+. Pool depth is the single biggest determinant of execution quality. This is why DeFi protocols fight for liquidity.

Sandwich attacks

A bot sees your pending swap in the mempool. It front-runs you (buying before you, pushing the price up), lets your trade execute at the worse price, then back-runs (selling after you, pocketing the difference). Your slippage is their profit. This is the honest beat: on AMMs, your trade is visible before it executes.

The pool needs tokens to function.

Someone has to supply them.
Ch 03 — The Provider

Anyone can become the market maker. All it costs is trust.

On a traditional exchange, professional market makers provide liquidity and manage their risk with sophisticated hedging. On an AMM, anyone can deposit both tokens into the pool and earn a share of every trading fee — typically 0.3% of each swap. You get LP tokens representing your position.

Deposit into the pool. Then simulate trades to watch fees accrue to your position. Each trade generates a small fee, proportional to your pool share.

The 50/50 split

To provide liquidity, you deposit both tokens in equal dollar value. $5,000 of ETH and $5,000 of USDC. The pool gives you LP tokens representing your 10% (or whatever your share is) of the total pool.

Fee accrual

Every swap pays a fee (0.05%–1%, depending on the pool tier). Fees are added to the pool reserves, increasing the value of your LP tokens. You don't collect fees separately — they compound automatically.

What's the catch?

The catch is impermanent loss. The pool doesn't care which direction the market moves. But you do.

The pool doesn't care which direction the market moves.

But you do.
Ch 04 — The Loss

If the price moves, you would have been better off holding.

Impermanent loss is the difference between holding your tokens and providing them as liquidity. As the price of one token rises, the pool rebalances — selling the appreciating token and buying the depreciating one. You end up with more of the token that fell in value. The bigger the price move, the larger the loss.

Drag the price slider. Watch how the LP'd position falls behind the held position. The red gap is impermanent loss — the cost of being a passive market maker.

ETH price change: 0%
-90%0%+300%
If held
$10,000
If LP'd
$10,000
Impermanent loss
0.00%
−$0
Why 'impermanent'?

If the price returns to your entry ratio, the loss disappears — hence “impermanent.” But in practice, most price moves don't revert. A 2x price change costs ~5.7% IL. A 5x change costs ~25.5%. For volatile pairs, accumulated fees rarely compensate.

LPs are short volatility

Providing liquidity is structurally similar to selling options. You earn a premium (fees) in exchange for taking on downside risk (IL). The ideal LP position is a stable pair with high volume — maximum fees, minimal price movement. LPs profit from volume, not from price direction.

Impermanent loss reference
1.25x (25% up)0.6%
1.50x (50% up)2.0%
2x (100% up)5.7%
3x (200% up)13.4%
5x (400% up)25.5%
Ch 05 — The Invisible Hand

AMMs don't discover prices. They react to them.

The pool has no oracle. It doesn't know the “real” price of anything. When Binance shows ETH at $2,100 but the pool is stuck at $2,000, there's free money on the table. Arbitrage bots buy the cheap ETH from the pool and sell it on Binance, pocketing the difference. In doing so, they push the pool price back to $2,100.

Push the external price up or down. Then hit “Arb it” to watch the bot close the gap. The arb profit comes directly from LP positions — it's the cost of passive market making.

Arb profit = LP loss

Every dollar an arbitrageur extracts comes from the pool — which means from LPs. This is impermanent loss in action: the pool is systematically selling the token that's going up and buying the token that's going down.

The MEV arms race

Maximal Extractable Value (MEV) includes arbitrage, sandwich attacks, and liquidations. Searchers compete by paying higher gas to get their transactions included first. This creates an arms race that ultimately flows to block builders and validators — a hidden tax on every swap.

Price convergence

Despite the extraction, arbitrage serves a critical function: it keeps AMM prices aligned with global markets. Without arbs, prices would drift until manual traders corrected them. Arbs are the invisible hand — the price is accurate because it's profitable to correct it.

Same formula. Different curve.

Completely different behaviour.
Ch 06 — The Curves

The shape of the curve is a design choice.

x · y = k is the simplest AMM formula, but it's not the only one. Different curves make different trade-offs. Curve Finance flattened the curve for stablecoin pairs. Uniswap v3 let LPs concentrate liquidity in specific price ranges. Each design optimises for a different use case.

Toggle between curves. Move the position slider to see how each curve behaves at different reserve ratios. Notice how StableSwap stays flat near 1:1.

Swap position: 20%
Constant product

x · y = k. Works for any token pair. Provides liquidity across the entire price range from zero to infinity. Simple, robust, but capital-inefficient: most of the liquidity sits at prices far from the current market.

StableSwap (Curve)

Flattens the curve near the 1:1 ratio, giving near-zero slippage for pegged assets (USDC/USDT, stETH/ETH). Extremely capital-efficient for stable pairs. For volatile pairs, the flat curve would let the pool be drained.

Concentrated liquidity

Uniswap v3 lets LPs choose a price range. All their capital is deployed within that range, giving massive capital efficiency. The trade-off: if the price moves outside your range, you earn zero fees and hold 100% of the losing token.

Ch 07 — The Flywheel

The cold start problem — and the machine that solves it.

Every new pool faces the same chicken-and-egg problem: no liquidity means no trading, no trading means no fees, no fees means no LPs. Early DeFi solved this with liquidity mining — pay people in tokens to provide liquidity. It worked short-term but created mercenary capital that left the moment incentives stopped.

The ve(3,3) model, pioneered by Solidly and perfected by Aerodrome on Base, solves this structurally. Protocols bribe veAERO voters to direct token emissions to their pools. Voters earn bribes + fees. LPs earn emissions. Deeper liquidity attracts more volume, which generates more fees, which attracts more bribes. The flywheel spins.

Start the flywheel. Watch how each stage feeds into the next. This is the engine that made Aerodrome the largest DEX on Base.

Bribe
Vote
Deposit
Depth
Volume
Fees
Why ve(3,3) works

The key insight: instead of paying LPs directly (liquidity mining), pay the people who direct liquidity (voters). Protocols that need liquidity compete by offering bribes. Voters lock tokens for voting power, creating long-term alignment. Everyone profits from volume, not from dumping tokens.

Aerodrome on Base

Aerodrome is Base's central liquidity hub. It routes the majority of swap volume on the network. Its ve(3,3) flywheel has attracted over $1B in TVL by aligning incentives across protocols, voters, and LPs. This is the infrastructure layer that makes everything else in DeFi on Base work.

Try it yourself
Explore Aerodrome →
Base's central liquidity hub
Test yourself

10 questions. No going back.

Your result is shareable.