Skip to content

[scanner] Mempool monitor: pending Venus oracle-update txs + pre-computed impacted positions #17

@obchain

Description

@obchain

Context

When a price oracle update is pending in the mempool, its effect on health factors is already knowable — no need to wait for the block to land. Pre-computing liquidation txs against the incoming price gives us a head start on every competing bot that waits for confirmation.

Scope

  • charon-scanner/src/mempool.rs with a MempoolMonitor task
  • subscribe_pending_transactions() via alloy pub-sub
  • Detect txs whose to address matches a known oracle (Venus Oracle, Chainlink, etc.)
  • Decode the new price from calldata
  • Simulate: which tracked positions would cross health_factor < 1.0 at the new price?
  • Push pre-computed LiquidationOpportunity into the executor queue, flagged as "pre-computed"
  • When the block lands, fire immediately (zero compute delay)

Acceptance criteria

  • Mempool subscription runs as a spawned task
  • Oracle update transactions are detected and logged (no false positives on unrelated txs)
  • Price-impact simulation produces the same Position.health_factor as a fresh scan would post-confirmation
  • Pre-computed opportunities are tagged in logs and can be distinguished from scan-driven ones
  • Stable for 10+ minutes without memory growth

References

  • PRD section 6b (Mempool Monitoring & Pre-computation)
  • PRD Diagram 06 (MEV Defense Pipeline)

Metadata

Metadata

Assignees

No one assigned

    Labels

    layer:rustRust crates (core / scanner / protocols / executor / cli)priority:p1-coreCore MVP scopestatus:readyScoped and ready to pick uptype:featureNew capability or deliverable

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions