Impermanent Loss and LP Economics
Holding benchmarks, divergence loss, fee income, rewards, costs, and exact LP performance accounting.
View the tested implementationDay 8 established that LP shares are proportional claims on both AMM reserves. Day 9 asks whether owning that claim was actually better than simply holding the tokens.
The complete Rust implementation and its 142 passing tests live in the DeFi AMM repository.
An LP can make money in absolute terms and still make a worse decision than holding.
Profit is not outperformance
Suppose an LP supplies:
SOL initially trades at 100 USDC, so the two sides are equally valuable and the starting position is worth:
The pool begins with:
Now SOL rises externally to 400 USDC. Arbitrageurs trade against the pool until its reserve price reaches the market price:
while the fee-free constant product remains:
Substituting y' = 400x' gives:
Marked at the new price, the LP claim is worth:
The LP doubled the original 2,000-USDC position. But holding the original assets would be worth:
So the LP made 2,000 USDC in absolute profit while underperforming holding by 1,000 USDC.
Both statements are true because they use different benchmarks.
What the AMM did to the inventory
As SOL became more valuable, the AMM automatically sold it to arbitrageurs. The LP moved from:
to:
The pool owns less of the outperforming asset and more of the underperforming one. This continuous rebalancing is the source of divergence loss.
The loss is not necessarily a cash loss against the starting position. It is an opportunity-cost loss against the token portfolio the LP could have continued holding.
Deriving the general formula
Let the relative price change be:
For an initially balanced, fee-free constant-product position, the pool's final reserves satisfy:
The LP's final marked value grows by sqrt(r) relative to its starting value, while the held portfolio grows by (1+r)/2:
Therefore:
and theoretical impermanent loss is:
This is a comparison with holding, not a return calculated from the original capital.
A 2.25× worked example
If SOL rises from 100 to 225 USDC:
Starting again from 10 SOL / 1,000 USDC, equilibrium reserves become:
The LP claim is worth:
Holding is worth:
Therefore:
The implementation represents this example with scaled base units so 6⅔ SOL is exact instead of prematurely truncating it.
Useful reference points
| Relative price | Price movement | Theoretical IL |
| ---: | ---: | ---: |
| 1× | unchanged | 0% |
| 1.25× | +25% | about −0.62% |
| 2× | +100% | about −5.72% |
| 2.25× | +125% | about −7.69% |
| 4× | +300% | −20% |
| 0.5× | −50% | about −5.72% |
| 0.25× | −75% | −20% |
The Rust API floors its requested fixed-point output. At basis-point precision, the 2× result is therefore −571 bps, not a nearest-rounded −572 bps. At six decimal places it returns −5.7190%, exposing the familiar −5.7191…% result much more closely.
The rounding rule is explicit because changing presentation precision must not silently change economic meaning.
Reciprocal symmetry
The formula has a useful symmetry:
A fourfold increase and a fall to one-quarter produce the same percentage divergence from holding:
The implementation rewrites the formula in a reciprocal-symmetric form:
Swapping a and b changes neither their sum nor their product, so reciprocal inputs produce bit-for-bit identical results rather than merely approximately equal ones.
Theoretical IL is also never positive:
That does not say the LP always loses money. It says that before fees, an initially balanced constant-product position cannot beat holding when the tokens' relative price changes.
Why “impermanent” is misleading
If the relative price returns to its starting point while liquidity remains in the same fee-free pool, the divergence disappears. That is the impermanent part.
But while prices remain apart, the underperformance is economically real. Withdrawing crystallizes the pool's changed token inventory. After withdrawal, later market movement applies to that new inventory; it does not rewind the AMM trades that already occurred.
“Divergence loss relative to holding” is usually the clearer description.
Fees can pay for divergence loss
Liquidity providers earn swap fees because traders use their inventory. In this constant-product model, input fees remain inside the reserves, increasing the assets backing the same LP supply.
Return to the 4× example:
- Fee-free LP value:
4,000 USDC. - Holding value:
5,000 USDC. - Shortfall:
1,000 USDC.
There are two valid ways to express the gap:
Both describe the same amount using different denominators. Saying “fees must cover 20%” without naming the benchmark is incomplete.
The clean break-even condition is:
Do not count embedded fees twice
Real swap fees in this model remain in the AMM reserves. When final LP reserves are marked to market, those fees are already inside V_LP.
Adding an estimated fee balance again would double-count the same value:
External liquidity incentives are different. If another program pays rewards outside the pool, those rewards are not present in the AMM reserves and may be added separately.
IL and fee income observe different things
Suppose two markets both start at 100 and end at 200:
Both have the same endpoint ratio r=2, so both have the same theoretical fee-free IL.
But Path B can create much more arbitrage and trading volume. More swaps can leave more fees in the reserves.
Therefore:
- Theoretical IL is endpoint-dependent.
- Fee income is path- and volume-dependent.
- Net LP performance depends on both.
This is why an IL percentage alone cannot tell us whether providing liquidity was profitable.
The complete economic comparison
For initial assets (x_0,y_0), an actual final LP claim (x_LP,y_LP), and external price P_1:
The useful outputs are:
If external rewards and operating costs exist:
An LP can make money against its starting capital, underperform holding, and still outperform another strategy such as lending. There is no contradiction: each statement answers a different question.
Exact rational valuation in Rust
The implementation uses the Day 6 convention that PriceRatio represents token-Y units per token X:
A portfolio is valued in token Y as:
Rather than immediately flooring that result, PortfolioValue stores the exact rational:
pub struct PortfolioValue {
pub numerator: u128,
pub denominator: u128,
}Signed value differences and ratios also preserve rational numerators, denominators, and an explicit sign. Comparisons use checked cross-multiplication, with a same-denominator fast path where possible.
Only the theoretical square-root formula is intrinsically approximate. It scales before taking the integer square root and documents the requested fixed-point precision. Actual reserve valuation and LP-versus-hold comparison remain exact.
This distinction matters:
theoretical_impermanent_lossmodels an initially balanced, fee-free constant-product position.compare_lp_to_holdvalues actual integer reserve claims and is authoritative.- Actual performance can differ because of fees, initial imbalance, rounding, rewards, or costs.
Solana interpretation
On Solana, an LP's ownership may live in token accounts while pool reserves live in program-controlled token accounts. The arithmetic still has to keep three layers separate:
- The user's LP-token balance determines their proportional reserve claim.
- Pool token-account balances determine the assets actually owned by LPs.
- An external price source determines the unit used to mark both LP and holding portfolios.
The economics library deliberately does not pretend to solve oracle trust, price staleness, reward-token conversion, or user authorization. Those are separate protocol layers. The official Solana token documentation describes the token-account and mint mechanics underlying such an implementation.
What the tests cover
Day 9 adds 27 tests: 16 examples and 11 generated properties. Together with all 115 unmodified Day 6–8 tests, the crate now has 142 passing tests.
They verify:
- Zero IL when relative prices do not change.
- The 2×, 2.25×, 4×, and reciprocal price examples.
- Exact reciprocal symmetry.
- Non-positive theoretical IL.
- Monotonic divergence as price moves farther from one.
- Exact rational portfolio valuation and comparison.
- Positive absolute profit alongside negative outperformance.
- Fee-inclusive reserve claims without double-counting.
- Rewards and operating costs applied exactly once.
- Agreement between theoretical IL and specially constructed exact
xy=kreserve states. - Malformed price rejection and checked arithmetic.
- Purity: economics calculations never mutate pool or liquidity state.
The economics properties pass at 2,000 generated cases, and the complete suite passes across five repeated runs. A derived two-unit tolerance is used only for adjacent fixed-point monotonicity comparisons where each calculation may floor once; reciprocal symmetry itself is exact.
What I learned
- Profit and outperformance are different measurements.
- The correct baseline for IL is holding the originally supplied assets.
- Constant-product rebalancing sells the outperforming asset and accumulates the underperforming one.
- The standard IL formula assumes an initially balanced, fee-free position.
- Reciprocal price moves produce symmetric theoretical IL.
- “Impermanent” does not mean the opportunity cost is imaginary.
- Theoretical IL depends on endpoints; trading fees depend on the path and volume.
- Fees already held in reserves must not be added twice.
- Rewards and costs belong in the comparison only when they are economically external.
- Actual reserve claims beat theoretical formulas as the source of truth.
- Exact rational comparisons prevent presentation rounding from deciding economic results.
Day 10 closes Module 2 by moving beyond full-range constant-product pools: concentrated liquidity, range-dependent inventory, alternative curves, and how these ideas map onto Solana AMM architectures.
References
- Uniswap, Uniswap v2 Core whitepaper.
- Uniswap, Uniswap v2 concepts.
- Uniswap, Uniswap v3 Core whitepaper.
- Solana, SPL Token basics.
- Rust standard library, checked arithmetic on
u128andu128::isqrt.