Simulating Impermanent Loss
The goal of this article is to calculate impermanent loss by simulating the price drop in ETH for an ETH-Dai pool using Uniswap Contracts. Using the Calculator we are able to figure out the breakeven price of ETH.
The breakeven price of ETH is the price at which the impermanent loss causes the value of loan amount equivalent to the value of LPT tokens locked.
We could have run these simulations either on the Kovan Testnet or by decompiling Uniswap’s Smart Contracts to work with our local blockchain node. The latter option was faster and helped us test multiple data points quickly. We plan to configure a CMD tool for these simulations and open it up for community testing.
Step 1 We deploy the simulations repo with the Ganache Blockchain Node running in the background.
Step 2 We use the Calculator for the ETH-DAI pair.
Step 3 The LTV we selected was 85%. The start price is $440.25 and the breakeven price of the ETH is $340.93 (Not accounting for Fees Earned)
Step 4 We now head to the Simulation Script.
Step 5 We would now simulate the price drop.
Step 6 For our Math results and Simulations to Match.