Skip to content

[flashloan] Router: cheapest-source selection (Aave V3 on BSC) + fallback chain #14

@obchain

Description

@obchain

Context

The flash-loan source router picks the cheapest available source for each liquidation. BSC does not have Balancer V2 deployed — so Aave V3 (0.05% fee) is the primary choice. The router still speaks the full abstraction so multi-source selection just works once other chains ship.

Scope

  • New crates/charon-flashloan/ crate
  • FlashLoanRouter struct with pick_source(token, chain_id, amount) -> FlashLoanSource
  • Per-chain source registry loaded from config ([flashloan.<name>])
  • v0.1 logic: always returns FlashLoanSource::AaveV3 for BSC (only configured source)
  • Shape scaffolding for future Balancer / Uniswap fallbacks (commented stubs)
  • Returns Option<FlashLoanSource> (None = skip the liquidation — no source available)

Acceptance criteria

  • charon-flashloan crate compiles independently
  • pick_source returns Some(AaveV3) for BSC/any common token
  • Returns None for an unconfigured chain
  • Unit test covers the selection logic

References

  • PRD section 5a (Flash Loan Router)
  • PRD Diagram 05 (Flash Loan Source Selection)

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