35 min

Fees, impermanent loss, and what providers earn

A liquidity provider's return is fee income minus impermanent loss, and only the yield that survives with no token emissions is real.

Where you are. You have a pool that prices trades by a formula. Somebody put the money in it. This lesson works out what happens to them, and the answer is more interesting than the advertised yield.

Put a million in cash and ten thousand bonds into a pool. Walk away for a month. The price of the bond doubles.

You come back expecting to have done well, and you have: the position is worth more than it was. It is also worth less than if you had done nothing at all, and the gap has a name and a formula.

The idea in one paragraph

A pool is always selling whichever asset is going up and buying whichever is going down, because that is what keeping the invariant means. That behaviour is systematically the wrong side of every move, and the resulting shortfall against simply holding is called impermanent loss: impermanent because if the price comes back, it vanishes completely. Against that, the pool collects a fee on every trade. A provider’s actual return is the fee income minus the impermanent loss, and the whole question of whether providing liquidity is worth doing reduces to whether the first number beats the second on the path the price actually took.

image/svg+xml Matplotlib v3.11.1, https://matplotlib.org/ 0 1 2 3 4 step along the price path 2.0 2.2 2.4 2.6 2.8 3.0 value, millions simply holding in the pool, fees included 1 2 3 4 price now, as a multiple of the price then −20 −15 −10 −5 0 impermanent loss, percent a doubling costs 5.7%
A pool position against simply holding over a doubling, and the impermanent-loss curve against the price ratio

Two paths, one pool

The exercise walks the same pool down two price paths and compares each with holding.

On a round trip, from a hundred up to a hundred and fifty and back, the impermanent loss is exactly zero at the end, because the price ended where it started. Every fee collected on the way is profit. That is the case liquidity providers are shown.

On a straight doubling, the loss is 5.72 percent of the position, the fees on this path come nowhere near covering it, and the provider ends well behind somebody who did nothing.

price pathimpermanent lossfees earnednet against holding
100 to 150 and back to 1000.00%1,353+1,353
100 rising to 200-5.72%1,246-170,326

n = 2 trials · the same pool, two deterministic price paths

The number the yield figure hides

The advertised return on a pool is usually fee income, sometimes with token emissions added on top, and both are gross of the thing that actually determines the outcome.

Emissions are the sharper problem. A pool paying a return in a token it prints is paying you in something whose supply it controls, and a yield that only exists while the printing continues is not a yield, it is a marketing budget. The test is simple and worth applying to every such figure you meet: what is the return with emissions set to zero? If nobody can tell you, the answer is that nobody has measured it.

Try it

Set the fee and the price the pool ends at, and read off the impermanent loss, the fee income and the net against simply holding. The arithmetic is the exercise’s, so the numbers agree with the table above. Try finding the fee level at which a doubling breaks even.

Check yourself

1. Why does a pool lose against holding when the price moves?

Because keeping the invariant means selling whichever asset is rising and buying whichever is falling. The pool is systematically on the wrong side of every move, and the accumulated shortfall against having done nothing is the impermanent loss.

2. In what sense is the loss impermanent?

Only in that a price returning to where it started erases it completely, as the round-trip run shows. If the price ends somewhere else, the loss is entirely permanent, and the word has misled a great many people who read it as “temporary”.

3. A pool advertises a healthy yield. What is the first question to ask?

What the return is with token emissions set to zero. A yield paid in a token the protocol prints is a transfer rather than an income, and it lasts as long as the printing does. The second question is what the impermanent loss was over the same period, since the advertised figure is almost always gross of it.

4. What is a provider actually being paid for?

For supplying inventory to traders, in fees. They are not being compensated for price risk in the ordinary sense, because given the start and end prices the loss is a closed-form number with no uncertainty in it. The position’s payoff shape is that of having sold volatility, and the fees are the premium.

Do this

Measure the position against doing nothing.

python3 code/impermanent_loss.py

The starter provides the arbitrage step that keeps the pool honest at each price and leaves you the accounting: the pool’s value in cash terms, what the same tokens would have been worth untouched, the ratio between them, and the net once fees are added back. The assertions check that the round trip leaves no loss and pure fee profit, and that the doubling’s loss matches the closed form to six decimal places.

The completed version is in solutions/impermanent_loss.py.

What you can now do. You can measure a pool position against holding, explain why the loss is structural rather than accidental, and apply the emissions-to-zero test to any advertised pool yield. The next lesson concentrates the same capital into a price range and finds a sharper version of both the gain and the problem.

What you can now do

You can measure a pool position against simply holding and say what fee level would have paid for the difference.