Learn · season 03 · episode 09
Uniswap V2: pools, swaps and LP returns
A trader pays to exchange tokens. A liquidity provider supplies those tokens and earns a share of trading fees. Those fees can still be smaller than the cost of the changing inventory.
No prerequisites beyond knowing what a token is. All examples are browser simulations; no wallet or real funds.
01 · who supplies the tokens?
LP means liquidity provider
A decentralised exchange (DEX) lets people exchange tokens through smart contracts. Uniswap uses an automated market maker (AMM): a pool holds two tokens and a formula prices exchanges. A trader swaps with that inventory. An LP deposits inventory into the pool.
In V2, an LP receives transferable pool-share tokens. Owning 10% of the shares means a claim on roughly 10% of each reserve, not a promise to get back the same token amounts deposited. As traders buy one asset, the pool holds less of it and more of the other.
Here, WETH is wrapped ETH, an ERC-20 token representing ETH. We pair it with USDC and assume USDC stays worth $1.
Source: How Uniswap works.
Follow your deposit and withdrawal
Simulated · computed hereYour example wallet starts with 5 WETH and 10,000 USDC. An existing pool holds 10 WETH and 20,000 USDC, with 1,000 LP tokens already issued to other providers.
Your wallet
5.0000 WETH
10,000 USDC
Tokens available outside the pool.
Pool reserves
10.0000 WETH
20,000 USDC
Shared by all LP token holders.
Your LP tokens in wallet
0 / 1,000
0.00% of pool
The coloured segment is your claim on both reserves.
Choose a deposit, then move both tokens into the pool.
1. Deposit both tokens → receive LP tokens
At this pool ratio, add 2,000 USDC alongside your WETH. This mints 100 LP tokens: 100 ÷ 1,100 = 9.09% of the enlarged pool.
Minted LP tokens = WETH deposited ÷ existing WETH reserve × existing LP supply. A matching deposit preserves the reserve ratio.
2. Optional: another trader changes the inventory
A trader pays 2,200 USDC to buy WETH. Your number of LP tokens stays the same; the tokens those shares represent change. Skip this step to compare a withdrawal without a trade.
3. Burn LP tokens → receive current reserves
Deposit first to see your withdrawal preview.
Each token returned = LP tokens burned ÷ current total LP supply × that token’s current reserve. V2 fees remain inside those reserves, so they are included in this claim.
Teaching assumptions: existing pool, matching deposits, protocol fee off, no other LP changes, no external arbitrage, no gas and no contract integer rounding. LP supply uses illustrative units; this does not model the first deposit or locked minimum liquidity. No wallet connection or real asset movement.
Sources: Uniswap V2 pools and the pair contract’s mint and burn calculations.
02 · exchange inventory
A larger swap moves the price further
Before fees, V2 follows x × y = k: WETH reserve × USDC reserve stays constant during a swap. Buying WETH adds USDC and removes WETH. The reserve ratio rises, making the next WETH more expensive. This is price impact.
Try a 100 USDC trade, then reset and try 10,000. Compare the average price paid. The V2 calculation takes a 0.30% fee from the input before computing output; the full input enters the reserve, so fees increase the reserve product.
Trade against the pool
Simulated · computed hereStarting pool: 10 WETH + 20,000 USDC. You supplied 1 WETH + 2,000 USDC, so you own 10% of the LP shares. USDC is held at $1 in this example.
Preview the next swap below. After you simulate it, these figures update for another trade against the new reserves.
- Swap fee · 0.30%
- $3.00
- Input used to calculate output
- $997.00
- Trader receives
- 0.4748 WETH
- Average paid per WETH · includes fee
- $2,106.02
Before this swap, the reserve ratio is $2,000.00 per WETH. A larger trade buys through progressively higher prices. The fee and price impact both affect what the trader receives.
No swaps yet. Change the input to preview how much WETH the trader receives.
| Claim | WETH | USDC |
|---|---|---|
| Whole pool | 10.0000 | $20,000.00 |
| Your 10% | 1.0000 | $2,000.00 |
Your cumulative share of fee contributions: $0.00. This is a fee tally, not profit. Your inventory is changing at the same time.
Mechanics example: protocol fee off, no other deposits or withdrawals, no external arbitrage, no gas, and continuous amounts rather than contract integer rounding. Fees stay inside V2 reserves; they are not sent to your wallet after each swap. Live protocol-fee settings can reduce LP returns.
Calculation: Uniswap V2 swap formula.
03 · follow the fee
Swapping generates fees, not guaranteed profit
The trader pays the swap fee. LPs earn the LP portion for supplying inventory; a protocol fee can take a share. A trader does not automatically make money by swapping. An arbitrage trader may profit by buying on a cheaper market and selling on a dearer one, after fees and costs. These trades help bring pool prices back toward other markets.
Where the swap fee goes
Illustrative fee estimateTraders pay a fee on swaps. The LP portion is shared among the liquidity participating in those trades. This calculator holds your share constant over the selected volume.
Estimated fees for your position: $25.00
$100,000.00 × 0.30% × 83.33% retained for LPs × 10% share.
These are selectable assumptions, not live pool quotes or an APR forecast. Dollar volume and fee values use a fixed conversion. Actual earnings depend on the price path, trading volume and competing active liquidity. V2 protocol fees use share-minting accounting; this is an economic allocation estimate, not a reproduction of that mint.
The selected protocol share is an assumption, not a live pool setting. See Uniswap’s LP and protocol fee explanation.
04 · choose the comparison
Fees can be smaller than impermanent loss
Suppose you supply 1 WETH and 2,000 USDC. WETH rises from $2,000 to $4,000. Holding would be worth $6,000. After arbitrage, your fee-free V2 position holds about 0.7071 WETH and 2,828.43 USDC: $5,656.85 total. It sold some WETH as WETH rose.
That $343.15 shortfall against holding is impermanent loss: 5.72% in this example, before fees. If you earn $100 in fees with no costs, you still trail holding by $243.15. You gained dollars compared with the $4,000 deposit, but earned less than holding.
Now set the final price to $1,000. Both holding and LP principal lose dollar value. The LP position also trails holding. A market-price loss and impermanent loss are different measurements, and can happen together.
Does the fee cover the shortfall?
Simulated · computed here · hypothetical prices
Start with $4,000 at $2,000 per WETH. USDC stays at $1 in this model.
Your starting inventory: 1.0000 WETH + 2000.0000 USDC.
Final LP inventory, excluding fees: 0.7071 WETH + 2828.4271 USDC.
Impermanent loss before fees: $343.15 (5.72% behind holding).
After fees and costs, your LP position is $243.15 behind holding.
Compared with your original $4,000 deposit: $1,756.85 gain. This answers a different question from the holding comparison.
Fees needed to match holding: $343.15 = inventory shortfall + costs.
Assumptions: arbitrage aligns the pool with the final market price; no deposits, withdrawals or range changes along the way. Fees are a separate hypothetical dollar total after any protocol share, not a forecast from the price move. No reinvestment or compounding is modelled. Real V2 fees accumulate in reserves; adding their value separately here isolates the fee-versus-divergence comparison.
“Impermanent” does not promise recovery. In this simplified unchanged-position model, returning to the starting relative price removes the fee-free divergence. Prices may never return. Withdrawing locks in the inventory you receive; the economic shortfall already exists before withdrawal.
Definition: Uniswap on impermanent loss.