Skip to content

[scanner] Chainlink PriceCache: latestRoundData ABI + staleness check + per-asset config #11

@obchain

Description

@obchain

Context

Health-factor computation needs USD prices. Chainlink is the primary source; per BSC asset we configure the feed address, then poll latestRoundData each block. Stale feeds are rejected (threshold 10 min) to avoid valuing positions against dead oracles.

Scope

  • charon-scanner/src/price.rs with a PriceCache struct
  • sol! macro bindings for AggregatorV3Interface.latestRoundData()
  • Per-asset config: [chainlink.<chain>.<asset>] feed_address = "0x..."
  • Top-5 BSC assets for v0.1: BNB, USDT, USDC, BTC, ETH
  • Stale price check: reject if updatedAt < now() - 10 min (configurable)
  • Cache stores { price: U256, decimals: u8, updated_at: u64 }
  • Updates alongside the block listener

Acceptance criteria

  • charon-scanner compiles with Chainlink ABI bindings
  • PriceCache::refresh() fetches all configured feeds in one multicall
  • Stale prices are dropped with a WARN log naming the asset + age
  • PriceCache::get(&asset) -> Option<Price> returns None if stale / missing
  • Config supports adding more assets by editing the TOML only

References

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