Skip to content

[protocols] charon-protocols crate + Venus adapter (getAccountLiquidity + vToken bindings) #9

@obchain

Description

@obchain

Context

First concrete implementation of LendingProtocol. Venus doesn't expose a direct health factor — we compute it from collateral × collateral factor / debt, using the Comptroller and vToken ABIs. Also the proving ground for the charon-protocols crate that future adapters (Aave, Compound, Morpho) will live in.

Scope

  • Create crates/charon-protocols/ crate and add to workspace members
  • sol! macro bindings for Venus Comptroller (getAccountLiquidity, getAssetsIn, markets) and VToken (borrowBalanceCurrent, balanceOfUnderlying, underlying)
  • VenusAdapter struct implementing LendingProtocol
  • fetch_positions(borrowers) — multicall to query position state in one RPC round
  • Compute health factor from collateral value × collateral factor / debt value
  • Seed a small hardcoded list of known BSC borrowers for initial testing
  • Subscribe to Venus Borrow events to accumulate the borrower set over time

Acceptance criteria

  • charon-protocols crate compiles independently
  • VenusAdapter::new(config) connects to BSC and can query the Comptroller
  • fetch_positions(&[borrower]) returns a populated Position with non-zero collateral/debt for a known borrower
  • Position mapping produces a sensible health_factor (> 0, ≤ ~10 for real accounts)
  • Event subscription for Borrow events runs without errors

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    layer:rustRust crates (core / scanner / protocols / executor / cli)priority:p0-blockerBlocks the critical pathstatus:readyScoped and ready to pick uptype:featureNew capability or deliverable

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions