{"record":{"id":"e92504f45fda9921","repo":"nautechsystems/nautilus_trader","slug":"invalid-fee-denom-e","errorCode":null,"errorMessage":"Invalid fee denom: {e}","messagePattern":"Invalid fee denom: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/dydx/src/grpc/builder.rs","lineNumber":108,"sourceCode":"        // Gas price for dYdX (typically 0.025 adydx per gas)\n        let gas_price = Decimal::new(25, 3); // 0.025\n        let amount = (gas_price * gas_limit).ceil();\n\n        let gas_limit_u64 = gas_limit\n            .to_u64()\n            .ok_or_else(|| anyhow::anyhow!(\"Failed converting gas limit to u64\"))?;\n\n        let amount_u128 = amount\n            .to_u128()\n            .ok_or_else(|| anyhow::anyhow!(\"Failed converting gas cost to u128\"))?;\n\n        Ok(Fee::from_amount_and_gas(\n            Coin {\n                amount: amount_u128,\n                denom: self\n                    .fee_denom\n                    .parse()\n                    .map_err(|e| anyhow::anyhow!(\"Invalid fee denom: {e}\"))?,\n            },\n            gas_limit_u64,\n        ))\n    }\n\n    /// Get default fee (zero fee).\n    fn default_fee() -> Fee {\n        Fee {\n            amount: vec![],\n            gas_limit: 0,\n            payer: None,\n            granter: None,\n        }\n    }\n\n    /// Build a transaction for given messages.\n    ///\n    /// When `authenticator_ids` is provided, the transaction will include a `TxExtension`","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/dydx/src/grpc/builder.rs#L90-L126","documentation":"The fee Coin's denom string (the on-chain token denomination, e.g. \"adydx\") is parsed into cosmrs's Denom type, which validates denomination rules. If self.fee_denom is not a valid Cosmos SDK coin denomination, parse fails and this error is returned.","triggerScenarios":"Calling calculate_fee when the builder's fee_denom field contains an invalid denom: empty string, uppercase letters, invalid characters, or a too-long string per Cosmos denom rules.","commonSituations":"Configuring the adapter with a typo'd fee denom (e.g. \"ADYDX\" instead of \"adydx\"); an empty or missing config field defaulting to an invalid denom; a network whose native denom differs from the configured one (mainnet adydx vs testnet variants).","solutions":["Set fee_denom to the correct lowercase native denom, \"adydx\", in the client config.","Check for empty/missing config: ensure the fee denom config field is populated (this will otherwise parse as an invalid empty denom).","Match the denom exactly to what the dYdX chain expects for the target network (mainnet vs testnet).","Validate the denom against Cosmos denom rules (lowercase alnum, may contain '/' and ':', 3-128 chars) before constructing the builder."],"exampleFix":"// before\n// fee_denom: \"ADYDX\".to_string(), // uppercase invalid\n// after\nfee_denom: \"adydx\".to_string(),","handlingStrategy":"validation","validationCode":"fn is_valid_denom(d: &str) -> bool {\n    !d.is_empty()\n        && d.len() >= 3\n        && d.len() <= 128\n        && d.chars().all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '/' || c == ':')\n}\nassert!(is_valid_denom(&fee_denom));","typeGuard":null,"tryCatchPattern":"let fee = client.calculate_fee(instrument_id, gas_limit)\n    .map_err(|e| {\n        if e.to_string().contains(\"Invalid fee denom\") {\n            // fix fee_denom config to \"adydx\"\n        }\n        e\n    })?;","preventionTips":["Default fee_denom to \"adydx\" (lowercase) for dYdX mainnet","Fail fast at config load if fee_denom is empty or uppercase","Confirm the denom matches the target network (mainnet vs testnet)"],"tags":["dydx","fee","denom","config","validation"],"backgroundTag":"invalid-config-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"}