{"record":{"id":"3c7047c5860f0de3","repo":"nautechsystems/nautilus_trader","slug":"slippage-slippage-bps-bps-must-be-below-bps-den","errorCode":null,"errorMessage":"Slippage {slippage_bps} bps must be below {BPS_DENOMINATOR}","messagePattern":"Slippage (.+?) bps must be below (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/execution/client.rs","lineNumber":5288,"sourceCode":"fn exact_output_amount(quote: &SwapQuote, zero_for_one: bool) -> anyhow::Result<U256> {\n    let amount = if zero_for_one {\n        quote.amount1\n    } else {\n        quote.amount0\n    };\n\n    if !amount.is_negative() {\n        anyhow::bail!(\"Swap quote output amount {amount} is not a positive output\");\n    }\n    Ok(amount.unsigned_abs())\n}\n\n/// Derives the minimum output accepted for the swap: the quoted output reduced by\n/// `slippage_bps`, in exact integer arithmetic. Rejects a zero minimum, which would leave\n/// the swap without slippage protection.\nfn derive_min_amount_out(quoted_amount_out: U256, slippage_bps: u32) -> anyhow::Result<U256> {\n    if slippage_bps >= BPS_DENOMINATOR {\n        anyhow::bail!(\"Slippage {slippage_bps} bps must be below {BPS_DENOMINATOR}\");\n    }\n    let min_amount_out = quoted_amount_out\n        .checked_mul(U256::from(BPS_DENOMINATOR - slippage_bps))\n        .and_then(|scaled| scaled.checked_div(U256::from(BPS_DENOMINATOR)))\n        .ok_or_else(|| anyhow::anyhow!(\"Minimum output derivation overflow\"))?;\n    if min_amount_out.is_zero() {\n        anyhow::bail!(\n            \"Derived minimum output is zero for quoted output {quoted_amount_out} at {slippage_bps} bps slippage\"\n        );\n    }\n    Ok(min_amount_out)\n}\n\nimpl BlockchainExecutionClient {\n    async fn build_execution_verification_migration(\n        &self,\n        snapshot: ExecutionVerificationMigrationSnapshot,\n        finalized: VerifiedBlockHeader,","sourceCodeStart":5270,"sourceCodeEnd":5306,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/execution/client.rs#L5270-L5306","documentation":"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.","triggerScenarios":"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%).","commonSituations":"Config mistake: user enters 10000 (100%) or a percent value like 50 intended as 0.5%; adapter config validated too late at swap time.","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)"],"exampleFix":"// before\nlet min_out = derive_min_amount_out(quoted, 10_000)?;\n// after\nlet slippage_bps = 100; // 1%\nassert!(slippage_bps < 10_000);\nlet min_out = derive_min_amount_out(quoted, slippage_bps)?;","handlingStrategy":"validation","validationCode":"const BPS_DENOMINATOR: u32 = 10_000;\nif slippage_bps >= BPS_DENOMINATOR {\n    return Err(anyhow::anyhow!(\"slippage_bps must be < 10000, got {slippage_bps}\"));\n}\nderive_min_amount_out(quoted_amount_out, slippage_bps)?;","typeGuard":null,"tryCatchPattern":"match derive_min_amount_out(quoted, bps) {\n    Ok(min) => swap(min),\n    Err(e) if e.to_string().contains(\"must be below\") => fix_config_and_abort(),\n    Err(e) => return Err(e),\n}","preventionTips":["Validate slippage_bps at config load time (0 < bps < 10000)","Remember units: bps, not percent (1% = 100)"],"tags":["blockchain","slippage","config"],"backgroundTag":"invalid-config-value","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}