Skip to main content

Module meta

Module meta 

Source
Expand description

Hyperliquid’s market metadata: the coin each perpetual and spot pair is subscribed by.

A Hyperliquid subscription names its market by a coin, exactly as Hyperliquid spells it, and a wrong coin gets no data. Worse, the server closes the connection, ending every other subscription on it too. HyperliquidMeta reads the coins from Hyperliquid’s info endpoint and finds them by name:

Build the subscription’s instrument from the result with MarketInstrumentData::hyperliquid_perp or MarketInstrumentData::hyperliquid_spot.

ⓘ
use rustrade_data::{
    exchange::hyperliquid::{HyperliquidMeta, Network},
    instrument::MarketInstrumentData,
};

// The default perpetuals and spot pairs, plus builder deployer `xyz`'s perpetuals.
let meta = HyperliquidMeta::fetch(Network::Mainnet, &["xyz"]).await?;

let pepe = meta.perp_coin("KPEPE").ok_or("no such perpetual")?;
let tsla = meta.perp_coin("xyz:TSLA").ok_or("no such perpetual")?;
let hype = meta.spot_pair("HYPE", "USDC").ok_or("no such pair")?;

let perps = [
    MarketInstrumentData::hyperliquid_perp(0, pepe),
    MarketInstrumentData::hyperliquid_perp(1, tsla),
];
let spot = MarketInstrumentData::hyperliquid_spot(2, hype);

§Snapshot

A HyperliquidMeta is what the info endpoint listed when it was read. A market listed since is missing from it, so read it again to find one.

Structs§

HyperliquidMeta
Hyperliquid’s perpetuals and spot pairs, read from its info endpoint. See the module docs.

Enums§

HyperliquidMetaError
Why HyperliquidMeta::fetch failed.