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:
HyperliquidMeta::perp_cointakes a perpetual’s name in any ASCII case and returns the venue’s spelling (KPEPEfindskPEPE).HyperliquidMeta::spot_pairtakes a pair’s base and quote tokens (HYPE,USDC) and returns its coin (@107).
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§
- Hyperliquid
Meta - Hyperliquid’s perpetuals and spot pairs, read from its info endpoint. See the module docs.
Enums§
- Hyperliquid
Meta Error - Why
HyperliquidMeta::fetchfailed.