Skip to main content

Module spot

Module spot 

Source
Expand description

Hyperliquid spot trading ExecutionClient implementation.

Uses the same hyperliquid_rust_sdk clients as the perpetuals client, but with spot-specific endpoints and data handling.

§Differences from Perpetuals

  • Coin naming: Spot uses pair format "PURR/USDC" vs symbol-only "BTC" for perps
  • Asset indices: Spot uses 10000+ (vs 0-9999 for perps)
  • Balances: Uses user_token_balances() instead of user_state() margin summary
  • No positions: Spot has no margin/leverage concepts
  • $10 minimum: Spot orders require minimum $10 notional value

§Unified Account Model

Hyperliquid uses a unified account model:

  • Spot balances count as perpetual collateral
  • Separate wallets within the unified account (explicit transfer required)
  • Perpetual liquidation cannot sweep spot holdings

§WebSocket Events

UserFills and OrderUpdates subscriptions deliver both spot and perp events, intermingled in the same stream. Events are filtered by coin name format:

  • Spot coins contain / (e.g., "PURR/USDC")
  • Perp coins are single symbols (e.g., "BTC")

If a user has both perp and spot clients for the same wallet, events will be duplicated. Consumers should use one client type per account, or deduplicate externally.

§Conditional Orders (Stop, TakeProfit)

See super module documentation for conditional order support details. The same constraints apply to spot:

Structs§

HyperliquidSpotClient
Hyperliquid spot trading execution client.