pub struct MarketState {
pub cum_funding_rate_long: IFixed,
pub cum_funding_rate_short: IFixed,
pub funding_last_upd_ms: u64,
pub premium_twap: IFixed,
pub premium_twap_last_upd_ms: u64,
pub spread_twap: IFixed,
pub spread_twap_last_upd_ms: u64,
pub gas_price_mean: IFixed,
pub gas_price_variance: IFixed,
pub gas_price_last_upd_ms: u64,
pub open_interest: IFixed,
pub fees_accrued: IFixed,
}Expand description
The state of a perpetuals market.
Fields§
§cum_funding_rate_long: IFixedThe latest cumulative funding premium in this market for longs. Must be updated periodically.
cum_funding_rate_short: IFixedThe latest cumulative funding premium in this market for shorts. Must be updated periodically.
funding_last_upd_ms: u64The timestamp (millisec) of the latest cumulative funding premium update (both longs and shorts).
The last calculated funding premium TWAP (used for funding settlement).
The timestamp (millisec) of the last update of premium_twap.
spread_twap: IFixedThe last calculated spread TWAP (used for liquidations). Spread is (book - index).
spread_twap_last_upd_ms: u64The timestamp (millisec) of spread_twap last update.
gas_price_mean: IFixedGas price TWAP mean. It is used to calculate the penalty to add to taker fees based on the Z-score of the current gas price relative to the smoothed mean and variance.
gas_price_variance: IFixedGas price TWAP variance. It is used to calculate the penalty to add to taker fees based on the Z-score of the current gas price relative to the smoothed mean and variance.
gas_price_last_upd_ms: u64The timestamp (millisec) of the last update of gas_price_mean and gas_price_variance.
open_interest: IFixedOpen interest (in base tokens) as a fixed-point number. Counts the total size of contracts as the sum of all long positions.
fees_accrued: IFixedTotal amount of fees accrued by this market (in T’s units) Only admin can withdraw these fees.
Implementations§
Source§impl MarketState
impl MarketState
Sourcepub fn unrealized_funding(&self, pos: &Position) -> IFixed
pub fn unrealized_funding(&self, pos: &Position) -> IFixed
Convenience method for computing a position’s unrealized funding.
Forwards to Position::unrealized_funding.
Source§impl MarketState
impl MarketState
Sourcepub fn new(
cum_funding_rate_long: IFixed,
cum_funding_rate_short: IFixed,
funding_last_upd_ms: u64,
premium_twap: IFixed,
premium_twap_last_upd_ms: u64,
spread_twap: IFixed,
spread_twap_last_upd_ms: u64,
gas_price_mean: IFixed,
gas_price_variance: IFixed,
gas_price_last_upd_ms: u64,
open_interest: IFixed,
fees_accrued: IFixed,
) -> Self
pub fn new( cum_funding_rate_long: IFixed, cum_funding_rate_short: IFixed, funding_last_upd_ms: u64, premium_twap: IFixed, premium_twap_last_upd_ms: u64, spread_twap: IFixed, spread_twap_last_upd_ms: u64, gas_price_mean: IFixed, gas_price_variance: IFixed, gas_price_last_upd_ms: u64, open_interest: IFixed, fees_accrued: IFixed, ) -> Self
Constructs a new MarketState.
Source§impl MarketState
impl MarketState
pub fn move_instance(self, address: Address) -> MoveInstance<Self>
pub fn type_(address: Address) -> MarketStateTypeTag
Trait Implementations§
Source§impl Clone for MarketState
impl Clone for MarketState
Source§fn clone(&self) -> MarketState
fn clone(&self) -> MarketState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MarketState
impl Debug for MarketState
Source§impl<'de> Deserialize<'de> for MarketState
impl<'de> Deserialize<'de> for MarketState
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 Display for MarketState
impl Display for MarketState
Source§impl Hash for MarketState
impl Hash for MarketState
Source§impl MoveStruct for MarketState
impl MoveStruct for MarketState
Source§impl MoveType for MarketState
impl MoveType for MarketState
Source§impl PartialEq for MarketState
impl PartialEq for MarketState
Source§impl Serialize for MarketState
impl Serialize for MarketState
Source§impl StaticModule for MarketState
impl StaticModule for MarketState
fn module() -> Identifier
Source§impl StaticName for MarketState
impl StaticName for MarketState
fn name() -> Identifier
Source§impl StaticTypeParams for MarketState
impl StaticTypeParams for MarketState
fn type_params() -> Vec<TypeTag>
Source§impl Tabled for MarketState
impl Tabled for MarketState
impl Eq for MarketState
impl StructuralPartialEq for MarketState
Auto Trait Implementations§
impl Freeze for MarketState
impl RefUnwindSafe for MarketState
impl Send for MarketState
impl Sync for MarketState
impl Unpin for MarketState
impl UnwindSafe for MarketState
Blanket Implementations§
Source§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§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<'de, T> FromBcs for Twhere
T: Deserialize<'de>,
impl<'de, T> FromBcs for Twhere
T: Deserialize<'de>,
fn from_bcs<'de>(bytes: &'de [u8]) -> Result<Self, Error>where
Self: Deserialize<'de>,
fn from_bcs_base64(base64: &str) -> Result<Self, Error>where
Self: DeserializeOwned,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.