The Physics of Liquidity Pools: x*y=k and LVR
Why 'Impermanent Loss' is actually 'Permanent Arbitrage'. The conservation law of AMMs, convexity, and why Uniswap V3 is a leveraged bet.
🎯 What You'll Learn
- Derive the Constant Product Formula ($x \cdot y = k$)
- Calculate LVR (Loss-Versus-Rebalancing) mathematically
- Visualize Uniswap V3 Concentrated Liquidity as a Limit Order
- Analyze the Arbitrageur's role in price discovery
- Trace a Swap's impact on Pool Reserves
Introduction
An Automated Market Maker (AMM) is not a “Market Maker” in the traditional sense. It is a robot that enforces a conservation law. It does not “know” the price of ETH. It only knows it must preserve the constant .
When the price of ETH moves on Binance, the AMM does not move. It waits for an Arbitrageur to come and “correct” its reserves, paying them a profit to do so. This payment is what we call Impermanent Loss.
The Conservation Law ()
Consider a pool with two assets, and . The invariant is:
If a trader wants to buy amount of Token X, they must deposit amount of Token Y such that the product stays at .
This curve is a hyperbola. As reserves of approach 0, the price of (in terms of ) approaches infinity. The pool can never run out of liquidity completely.
Impermanent Loss is LVR
“Impermanent Loss” is a marketing term. The academic term is LVR (Loss-Versus-Rebalancing).
The Mechanism:
- ETH is $1000. Pool has correct ratio.
- ETH pumps to $1100 on Binance.
- Pool still offers ETH at $1000.
- Arbitrageur buys “cheap ETH” from pool until price matches $1100.
- Result: The pool sold ETH too cheap. You (the LP) subsidized the arbitrageur’s profit.
You are effectively shorting gamma (volatility). You profit when price is stable (Fees > LVR). You lose when price is volatile (LVR > Fees).
Concentrated Liquidity (Uniswap V3)
In V2, your liquidity covers to . In V3, you pick a range: .
- If Price < : You hold 100% Token X.
- If Price > : You hold 100% Token Y.
- Inside Range: You earn amplified fees relative to V2.
Risk: If price exits your range, you earn 0 fees, but you already suffered the LVR of the move that took it out of range.
Code: Simulating a Swap
How does the contract actually calculate amountOut?
def get_amount_out(amount_in, reserve_in, reserve_out):
# x * y = k
# (reserve_in + amount_in) * (reserve_out - amount_out) = reserve_in * reserve_out
amount_in_with_fee = amount_in * 997 # 0.3% fee
numerator = amount_in_with_fee * reserve_out
denominator = (reserve_in * 1000) + amount_in_with_fee
amount_out = numerator / denominator
return amount_out
# Example
# Reserve: 10 ETH (In), 20,000 USDC (Out). Price 2000.
# Input: 1 ETH.
# New Reserve In ~ 11 ETH.
# New Reserve Out ~ 18,181 USDC.
# User receives: 20,000 - 18,181 = 1,819 USDC.
# Effective Price: $1,819 (slippage due to pool depth).
Practice Exercises
Exercise 1: The Arb (Beginner)
Scenario: Pool Price 1010. Task: Calculate how much ETH an arb can buy before the pool price hits k$).
Exercise 2: Leverage Calculation (Intermediate)
Scenario: V3 Position with range 2010. Task: Compare the capital efficiency vs a V2 position over the same range. Tighter ranges amplify fee earnings but also amplify LVR.
Exercise 3: Rekt Check (Advanced)
Scenario: You LP’d a memecoin that rugged (-99%). Task: Calculate your approximate IL. (Approaches 100% — you end up holding mostly the worthless token.)
Knowledge Check
- What does “Constant Product” preserve?
- Why do LPs lose money during volatility?
- What happens to a V3 LP position when price goes out of range?
- Who sets the price in an AMM?
- Why is the fee typically 0.3%?
Answers
- The multiplication of reserves ().
- LVR. They are constantly selling winners and buying losers against arbitrageurs.
- Dormancy. It stops earning fees and consists entirely of the less valuable asset.
- Arbitrageurs. They trade until the pool price matches the external market price.
- Standard convention. It creates a bid-ask spread that compensates LPs for volatility risk.
Summary
- AMM: A dumb robot following a math law.
- LVR: The tax LPs pay to Arbitrageurs.
- V3: Concentrated liquidity with amplified fees and amplified risk.
Want to go deeper?
Weekly infrastructure insights for engineers who build trading systems.
Free forever. Unsubscribe anytime.
You're in. Check your inbox.
Questions about this lesson? Working on related infrastructure?
Let's discuss