Trait YieldSpace

Source
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§

Source

fn z(&self) -> FixedPoint<U256>

The share reserves.

Source

fn zeta(&self) -> I256

The share adjustment.

Source

fn y(&self) -> FixedPoint<U256>

The bond reserves.

Source

fn c(&self) -> FixedPoint<U256>

The share price.

Source

fn mu(&self) -> FixedPoint<U256>

The initial vault share price.

Source

fn t(&self) -> FixedPoint<U256>

The YieldSpace time parameter.

Provided Methods§

Source

fn ze(&self) -> Result<FixedPoint<U256>>

The effective share reserves.

Source

fn calculate_spot_price(&self) -> Result<FixedPoint<U256>>

Source

fn calculate_bonds_out_given_shares_in_down( &self, dz: FixedPoint<U256>, ) -> 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.

Source

fn calculate_shares_in_given_bonds_out_up( &self, dy: FixedPoint<U256>, ) -> Result<FixedPoint<U256>>

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.

Source

fn calculate_shares_in_given_bonds_out_down( &self, dy: FixedPoint<U256>, ) -> Result<FixedPoint<U256>>

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.

Source

fn calculate_shares_out_given_bonds_in_down( &self, dy: FixedPoint<U256>, ) -> Result<FixedPoint<U256>>

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.

Source

fn calculate_max_buy_shares_in(&self) -> Result<FixedPoint<U256>>

Calculates the share payment required to purchase the maximum amount of bonds from the pool.

Source

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.

Source

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.

Source

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.

Source

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.

Implementors§