pub struct PerpInfo {
Show 16 fields pub perp_market_index: PerpMarketIndex, pub settle_token_index: TokenIndex, pub maint_base_asset_weight: I80F48, pub init_base_asset_weight: I80F48, pub maint_base_liab_weight: I80F48, pub init_base_liab_weight: I80F48, pub maint_overall_asset_weight: I80F48, pub init_overall_asset_weight: I80F48, pub base_lot_size: i64, pub base_lots: i64, pub bids_base_lots: i64, pub asks_base_lots: i64, pub quote: I80F48, pub base_prices: Prices, pub has_open_orders: bool, pub has_open_fills: bool,
}
Expand description

Stores information about perp market positions and their open orders.

Perp markets affect account health indirectly, though the token balance in the perp market’s settle token. See effective_token_balances().

Fields

perp_market_index: PerpMarketIndexsettle_token_index: TokenIndexmaint_base_asset_weight: I80F48init_base_asset_weight: I80F48maint_base_liab_weight: I80F48init_base_liab_weight: I80F48maint_overall_asset_weight: I80F48init_overall_asset_weight: I80F48base_lot_size: i64base_lots: i64bids_base_lots: i64asks_base_lots: i64quote: I80F48base_prices: Priceshas_open_orders: boolhas_open_fills: bool

Implementations

The perp-risk (but not token-risk) adjusted upnl. Also called “hupnl”.

In settle token native units.

This is what gets added to effective_token_balances() and then contributes to account health.

For fully isolated perp markets, users may never borrow against unsettled positive perp pnl, there overall_asset_weight == 0 and there can’t be positive health contributions from these perp market. We sometimes call these markets “untrusted markets”.

In these, users need to settle their perp pnl with other perp market participants in order to realize their gains if they want to use them as collateral.

This is because we don’t trust the perp’s base price to not suddenly jump to zero (if users could borrow against their perp balances they might now be bankrupt) or suddenly increase a lot (if users could borrow against perp balances they could now borrow other assets).

Other markets may be liquid enough that we have enough confidence to allow users to borrow against unsettled positive pnl to some extend. In these cases, the overall asset weights would be >0.

Settle token native provided by perp position and open orders, without the overall asset weight.

Also called “uhupnl”.

For open orders, this computes the worst-case amount by considering the scenario where all bids execute and the one where all asks execute.

It’s always less than the PerpPosition’s unsettled_pnl() for two reasons: The open orders are taken into account and the base weight is applied to the base position.

Generally: hupnl <= uhupnl <= upnl

Trait Implementations

Deserializes this instance from a given slice of bytes. Updates the buffer to point at the remaining bytes. Read more
Deserialize this instance from a slice of bytes.
Serialize this instance into a vector of bytes.
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Casts the value.
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Casts the value.
Casts the value.
Casts the value.

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

Performs the conversion.
Performs the conversion.
Casts the value.
Casts the value.
The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
Casts the value.
Casts the value.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Casts the value.
Casts the value.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Casts the value.
Casts the value.