# Impermanent Loss Value

The concept of impermanent loss value (ILV) underpins the protocol mechanics of NIL.

ILV is defined as the exact value of tokens required to cover IL incurred on a AMM token pair, given a set of starting and ending token prices and quantities. Let's look at an example scenario.

We start with an initial $10,000 LP position for the WETH-USDC pair on Uniswap V2:

WETH | USDC | |
---|---|---|

Initial Price | $1,000 | $1 |

Initial Quantity | 5 | 5,000 |

Let’s say the price of WETH moves +50% during the LP period:

WETH | USDC | |
---|---|---|

Initial Price | $1,000 | $1 |

Initial Quantity | 5 | 5,000 |

Ending Price | $1,500 | $1 |

Ending Quantity | 4.082 | 6,123.72 |

By multiplying the ending token prices and quantities, we can calculate ILV as follows:

Value If Held (No LP) | 5 WETH * $1,500 + 5,000 USDC * $1
= $12,500 |

LP Value With IL | 4.082 WETH * $1,500 + 6.123.72 USDC * $1
= $12,247.45 |

Impermanent Loss Value (ILV) | = $252.55 |

The formula for impermanent loss value (ILV) is easily conceptualized as the value of the LP’s holdings at time T if they had just held their tokens, minus the value of their holdings after providing liquidity in the pool.

$ILV = V_{HODL} \: – \: V_{LP}$

Constant function AMMs use a formulaic approach to determine the price of an asset, and we can use these formulas to deterministically calculate the ILV incurred on an LP position. The input values required to make these ILV calculations are embedded in each NIL Contract.

For example, in constant product function AMMs (e.g. Uniswap V2 and forks), we can calculate the ILV of an AMM position if we know the starting and ending prices of Token A, and the starting value of the total LP position (in units of Token B).

$V_{HODL} = \text{\(\cfrac {LP_{0}} {2}\)}\:*\:(\text{\(\cfrac {P_{t}} {P_{0}}\)}\:+ \:1)\:\:\:\:\:\:and\:\:\:\:\:\:V_{LP} \: = \:LP_{0}\:*\:\sqrt{P_{t} / P_{0}}$

$ILV = \text{\(\cfrac {LP_{0}} {2}\)}\:*\:(\text{\(\cfrac {P_{t}} {P_{0}}\)}\:+ \:1) \:\: – \:LP_{0}\:*\:\sqrt{P_{t} / P_{0}}$

NIL Contracts are a new crypto derivative and DeFi primitive with a payout function that perfectly replicates the ILV incurred on a given AMM LP position. Participants can use NIL contracts to go long/short impermanent loss in order to generate returns or hedge their LP positions.

Because impermanent loss is incurred on movements of the exchange rate between two on-chain tokens, NIL uses AMM-specific TWAP price oracles (e.g. Uniswap V2 price oracle) to calculate ILV.

By using token price oracles and the data on a NIL Contract, the impermanent loss value incurred on an AMM LP position can be calculated at any point in time.

Last modified 7mo ago