Struct PoolDelta

Source
pub struct PoolDelta<T: Unsigned> { /* private fields */ }
Expand description

Delta of pool usd values.

Implementations§

Source§

impl<T: Unsigned> PoolDelta<T>

Source

pub fn try_new<P>( pool: &P, delta_long_token_usd_value: T::Signed, delta_short_token_usd_value: T::Signed, long_token_price: &T, short_token_price: &T, ) -> Result<Self>
where T: CheckedAdd + CheckedSub + CheckedMul, P: Balance<Num = T, Signed = T::Signed> + ?Sized,

Create a new PoolDelta.

Source

pub fn try_from_delta_amounts<P>( pool: &P, long_delta_amount: &T::Signed, short_delta_amount: &T::Signed, long_token_price: &T, short_token_price: &T, ) -> Result<Self>
where T: CheckedAdd + CheckedSub + CheckedMul, P: Balance<Num = T, Signed = T::Signed> + ?Sized,

Create a new PoolDelta.

Source

pub fn delta(&self) -> &PoolValue<T::Signed>

Get delta values.

Source§

impl<T: Unsigned + Clone + Ord> PoolDelta<T>

Source

pub fn initial_diff_value(&self) -> T

Initial diff usd value.

Source

pub fn next_diff_value(&self) -> T

Next diff usd value.

Source

pub fn is_same_side_rebalance(&self) -> bool

Returns whether it is a same side rebalance.

Source

pub fn price_impact<const DECIMALS: u8>( &self, params: &PriceImpactParams<T>, ) -> Result<T::Signed>
where T: FixedPointOps<DECIMALS>,

Calculate price impact.

Auto Trait Implementations§

§

impl<T> Freeze for PoolDelta<T>
where T: Freeze, <T as Unsigned>::Signed: Freeze,

§

impl<T> RefUnwindSafe for PoolDelta<T>

§

impl<T> Send for PoolDelta<T>
where T: Send, <T as Unsigned>::Signed: Send,

§

impl<T> Sync for PoolDelta<T>
where T: Sync, <T as Unsigned>::Signed: Sync,

§

impl<T> Unpin for PoolDelta<T>
where T: Unpin, <T as Unsigned>::Signed: Unpin,

§

impl<T> UnwindSafe for PoolDelta<T>
where T: UnwindSafe, <T as Unsigned>::Signed: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V