{"record":{"id":"4858adcc28c534f3","repo":"nautechsystems/nautilus_trader","slug":"swap-quote-failed-for-instrument-id-e","errorCode":null,"errorMessage":"Swap quote failed for {instrument_id}: {e}","messagePattern":"Swap quote failed for (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/execution/client.rs","lineNumber":1676,"sourceCode":"            .ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"No pool profiler for {instrument_id}; an active data subscription is required to quote the swap\"\n                )\n            })?;\n\n        if !profiler.is_initialized {\n            anyhow::bail!(\"Pool profiler for {instrument_id} is not initialized\");\n        }\n        let profiler_position = profiler.last_processed_event.clone().ok_or_else(|| {\n            anyhow::anyhow!(\"Pool profiler for {instrument_id} has processed no events\")\n        })?;\n\n        let zero_for_one = token_in == pool.token0.address;\n        let (amount_in, quoted_amount_out) = match order.order_side() {\n            OrderSide::Sell => {\n                let quote = profiler\n                    .swap_exact_in(base_amount, zero_for_one, None)\n                    .map_err(|e| anyhow::anyhow!(\"Swap quote failed for {instrument_id}: {e}\"))?;\n                let amount_filled = if zero_for_one {\n                    quote.amount0\n                } else {\n                    quote.amount1\n                };\n\n                if amount_filled != I256::from(base_amount) {\n                    anyhow::bail!(\n                        \"Local quote for {instrument_id} filled {amount_filled} of the {base_amount} order amount; pool liquidity cannot fill the order\"\n                    );\n                }\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();","sourceCodeStart":1658,"sourceCodeEnd":1694,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/execution/client.rs#L1658-L1694","documentation":"This error wraps a failure from the local Uniswap V3 pool quote calculation (`swap_exact_in`) when preparing a SELL swap order. The pool profiler could not compute the expected amount out for the given base amount and direction, so the swap cannot be priced and the order preparation aborts. The underlying cause `e` is embedded in the message.","triggerScenarios":"Calling submit_order for a SELL order on a DEX instrument where the internal `profiler.swap_exact_in(base_amount, zero_for_one, None)` returns Err — e.g. pool state cannot be fetched, the tick math overflows, or the pool has no liquidity for the direction.","commonSituations":"Trading against a newly created or empty pool with zero liquidity; pool contract reverted during quote; stale or disconnected RPC during state sync; instrument/token address misconfiguration so the direction flag (zero_for_one) is wrong.","solutions":["Inspect the chained cause `e` in the message to see the underlying pool-quote failure (RPC error, revert, math overflow).","Verify the pool has sufficient liquidity in the swap direction; test with a smaller base_amount.","Check the instrument's token0/token1 configuration matches the actual pool contract so zero_for_one is correct.","Ensure the RPC connection is healthy and the client is connected (signer initialized) before submitting.","Re-create the pool/profiler from fresh on-chain state if cached pool data is stale."],"exampleFix":"// before: submitting a SELL swap against an empty pool\nclient.submit_order(sell_order)?; // Swap quote failed for ETH/USDC: ...\n// after: guard on liquidity first\nif profiler.liquidity() == 0 { return Err(anyhow!(\"pool has no liquidity\")); }\nclient.submit_order(sell_order)?;","handlingStrategy":"validation","validationCode":"if pool.liquidity == 0 { return Err(\"pool has no liquidity for swap\"); }\nif !client.is_connected() { return Err(\"client not connected\"); }","typeGuard":"fn is_quoteable(pool: &Pool) -> bool { pool.liquidity > 0 && pool.token0.valid() && pool.token1.valid() }","tryCatchPattern":"match client.submit_order(order) { Err(e) if e.to_string().contains(\"Swap quote failed\") => { log_cause_and_retry_with_fresh_pool(e); } Ok(r) => r }","preventionTips":["Check pool liquidity before submitting swaps","Keep instrument token0/token1 config in sync with on-chain pool","Monitor RPC health before quoting"],"tags":["swap","quote","uniswap-v3","defi"],"backgroundTag":"api-request-failed","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"}