Skip to content

[PR #33] VenusAdapter snapshot fields are pub and never refreshed — stale on governance change or new market #102

@obchain

Description

@obchain

PR: #33 (feat/08-venus-adapter)
File: crates/charon-protocols/src/venus.rs
Lines: 119-136

Problem: Six fields on VenusAdapter declared pub: comptroller, oracle, markets, close_factor_mantissa, chain_id, underlying_to_vtoken, vtoken_to_underlying. All snapshotted once in connect(), never refreshed. Venus governance can change oracle, closeFactorMantissa, market list via on-chain proposals. New markets added regularly. pub also means any caller can silently overwrite, breaking adapter internal consistency invariant between the two maps.

Impact: Governance vote changing closeFactorMantissa or oracle address → running bot uses stale values until restart. New Venus market listed post-connect never scanned. External mutability invites desync of underlying_to_vtoken and vtoken_to_underlying. close_factor_mantissa used directly in repay-amount computation — stale value produces wrong repay amounts, risking on-chain revert or under-repay.

Fix: Make fields pub(crate) or private, expose read-only accessors where needed. Add refresh() async method re-fetching oracle, closeFactorMantissa, getAllMarkets, rebuilding maps. Call on configurable interval (every N blocks / epoch) from scan loop. Consider watching NewMarket / NewPriceOracle Comptroller events for targeted refreshes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    layer:rustRust crates (core / scanner / protocols / executor / cli)pr-reviewFindings from PR review processpriority:p2-polishNice-to-have / polish

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions