Description
Calculate Impermanent Loss in Automated Market Maker (AMM) Liquidity Pools.
Description
Computes the key metrics for assessing the performance of a liquidity provider (LP) position in a weighted multi-asset Automated Market Maker (AMM) pool. Calculates the nominal and percentage impermanent loss (IL) by comparing the portfolio value inside the pool (based on the weighted geometric mean of price ratios) against the value of simply holding the assets outside the pool (based on the weighted arithmetic mean). The primary function, `impermanent_loss()`, incorporates the effect of earned trading fees to provide the LP's net profit and loss relative to a holding strategy, using a methodology derived from Tiruviluamala, N., Port, A., and Lewis, E. (2022) <doi:10.48550/arXiv.2203.11352>.
README.md
Quickstart
Example: 3-Asset Pool (30/20/50 weighting)
library(impermanentlosscalc)
impermanent_loss(
prices_old = c(10, 20, 40),
prices_new = c(9, 22, 35),
weights = c(0.3, 0.2, 0.5),
investment = 1000,
fees = 10,
plot = TRUE
)
⚠️ Disclaimer and Usage Agreement
This package, impermanentlosscalc, is provided for educational and informational purposes only. It is intended to help users understand the mathematical principles behind Impermanent Loss (IL) in Automated Market Makers (AMM).
It is not financial advice. The calculations are projections based on user-supplied hypothetical data and do not guarantee future results. You should always conduct your own research and consult a professional financial advisor before making any investment decisions.