Skip to content

Commit

Permalink
linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MazyGio committed Apr 26, 2024
1 parent 2378e6e commit eead4ce
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions crates/hyperdrive-math/src/short/open.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,16 @@ impl State {
/// $$
/// r_{implied} = \frac{r_{variable} - r_{effective}}{r_{effective}}
/// $$
///
///
/// We can short-cut this calculation using the amount of base the short
/// will pay and comparing this to the amount of base the short will receive
/// if the variable rate stays the same. The implied rate is just the ROI
/// if the variable rate stays the same.
///
///
/// To do this, we must adjust the variable rate $r_{adjusted}$ according to
/// the position duration $t$ and the variable yield source's compounding
/// frequency $f$. The adjusted rate will be:
///
///
/// $$
/// r_{adjusted} = ((1 + r_{variable})^{1/f})^{t*f}-1
/// $$
Expand All @@ -174,10 +174,9 @@ impl State {
) -> Result<I256> {
let base_paid = self.calculate_open_short(bond_amount, open_vault_share_price)?;
let base_proceeds = bond_amount
* (((fixed!(1e18) + variable_apy)
.pow(fixed!(1e18) / compounding_frequency))
.pow(self.annualized_position_duration() * compounding_frequency)
- fixed!(1e18));
* (((fixed!(1e18) + variable_apy).pow(fixed!(1e18) / compounding_frequency))
.pow(self.annualized_position_duration() * compounding_frequency)
- fixed!(1e18));
if base_proceeds > base_paid {
Ok(I256::try_from((base_proceeds - base_paid) / base_paid)?)
} else {
Expand Down

0 comments on commit eead4ce

Please sign in to comment.