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: PerpMarketIndex
settle_token_index: TokenIndex
maint_base_asset_weight: I80F48
init_base_asset_weight: I80F48
maint_base_liab_weight: I80F48
init_base_liab_weight: I80F48
maint_overall_asset_weight: I80F48
init_overall_asset_weight: I80F48
base_lot_size: i64
base_lots: i64
bids_base_lots: i64
asks_base_lots: i64
quote: I80F48
base_prices: Prices
has_open_orders: bool
has_open_fills: bool
Implementations
sourceimpl PerpInfo
impl PerpInfo
sourcepub fn health_unsettled_pnl(&self, health_type: HealthType) -> I80F48
pub fn health_unsettled_pnl(&self, health_type: HealthType) -> I80F48
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.
sourcepub fn unweighted_health_unsettled_pnl(&self, health_type: HealthType) -> I80F48
pub fn unweighted_health_unsettled_pnl(&self, health_type: HealthType) -> I80F48
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