nautechsystems/nautilus_trader · error
`max_quote_age_blocks` must be in 1..=4095
Error message
`max_quote_age_blocks` must be in 1..=4095
What it means
max_quote_age_blocks bounds how stale a quote (in blocks) may be when used, and is stored in a 12-bit field, so the library enforces 1..=4095. The throws when the configured value is 0 or greater than 4095.
Source
Thrown at crates/adapters/blockchain/src/execution/client.rs:349
{
anyhow::bail!(
"Duplicate quote spend limit for token pair {token_in} -> {token_out}"
);
}
}
if slippage_bps > max_slippage_bps {
anyhow::bail!(
"`slippage_bps` {slippage_bps} exceeds `max_slippage_bps` {max_slippage_bps}"
);
}
if max_slippage_bps >= BPS_DENOMINATOR {
anyhow::bail!("`max_slippage_bps` {max_slippage_bps} must be below {BPS_DENOMINATOR}");
}
if !(1..=4_095).contains(&max_quote_age_blocks) {
anyhow::bail!("`max_quote_age_blocks` must be in 1..=4095");
}
Ok(TransactionLimits {
allowed_token_pairs: parsed_pairs,
quote_spend_limits: parsed_quote_spend_limits,
slippage_bps,
max_slippage_bps,
max_order_amount,
deadline_seconds,
max_quote_age_blocks,
receipt_timeout_secs,
})
}
fn validate_manifest_contracts(
config: &BlockchainExecutionClientConfig,
routers: &[Address],
weth: Address,View on GitHub (pinned to 18893faf8b)
Solutions
- Set max_quote_age_blocks to an integer between 1 and 4095
- Convert time-based staleness to an approximate block count for the target chain's block time
- Use 0 carefully: it is invalid; pick the smallest acceptable staleness bound instead
Example fix
// before max_quote_age_blocks = 0 // after max_quote_age_blocks = 10
Defensive patterns
Strategy: validation
Validate before calling
if !(1..=4095).contains(&cfg.max_quote_age_blocks) {
return Err(format!("max_quote_age_blocks {} must be in 1..=4095", cfg.max_quote_age_blocks));
} Prevention
- Convert desired staleness time to blocks: blocks = seconds / avg_block_time(chain)
- Never use 0 to mean 'unlimited'; pick an explicit positive bound
- Clamp or reject values at config parse time via serde range validation
When it happens
Trigger: Calling new/transaction_limits with config.max_quote_age_blocks = 0, negative (if signed at config layer), or > 4095.
Common situations: Setting 0 intending 'no limit' when the field actually requires a positive bound; entering a seconds value (e.g. 30000) where blocks are expected; large values copied from another chain's config.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- Lighter API key index must be in 0..=254
- request_rate_per_second must be greater than zero
- order_request_rate_per_second must be greater than zero
- heartbeat_secs must be positive when set
- heartbeat_timeout_secs must cover at least two server heartb
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/1ab5b941a9614dab.
Report an issue: GitHub.