{"record":{"id":"c39e3f04a65b531d","repo":"nautechsystems/nautilus_trader","slug":"unknown-dex-dex-id-on-chain","errorCode":null,"errorMessage":"Unknown DEX {dex_id} on chain {}","messagePattern":"Unknown DEX (.+?) on chain (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/data/core.rs","lineNumber":1430,"sourceCode":"    /// absent from the cache database is left for the caller's later lookup to report.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if DEX registration or the pool load fails.\n    pub async fn register_dex_exchange_for_pool(\n        &mut self,\n        dex_id: DexType,\n        pool_identifier: &PoolIdentifier,\n    ) -> anyhow::Result<()> {\n        self.register_dex(dex_id).await?;\n        let _ = self.cache.load_pool(&dex_id, pool_identifier).await?;\n        Ok(())\n    }\n\n    /// Registers a DEX in the cache and its event signatures for subscriptions, without loading pools.\n    async fn register_dex(&mut self, dex_id: DexType) -> anyhow::Result<()> {\n        let Some(dex_extended) = get_dex_extended(self.chain.name, &dex_id) else {\n            anyhow::bail!(\"Unknown DEX {dex_id} on chain {}\", self.chain.name);\n        };\n\n        log::debug!(\"Registering DEX {dex_id} on chain {}\", self.chain.name);\n        self.cache.add_dex(dex_extended.dex.clone()).await?;\n        self.subscription_manager.register_dex_for_subscriptions(\n            dex_id,\n            dex_extended.swap_created_event.as_ref(),\n            dex_extended.mint_created_event.as_ref(),\n            dex_extended.burn_created_event.as_ref(),\n            dex_extended.collect_created_event.as_ref(),\n            dex_extended.flash_created_event.as_deref(),\n        );\n        self.subscription_manager.register_dex_fee_protocol_events(\n            dex_id,\n            dex_extended.fee_protocol_update_event.as_deref(),\n            dex_extended.fee_protocol_collect_event.as_deref(),\n        );\n        Ok(())","sourceCodeStart":1412,"sourceCodeEnd":1448,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/data/core.rs#L1412-L1448","documentation":"register_dex validates that the requested DEX type exists for the target chain via get_dex_extended. If there is no registry entry for this DEX on this chain (e.g. SushiSwap on a chain where it isn't indexed), registration cannot proceed and the error names both the DEX and chain.","triggerScenarios":"Calling register_dex (directly or via register_dex_exchange / register_dex_exchange_for_pool) with a DexType not supported/indexed on the configured chain.","commonSituations":"Configuring a DEX on the wrong chain in the adapter config; typo in DEX id; DEX not yet supported by the underlying dex metadata registry for that network.","solutions":["Check the supported DEX list for your chain and pick a valid DexType","Correct the chain configuration if the DEX should exist on it","Upgrade the library/dex-metadata dependency if the DEX was recently added upstream"],"exampleFix":"// before\nclient.register_dex_exchange(chain, DexType::Camelot).await?; // not on this chain\n// after\nclient.register_dex_exchange(chain, DexType::UniswapV3).await?; // supported on this chain","handlingStrategy":"validation","validationCode":"if get_dex_extended(chain.name, dex_id).is_none() {\n    return Err(anyhow::anyhow!(\"DEX {:?} unsupported on {}\", dex_id, chain.name));\n}\nclient.register_dex_exchange(chain, dex_id).await?;","typeGuard":null,"tryCatchPattern":"if let Err(e) = client.register_dex_exchange(chain, dex).await {\n    if e.to_string().starts_with(\"Unknown DEX\") {\n        log::warn!(\"{} unsupported on {}; skipping\", dex, chain.name);\n        return Ok(()); // or fall back to a supported DEX\n    }\n    return Err(e);\n}","preventionTips":["Validate the (chain, dex) pair against the supported list at config load","Keep DEX enums and chain configs in sync after upgrades","Test registration for every configured DEX on startup"],"tags":["dex","registry","configuration","chain"],"backgroundTag":"invalid-enum-value","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"}