Skip to content

Commit

Permalink
Merge branch 'nakul/fix_premium_redeem' of https://github.com/interla…
Browse files Browse the repository at this point in the history
…y/interbtc into nakul/fix_premium_redeem
  • Loading branch information
nakul1010 committed Dec 6, 2023
2 parents 5a00bac + a81259a commit 311d9a4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions crates/vault-registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -785,16 +785,17 @@ impl<T: Config> Pallet<T> {
// 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 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 global secure threshold, which gives:
// 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:
// 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
Expand Down

0 comments on commit 311d9a4

Please sign in to comment.