nautechsystems/nautilus_trader · error
Slippage bps must be below
Error message
Slippage {slippage_bps} bps must be below {BPS_DENOMINATOR} What it means
derive_min_amount_out applies slippage_bps reduction to the quoted output and rejects slippage_bps >= BPS_DENOMINATOR (10000 bps = 100%), because 100%+ slippage is nonsensical and would make the computation invalid. The value must be strictly below the denominator.
Solutions
- Set slippage_bps to a sane value strictly below 10000 (e.g. 50 = 0.5%, 100 = 1%)
- Validate slippage_bps at config load time, before any swap is attempted
- Check unit conventions: bps not percent (1% = 100 bps)
Example fix
// before let min_out = derive_min_amount_out(quoted, 10_000)?; // after let slippage_bps = 100; // 1% assert!(slippage_bps < 10_000); let min_out = derive_min_amount_out(quoted, slippage_bps)?;
Defensive patterns
Strategy: validation
Validate before calling
const BPS_DENOMINATOR: u32 = 10_000;
if slippage_bps >= BPS_DENOMINATOR {
return Err(anyhow::anyhow!("slippage_bps must be < 10000, got {slippage_bps}"));
}
derive_min_amount_out(quoted_amount_out, slippage_bps)?; Try / catch
match derive_min_amount_out(quoted, bps) {
Ok(min) => swap(min),
Err(e) if e.to_string().contains("must be below") => fix_config_and_abort(),
Err(e) => return Err(e),
} Prevention
- Validate slippage_bps at config load time (0 < bps < 10000)
- Remember units: bps, not percent (1% = 100)
When it happens
Trigger: Calling derive_min_amount_out (via the swap execution path) with slippage_bps = 10000 or more, e.g. a config value of 10000+ bps or a percentage-vs-bps mixup (passing 100 to mean 1% is fine, but passing a fraction like 0.5 cast to u32, or passing 10000 meaning 100%).
Common situations: Config mistake: user enters 10000 (100%) or a percent value like 50 intended as 0.5%; adapter config validated too late at swap time.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- Allowed token pair -> is not fully pinned by the deployment…
- BUY quote amount exceeds the configured quote-spend maximum…
- Chain anchor ID must be nonzero
- Chain checkpoint hash must be nonzero
- Chain checkpoint hash must contain 32 hexadecimal bytes
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/3c7047c5860f0de3.
Report an issue: GitHub.
Appendix: source
Thrown at crates/adapters/blockchain/src/execution/client.rs:5288
fn exact_output_amount(quote: &SwapQuote, zero_for_one: bool) -> anyhow::Result<U256> {
let amount = if zero_for_one {
quote.amount1
} else {
quote.amount0
};
if !amount.is_negative() {
anyhow::bail!("Swap quote output amount {amount} is not a positive output");
}
Ok(amount.unsigned_abs())
}
/// Derives the minimum output accepted for the swap: the quoted output reduced by
/// `slippage_bps`, in exact integer arithmetic. Rejects a zero minimum, which would leave
/// the swap without slippage protection.
fn derive_min_amount_out(quoted_amount_out: U256, slippage_bps: u32) -> anyhow::Result<U256> {
if slippage_bps >= BPS_DENOMINATOR {
anyhow::bail!("Slippage {slippage_bps} bps must be below {BPS_DENOMINATOR}");
}
let min_amount_out = quoted_amount_out
.checked_mul(U256::from(BPS_DENOMINATOR - slippage_bps))
.and_then(|scaled| scaled.checked_div(U256::from(BPS_DENOMINATOR)))
.ok_or_else(|| anyhow::anyhow!("Minimum output derivation overflow"))?;
if min_amount_out.is_zero() {
anyhow::bail!(
"Derived minimum output is zero for quoted output {quoted_amount_out} at {slippage_bps} bps slippage"
);
}
Ok(min_amount_out)
}
impl BlockchainExecutionClient {
async fn build_execution_verification_migration(
&self,
snapshot: ExecutionVerificationMigrationSnapshot,
finalized: VerifiedBlockHeader,View on GitHub (pinned to 18893faf8b)