TradingView
Bribri333
Jul 25, 2021 6:17 PM

Liquidity Pair Impermanent Asset Loss 

Harmony / TetherUSBinance

Description

With limited tracking of impermanent loss for liquidity pairs across all chains, I wanted a very simple display of live dollar value loss in an asset pair. This should allow you to set alerts based on how much you are down and take action if needed. The output column is by default set to show your losses in USD. For those that need it, I also setup an option to track the output in something other than USDT, e.g., GBP or ETH, etc..

Release Notes

Calculation Output Error Fixed. Code Cleaned up.

Release Notes

The more I consider LPs (liquidity pools), the more I realize impermanent loss is simply an incomplete snapshot of your total dollar loss at that minute. It doesn't account for opportunity costs. Case in point: I love Asset A, but I want earnings so I buy 50% of Asset B so I can enter the LP. I'm happily earning away seeing low total dollar losses, but ignorant of my dwindling supply of Asset A. So the question that should be answered is where would my investment be had I just kept Asset A all along. There's a checkbox to display this information now.
Comments
aeperalta
Lets consider a pool of pair volatile/stable such as BNB/BUSD
Since the holdings of BNB is: qty = sqrt(k/price); and this amount goes down when the price goes up and viceversa...
...what if you hedge the position with a future in the opposite direction? Will it work?
I think its a matter of calculating the appropriate lot size and adjust it dynamically in order for the Pool Value$ + Future PnL hovers around zero.
Hum...
Bribri333
@aeperalta, You could certainly give it a shot. My main concern was not only tracking IL but understanding long term opportunity costs. For instance I was down 75k ONE which in today's dollars is a 20k opportunity cost. If you wanted, you could also use the opportunity cost calc to accumulate more of a token.
aeperalta
@Bribri333, I gave it a shot indeed. Since my comment back then, I've been coding this, backtesting it and I get almost a flat line everytime on my equity meanwhile I get to keep the yield regardless of the direction of the market.
Moreover, I was so confident of this analysis that I've put good money on it. It's working just fine. I get the yield of the pool, while Im hedging the token price variation shorting its future.
Now it's a matter of keeping an eye on the short position. If you hit the stop loss, and the same time you should liquidate your pool and spot token.
The other issues is pool rotation cost (or portfolio rotation cost). But all those figures are well known and predictable. Dont spend your yield rotating too often.
That's it. Im getting more APY than Warren Buffet and Kathy Woods combined.
Lol.

-
Bribri333
@aeperalta, How'd that work out for you?
aeperalta
@Bribri333, it's been a while. But one of my shorts got liquidated on a short squeeze. it's a risky strategy.
More