Innovation Stories
Published in

Innovation Stories

“Impermanent loss” is inevitable in AMM DeFi protocols — and that’s totally fine

Impermanent loss is the opportunity cost of providing liquidity to constant product Automated Market Making (AMM) DeFi protocols. It is measured as the difference between the value of a Liquidity Provider’s (LP) tokens at the time of withdrawal from the pool, versus the hypothetical situation where the LP had not made the investment at all.

As long as an LP remains invested in a constant product decentralized exchange (DEX) pool like Uniswap, the loss is merely an accounting issue. The loss becomes larger as the ratio of token prices outside the pool drifts further away from the point when the LP entered the pool. It is ultimately realized — and becomes a real or “permanent” loss— when an LP withdraws their tokens from the pool.

This post explains why providing liquidity to constant product AMM DeFi protocols necessarily involves some impermanent loss. Before proceeding, bear in mind that the loss is merely the cost of doing business — as DEX protocols compensate LPs with income from trading fees and protocol rewards.

The idea behind impermanent loss is simple. Suppose the ratio of token prices outside the pool changes (in any direction). The divergence in relative prices within and outside the AMM pool presents traders with the opportunity to exchange tokens (with the DEX) on terms that are more favorable than the wider market. Naturally, the direction of the arbitrage trade depends on the direction in which relative prices have changed. As traders take advantage of the price difference, the ratio of token prices within the pool approaches that as the market’s. However, in the course of these exchanges, the pool is left with a modified balance of tokens. If an LP were to withdraw their share of tokens from the pool, their share will be worth less than the LP’s original investment (when computed using current prices). This is illustrated in an intuitive fashion by online calculators such as this one.

While it is easy to grasp the intuition behind the drop in value, I was not able to view it as a general result in my mind. Thinking about a simple proof helped me realize my mistake. The error was that I only thought about the curve in an AMM pool as being determined by the product of the number of tokens initially deposited in the pool — something like xy=k

While the above is true, it glosses over the fact that the constant depends on asset prices too, not just quantities. Indeed, it is this dependence on prices which provides a “liquidity interpretation” to the constant in constant product protocols.

An AMM relationship is not an arbitrary product of some initial amount “x0” of token X and some initial “y0” of token Y. At the time of creating or entering a pool, these amounts must be worth the same value (measured in dollars or any coin/token). Using px0 and py0 to denote the initial token prices, the quantities must satisfy the relation

where L denotes the liquidity provided (e.g. in USD) in each token for a total investment of 2L in the pool.

For simplicity, assume there are no other liquidity providers. Then, a constant product market AMM curve is something like

The relative price or the exchange rate of token Y (for 1 unit of token X) at any point along the curve is given by the slope of a tangent at that point. This is just the absolute value of the derivative of the curve

The initial ratio of prices must satisfy the above for the initial quantities x=x0 and y=y0

Change in asset prices

Now suppose the prices change to px1 and py1. Unless the two tokens are highly correlated, the new ratio will generally be different from before. This will move us to a new point on the curve that has the slope corresponding to the new ratio of prices. The actual shift will be driven by traders who view any difference in the ratio of prices within a pool and outside as an arbitrage opportunity.

Being on the same invariant (curve) as before implies the new point (x1,y1) satisfies

The slope of the tangent then provides the new price condition

Solving for x1

and for y1

The total value of assets in the pool is then given by

Opportunity cost of providing liquidity

The hypothetical value of assets outside the pool under the new prices — i.e. imagine the LP never invested

Now we can see why the opportunity cost is always positive. We’ll assume (incorrectly) that providing liquidity is always profitable and then arrive at a contradiction.

Naturally, the loss only arises if there is a change in the ratio of prices at the time of withdrawal. If the price of both tokens increases or decreases by the same factor, then there is no loss.

Thanks to Julian Kusnetzoff, Julian Len, Nicolás Vescovo, Diego Masini and members of the IOV Labs R&I DeFi group for discussions.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store