hl-types
Shared domain types for the motosan-hyperliquid SDK -- orders, positions, candles, errors, and signatures.
Overview
hl-types is the foundation crate that every other crate in the SDK depends on. It defines the Rust structs that map to Hyperliquid's API data model, plus a unified error type.
This crate has no network dependencies. It only uses serde for serialization and thiserror for error derivation.
Key Types
Market Data
HlCandle-- OHLCV candle withtimestamp,open,high,low,close,volumeHlOrderbook-- L2 orderbook snapshot withbids,asksasVec<(f64, f64)>HlAssetInfo-- Static asset metadata (symbol, asset ID, size/price decimals, min size)HlFundingRate-- Current funding rate and next funding time
Account
HlAccountState-- Equity, available margin, and open positionsHlPosition-- Single position with size, entry price, PnL, leverage, liquidation priceHlFill-- Trade fill with price, size, side, fee, and realized PnL
Orders
OrderWire-- Wire format for submitting orders (asset index, price, size, order type)OrderTypeWire-- Either a limit order (LimitOrderType) or trigger order (TriggerOrderType)OrderResponse-- Parsed response after order submission (order ID, fill info, status)
Signing
Signature-- ECDSA signature split intor,s(hex strings) andv(recovery byte)
Errors
HlError-- Unified error enum with variants for HTTP, API, signing, parsing, and rate limiting. Includesis_retryable()andretry_after_ms()helpers.
Usage
use ;
// Construct a limit order using the builder
let order = limit_buy
.tif
.build;
// Check if an error is retryable
let err = RateLimited ;
assert!;
assert_eq!;
Utility Functions
normalize_coin(coin)-- Strips-PERP,-USDC,-USDsuffixes from a symbol string."BTC-PERP"becomes"BTC".
License
MIT