Skip to main content

HyperliquidMarket

Enum HyperliquidMarket 

Source
pub enum HyperliquidMarket {
    Perp {
        base: String,
        quote: String,
        index: u32,
        instrument_meta: Option<InstrumentMetaConfig>,
    },
    Spot {
        base: String,
        quote: String,
        index: u32,
        instrument_meta: Option<InstrumentMetaConfig>,
    },
    Hip3 {
        base: String,
        quote: String,
        dex: String,
        dex_index: u32,
        asset_index: u32,
        instrument_meta: Option<InstrumentMetaConfig>,
    },
    Outcome {
        name: String,
        outcome_id: u32,
        side: u8,
        instrument_meta: Option<InstrumentMetaConfig>,
    },
}
Expand description

Hyperliquid market types — Perp, Spot, HIP-3, or Outcome.

Variants§

§

Perp

Standard perpetual contract on main Hyperliquid.

Fields

§base: String

Base asset (e.g., “BTC”, “ETH”)

§quote: String

Quote asset (always “USDC” for main perps)

§index: u32

Asset index on Hyperliquid (e.g., 0 for BTC)

§instrument_meta: Option<InstrumentMetaConfig>

Instrument metadata (tick/lot sizes)

§

Spot

Spot market on Hyperliquid.

Fields

§base: String

Base asset (e.g., “HYPE”, “PURR”)

§quote: String

Quote asset (e.g., “USDC”)

§index: u32

Spot market index (e.g., 10107 for HYPE/USDC)

§instrument_meta: Option<InstrumentMetaConfig>

Instrument metadata (tick/lot sizes)

§

Hip3

HIP-3 builder-deployed perpetual DEX.

Fields

§base: String

Base asset (e.g., “BTC”, “HFUN”)

§quote: String

Quote currency (e.g., “USDC”, “USDE”, “USDH”)

§dex: String

DEX name (e.g., “hyna”, “hypurrfun”)

§dex_index: u32

DEX index in perpDexs() array (starts at 1)

§asset_index: u32

Asset index within this DEX’s meta.universe

§instrument_meta: Option<InstrumentMetaConfig>

Instrument metadata (tick/lot sizes)

§

Outcome

Prediction market outcome.

Outcomes trade like spot but use asset ID = 100_000_000 + encoding, where encoding = 10 * outcome_id + side. Live outcome books quote in USDH.

Fields

§name: String

Human-readable name (e.g., “BTC > 69070”)

§outcome_id: u32

Outcome ID from outcomeMeta (e.g., 516)

§side: u8

Side: 0 = Yes, 1 = No

§instrument_meta: Option<InstrumentMetaConfig>

Instrument metadata (tick/lot sizes)

Implementations§

Source§

impl HyperliquidMarket

Source

pub fn outcome_encoding(outcome_id: u32, side: u8) -> u32

Calculate the encoding for an outcome: 10 * outcome_id + side.

Source

pub fn instrument_id(&self) -> InstrumentId

Get the canonical instrument ID.

Source

pub fn market_index(&self) -> MarketIndex

Get the market index.

Source

pub fn is_spot(&self) -> bool

Check if this is a spot market.

Source

pub fn is_spot_like(&self) -> bool

Check if this market settles like spot with no margin/leverage.

Source

pub fn is_outcome(&self) -> bool

Check if this is a prediction market outcome.

Source

pub fn base(&self) -> &str

Get the base asset.

Source

pub fn quote(&self) -> &str

Get the quote asset.

Source

pub fn effective_asset_id(&self) -> u32

Get the effective asset ID for order placement.

  • Perp: returns the index directly
  • Spot: returns the index directly (e.g., 10107)
  • Hip3: calculates 110000 + ((dex_index-1) * 10000) + asset_index
  • Outcome: returns 100_000_000 + encoding
Source

pub fn coin_name(&self) -> Option<String>

Get the coin name used in allMids/fills lookups.

  • Outcome: #<encoding> (e.g., #5160)
  • Spot: base coin name (e.g., HYPE)
  • Others: None (uses standard name)
Source

pub fn spot_coin(&self) -> Option<String>

Get the spot coin name for @tokenId alias resolution.

Source

pub fn spot_market_index(&self) -> Option<u32>

Get the spot market index for price lookups.

Source

pub fn hip3_config(&self) -> Option<Hip3MarketConfig>

Get HIP-3 configuration if applicable.

Source

pub fn uses_alternate_collateral(&self) -> bool

Check if this HIP-3 market uses non-USDC collateral.

Source

pub fn dex_name(&self) -> Option<&str>

Get the DEX name for API calls (None for non-HIP3).

Source

pub fn instrument_meta(&self) -> Option<&InstrumentMetaConfig>

Get instrument metadata if configured.

Source

pub fn price_bounds(&self) -> Option<(Decimal, Decimal)>

Optional exclusive price bounds for markets with bounded price domains.

Source

pub fn validation_errors(&self) -> Vec<String>

Validate Hyperliquid market-specific invariants.

Trait Implementations§

Source§

impl Clone for HyperliquidMarket

Source§

fn clone(&self) -> HyperliquidMarket

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HyperliquidMarket

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for HyperliquidMarket

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl JsonSchema for HyperliquidMarket

Source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
Source§

impl Serialize for HyperliquidMarket

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.