Skip to content

Commit

Permalink
add zeta adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
dpaiton committed Jul 17, 2024
1 parent 4258923 commit 94bae7c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions crates/hyperdrive-math/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl State {

/// Calculates the pool reserve levels to achieve a target interest rate.
/// This calculation does not take into account Hyperdrive's solvency
/// constraints, share adjustments, or exposure and shouldn't be used
/// constraints or exposure and shouldn't be used
/// directly.
///
/// The price for a given fixed-rate is given by
Expand All @@ -177,7 +177,7 @@ impl State {
/// For a target rate, `$r_t$`, the pool share reserves, `$z_t$`, must be:
///
/// ```math
/// z_t = \frac{1}{\mu} \left(
/// z_t = \zeta + \frac{1}{\mu} \left(
/// \frac{k}{\frac{c}{\mu} + \left(
/// (r_t \cdot t + 1)^{\frac{1}{t_s}}
/// \right)^{1 - t_{s}}}
Expand Down Expand Up @@ -208,7 +208,10 @@ impl State {
let inner = (self.k_down()?
/ (c_over_mu + scaled_rate.pow(fixed!(1e18) - self.time_stretch())?))
.pow(fixed!(1e18) / (fixed!(1e18) - self.time_stretch()))?;
let target_share_reserves = inner / self.initial_vault_share_price();
let target_effective_share_reserves = inner / self.initial_vault_share_price();
let target_share_reserves = FixedPoint::try_from(
I256::try_from(target_effective_share_reserves)? + self.share_adjustment(),
)?;

// Then get the target bond reserves.
let target_bond_reserves = inner * scaled_rate;
Expand Down
2 changes: 1 addition & 1 deletion crates/hyperdrive-math/src/long/targeted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl State {
let checkpoint_exposure = checkpoint_exposure.into();
let allowable_error = match maybe_allowable_error {
Some(allowable_error) => allowable_error.into(),
None => fixed!(1e14),
None => fixed!(1e15),
};
let current_rate = self.calculate_spot_rate()?;
if target_rate >= current_rate {
Expand Down

0 comments on commit 94bae7c

Please sign in to comment.