library(impermanentlosscalc)
library(ggplot2)
# Example 1: 3-Asset Unbalanced Pool (Weights: 30/20/50)
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
)
# Example 2: No price change, demonstrating IL is zero.
impermanent_loss(
prices_old = c(3, 3),
prices_new = c(3, 3),
weights = c(0.5, 0.5),
investment = 500,
fees = 0
)
Run the code above in your browser using DataLab