diff --git a/crates/redeem/src/lib.rs b/crates/redeem/src/lib.rs index f0e2c50396..0ab97d3316 100644 --- a/crates/redeem/src/lib.rs +++ b/crates/redeem/src/lib.rs @@ -517,7 +517,20 @@ impl Pallet { ext::fee::get_premium_redeem_fee::(&premium_tokens_in_collateral)? } else { - // Formula = max_premium_collateral = (FEE * (oldTokens * EXCH * SECURE - oldCol)) / (SECURE - FEE) + // The goal of premium redeems is to get the vault back the a healthy collateralization ratio. As such, + // we only award a premium for the amount of tokens required to get the vault back to secure threshold. + // The CollateralizationRate is defined as `totalCollateral / convertToCollateral(totalTokens)` + // When paying a premium, the collateralization rate gets updated according to the following formula: + // `NewCollateralization = (oldCol - awardedPremium) / ( oldTokens*EXCH - awardedPremium/FEE)` + // To calculate the maximum premium we are willing to pay, we set the newCollateralization to + // the secure threshold, which gives: + // `SECURE = (oldCol - awardedPremium) / (oldTokens*EXCH - awardedPremium/FEE)`` + // We can rewrite this formula to calculate the `premium` amount that would get us to the secure threshold: + // `maxPremium = (oldTokens * EXCH * SECURE - oldCol) * (FEE / (SECURE - FEE))` + // Which can be interpreted as: + // `maxPremium = missingCollateral * (FEE / (SECURE - FEE)) + // Note that to prevent repeated premium redeems while waiting for execution, we use to_be_backed_tokens + // for `oldCol`, which takes into account pending issues and redeems let backing_collateral = ext::vault_registry::get_backing_collateral(&vault_id)?;