PR: #33 (feat/08-venus-adapter)
File: crates/charon-protocols/src/venus.rs
Lines: 299-308
Problem: Health factor hardcoded to 0 when shortfall > 0 and 2e18 otherwise. Inline comment acknowledges placeholder and defers to follow-up. But getAccountLiquidity already returns (errorCode, liquidity, shortfall) at line 234 — both liquidity and shortfall available with no additional RPC. Real ratio computable immediately.
Impact: Scanner cannot distinguish a 0.01% underwater position from a 50% underwater one. All underwater accounts receive health_factor=0, treated identically. Defeats profit ranking: bot may spend gas on near-zero-shortfall account while high-shortfall position (larger bonus) goes unliquidated. PRD requires Position.health_factor be a 1e18-scaled ratio, not a sentinel.
Fix: Compute from values in scope:
let one_e18 = U256::from(10u64).pow(U256::from(18u64));
let health_factor = if shortfall > U256::ZERO {
one_e18.saturating_sub(
shortfall.saturating_mul(one_e18)
/ (liq._1 + shortfall + U256::from(1u64))
)
} else {
one_e18 + liq._1.saturating_mul(one_e18) / (liq._1 + U256::from(1u64))
};
Open tracking issue for finer-grained oracle-weighted HF if wanted; remove sentinel immediately.
PR: #33 (feat/08-venus-adapter)
File: crates/charon-protocols/src/venus.rs
Lines: 299-308
Problem: Health factor hardcoded to
0whenshortfall > 0and2e18otherwise. Inline comment acknowledges placeholder and defers to follow-up. ButgetAccountLiquidityalready returns(errorCode, liquidity, shortfall)at line 234 — both liquidity and shortfall available with no additional RPC. Real ratio computable immediately.Impact: Scanner cannot distinguish a 0.01% underwater position from a 50% underwater one. All underwater accounts receive
health_factor=0, treated identically. Defeats profit ranking: bot may spend gas on near-zero-shortfall account while high-shortfall position (larger bonus) goes unliquidated. PRD requiresPosition.health_factorbe a 1e18-scaled ratio, not a sentinel.Fix: Compute from values in scope:
Open tracking issue for finer-grained oracle-weighted HF if wanted; remove sentinel immediately.