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

  1. Set max_quote_age_blocks to an integer between 1 and 4095
  2. Convert time-based staleness to an approximate block count for the target chain's block time
  3. 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

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


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/1ab5b941a9614dab. Report an issue: GitHub.