MarketId type provides a type-safe way to identify and work with Drift markets.
Type Definition
index- The numeric index of the market (0-65535)kind- The type of market (Perp or Spot)
Constructors
new
Create a new MarketId from parts.
perp
Create a perp market ID.
spot
Create a spot market ID.
Constants
QUOTE_SPOT
The USDC spot market (market index 0).
Methods
index
Get the market index.
kind
Get the market type.
to_parts
Convert the MarketId into its component parts.
is_perp
Check if this is a perp market.
is_spot
Check if this is a spot market.
Traits
Debug
MarketId implements Debug with a human-readable format.
Format:
- Perp markets:
perp/{index} - Spot markets:
spot/{index}
From<(u16, MarketType)>
Convert a tuple into a MarketId.
Other Traits
MarketId also implements:Copy- Can be copiedClone- Can be clonedDefault- Defaults toMarketId { index: 0, kind: MarketType::Perp }PartialEq- Can be compared for equalityEq- Full equalityHash- Can be used as a hash map key