fix: reject a zero-scaled feed price and staleness-check the composite USD leg#206
Closed
nikkaroraa wants to merge 1 commit into
Closed
fix: reject a zero-scaled feed price and staleness-check the composite USD leg#206nikkaroraa wants to merge 1 commit into
nikkaroraa wants to merge 1 commit into
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
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.
Addresses two Bugbot findings on the Aave v4 price feeds (raised on #199). Both are behavior-preserving hardening; also pushed to
feat/lend-price-feedsso #199/master stays in sync.Context
Neither issue was introduced by the recent
BaseAaveV4PriceFeedextraction — both existed verbatim in the original feeds. The extraction just centralized the logic into_composeUsd, which is now the single place to fix them. The production listing script (AddSummerLendCollateral) already wires the safe pattern; the unsafe wiring only lived in the fork tests.Fixes
_composeUsdcan't check the underlying's age (theIAaveV4PriceFeedinterface has no timestamp), so the invariant is now documented in NatSpec — the underlying must be a staleness-checking feed, never a raw aggregator. The fork tests were rewired to wrap ETH/USD in aChainlinkPriceFeed(the pattern prod already uses), and a newtest_reverts_whenUnderlyingStaleproves a stale underlying makes the composite revertStalePrice.0._composeUsdnow revertsInvalidPriceon a zero result (matchingPriceProviderV2). Newtest_latestAnswer_revertsWhenScaledPriceFloorsToZerocovers it.Testing
forge buildclean,forge fmt/forge lintclean. All 33 feed tests pass (test/price-provider/{Chainlink,VedaAccountant,Pyth}PriceFeed.t.sol), including the 3 new ones.Follow-up (not in this PR)
scripts/aave-v4/DeployAaveV4TestInstance.s.sol(a dev test-instance deployer, not prod) still wires a raw ETH/USD aggregator as the underlying. Worth aligning to the wrapped pattern for consistency, but it's dev-only and doesn't affect deployed feeds.Note
Medium Risk
Changes oracle collateral pricing invariants (no zero prices, composite staleness via wiring); behavior-preserving hardening but affects lending risk if misconfigured underlying feeds remain in production.
Overview
Hardens Aave v4 composite price feeds in
BaseAaveV4PriceFeed._composeUsdso collateral prices cannot be reported as 0 after decimal scaling, and documents how the USD leg must be wired for freshness._composeUsdnow uses a single path through stable snapping, then revertsInvalidPriceif the result is zero (e.g. a positive rate that floors away in integer division). NatSpec also states thatunderlyingUsdFeedmust be a staleness-checkingIAaveV4PriceFeed, not a raw Chainlink aggregator, because the base trustslatestAnswer()and does not re-check timestamps on that leg.Fork tests for Chainlink and VedaAccountant composites were updated to wrap ETH/USD in a
ChainlinkPriceFeed(matching production wiring), with newtest_reverts_whenUnderlyingStalecases. Pyth addstest_latestAnswer_revertsWhenScaledPriceFloorsToZerofor the zero-after-scaling case.Reviewed by Cursor Bugbot for commit 454f0c0. Bugbot is set up for automated code reviews on this repo. Configure here.