Expand description
Rate-limit quotas and keys for the Derive adapter.
Derive runs a fixed-window limiter that replenishes the request allowance every five seconds, splitting traffic into matching-engine actions (order create/cancel/replace) and everything else (“non-matching”: market-data reads, channel subscriptions, login). Matching limits are per account and tiered (Trader vs Market Maker); the non-matching limit is a flat per-IP allowance. See https://docs.derive.xyz/reference/rate-limits.
The nautilus_network limiter is GCRA-based, so each quota is expressed as a
sustained per-second rate with a burst capacity of five seconds’ worth of
cells. That reproduces Derive’s “5x burst, replenished every 5 seconds”
model: a full burst of tps * 5 cells drains, then refills one cell every
1 / tps seconds (five seconds to refill the whole burst).
Constants§
- DERIVE_
DEFAULT_ MATCHING_ TPS - Default matching-engine allowance for a Trader-tier account (requests per
second). Market Maker accounts negotiate higher limits and raise this via
crate::config::DeriveExecClientConfig::max_matching_requests_per_second. - DERIVE_
MATCHING_ RATE_ KEY - Rate-limit key for matching-engine requests (order create/cancel/replace).
- DERIVE_
NON_ MATCHING_ RATE_ KEY - Rate-limit key for non-matching requests (reads, subscriptions, login).
- DERIVE_
NON_ MATCHING_ TPS - Flat non-matching allowance per IP (requests per second).
- DERIVE_
RATE_ BURST_ MULTIPLIER - Burst multiplier: Derive permits five seconds’ worth of requests in a single burst before the fixed window replenishes.
Functions§
- matching_
quota - Builds the matching-engine quota for
max_requests_per_second, falling back toDERIVE_DEFAULT_MATCHING_TPSwhen unset or zero. - non_
matching_ quota - Builds the flat non-matching quota (
DERIVE_NON_MATCHING_TPS).