nautechsystems/nautilus_trader · error

Router allowance for token

Error message

Router allowance for token {token} is already {}; approve zero before setting a new nonzero allowance

What it means

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.

Solutions

  1. Approve zero first, then set the new allowance
  2. Reuse the existing sufficient allowance if it covers the intended spend
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/adapters/blockchain/src/execution/client.rs:2630 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/29a35463a58d1d84. Report an issue: GitHub.

Appendix: source

Thrown at crates/adapters/blockchain/src/execution/client.rs:2630

                    spender: router,
                }
                .abi_encode();
                let allowance = required_verification(
                    self.verification
                        .verify_decoded_call(
                            None,
                            &token,
                            U256::ZERO,
                            &allowance_call,
                            block,
                            |result| {
                                ERC20::allowanceCall::abi_decode_returns(result).map_err(Into::into)
                            },
                        )
                        .await,
                    "pre-sign router allowance",
                )?;
                anyhow::ensure!(
                    allowance.value.is_zero() || amount.is_zero(),
                    "Router allowance for token {token} is already {}; approve zero before setting a new nonzero allowance",
                    allowance.value
                );

                let approve_call = ERC20::approveCall {
                    spender: router,
                    amount,
                }
                .abi_encode();
                let simulation = required_verification(
                    self.verification
                        .verify_decoded_simulation(
                            &self.wallet_address,
                            &token,
                            U256::ZERO,
                            &approve_call,
                            block,

View on GitHub (pinned to 18893faf8b)