Struct levana_perpswap_cosmos::contracts::market::liquidity::LiquidityStats
source · pub struct LiquidityStats {
pub locked: Collateral,
pub unlocked: Collateral,
pub total_lp: LpToken,
pub total_xlp: LpToken,
}
Expand description
Protocol wide stats on liquidity
Fields§
§locked: Collateral
Collateral locked as counter collateral in the protocol
unlocked: Collateral
Total amount of collateral available to be used as liquidity
total_lp: LpToken
Total number of LP tokens
total_xlp: LpToken
Total number of xLP tokens
Implementations§
source§impl LiquidityStats
impl LiquidityStats
sourcepub fn total_collateral(&self) -> Result<Collateral, OverflowError>
pub fn total_collateral(&self) -> Result<Collateral, OverflowError>
Total amount of locked and unlocked collateral.
sourcepub fn total_tokens(&self) -> Result<LpToken, OverflowError>
pub fn total_tokens(&self) -> Result<LpToken, OverflowError>
Total number of LP and xLP tokens
sourcepub fn lp_to_collateral(&self, lp: LpToken) -> Result<Collateral>
pub fn lp_to_collateral(&self, lp: LpToken) -> Result<Collateral>
Calculate the amount of collateral for a given number of LP tokens
This method can fail due to arithmetic overflow. It can also fail if invariants are violated, specifically if there is 0 collateral in the pool when this is called with a non-zero amount of LP.
Note that even with a non-zero input value for lp
, due to rounding
errors this function may return 0 collateral.
sourcepub fn lp_to_collateral_non_zero(
&self,
lp: NonZero<LpToken>,
) -> Result<NonZero<Collateral>>
pub fn lp_to_collateral_non_zero( &self, lp: NonZero<LpToken>, ) -> Result<NonZero<Collateral>>
Same as Self::lp_to_collateral, but treats round-to-zero as an error.
sourcepub fn collateral_to_lp(
&self,
amount: NonZero<Collateral>,
) -> Result<NonZero<LpToken>>
pub fn collateral_to_lp( &self, amount: NonZero<Collateral>, ) -> Result<NonZero<LpToken>>
Calculate how many LP tokens would be produced from the given collateral.
If there is currently no liquidity in the pool, this will use a 1:1 ratio.
Trait Implementations§
source§impl Clone for LiquidityStats
impl Clone for LiquidityStats
source§fn clone(&self) -> LiquidityStats
fn clone(&self) -> LiquidityStats
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for LiquidityStats
impl Debug for LiquidityStats
source§impl Default for LiquidityStats
impl Default for LiquidityStats
source§fn default() -> LiquidityStats
fn default() -> LiquidityStats
source§impl<'de> Deserialize<'de> for LiquidityStats
impl<'de> Deserialize<'de> for LiquidityStats
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl JsonSchema for LiquidityStats
impl JsonSchema for LiquidityStats
source§fn schema_name() -> String
fn schema_name() -> String
source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read moresource§impl PartialEq for LiquidityStats
impl PartialEq for LiquidityStats
source§fn eq(&self, other: &LiquidityStats) -> bool
fn eq(&self, other: &LiquidityStats) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl Serialize for LiquidityStats
impl Serialize for LiquidityStats
impl StructuralPartialEq for LiquidityStats
Auto Trait Implementations§
impl Freeze for LiquidityStats
impl RefUnwindSafe for LiquidityStats
impl Send for LiquidityStats
impl Sync for LiquidityStats
impl Unpin for LiquidityStats
impl UnwindSafe for LiquidityStats
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
self
to type T
. The semantics of numeric casting with the as
operator are followed, so <T as As>::as_::<U>
can be used in the same way as T as U
for numeric conversions. Read moresource§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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