Refs #42
PR: feat(cli): wire scanner → router → builder → simulator pipeline (feat/17-cli-e2e-pipeline)
Commit: latest on feat/17-cli-e2e-pipeline
File: crates/charon-cli/src/main.rs (pipeline tick loop), crates/charon-core/src/profit.rs
PRD / invariant violated: CLAUDE.md safety: off-chain gates (profitability) must all run before simulation. A broken gate is equivalent to no gate.
Problem:
PR #42 wires the full pipeline and calls calculate_profit() from PR #40. PR #40 has three unresolved p0 blockers:
- ProfitInputs accepts USD cents (u64) but no wei-to-USD conversion exists anywhere in the codebase. The field repay_amount_cents cannot be populated from real LiquidationOpportunity data.
- The profit formula gross = repay_cents * bonus_bps / 10_000 drops the collateral/debt price ratio. It is only correct when collateral and debt have the same USD price. For BNB/BTC/ETH debt positions it produces a number unrelated to actual profit.
- No wei-to-USD conversion path (Chainlink 8-decimal feed + per-token decimals) exists. ProfitInputs cannot be constructed from on-chain data.
PR #42 adds placeholder shims (repay_to_usd_cents_placeholder, PLACEHOLDER_GAS_USD_CENTS = 50) and still pushes results into OpportunityQueue. The queue is sorted by net_profit_usd_cents. For BNB-collateral or BTC-debt markets (the largest Venus markets on BSC), this value is off by 600x-60,000x. When the broadcast PR (#44) consumes the queue, it will execute liquidations ranked by a fabricated number.
Impact: The profit gate — the primary economic off-chain guard before eth_call simulation — produces meaningless output for all non-stablecoin markets. Unprofitable or net-negative liquidations (after gas) will reach the chain.
Fix: Block merge of PR #42 until PR #40 p0 findings (unit mismatch, formula, wei->USD path) are resolved. Alternatively, strip the profit-calc call from this PR entirely and have the pipeline gate on health factor alone until the calculator is fixed.
Refs #42
PR: feat(cli): wire scanner → router → builder → simulator pipeline (feat/17-cli-e2e-pipeline)
Commit: latest on feat/17-cli-e2e-pipeline
File: crates/charon-cli/src/main.rs (pipeline tick loop), crates/charon-core/src/profit.rs
PRD / invariant violated: CLAUDE.md safety: off-chain gates (profitability) must all run before simulation. A broken gate is equivalent to no gate.
Problem:
PR #42 wires the full pipeline and calls calculate_profit() from PR #40. PR #40 has three unresolved p0 blockers:
PR #42 adds placeholder shims (repay_to_usd_cents_placeholder, PLACEHOLDER_GAS_USD_CENTS = 50) and still pushes results into OpportunityQueue. The queue is sorted by net_profit_usd_cents. For BNB-collateral or BTC-debt markets (the largest Venus markets on BSC), this value is off by 600x-60,000x. When the broadcast PR (#44) consumes the queue, it will execute liquidations ranked by a fabricated number.
Impact: The profit gate — the primary economic off-chain guard before eth_call simulation — produces meaningless output for all non-stablecoin markets. Unprofitable or net-negative liquidations (after gas) will reach the chain.
Fix: Block merge of PR #42 until PR #40 p0 findings (unit mismatch, formula, wei->USD path) are resolved. Alternatively, strip the profit-calc call from this PR entirely and have the pipeline gate on health factor alone until the calculator is fixed.