nautechsystems/nautilus_trader · error

slippage_bps parameter

Error message

slippage_bps parameter {value} exceeds the u32 range

What it means

The slippage_bps custom parameter supplied with the order command cannot be represented in u32 (negative or above 2^32-1); the bounded conversion into the swap-router's slippage bound fails before the transaction is built.

Solutions

  1. Send slippage_bps as a value within u32 range (basis points, e.g. 50 = 0.5%)
  2. Convert the caller's slippage representation to basis points before submitting the order
  3. Omit the param to fall back to the configured `transaction_limits.slippage_bps`

Example fix

// before
params: {"slippage_bps": 500000000000000000000}
// after
params: {"slippage_bps": 50} // 0.5%
Defensive patterns

Strategy: validation

Validate before calling

let slippage: u64 = params.get_u64("slippage_bps")?;
if slippage > u32::MAX as u64 {
    return Err("slippage_bps must be in basis points (u32 range)".into());
}

Type guard

fn valid_slippage(v: u64) -> Option<u32> {
    u32::try_from(v).ok()
}

Try / catch

match client.submit_order(order).await {
    Err(e) if e.to_string().contains("exceeds the u32 range") => {
        order.params.remove("slippage_bps"); // fall back to configured default
        client.submit_order(order).await
    }
    r => r,
}

Prevention

When it happens

Trigger: `submit_order()` -> `prepare_swap()` with order params containing `slippage_bps` larger than 4,294,967,295 (e.g. sending raw wei-style or unconverted units).

Common situations: Passing slippage as a raw integer in a different unit (e.g. 1e18-scaled); client sends slippage in a string/big-number format; copy-pasted value from another adapter expecting different units.

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/e1b4f5b56f1ed232. Report an issue: GitHub.

Appendix: source

Thrown at crates/adapters/blockchain/src/execution/client.rs:1613

                "Token pair {token_in} -> {token_out} is not in the `allowed_token_pairs` allowlist"
            );
        }

        let base_amount = quantity_to_raw_amount(order.quantity(), base_token.decimals)?;
        if base_amount > U256::from(self.transaction_limits.max_order_amount) {
            anyhow::bail!(
                "Order amount {base_amount} exceeds the configured `max_order_amount` {}",
                self.transaction_limits.max_order_amount
            );
        }

        let slippage_bps = match cmd
            .params
            .as_ref()
            .and_then(|params| params.get_u64("slippage_bps"))
        {
            Some(value) => u32::try_from(value).map_err(|_| {
                anyhow::anyhow!("slippage_bps parameter {value} exceeds the u32 range")
            })?,
            None => self.transaction_limits.slippage_bps,
        };

        if slippage_bps > self.transaction_limits.max_slippage_bps {
            anyhow::bail!(
                "Slippage {slippage_bps} bps exceeds the configured `max_slippage_bps` {}",
                self.transaction_limits.max_slippage_bps
            );
        }

        let quote_spend_ceiling = if order.order_side() == OrderSide::Buy {
            let ceiling = self
                .transaction_limits
                .quote_spend_limits
                .get(&(token_in, token_out))
                .ok_or_else(|| {
                    anyhow::anyhow!(

View on GitHub (pinned to 18893faf8b)