[#36] Add a work-in-progress js earnings calculator
The code is mostly based off the code of Leif the Lucky.
It adds LPvsHodl Earnings (current value of Rune and/or Asset that was added to the pool at any time VS the value of this same Rune and/or Asset if it were held since the time of add). All strategies (inRune, inAsset, inUsd, combined/Rune&Asset) are supported.
To calculate the total earnings the this.added* is taken as the Hodl value and the sum of the this.withdrawn* and this.redeemable* are taken as the current (LP) value.
To calculate the realised and unrealised earnings assets that are still in the pool and assets that have already been withdrawn have to be differentiated. The current (LP) value is already separated, but the Hodl value has to be looked at carefully. For this reason in the for loop we keep track how much of a withdraw constitutes of the originally added assets and how much of it is from earnings. To achieve this we always check the liquidity units corresponding to an action and keep track of the 'original' asset balance in the pool. This way at the end of the calculation we can simply take this 'original' value and the current value and calculate the resulting earnings.
Earnings calculations are achieved by a function that takes the current assetPriceInRune, the current assetPriceInUSD, the current amount of Runes and Assets and the hodl amount of Runes and Assets and as an output returns all the interesting earning metrics.
Earnings calculation for a given interval are also calculated if the start and/or end times are specified. To not have skewed results assets in the pool at the starting time are also taken into account. This is done by thinking of them as an "add" at the starting time. This way calculations are not affected.