fix(scanner): per-feed Chainlink max_age overrides (closes #331)#339
Merged
Conversation
…artbeats (closes #331) The single global DEFAULT_MAX_AGE = 600s in oracle.rs cannot fit feeds whose heartbeats span two orders of magnitude. BSC stable-coin Chainlink feeds (USDT, USDC, FDUSD) update on deviation, not heartbeat — heartbeat is ~24h — so the 600s gate routinely flags them as stale even when the price has not moved, and the freshness gate then silently drops every position priced against them. Add a top-level config section `[chainlink_max_age_secs.<chain>]` keyed by symbol → seconds. Missing entries fall through to the global default, so volatile feeds (BNB, ETH, BTCB) stay gated tightly at 600s. Wire the parsed map into `PriceCache::with_per_symbol_max_age` in the CLI bootstrap. Top-level section instead of `[chainlink.<chain>.max_age_secs]`: the existing `chainlink.<chain>` table is `HashMap<symbol, Address>` with `deny_unknown_fields`, so a typed sub-table would require a breaking schema change. Doc comment on the new field justifies. Ship sane stable defaults out of the box: USDT and USDC = 86400s in both default.toml and fork.toml, matching Chainlink's documented 24h heartbeat ceiling. Operators can lower per-deployment without rebuilding. Tests: round-trip TOML deserialization + serde-default empty fallthrough.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
[chainlink_max_age_secs.<chain>](symbol → seconds) lets stable-coin feeds bypass the global 600s freshness gate.PriceCache::with_per_symbol_max_ageconstructor.default.tomlandfork.tomlto match Chainlink's documented heartbeat ceiling for BSC stables.Why
USDT/USDC on BSC are deviation-triggered — heartbeat ~24h. The single global 600s default routinely flagged them stale even when the price had not moved, silently dropping every position priced against them. Volatile feeds (BNB/ETH/BTCB) keep the 600s gate. Closes #331.
Test plan
cargo test -p charon-core --lib(45/45 incl. 2 new round-trip tests)cargo test --workspace --lib(56/56)cargo build --workspaceclean