Skip to content

[PR #28] fetch_positions has no block number — snapshot semantics undefined #72

@obchain

Description

@obchain

PR: #28 (feat/03-lending-protocol-trait)
File: crates/charon-core/src/traits.rs, lines 26-31

fetch_positions(&self, borrowers: &[Address]) has no block number / block tag parameter. Method contract is silent on whether reads are at latest, pending, or a pinned block. Consequences:

  1. Scanner cannot reconcile positions with a specific chainhead. Two borrowers read at different blocks = inconsistent health factor view.
  2. Mempool monitor (PR feat(scanner): mempool monitor for Venus oracle updates #46) needs pre-confirmation reads at pending; this trait cannot express that.
  3. Fork tests (PR test(contracts): CharonLiquidator unit + reentrancy + skipped fork #38, test(contracts): CharonLiquidator fork-test suite across 5 Venus markets #53) pin block number; adapter must be forced to honor it.

Impact: Race between oracle price update and position read leads to stale health factor, wrong liquidation decision, wasted gas.

Fix: Add block tag parameter:

async fn fetch_positions(
    &self,
    borrowers: &[Address],
    block: BlockNumberOrTag,
) -> Result<Vec<Position>>;

Callers pass BlockNumberOrTag::Latest by default; scanner pins to received-block-number for consistent snapshots.

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