Skip to main content

Module client

Module client 

Source
Expand description

Connecting to Hyperliquid: /info and /exchange over HTTP, the websocket, HyperEVM RPC, rate limits, and the Client that signs and sends.

Re-exports§

pub use api::Api;
pub use api::Clock;
pub use limit::Spent;
pub use network::L1_CHAIN_ID;
pub use network::MAINNET_HYPE;
pub use network::MAINNET_USDC;
pub use network::Network;
pub use network::TESTNET_HYPE;
pub use network::TESTNET_USDC;
pub use network::Token;
pub use network::USDC_INDEX;
pub use network::UnknownNetwork;
pub use transport::Accepted;
pub use transport::ApiError;
pub use transport::ExchangeResponse;
pub use transport::Http;
pub use transport::Method;
pub use transport::Request;
pub use transport::Response;
pub use transport::Status;
pub use transport::Transport;
pub use transport::TransportError;
pub use transport::exchange;
pub use transport::info;
pub use transport::info_request;
pub use transport::user_request;

Modules§

api
One network’s /info and /exchange behind one rate-limit gate. Api is a Transport, so every read and send passes the gate and the meter; the Http underneath knows nothing of networks.
body
The /exchange body, keys in the official Python SDK’s order. The venue reads it as JSON, so only the action’s own key order reaches a hash.
evm
HyperEVM and the Arbitrum side of the bridge: typed JSON-RPC, ABI, RLP, EIP-1559 transactions, HyperCore’s read precompiles and CoreWriter actions. Sans-IO; quantities are exact integers (U256) and amounts convert to crate::utils::Dec.
limit
Request weights against Hyperliquid’s rate limit (the docs’ “Rate limits and user limits”), the last minute’s spend, and the gate a 429 closes. No clock and no I/O: every call is handed the time.
native
HTTP and websocket for native programs: Native sends requests through reqwest on rustls, and clock is the system clock. Hand both to crate::client::Api:
network
Mainnet and testnet. Everything that differs between them is a method on Network; an action signed for one is never valid on the other, so the network is never assumed.
transport
The Transport and Http traits, and the /info and /exchange calls every read and action goes through.
web
HTTP and websocket for the browser and Workers: Web sends requests through the global fetch, clock is Date.now(), and a Feed keeps the websocket open over the global WebSocket. Hand the first two to crate::client::Api:

Structs§

Client
Reads for any module (markets::perps::meta(&client)) and, with a Signer, actions. S is () for a client that only reads.

Enums§

SendError
Why an action was not taken. An action whose answer never came (TransportError::Unreachable) may have landed, so it is never resent.