Refs #40
File: crates/charon-core/src/profit.rs, crates/charon-core/src/config.rs
PR branch: feat/15-profit-calc-and-queue
Problem:
The PR operates in USD cents (u64) throughout ProfitInputs and NetProfit. BotConfig.min_profit_usd in the actual config.rs is f64 (plain USD float). The threshold comparison therefore requires a f64 -> u64 conversion:
net >= (min_profit_usd * 100.0) as u64
This cast is not implemented, reviewed, or tested. Under the workspace deny(cast_possible_truncation) lint this is either a compile error or a silent truncation depending on how the cast is written. If min_profit_usd is negative, NaN, or infinity the cast produces 0 or u64::MAX — both catastrophic. A threshold of 0 cents passes all opportunities including unprofitable ones; u64::MAX permanently blocks all liquidations.
PRD clause: CLAUDE.md safety invariants — off-chain profit gate must correctly reject sub-threshold opportunities before simulation.
Impact: Off-by-100x silent pass or permanent block. Funds at risk if bot executes sub-threshold liquidations.
Fix: Unify the unit system. Preferred: change BotConfig to min_profit_usd_cents: u64, update config/default.toml accordingly, remove all f64 in the profit path. Alternative: add a validated conversion fn that returns Err on non-finite or negative f64.
Refs #40
File: crates/charon-core/src/profit.rs, crates/charon-core/src/config.rs
PR branch: feat/15-profit-calc-and-queue
Problem:
The PR operates in USD cents (u64) throughout ProfitInputs and NetProfit. BotConfig.min_profit_usd in the actual config.rs is f64 (plain USD float). The threshold comparison therefore requires a f64 -> u64 conversion:
net >= (min_profit_usd * 100.0) as u64
This cast is not implemented, reviewed, or tested. Under the workspace deny(cast_possible_truncation) lint this is either a compile error or a silent truncation depending on how the cast is written. If min_profit_usd is negative, NaN, or infinity the cast produces 0 or u64::MAX — both catastrophic. A threshold of 0 cents passes all opportunities including unprofitable ones; u64::MAX permanently blocks all liquidations.
PRD clause: CLAUDE.md safety invariants — off-chain profit gate must correctly reject sub-threshold opportunities before simulation.
Impact: Off-by-100x silent pass or permanent block. Funds at risk if bot executes sub-threshold liquidations.
Fix: Unify the unit system. Preferred: change BotConfig to min_profit_usd_cents: u64, update config/default.toml accordingly, remove all f64 in the profit path. Alternative: add a validated conversion fn that returns Err on non-finite or negative f64.