nautechsystems/nautilus_trader · error · anyhow::Error

Wallet balance snapshot is missing configured token addresse

Error message

Wallet balance snapshot is missing configured token addresses: {}; contains unexpected token addresses: {}

What it means

validate_token_addresses compares the snapshot's token addresses against the configured token set and fails when addresses are both missing from the snapshot AND unexpected addresses are present. The message lists both sorted, deduplicated address lists.

Source

Thrown at crates/model/src/defi/wallet.rs:245

                "Wallet balance snapshot contains duplicate token addresses: {}",
                format_addresses(&duplicates)
            );
        }

        let mut missing = self
            .token_universe
            .difference(&token_addresses)
            .copied()
            .collect::<Vec<_>>();
        let mut unexpected = token_addresses
            .difference(&self.token_universe)
            .copied()
            .collect::<Vec<_>>();
        missing.sort_unstable();
        unexpected.sort_unstable();

        match (missing.is_empty(), unexpected.is_empty()) {
            (false, false) => anyhow::bail!(
                "Wallet balance snapshot is missing configured token addresses: {}; contains unexpected token addresses: {}",
                format_addresses(&missing),
                format_addresses(&unexpected)
            ),
            (false, true) => anyhow::bail!(
                "Wallet balance snapshot is missing configured token addresses: {}",
                format_addresses(&missing)
            ),
            (true, false) => anyhow::bail!(
                "Wallet balance snapshot contains unexpected token addresses: {}",
                format_addresses(&unexpected)
            ),
            (true, true) => Ok(()),
        }
    }
}

fn format_addresses(addresses: &[Address]) -> String {

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Compare the missing/unexpected address lists in the error with your configured token list and update the configuration to match the wallet's actual holdings.
  2. Verify the snapshot was taken for the intended wallet address, chain, and block.
  3. If tokens legitimately changed, rebuild the snapshot from fresh on-chain data rather than reusing a stale one.
Defensive patterns

Strategy: validation

Validate before calling

let snap_addrs: HashSet<_> = snapshot.token_addresses().into_iter().collect();
let configured: HashSet<_> = configured_tokens.iter().collect();
assert!(snap_addrs.symmetric_difference(&configured).next().is_none(), "snapshot/config token set mismatch");

Prevention

When it happens

Trigger: Calling account_balances on a snapshot whose token set diverges from the configured expectations in both directions — some configured tokens absent, plus tokens present that were not configured.

Common situations: A wallet acquired or sold a token between configuration and snapshot; tracking config lists one token set while the on-chain wallet holds another; reusing a snapshot from a different wallet or network.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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