{"record":{"id":"9acbc6b8c2ad7255","repo":"nautechsystems/nautilus_trader","slug":"buy-quote-amount-amount-in-exceeds-the-configure","errorCode":null,"errorMessage":"BUY quote amount {amount_in} exceeds the configured `quote_spend_limits` maximum {} for {token_in} -> {token_out}","messagePattern":"BUY quote amount (.+?) exceeds the configured `quote_spend_limits` maximum (.+?) for (.+?) -> (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/execution/client.rs","lineNumber":1705,"sourceCode":"                }\n                (base_amount, exact_output_amount(&quote, zero_for_one)?)\n            }\n            OrderSide::Buy => {\n                let quote = profiler\n                    .swap_exact_out(base_amount, zero_for_one, None)\n                    .map_err(|e| anyhow::anyhow!(\"Swap quote failed for {instrument_id}: {e}\"))?;\n                let amount_in = quote.get_input_amount();\n                if amount_in.is_zero() {\n                    anyhow::bail!(\"Local quote for {instrument_id} produced a zero quote input\");\n                }\n                let ceiling = quote_spend_ceiling.ok_or_else(|| {\n                    anyhow::anyhow!(\n                        \"No `quote_spend_limits` entry for BUY token pair {token_in} -> {token_out}\"\n                    )\n                })?;\n\n                if amount_in > ceiling.max_amount {\n                    anyhow::bail!(\n                        \"BUY quote amount {amount_in} exceeds the configured `quote_spend_limits` maximum {} for {token_in} -> {token_out}\",\n                        ceiling.max_amount\n                    );\n                }\n                (amount_in, base_amount)\n            }\n        };\n        let min_amount_out = derive_min_amount_out(quoted_amount_out, slippage_bps)?;\n\n        self.ensure_transaction_ready(TransactionPurpose::Swap)?;\n\n        if self.signer.is_none() {\n            anyhow::bail!(\"Signer not initialized; connect the client first\");\n        }\n\n        let pool_address = pool.address;\n        let factory = self.uniswap_v3_factory()?;\n        anyhow::ensure!(","sourceCodeStart":1687,"sourceCodeEnd":1723,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/execution/client.rs#L1687-L1723","documentation":"For BUY orders the quote amount spent (amount_in, in the quote token) is checked against a per-pair ceiling in `quote_spend_limits`; exceeding ceiling.max_amount aborts the swap as a spend guard. This limits how much quote token a single BUY swap may consume.","triggerScenarios":"submit_order (BUY side) where the locally quoted amount_in exceeds quote_spend_limits[(token_in, token_out)].max_amount — i.e. the pool price/size makes the swap cost more quote token than the configured ceiling.","commonSituations":"Large BUY orders on pools with poor pricing so the required spend balloons past the ceiling; quote_spend_limits left at conservative defaults while the strategy sizes positions larger; a price spike between signal and execution inflating the quoted spend.","solutions":["Raise the `max_amount` for this token pair in `quote_spend_limits` if the spend is intended.","Reduce the order quantity so the quoted spend fits under the ceiling.","Split the order into smaller buys, or add a price/sanity check before submitting so orders are not sent when spend would exceed the limit."],"exampleFix":"// before\nquote_spend_limits[(usdc, weth)].max_amount = 1_000; // too low for order size\nclient.submit_order(cmd, &order)?;\n// after\nquote_spend_limits[(usdc, weth)].max_amount = 25_000; // matches intended size\nclient.submit_order(cmd, &order)?;","handlingStrategy":"validation","validationCode":"// Rust\nif order.order_side() == OrderSide::Buy {\n    if let Some(ceiling) = transaction_limits.quote_spend_limits.get(&(token_in, token_out)) {\n        if estimated_spend > ceiling.max_amount {\n            return Err(anyhow::anyhow!(\"estimated spend exceeds quote_spend_limits\"));\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Configure quote_spend_limits to match realistic position sizes per pair.","Re-estimate spend at submission time and split orders exceeding ceilings.","Add a max-price sanity check so price spikes don't push spend over limits."],"tags":["blockchain","risk-limit","spend-limit","buy-order"],"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-14T00:17:10.932Z"}