#[repr(C)]
pub struct PerpMarket {
Show 48 fields pub group: Pubkey, pub settle_token_index: TokenIndex, pub perp_market_index: PerpMarketIndex, pub blocked1: u8, pub group_insurance_fund: u8, pub bump: u8, pub base_decimals: u8, pub name: [u8; 16], pub bids: Pubkey, pub asks: Pubkey, pub event_queue: Pubkey, pub oracle: Pubkey, pub oracle_config: OracleConfig, pub stable_price_model: StablePriceModel, pub quote_lot_size: i64, pub base_lot_size: i64, 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 open_interest: i64, pub seq_num: u64, pub registration_time: u64, pub min_funding: I80F48, pub max_funding: I80F48, pub impact_quantity: i64, pub long_funding: I80F48, pub short_funding: I80F48, pub funding_last_updated: u64, pub base_liquidation_fee: I80F48, pub maker_fee: I80F48, pub taker_fee: I80F48, pub fees_accrued: I80F48, pub fees_settled: I80F48, pub fee_penalty: f32, pub settle_fee_flat: f32, pub settle_fee_amount_threshold: f32, pub settle_fee_fraction_low_health: f32, pub settle_pnl_limit_factor: f32, pub padding3: [u8; 4], pub settle_pnl_limit_window_size_ts: u64, pub reduce_only: u8, pub force_close: u8, pub padding4: [u8; 6], pub maint_overall_asset_weight: I80F48, pub init_overall_asset_weight: I80F48, pub positive_pnl_liquidation_fee: I80F48, pub reserved: [u8; 1888],
}

Fields

group: Pubkeysettle_token_index: TokenIndex

Token index that settlements happen in.

Currently required to be 0, USDC. In the future settlement may be allowed to happen in other tokens.

perp_market_index: PerpMarketIndex

Index of this perp market. Other data, like the MangoAccount’s PerpPosition reference this market via this index. Unique for this group’s perp markets.

blocked1: u8

Field used to contain the trusted_market flag and is now unused.

group_insurance_fund: u8

Is this market covered by the group insurance fund?

bump: u8

PDA bump

base_decimals: u8

Number of decimals used for the base token.

Used to convert the oracle’s price into a native/native price.

name: [u8; 16]

Name. Trailing zero bytes are ignored.

bids: Pubkey

Address of the BookSide account for bids

asks: Pubkey

Address of the BookSide account for asks

event_queue: Pubkey

Address of the EventQueue account

oracle: Pubkey

Oracle account address

oracle_config: OracleConfig

Oracle configuration

stable_price_model: StablePriceModel

Maintains a stable price based on the oracle price that is less volatile.

quote_lot_size: i64

Number of quote native in a quote lot. Must be a power of 10.

Primarily useful for increasing the tick size on the market: A lot price of 1 becomes a native price of quote_lot_size/base_lot_size becomes a ui price of quote_lot_size*base_decimals/base_lot_size/quote_decimals.

base_lot_size: i64

Number of base native in a base lot. Must be a power of 10.

Example: If base decimals for the underlying asset is 6, base lot size is 100 and and base position lots is 10_000 then base position native is 1_000_000 and base position ui is 1.

maint_base_asset_weight: I80F48

These weights apply to the base position. The quote position has no explicit weight (but may be covered by the overall pnl asset weight).

init_base_asset_weight: I80F48maint_base_liab_weight: I80F48init_base_liab_weight: I80F48open_interest: i64

Number of base lot pairs currently active in the market. Always >= 0.

seq_num: u64

Total number of orders seen

registration_time: u64

Timestamp in seconds that the market was registered at.

min_funding: I80F48

Minimal funding rate per day, must be <= 0.

max_funding: I80F48

Maximal funding rate per day, must be >= 0.

impact_quantity: i64

For funding, get the impact price this many base lots deep into the book.

long_funding: I80F48

Current long funding value. Increasing it means that every long base lot needs to pay that amount of quote native in funding.

PerpPosition uses and tracks it settle funding. Updated by the perp keeper instruction.

short_funding: I80F48

See long_funding.

funding_last_updated: u64

timestamp that funding was last updated in

base_liquidation_fee: I80F48

Fees Fee for base position liquidation

maker_fee: I80F48

Fee when matching maker orders. May be negative.

taker_fee: I80F48

Fee for taker orders, may not be negative.

fees_accrued: I80F48

Fees accrued in native quote currency

fees_settled: I80F48

Fees settled in native quote currency

fee_penalty: f32

Fee (in quote native) to charge for ioc orders

settle_fee_flat: f32

In native units of settlement token, given to each settle call above the settle_fee_amount_threshold.

settle_fee_amount_threshold: f32

Pnl settlement amount needed to be eligible for the flat fee.

settle_fee_fraction_low_health: f32

Fraction of pnl to pay out as fee if +pnl account has low health.

settle_pnl_limit_factor: f32

Controls the strictness of the settle limit. Set to a negative value to disable the limit.

This factor applies to the settle limit in two ways

  • for the unrealized pnl settle limit, the factor is multiplied with the stable perp base value (i.e. limit_factor * base_native * stable_price)
  • when increasing the realized pnl settle limit (stored per PerpPosition), the factor is multiplied with the stable value of the perp pnl being realized (i.e. limit_factor * reduced_native * stable_price)

See also PerpPosition::settle_pnl_limit_realized_trade

padding3: [u8; 4]settle_pnl_limit_window_size_ts: u64

Window size in seconds for the perp settlement limit

reduce_only: u8

If true, users may no longer increase their market exposure. Only actions that reduce their position are still allowed.

force_close: u8padding4: [u8; 6]maint_overall_asset_weight: I80F48

Weights for full perp market health, if positive

init_overall_asset_weight: I80F48positive_pnl_liquidation_fee: I80F48reserved: [u8; 1888]

Implementations

Use current order book price and index price to update the instantaneous funding

Convert from the price stored on the book to the price used in value calculations

Is native_price an acceptable order for the side of this market, given oracle_price?

Socialize the loss in this account across all longs and shorts

loss is in settle token native units

Returns the fee for settling settlement when the negative-pnl side has the given health values.

Creates default market for tests

Trait Implementations

Deserializes previously initialized account data. Should fail for all uninitialized accounts, where the bytes are zeroed. Implementations should be unique to a particular account type so that one can never successfully deserialize the data of one account type into another. For example, if the SPL token program were to implement this trait, it should be impossible to deserialize a Mint account into a token Account. Read more
Deserializes account data without checking the account discriminator. This should only be used on account initialization, when the bytes of the account are zeroed. Read more
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.
Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern. Read more
If this function returns true, then it must be valid to reinterpret bits as &Self. Read more
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.