Skip to content

Commit

Permalink
feat: virtual shares in rebase impl
Browse files Browse the repository at this point in the history
  • Loading branch information
hoomp3 committed Feb 3, 2024
1 parent c69a8fe commit 9f83b21
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/math/src/traits/rebase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ pub trait Rebase {
let mut base;

// Use virtual offset approach in YieldBox to enforce a base conversion rate.
// Because we want to support at most 18 decimal fixed point math, we set the ratio to 1 : 1e18.
let total_shares = self.base() + exp10(18);
// Because we want to support at most 18 decimal fixed point math, we set the ratio to 1 : 1e19.
let total_shares = self.base() + exp10(19);
let total_amount = self.elastic() + U256::ONE;

base = muldiv(elastic, total_shares, total_amount)?;
Expand All @@ -38,8 +38,8 @@ pub trait Rebase {
let mut elastic;

// Use virtual offset approach in YieldBox to enforce a base conversion rate.
// Because we want to support at most 18 decimal fixed point math, we set the ratio to 1 : 1e18.
let total_shares = self.base() + exp10(18);
// Because we want to support at most 18 decimal fixed point math, we set the ratio to 1 : 1e19.
let total_shares = self.base() + exp10(19);
let total_amount = self.elastic() + U256::ONE;

elastic = muldiv(base, total_amount, total_shares)?;
Expand Down

0 comments on commit 9f83b21

Please sign in to comment.