{"record":{"id":"637f0c5f065e44b6","repo":"nautechsystems/nautilus_trader","slug":"wallet-balance-snapshot-is-missing-configured-toke","errorCode":null,"errorMessage":"Wallet balance snapshot is missing configured token addresses: {}; contains unexpected token addresses: {}","messagePattern":"Wallet balance snapshot is missing configured token addresses: (.+?); contains unexpected token addresses: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/model/src/defi/wallet.rs","lineNumber":245,"sourceCode":"                \"Wallet balance snapshot contains duplicate token addresses: {}\",\n                format_addresses(&duplicates)\n            );\n        }\n\n        let mut missing = self\n            .token_universe\n            .difference(&token_addresses)\n            .copied()\n            .collect::<Vec<_>>();\n        let mut unexpected = token_addresses\n            .difference(&self.token_universe)\n            .copied()\n            .collect::<Vec<_>>();\n        missing.sort_unstable();\n        unexpected.sort_unstable();\n\n        match (missing.is_empty(), unexpected.is_empty()) {\n            (false, false) => anyhow::bail!(\n                \"Wallet balance snapshot is missing configured token addresses: {}; contains unexpected token addresses: {}\",\n                format_addresses(&missing),\n                format_addresses(&unexpected)\n            ),\n            (false, true) => anyhow::bail!(\n                \"Wallet balance snapshot is missing configured token addresses: {}\",\n                format_addresses(&missing)\n            ),\n            (true, false) => anyhow::bail!(\n                \"Wallet balance snapshot contains unexpected token addresses: {}\",\n                format_addresses(&unexpected)\n            ),\n            (true, true) => Ok(()),\n        }\n    }\n}\n\nfn format_addresses(addresses: &[Address]) -> String {","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/model/src/defi/wallet.rs#L227-L263","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","Verify the snapshot was taken for the intended wallet address, chain, and block.","If tokens legitimately changed, rebuild the snapshot from fresh on-chain data rather than reusing a stale one."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let snap_addrs: HashSet<_> = snapshot.token_addresses().into_iter().collect();\nlet configured: HashSet<_> = configured_tokens.iter().collect();\nassert!(snap_addrs.symmetric_difference(&configured).next().is_none(), \"snapshot/config token set mismatch\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Derive the configured token list from the same source as the snapshot when possible.","Log address-set diffs on wallet changes before they break validation."],"tags":["defi","validation","config-mismatch"],"backgroundTag":"schema-validation-failed","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"}