{"record":{"id":"e79bf922855c50a4","repo":"nautechsystems/nautilus_trader","slug":"slippage-actual-slippage-bps-exceeds-tolerance","errorCode":null,"errorMessage":"Slippage {actual_slippage} bps exceeds tolerance {max_slippage_bps} bps","messagePattern":"Slippage (.+?) bps exceeds tolerance (.+?) bps","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"warning","filePath":"crates/model/src/defi/pool_analysis/quote.rs","lineNumber":247,"sourceCode":"    /// # Returns\n    /// Total slippage in basis points (10000 = 100%)\n    ///\n    /// # Errors\n    /// Returns error if price calculations fail\n    pub fn get_slippage_bps(&mut self) -> anyhow::Result<u32> {\n        match self.check_if_trade_info_initialized() {\n            Ok(trade_info) => trade_info.get_slippage_bps(),\n            Err(e) => anyhow::bail!(\"Failed to calculate slippage: {e}\"),\n        }\n    }\n\n    /// # Errors\n    ///\n    /// Returns an error if the actual slippage exceeds the maximum slippage tolerance.\n    pub fn validate_slippage_tolerance(&mut self, max_slippage_bps: u32) -> anyhow::Result<()> {\n        let actual_slippage = self.get_slippage_bps()?;\n        if actual_slippage > max_slippage_bps {\n            anyhow::bail!(\n                \"Slippage {actual_slippage} bps exceeds tolerance {max_slippage_bps} bps\"\n            );\n        }\n        Ok(())\n    }\n\n    /// Validates that the quote satisfied an exact output request.\n    ///\n    /// # Errors\n    /// Returns error if the actual output is less than the requested amount.\n    pub fn validate_exact_output(&self, amount_out_requested: U256) -> anyhow::Result<()> {\n        let actual_out = self.get_output_amount();\n        if actual_out < amount_out_requested {\n            anyhow::bail!(\n                \"Insufficient liquidity: requested {amount_out_requested}, available {actual_out}\"\n            );\n        }\n        Ok(())","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/model/src/defi/pool_analysis/quote.rs#L229-L265","documentation":"`validate_slippage_tolerance` computes the quote's actual slippage in basis points and compares it to the caller-supplied `max_slippage_bps`. If actual slippage strictly exceeds the tolerance, it bails with this message naming both values. This is an intentional domain rejection, not an internal bug: the trade simply moves the price (including fees) beyond what the caller will accept.","triggerScenarios":"Calling `validate_slippage_tolerance(max_slippage_bps)` where `get_slippage_bps()` returns a value greater than `max_slippage_bps`; also triggered indirectly when the trade-info path fails, since slippage computation errors propagate through this method first.","commonSituations":"Large trade sizes relative to pool liquidity; low-liquidity pools; setting tolerance in the wrong unit (10 meaning 10% instead of 10 bps); volatile pairs at times of high price impact.","solutions":["Increase `max_slippage_bps` to an acceptable value (remember the unit is basis points: 100 bps = 1%).","Reduce the trade size or split it into smaller swaps to lower price impact.","Verify slippage is expressed in bps, not percent, before comparing.","Route through a deeper pool or different pool to reduce impact, then re-validate."],"exampleFix":"// before\n// 5% intended, but passed as percent-like value\nquote.validate_slippage_tolerance(5)?;\n// after\n// 5% expressed in basis points\nquote.validate_slippage_tolerance(500)?;","handlingStrategy":"try-catch","validationCode":"let slippage = quote.get_slippage_bps()?;\nif slippage > max_slippage_bps {\n    // skip trade or renegotiate size before calling validate_slippage_tolerance\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = quote.validate_slippage_tolerance(max_slippage_bps) {\n    if e.to_string().contains(\"exceeds tolerance\") {\n        // reduce size, widen tolerance, or skip the trade\n    } else {\n        return Err(e); // computation failure, not a tolerance rejection\n    }\n}","preventionTips":["Express all tolerances in basis points consistently (100 bps = 1%).","Size trades against pool depth before validating slippage.","Set tolerance from config with unit documentation and sane defaults.","Re-validate slippage shortly before execution; pool state changes shift impact."],"tags":["defi","slippage","validation","quote"],"backgroundTag":"value-out-of-range","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}