{"record":{"id":"61503f1fc07174d2","repo":"nautechsystems/nautilus_trader","slug":"insufficient-liquidity-requested-amount-out-requ","errorCode":null,"errorMessage":"Insufficient liquidity: requested {amount_out_requested}, available {actual_out}","messagePattern":"Insufficient liquidity: requested (.+?), available (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"warning","filePath":"crates/model/src/defi/pool_analysis/quote.rs","lineNumber":261,"sourceCode":"    /// 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(())\n    }\n\n    /// Converts this quote into a [`PoolSwap`] event with the provided metadata.\n    ///\n    /// # Returns\n    /// A [`PoolSwap`] event containing both the quote data and provided metadata\n    #[must_use]\n    #[expect(clippy::too_many_arguments)]\n    pub fn to_swap_event(\n        &self,\n        chain: SharedChain,\n        dex: SharedDex,\n        pool_identifier: PoolIdentifier,\n        block: BlockPosition,","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/model/src/defi/pool_analysis/quote.rs#L243-L279","documentation":"`validate_exact_output` compares the pool's computed output amount (`get_output_amount()`, a `U256`) against the caller's `amount_out_requested`. When the pool cannot deliver the requested output given the configured input, it bails with this message showing both amounts. It is an expected, caller-facing outcome for exact-output style trades on pools with limited reserves.","triggerScenarios":"Calling `validate_exact_output(amount_out_requested)` where `get_output_amount()` returns less than the requested `U256` amount; typically when the input amount is too small, the pool is thinly capitalized, or the requested amount uses wrong token decimals/scale.","commonSituations":"Exact-output arbitrage sizing against low-liquidity pools; requesting amounts scaled with the wrong decimals (e.g. 6 vs 18); quoting across the wrong pool variant; U256 vs native integer unit mismatches in the requested amount.","solutions":["Increase the input amount or recompute it so the pool can output `amount_out_requested`.","Lower `amount_out_requested` to what the pool can actually deliver.","Verify token decimals and scaling of `amount_out_requested` (U256 raw units).","Quote a different/higher-liquidity pool for the same pair."],"exampleFix":"// before\nlet requested = U256::from(1_000_000_000_000_000_000u64); // assumes 18 decimals\nquote.validate_exact_output(requested)?;\n// after\nlet actual = quote.get_output_amount();\nif actual < requested {\n    // adapt the trade to the achievable output\n    let requested = actual;\n}\nquote.validate_exact_output(requested)?;","handlingStrategy":"validation","validationCode":"let actual_out = quote.get_output_amount();\nif actual_out < amount_out_requested {\n    // adjust requested amount down or increase input before validating\n}","typeGuard":null,"tryCatchPattern":"quote.validate_exact_output(requested).map_err(|e| {\n    if e.to_string().contains(\"Insufficient liquidity\") {\n        // fall back to partial fill or larger input\n    }\n    e\n})?;","preventionTips":["Check pool reserves/liquidity before requesting exact-output amounts.","Verify token decimals and U256 scaling of the requested amount.","Split large exact-output requests across pools or time.","Validate against the same pool object you will execute on."],"tags":["defi","liquidity","quote","validation"],"backgroundTag":"insufficient-liquidity","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}