pub trait YieldSpace {
Show 17 methods
// Required methods
fn z(&self) -> FixedPoint<U256>;
fn zeta(&self) -> I256;
fn y(&self) -> FixedPoint<U256>;
fn c(&self) -> FixedPoint<U256>;
fn mu(&self) -> FixedPoint<U256>;
fn t(&self) -> FixedPoint<U256>;
// Provided methods
fn ze(&self) -> Result<FixedPoint<U256>> { ... }
fn calculate_spot_price(&self) -> Result<FixedPoint<U256>> { ... }
fn calculate_bonds_out_given_shares_in_down(
&self,
dz: FixedPoint<U256>,
) -> Result<FixedPoint<U256>> { ... }
fn calculate_shares_in_given_bonds_out_up(
&self,
dy: FixedPoint<U256>,
) -> Result<FixedPoint<U256>> { ... }
fn calculate_shares_in_given_bonds_out_down(
&self,
dy: FixedPoint<U256>,
) -> Result<FixedPoint<U256>> { ... }
fn calculate_shares_out_given_bonds_in_down(
&self,
dy: FixedPoint<U256>,
) -> Result<FixedPoint<U256>> { ... }
fn calculate_max_buy_shares_in(&self) -> Result<FixedPoint<U256>> { ... }
fn calculate_max_buy_bonds_out(&self) -> Result<FixedPoint<U256>> { ... }
fn calculate_max_sell_bonds_in(
&self,
z_min: FixedPoint<U256>,
) -> Result<FixedPoint<U256>> { ... }
fn k_up(&self) -> Result<FixedPoint<U256>> { ... }
fn k_down(&self) -> Result<FixedPoint<U256>> { ... }
}
Required Methods§
Sourcefn z(&self) -> FixedPoint<U256>
fn z(&self) -> FixedPoint<U256>
The share reserves.
Sourcefn y(&self) -> FixedPoint<U256>
fn y(&self) -> FixedPoint<U256>
The bond reserves.
Sourcefn c(&self) -> FixedPoint<U256>
fn c(&self) -> FixedPoint<U256>
The share price.
Sourcefn mu(&self) -> FixedPoint<U256>
fn mu(&self) -> FixedPoint<U256>
The initial vault share price.
Sourcefn t(&self) -> FixedPoint<U256>
fn t(&self) -> FixedPoint<U256>
The YieldSpace time parameter.
Provided Methods§
Sourcefn ze(&self) -> Result<FixedPoint<U256>>
fn ze(&self) -> Result<FixedPoint<U256>>
The effective share reserves.
fn calculate_spot_price(&self) -> Result<FixedPoint<U256>>
Calculates the amount of bonds a user will receive from the pool by providing a specified amount of shares. We underestimate the amount of bonds out to prevent sandwiches.
Calculates the amount of shares a user must provide the pool to receive a specified amount of bonds. We overestimate the amount of shares in.
Calculates the amount of shares a user must provide the pool to receive a specified amount of bonds. We underestimate the amount of shares in.
Calculates the amount of shares a user will receive from the pool by providing a specified amount of bonds. This function reverts if an integer overflow or underflow occurs. We underestimate the amount of shares out.
Calculates the share payment required to purchase the maximum amount of bonds from the pool.
Sourcefn calculate_max_buy_bonds_out(&self) -> Result<FixedPoint<U256>>
fn calculate_max_buy_bonds_out(&self) -> Result<FixedPoint<U256>>
Calculates the maximum amount of bonds that can be purchased with the specified reserves. We round so that the max buy amount is underestimated.
Sourcefn calculate_max_sell_bonds_in(
&self,
z_min: FixedPoint<U256>,
) -> Result<FixedPoint<U256>>
fn calculate_max_sell_bonds_in( &self, z_min: FixedPoint<U256>, ) -> Result<FixedPoint<U256>>
Calculates the maximum amount of bonds that can be sold with the specified reserves. We round so that the max sell amount is underestimated.
Sourcefn k_up(&self) -> Result<FixedPoint<U256>>
fn k_up(&self) -> Result<FixedPoint<U256>>
Calculates the YieldSpace invariant k. This invariant is given by:
k = (c / µ) * (µ * ze)^(1 - t) + y^(1 - t)
This variant of the calculation overestimates the result.
Sourcefn k_down(&self) -> Result<FixedPoint<U256>>
fn k_down(&self) -> Result<FixedPoint<U256>>
Calculates the YieldSpace invariant k. This invariant is given by:
k = (c / µ) * (µ * ze)^(1 - t) + y^(1 - t)
This variant of the calculation underestimates the result.