THORChain’s immunity to Impermanent Loss

How THORChain’s unique XYK implementation prevents impermanent loss for liquidity providers.

THORChain
THORChain
Nov 12 · 4 min read

Impermanent Loss

Impermanent loss is a phenomena unique to liquidity pools that implement the basic XYK formula. Given a pool with assets X and Y, and an input x and output y the formula is:

y = (x * Y) / (x + X) where Price P = X/Y.

The staker invested: X + (Y * P)

Price Change

After a period of time, the pool will have assets X' and Y' where X' = X + x and Y' = Y — y and the price is P' = X'/Y'.

Thus the assets are valued at:

STAKE: X` + (Y` * P`)

However, if the assets had just been held, they would be valued at:

HOLD: X + (Y * P`)

The loss is then given by (STAKE-HOLD)/HOLD

( X` + (Y` * P`)X + (Y * P`) ) / ( X + (Y * P`) )

Which simplifies to: -1 * (x²/(2 X² + 2 X x + x²))

This is explained further in this article, by PinTail:

THORChain’s CLP Implementation

THORChain has a unique implementation of the XYK concept, as outlined in the original spec, and referred to as “Continuous Liquidity Pools (CLPs)”

Instead of adding a fixed-rate fee for every swap, THORChain adds a slip-based fee. This ensures that liquidity is incentivised exactly where it is needed.

Given a pool with assets X and Y, and an input x and output y the CLP formula is:

y = (x * Y * X) / (x + X)^2 where P = X/Y.

After a period of time, the pool will have assets X' and Y' where X' = X + x and Y' = Y — y and the price is P' = X'/Y'.

Thus the staked assets are valued at:

STAKE: X` + (Y` * P`)

However, if the assets had just been held, they would be valued at:

HOLD: X + (Y * P`)

The change is then given by (STAKE-HOLD)/HOLD:

( X` + (Y` * P`)X + (Y * P`) ) / ( X + (Y * P`) )

Which simplifies to: x³/((X² + X*x + x²) (2 X + 2x))

Plotted on a log-curve, the relationship is can be seen more clear:

Example

Given the example from the blog linked above, we can compute for the two implementations.

Start (Basic XYK)

10,000 DAI and 100 Ether. Price: $100

Value: $20,000.00

Change (Basic XYK)

Input Asset: 954.45 DAI; Output Asset: 8.71 Ether

Price Change: +20%

Final (Basic XYK)

Assets: 10954.45 DAI and 91.29 Ether. Price: $120.00

HOLD Value: $22,000.00

STAKE Value: $21,908.90

LOSS: $91.10 (-0.41%)

Start (THORChain CLP)

10,000 Rune and 100 Ether. Ether Price: 100.00 (Rune)

Value: 20,000.00 Rune

Change (THORChain CLP)

Input Asset: 1005.00 Rune; Output Asset: 8.30 Ether

Price Change: +20%

Final (THORChain CLP)

Assets: 11,005.00 Rune and 91.70 Ether. Ether Price: 120.00 (Rune)

HOLD Value: 22,000.00 Rune

STAKE Value: 22,010.00 Rune

Gain: 10 Rune (0.04%)


Summary

For a given change in price, THORChain stakers will receive an overall gain in assets:

Note: these numbers are still dependant on the size of trades over the pools since they directly change the slip-based fee and could be less in reality. However, never at any stage will a THORChain staker receive an impermanent loss.

Other Benefits

There are more benefits to THORChain’s CLP algorithm since the fee is slip-based:

  1. Better incentives for pools with poor liquidity, since fees are proportional to the slip received.
  2. Very low fees for pools with deep liquidity.
  3. Greater inertia for pool pricing, which means sandwich attacks are extremely expensive to perform.
  4. Pool pricing can become a price feed (instead of more complex algorithms such as moving averages), since it is resistant to manipulation and sandwich attacks.

These will be expanded in a future blog.


Community

To keep up to date, please monitor community channels, particularly Telegram and Twitter:

THORChain

A lightning-fast decentralised liquidity network.

THORChain

Written by

THORChain

The official team for THORChain — the lightning fast decentralized liquidity network.

THORChain

THORChain

A lightning-fast decentralised liquidity network.