{"record":{"id":"29a35463a58d1d84","repo":"nautechsystems/nautilus_trader","slug":"router-allowance-for-token-token-is-already","errorCode":null,"errorMessage":"Router allowance for token {token} is already {}; approve zero before setting a new nonzero allowance","messagePattern":"Router allowance for token (.+?) is already (.+?); approve zero before setting a new nonzero allowance","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/execution/client.rs","lineNumber":2630,"sourceCode":"                    spender: router,\n                }\n                .abi_encode();\n                let allowance = required_verification(\n                    self.verification\n                        .verify_decoded_call(\n                            None,\n                            &token,\n                            U256::ZERO,\n                            &allowance_call,\n                            block,\n                            |result| {\n                                ERC20::allowanceCall::abi_decode_returns(result).map_err(Into::into)\n                            },\n                        )\n                        .await,\n                    \"pre-sign router allowance\",\n                )?;\n                anyhow::ensure!(\n                    allowance.value.is_zero() || amount.is_zero(),\n                    \"Router allowance for token {token} is already {}; approve zero before setting a new nonzero allowance\",\n                    allowance.value\n                );\n\n                let approve_call = ERC20::approveCall {\n                    spender: router,\n                    amount,\n                }\n                .abi_encode();\n                let simulation = required_verification(\n                    self.verification\n                        .verify_decoded_simulation(\n                            &self.wallet_address,\n                            &token,\n                            U256::ZERO,\n                            &approve_call,\n                            block,","sourceCodeStart":2612,"sourceCodeEnd":2648,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/execution/client.rs#L2612-L2648","documentation":"Allowance guard before approving a router spend: a nonzero allowance already exists for the token/spender pair; setting a new nonzero allowance directly is race-prone, so an approve-to-zero step is required first.","triggerScenarios":"Thrown at crates/adapters/blockchain/src/execution/client.rs:2630 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Approve zero first, then set the new allowance","Reuse the existing sufficient allowance if it covers the intended spend"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}