DeFi Liquidity Pools
Provide liquidity and understand impermanent loss interactively
What Are Liquidity Pools?
Liquidity pools are smart contracts that hold reserves of two or more tokens, enabling decentralized trading without traditional order books. Users can trade, earn fees, and provide liquidity 24/7.
💡 The Simple Explanation
Think of a liquidity pool like a community pot. Instead of waiting for a buyer and seller to match, you trade directly with the pool. Contributors earn fees from every trade. The pool automatically adjusts prices using a mathematical formula.
Anatomy of a Liquidity Pool
🏊 What Makes Up a Liquidity Pool?
A liquidity pool is a smart contract holding reserves of two tokens (like ETH and USDC). Unlike traditional exchanges with order books matching buyers and sellers, liquidity pools enable instant trading against the pool's reserves using an automated market maker (AMM) algorithm.
The Revolution: Anyone can become a market maker. Traditional finance requires $10M+ and regulatory approval to provide liquidity on centralized exchanges. DeFi liquidity pools democratize this—anyone with $100 or $10,000 can earn trading fees by providing liquidity.
📊 Pool Components
The pool holds reserves of both tokens (e.g., 100 ETH + 300,000 USDC). These reserves determine the current price and enable instant swaps.
Combined value of all assets in the pool. Higher TVL = more liquidity = less slippage on trades. Top pools have $100M-$1B+ TVL.
Fee charged on every swap (typically 0.05%-1%). Fees are distributed proportionally to all liquidity providers. High-volume pools generate substantial fee income.
Receipt tokens representing your share of the pool. If you own 5% of LP tokens, you can claim 5% of both reserves plus accumulated fees.
🎯 Popular Pool Types
Low volatility, low impermanent loss risk. APY: 2-10%. Safe for conservative investors. Massive volume ($10M-100M daily).
High volume, moderate IL risk. APY: 10-30%. Most popular for balanced risk/reward. $1M-50M daily volume.
High APY (50-200%), high IL risk. Prices diverge dramatically. Best for short-term speculation or strong conviction in both tokens.
💡 Why Liquidity Pools Matter
1. Explore Liquidity Pools
🏊 Interactive: Select a Pool
Pool Details: ETH/USDC
Becoming a Liquidity Provider
💰 How to Add Liquidity to a Pool
Providing liquidity means depositing equal values of both tokens into a pool. Unlike simply buying and holding, you're actively facilitating trades and earning a cut of every transaction. The process is permissionless—no application, no approval, just connect wallet and deposit.
The Balanced Deposit Requirement: You cannot deposit just one token. Pools require deposits in the current price ratio. If ETH/USDC is 1:3000, depositing 10 ETH requires exactly 30,000 USDC. This maintains pool balance and prevents price manipulation.
🔄 The 4-Step Process
Choose token pair (ETH/USDC, DAI/USDC, etc.). Review TVL, APY, trading volume. Higher TVL = safer but lower APY.
Input one token amount, the other auto-calculates to maintain ratio. Example: 10 ETH → automatically requires 30,000 USDC at 1:3000 price.
Sign two transactions: (1) Token approval for smart contract access, (2) Deposit transaction. Gas cost: $5-50 on Ethereum L1, $0.01-0.50 on Polygon.
Pool mints LP tokens representing your share. These tokens prove ownership and can be redeemed anytime for your portion of reserves + accumulated fees.
💵 Understanding Your Returns
Most pools charge 0.3% per swap. If you own 5% of the pool and daily volume is $1M, you earn: $1M × 0.3% × 5% = $15/day ($5,475/year).
Many protocols offer liquidity mining incentives—bonus tokens for staking LP tokens. Can boost APY from 10% to 50-200%+ during campaigns.
⚠️ Pool Share Matters
Your percentage of the pool determines both earnings and exposure. Larger share = more fees but also more capital at risk from impermanent loss.
✨ Pro Tips for New LPs
2. Provide Liquidity
💰 Interactive: Add Liquidity
⚖️ Balanced deposits: You must provide both tokens in the current pool ratio. This ensures the price stays consistent.
The Math Behind AMMs
📐 Understanding x × y = k
The constant product formula is the elegant algorithm powering most decentralized exchanges. It's deceptively simple: x × y = k, where x and y are the token reserves, and k is a constant that never changes (except when liquidity is added/removed).
The Key Insight: When someone buys token X, they add token Y to the pool. Reserve X decreases, reserve Y increases, but their product always equals k. This automatically adjusts prices—more demand for X makes it more expensive in terms of Y.
🧮 How Price Discovery Works
Pool starts: 100 ETH × 300,000 USDC = 30,000,000 (k)
Current price: 300,000 / 100 = $3,000 per ETH
The ratio of reserves determines the spot price at any moment.
Trader adds USDC to pool, removes ETH. To maintain k = 30,000,000:
New reserves: 90 ETH × 333,333 USDC = 30,000,000
New price: 333,333 / 90 = $3,704 per ETH
Price increased 23% because buying reduced ETH supply!
If Binance shows ETH at $3,000 but pool shows $3,704, arbitrage opportunity exists.
Arbitrageur buys ETH on Binance ($3,000), sells to pool ($3,704), pockets $704 profit.
This pushes pool price back toward $3,000, keeping DEX prices aligned with broader market.
📊 The Bonding Curve
The constant product formula creates a hyperbolic curve. As reserves of one token decrease, its price increases exponentially. This is why large trades cause dramatic price impact.
Minimal price impact (~1%). You get close to the spot price. Slippage is acceptable.
Massive price impact (~33%). Final units cost much more than first units. Severe slippage.
🔬 The Calculation Step-by-Step
💡 Why This Formula Matters
3. Automated Market Maker (AMM)
📐 Interactive: Constant Product Formula
Swap Calculation
Executing Token Swaps
🔄 How DEX Swaps Work
Swapping tokens on a decentralized exchange is fundamentally different from centralized exchanges. No order matching, no waiting—you trade directly against the pool's reserves. The smart contract calculates output using the constant product formula and executes instantly.
The User Experience: Select input token and amount → see exact output (including slippage and fees) → approve transaction → swap completes in ~15 seconds. The entire process is permissionless and censorship-resistant—no account signup, no KYC, no middleman.
⚙️ What Happens During a Swap
Your wallet sends tokens to the pool's smart contract. For ETH/USDC swap, you send 5 ETH to the pool address.
0.3% fee deducted from input (5 ETH × 0.3% = 0.015 ETH). Remaining 4.985 ETH goes into calculation. Fee stays in pool for LPs.
Smart contract uses x × y = k to compute output. New ETH reserve increases, USDC reserve must decrease proportionally to maintain k.
Pool sends calculated USDC amount to your wallet. Reserves update, new price set. Transaction complete.
💸 Cost Breakdown
Goes to liquidity providers. On a $10,000 swap: $30 fee. Higher on some pools (0.5%-1%).
Ethereum L1: $5-50
Polygon/Arbitrum: $0.01-0.50
Hidden cost from price impact. Large trades: 1-10% worse than spot price.
🎯 Slippage Tolerance Explained
Slippage tolerance is your maximum acceptable price change. If you set 1% tolerance and price moves 1.5% before your transaction executes, the swap automatically fails (you get refunded minus gas fee).
✨ Swap Best Practices
4. Execute a Swap
🔄 Interactive: Token Swap
The Impermanent Loss Problem
📉 Understanding the Biggest LP Risk
Impermanent loss (IL) is the hidden cost of providing liquidity when token prices diverge from your entry point. If you had simply held the tokens instead of depositing them, you'd end up with more value. The loss is "impermanent" because it only becomes permanent when you withdraw—prices could revert.
The Core Mechanism: Liquidity pools automatically rebalance through arbitrage. When one token appreciates, arbitrageurs buy it from your pool until its price matches external markets. This means you're force-selling your winners and force-buying your losers.
📊 Real Example: ETH Price Doubles
Initial: 10 ETH @ $3,000 + 30,000 USDC = $60,000 total
After ETH → $6,000: 10 ETH @ $6,000 + 30,000 USDC = $90,000 total
Profit: +$30,000 (50% gain)
Initial: 10 ETH + 30,000 USDC in pool = $60,000 total
After rebalancing: 7.07 ETH @ $6,000 + 42,426 USDC = $84,852 total
Profit: +$24,852 (41.4% gain)
Impermanent Loss: -$5,148 (5.7% loss vs HODL)
What happened: As ETH rose, arbitrageurs bought ETH from your pool (selling USDC), reducing your ETH exposure from 10 → 7.07 ETH. You sold 2.93 ETH at average prices between $3K-$6K, missing full upside. Your position rebalanced to 50/50 value.
📈 IL by Price Change Magnitude
Note: IL is symmetric—price going up 2x or down 2x both result in same ~5.7% loss vs holding.
💰 Can Trading Fees Offset IL?
• Stablecoin pool (DAI/USDC)
• Price divergence: minimal (~0.1%)
• IL: ~0.01%
• Daily volume: $10M, 0.05% fee
• Your 1% share earns: $5K/day, ~180% APY
Fees massively exceed IL ✅
• Volatile pool (SHIB/ETH)
• Price divergence: 5x in 3 months
• IL: -25.5%
• Daily volume: $500K, 0.3% fee
• Your 1% share earns: $15/day, ~5.5% APY
IL crushes fee income ❌
🛡️ Strategies to Minimize IL
Stablecoin pairs: DAI/USDC have minimal price divergence. IL typically <0.1%.
Correlated assets: ETH/stETH or WBTC/renBTC move together, reducing IL to 1-3%.
High-volume pools: Fee income can outpace IL. ETH/USDC on Uniswap does $100M+ daily.
Short timeframes: IL grows over time. Consider LPing for weeks, not years, in volatile pairs.
Concentrated liquidity: Uniswap v3 lets you provide liquidity in narrow price ranges for 2-10x higher fee earnings.
🎯 Key Takeaway
Impermanent loss is the price you pay for earning trading fees. It's not a bug, it's a feature—the automatic rebalancing is what enables 24/7 liquidity. Only provide liquidity if you believe fee income will exceed IL, or if you have no strong directional conviction on either token.
5. Impermanent Loss
📉 Interactive: Calculate IL
⚠️ Understanding IL: When token prices diverge from your entry point, you'd have been better off just holding. However, trading fees can offset this loss over time.
Earning Trading Fees as an LP
💵 The Passive Income Opportunity
Every swap on a liquidity pool charges a trading fee (typically 0.05%-1%), and 100% of that fee goes to liquidity providers. Your share of fees is proportional to your share of the pool. This creates a genuine passive income stream—fees accumulate automatically 24/7 with no action required.
The Scalability: Unlike staking where your rewards are fixed, LP fee income scales with trading volume. A $100M daily volume pool at 0.3% fee generates $300,000 daily fees to be distributed. Even a 0.1% pool share earns $300/day ($109K/year).
🔢 Fee Revenue Math
📊 Fee Tiers Explained
For highly correlated pairs (DAI/USDC, USDC/USDT). Lower fee compensated by massive volume. $100M+ daily volume common.
Standard for major pairs (ETH/USDC, BTC/ETH, UNI/ETH). Balances volume with fee capture. $10M-50M daily volume typical.
For risky or low-liquidity pairs. High IL risk compensated by high fees. Lower volume ($100K-1M daily) but premium fee capture.
💰 Real-World APY Examples
• TVL: $400M
• Daily Volume: $50M
• Fee: 0.3%
• Daily Fees: $150K
APY: ~13.7%
• TVL: $200M
• Daily Volume: $80M
• Fee: 0.04%
• Daily Fees: $32K
APY: ~5.8%
• TVL: $50M
• Daily Volume: $3M
• Fee: 0.3%
• Daily Fees: $9K
APY: ~6.6%
• TVL: $10M
• Daily Volume: $2M
• Fee: 0.3%
• Daily Fees: $6K
APY: ~21.9%
⚠️ High IL risk
🎯 Maximizing Fee Income
6. Earning Trading Fees
💵 Interactive: Fee Revenue Calculator
Slippage & Price Impact
📊 Why Large Trades Get Worse Prices
Slippage is the difference between the expected price and the actual execution price. On AMMs, slippage is directly proportional to your trade size relative to pool liquidity. The larger your trade as a % of the pool, the worse your price—exponentially.
The Math: The constant product formula means buying 1% of the pool's token moves price ~1%, but buying 10% moves it ~11%, and buying 50% moves it ~100% (doubles the price). This protects the pool from being drained but punishes large traders.
🔍 Real Example: Trade Size Impact
📉 Slippage Guidelines by Trade Size
🛡️ Protection Strategies
Set max acceptable slippage (e.g., 2%). Transaction reverts if actual slippage exceeds this, protecting you from sandwich attacks and extreme price movements.
Instead of buying 20 ETH at once (20% of pool, 25% slippage), buy 5 ETH four times (5% each, ~5.3% slippage per trade). Total slippage: ~21% vs 25%.
Tools like 1inch, Matcha, Paraswap route trades across multiple pools and DEXs to minimize slippage. A $100K swap might use 5 different pools simultaneously.
$100M+ TVL pools absorb large trades better. $50K trade in $1M pool = 5% size. Same trade in $100M pool = 0.05% size, minimal slippage.
⚠️ Beware: Sandwich Attacks
Bots monitor the mempool for large pending trades. They front-run (buy before you, driving price up) and back-run (sell after you, profiting from your purchase). You pay inflated prices while bot profits.
1. Your trade pending: Buy 10 ETH with 5% slippage tolerance
2. Bot front-runs: Buys 8 ETH, price jumps 3%
3. Your trade executes: You buy at 3% premium
4. Bot back-runs: Sells 8 ETH, pockets 3% profit
You lost ~$900 to MEV bot. Bot earned ~$720.
💡 Key Takeaway
Slippage is the tax for immediate liquidity. Trade size matters exponentially—keep trades under 1-2% of pool size for minimal slippage. For large trades, use aggregators, split orders, or consider OTC desks.
7. Price Impact & Slippage
📊 Interactive: Slippage Simulator
⚡ Pro tip: Large trades relative to pool size cause significant slippage. Consider splitting into smaller trades or using pools with deeper liquidity.
LP Tokens: Your Liquidity Receipt
🎫 How LP Tokens Work
When you deposit tokens into a liquidity pool, you receive LP (Liquidity Provider) tokens as a receipt. These tokens represent your proportional share of the pool and your claim on the underlying assets plus accumulated fees. Think of them as a warehouse receipt—you can redeem them anytime for your portion of the vault.
The Power of Composability: LP tokens are ERC-20 tokens themselves, so they can be transferred, sold, or used as collateral in other DeFi protocols. This creates yield-stacking opportunities—earn trading fees AND stake LP tokens for bonus rewards.
🔢 LP Token Math
💎 LP Token Use Cases
Stake your LP tokens in liquidity mining programs to earn bonus governance tokens. Example: Stake UNI-V2 ETH/USDC LP tokens on SushiSwap to earn SUSHI tokens (20-100% APY).
Use LP tokens as collateral on lending platforms like Aave or Rari. Borrow stablecoins against your LP position at 50-70% LTV. Earn fees while borrowing.
LP tokens are transferable ERC-20 tokens. Sell your position OTC without withdrawing liquidity. Transfer to another wallet instantly. No withdrawal fees.
Deposit LP tokens in yield aggregators (Yearn, Beefy) that automatically claim and reinvest fees. Compound earnings without manual intervention.
⚠️ LP Token Risks
LP tokens are tied to pool smart contracts. If the contract has a bug or exploit, your entire position could be drained. Stick to audited, battle-tested protocols (Uniswap, Curve, Balancer).
Scam projects create pools with fake tokens, attract liquidity, then drain the legitimate token (ETH/USDC). Always verify token contracts and team credibility before providing liquidity.
💡 LP Token Strategy
LP tokens unlock multi-layered yield: trading fees (base layer) + liquidity mining rewards (second layer) + auto-compounding vaults (third layer). Advanced users stack all three for 100-300% APY in bull markets.
8. LP Token Value
🎫 Interactive: LP Token Calculator
Visualizing AMM Price Curves
📈 The Hyperbolic Curve of Liquidity
The constant product formula x × y = k creates a hyperbolic curve when graphed. This curve represents all possible states of the pool—as you move along the curve (trading), you're always maintaining the constant k, but the ratio of tokens (the price) changes dramatically.
Why Hyperbolic? As one token reserve approaches zero, its price approaches infinity. The pool never fully drains—it just makes the price prohibitively expensive. This mathematical property ensures perpetual liquidity, even for extreme trades.
📊 Reading the Curve
• X-axis (horizontal): Reserve of Token A (e.g., ETH)
• Y-axis (vertical): Reserve of Token B (e.g., USDC)
• Any point on curve: Valid pool state where x × y = k
• Slope at any point: The current price (rate of exchange)
• Buy Token A (ETH): Move left and up—ETH reserve decreases, USDC reserve increases
• Buy Token B (USDC): Move right and down—USDC reserve decreases, ETH reserve increases
• Small trades: Small movements along curve = minimal price change
• Large trades: Large movements = you're "climbing" the steep part of curve = exponential price increase
🔬 Mathematical Properties
As you buy more of one token, its reserve approaches (but never reaches) zero. Price approaches infinity. The curve has vertical and horizontal asymptotes.
The curve is convex—it bends away from origin. This means price impact accelerates with trade size. Second half of your trade is more expensive than first half.
🆚 Comparing AMM Models
Hyperbolic curve. Liquidity spread across all prices (0 to ∞). Simple, capital inefficient. Good for volatile pairs.
LPs choose price range (e.g., $2,900-$3,100 for ETH). Liquidity concentrated in range. 2-10x capital efficiency, but requires active management.
Flat curve around 1:1 price, hyperbolic at extremes. Low slippage for similar-priced assets. Perfect for DAI/USDC, stETH/ETH.
Custom weights (e.g., 80% WBTC, 20% ETH). Curve adjusts based on weights. Allows 2-8 tokens per pool.
💡 Practical Implication
Understanding the curve helps you predict slippage. The steeper the curve at your trade point, the higher the slippage. Large trades push you up the steep part—split them to stay on the flatter section.
9. Understanding Price Curves
📈 Interactive: AMM Price Curve
Understanding APY & Yield
💎 Projecting Your Liquidity Pool Returns
APY (Annual Percentage Yield) shows your projected returns if current conditions persist for a year. In DeFi liquidity pools, APY comes from multiple sources: trading fees, liquidity mining rewards, and sometimes additional protocol incentives. Understanding how to calculate and interpret APY is crucial for comparing opportunities.
The Catch: Advertised APYs are snapshots, not guarantees. They fluctuate daily based on trading volume (fees), token prices (IL), and reward emissions. A 100% APY today could be 20% next week if volume drops or token rewards decline.
🧮 APY Calculation Breakdown
If you compound earnings (reinvest fees + rewards back into pool), APY is higher than simple addition:
📊 APY Reality Check
Driven by real trading fees from established pools. Volume is consistent. Returns predictable.
Mix of fees and farming rewards. Token rewards may decline. IL risk higher in volatile pairs.
Mostly from unsustainable token emissions. Rewards dump, APY crashes. High IL risk. Often new/unproven projects.
⚠️ APY Pitfalls to Avoid
🎯 Realistic Yield Expectations
💡 Pro Strategy: Risk-Adjusted Returns
Smart LPs don't chase maximum APY—they chase maximum risk-adjusted APY. A safe 15% on stablecoins beats a risky 80% that comes with 50% IL potential. Calculate: Expected APY - Expected IL - Gas Costs = True Return.
10. APY Calculator
💎 Interactive: Yield Projections
🎯 Key Takeaways
Automated Market Makers
Liquidity pools use mathematical formulas (x × y = k) to enable trading without order books. Prices adjust automatically based on supply and demand.
Earn Passive Income
Liquidity providers earn a share of all trading fees proportional to their pool ownership. High-volume pools generate substantial revenue.
Impermanent Loss Risk
When token prices diverge, LPs experience impermanent loss compared to holding. This loss can be offset by trading fees over time.
Balanced Deposits
You must provide both tokens in the current ratio. Pools automatically rebalance through arbitrage trading to maintain fair prices.
Slippage & Impact
Large trades cause price impact. The trade size relative to pool liquidity determines slippage. Deeper pools = less slippage.
LP Tokens
When you provide liquidity, you receive LP tokens representing your share. These can be staked for additional rewards or used as collateral.