Skip to content

[PR #29] Config structs missing #[serde(deny_unknown_fields)] — typos accepted silently #81

@obchain

Description

@obchain

PR: #29 (feat/04-toml-config-loader)
File: crates/charon-core/src/config.rs
Lines: 17-20 (Config), 29-35 (BotConfig), 40-44 (ChainConfig), 47-52 (ProtocolConfig), 55-59 (FlashLoanConfig), 62-65 (LiquidatorConfig)

Problem: None of the six serde-Deserialize structs carry #[serde(deny_unknown_fields)]. serde silently ignores TOML keys that do not match struct fields. Typo like min_profit_use instead of min_profit_usd produces no error; field stays at its zero default.

For BotConfig this is dangerous: typo on min_profit_usd leaves field at 0.0, every liquidation opportunity passes profitability gate regardless of cost.

Impact: Silent misconfiguration → unprofitable or loss-making liquidations. No runtime error; bot appears healthy while executing at wrong threshold.

Fix: Add #[serde(deny_unknown_fields)] to every config struct:

#[derive(Debug, Clone, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct BotConfig {
    pub min_profit_usd: f64,
    pub max_gas_gwei: u64,
    pub scan_interval_ms: u64,
}

Apply same attribute to Config, ChainConfig, ProtocolConfig, FlashLoanConfig, LiquidatorConfig.

Metadata

Metadata

Assignees

No one assigned

    Labels

    layer:rustRust crates (core / scanner / protocols / executor / cli)pr-reviewFindings from PR review processpriority:p1-coreCore MVP scope

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions