Skip to main content

Module rate_limiter

Module rate_limiter 

Source
Expand description

Rate limiters for the Hyperliquid REST API.

§IP-based (RestRateLimiter)

Tracks an aggregated weight budget of 1 200 per minute in a 60-second sliding window.

§Address-based (AddressRateLimiter)

Tracks the per-address action budget. Each address starts with 10 000 requests and accrues 1 request per 1 USDC traded. When exhausted, 1 request is allowed every 10 seconds. Cancels use a higher limit: min(limit + 100_000, limit * 2). A batch of n orders/cancels counts as n requests against this limit.

§Interface

Both limiters share the same interface:

  • acquire(...)Result<(), RateLimitError> — returns Err immediately if throttled.
  • acquire_blocking(...) — retries on Err, logging each wait via tracing::warn.

Structs§

AddressRateLimiter
Tracks the per-address action budget.
RateLimitError
RestRateLimiter

Constants§

ADDR_INITIAL_BUFFER
MAX_WEIGHT