{"record":{"id":"be84e3d75b5e73d1","repo":"nautechsystems/nautilus_trader","slug":"pool-instrument-id-references-factory-expect","errorCode":null,"errorMessage":"Pool {instrument_id} references factory {}, expected registered factory {factory}","messagePattern":"Pool (.+?) references factory (.+?), expected registered factory (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/execution/client.rs","lineNumber":1723,"sourceCode":"                    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!(\n            pool.dex.factory == factory,\n            \"Pool {instrument_id} references factory {}, expected registered factory {factory}\",\n            pool.dex.factory\n        );\n\n        Ok(SwapPlan {\n            order: order.clone(),\n            pool,\n            quote_currency,\n            instrument_id,\n            pool_address,\n            router: self.router_addresses[0],\n            factory,\n            weth: self.weth_address,\n            token_in,\n            token_out,\n            fee,\n            amount_in,","sourceCodeStart":1705,"sourceCodeEnd":1741,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/execution/client.rs#L1705-L1741","documentation":"Before executing a swap the client verifies that the pool's DEX factory matches the Uniswap V3 factory registered with the client. If the pool was deployed by a different factory, the swap plan is rejected to avoid interacting with an untrusted pool.","triggerScenarios":"Calling submit_order -> prepare_swap for a pool whose `pool.dex.factory` differs from the address returned by `self.uniswap_v3_factory()` — e.g. pool created on a fork or different deployment than the configured factory.","commonSituations":"Configured factory address points at Uniswap V3 while the pool is from PancakeSwap/Sushi or a fork; wrong chain configured so addresses resolve to different deployments; typo in factory registration.","solutions":["Register the factory that actually deployed the pool, or use a pool from the registered factory's deployment.","Verify the factory address and chain configuration match the pool's network.","Check that pool.dex.factory was populated from the correct on-chain `factory()` call.","Confirm the client is connected to the same chain the pool lives on."],"exampleFix":"// before: pool from a fork factory\n// uniswap_v3_factory = 0x1F98431c8aD... (Uniswap)\npool.dex.factory = 0x0BFbCF9fa4f9C56B0F40a671Ad40E0805A091865; // PancakeSwap\n// after: use the matching pool/factory\nlet factory = self.uniswap_v3_factory()?;\nlet pool = registry.get_pool_by_factory(factory, ...)?;","handlingStrategy":"validation","validationCode":"let factory = client.registered_factory()?;\nif pool.dex.factory != factory { return Err(\"pool factory mismatch\"); }","typeGuard":"fn pool_matches_factory(pool: &Pool, factory: Address) -> bool { pool.dex.factory == factory }","tryCatchPattern":"match client.submit_order(order) { Err(e) if e.to_string().contains(\"expected registered factory\") => switch_to_compliant_pool(e), Ok(r) => r }","preventionTips":["Register only factories whose pools you trade","Verify pool.factory() on-chain when loading pools","Pin chain and factory config together"],"tags":["uniswap-v3","config","validation","defi"],"backgroundTag":"invalid-argument-value","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"}