Skip to content

[core] TOML config loader with ${ENV_VAR} substitution #5

@obchain

Description

@obchain

Context

Bot-level knobs, per-chain RPC endpoints, per-protocol addresses, and flash-loan sources all live in a TOML file. Secrets (RPC URLs) are referenced via ${ENV_VAR} placeholders and substituted from the environment at load time — no secrets ever in the repo.

Scope

  • Config struct hierarchy: bot, chain, protocol, flashloan, liquidator
  • Hash-map keyed sections so adding chains / protocols later is a config edit, not a schema change
  • Config::load(path) — reads → substitutes env vars → parses via serde
  • Hand-rolled substitute_env_vars() helper that errors cleanly on unset vars
  • config/default.toml with real BSC addresses (Venus comptroller, Aave V3 Pool)
  • .env.example documenting BNB_WS_URL and BNB_HTTP_URL

Acceptance criteria

  • Config::load(path) returns anyhow::Result<Config>
  • Env substitution works for string values inside TOML
  • Parse errors include the file path for context
  • config/default.toml parses with a populated .env (copied from .env.example)

References

  • Delivered in commit 2495292
  • PRD section 4d (Config Loader)

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