{"record":{"id":"b85697b4b973ad96","repo":"nautechsystems/nautilus_trader","slug":"native-currency-not-specified-for-chain","errorCode":null,"errorMessage":"Native currency not specified for chain {}","messagePattern":"Native currency not specified for chain (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/model/src/defi/chain.rs","lineNumber":209,"sourceCode":"            // Ethereum and Ethereum testnets\n            Blockchain::Ethereum | Blockchain::Sepolia | Blockchain::Holesky => (\"ETH\", \"Ethereum\"),\n\n            // Ethereum L2s that use ETH\n            Blockchain::Arbitrum\n            | Blockchain::ArbitrumNova\n            | Blockchain::ArbitrumSepolia\n            | Blockchain::Base\n            | Blockchain::BaseSepolia\n            | Blockchain::Optimism\n            | Blockchain::OptimismSepolia\n            | Blockchain::Blast\n            | Blockchain::BlastSepolia\n            | Blockchain::Scroll\n            | Blockchain::Linea => (\"ETH\", \"Ethereum\"),\n            Blockchain::Polygon | Blockchain::PolygonAmoy => (\"POL\", \"Polygon\"),\n            Blockchain::Avalanche | Blockchain::Fuji => (\"AVAX\", \"Avalanche\"),\n            Blockchain::Bsc | Blockchain::BscTestnet => (\"BNB\", \"Binance Coin\"),\n            _ => panic!(\"Native currency not specified for chain {}\", self.name),\n        };\n\n        Currency::new(\n            code,\n            self.native_currency_decimals,\n            0,\n            name,\n            CurrencyType::Crypto,\n        )\n    }\n\n    /// Returns a reference to the `Chain` corresponding to the given `chain_id`, or `None` if it is not found.\n    #[must_use]\n    pub fn from_chain_id(chain_id: u32) -> Option<&'static Self> {\n        match chain_id {\n            2741 => Some(&chains::ABSTRACT),\n            42161 => Some(&chains::ARBITRUM),\n            42170 => Some(&chains::ARBITRUM_NOVA),","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/model/src/defi/chain.rs#L191-L227","documentation":"Blockchain::native_currency() panics when called on a blockchain variant that has no hard-coded native currency code/name mapping in the library. The match arm falls through to a catch-all panic for chains the crate has not been extended to support, so the error indicates the library lacks metadata for that chain rather than a caller mistake in values. It is a deliberate fail-fast instead of returning a bogus currency.","triggerScenarios":"Calling native_currency() on a Blockchain variant not covered by the match arms (e.g. an exotic or newly added chain like Blockchain::Unknown or a chain added by a newer version without a native currency entry). Also occurs indirectly when constructing instruments or data for such a chain.","commonSituations":"Connecting to an unsupported testnet or L2; a version upgrade introduced a new Blockchain variant used in config before model metadata was updated; building a custom chain enum value and expecting dynamic lookup.","solutions":["Use a Blockchain variant that has a native currency mapping (ETH chains, Polygon, Avalanche, BSC, etc.)","Check the match in crates/model/src/defi/chain.rs and add an arm for your chain, or upgrade nautilus_model to a version that supports the chain","Wrap in catch_unwind or use a chain->currency mapping of your own before calling native_currency() for unsupported chains"],"exampleFix":"// before\nlet currency = chain.native_currency(); // panics for unsupported chain\n// after\nif let Ok(currency) = std::panic::catch_unwind(|| chain.native_currency()) {\n    // use currency\n} else {\n    // supply fallback or reject the chain\n}","handlingStrategy":"validation","validationCode":"// Only call native_currency() on supported chains\nconst SUPPORTED: &[Blockchain] = &[Blockchain::Ethereum, Blockchain::Arbitrum, Blockchain::Base, Blockchain::Optimism, Blockchain::Polygon, Blockchain::Avalanche, Blockchain::Bsc];\nfn native_currency_safe(chain: Blockchain) -> Option<Currency> {\n    if SUPPORTED.contains(&chain) { Some(chain.native_currency()) } else { None }\n}","typeGuard":"fn has_native_currency(chain: Blockchain) -> bool {\n    !matches!(chain, Blockchain::Unknown) // extend with the unsupported set\n}","tryCatchPattern":"let currency = std::panic::catch_unwind(|| chain.native_currency())\n    .ok()\n    .and_then(|c| c.ok()) // adapt to your fallback","preventionTips":["Restrict chain configs to variants with known native currencies","Check the match arms in crates/model/src/defi/chain.rs before adding a new chain to production config","Add a startup assertion that every configured chain has native currency metadata"],"tags":["rust","panic","defi","chain-support"],"backgroundTag":"unsupported-enum-value","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}