Skip to content

feat: aave v4 price feeds#199

Open
nikkaroraa wants to merge 5 commits into
masterfrom
feat/lend-price-feeds
Open

feat: aave v4 price feeds#199
nikkaroraa wants to merge 5 commits into
masterfrom
feat/lend-price-feeds

Conversation

@nikkaroraa

@nikkaroraa nikkaroraa commented Jul 17, 2026

Copy link
Copy Markdown

What

The four price feed contracts for the Aave v4 oracle, plus their tests:

  • ChainlinkPriceFeed, PythPriceFeed, VedaAccountantPriceFeed: one instance per token, each implementing the Aave v4 price-feed interface (IAaveV4PriceFeed). Each feed works in two modes: a USD-quoted source scaled to feed decimals, or a rate source (e.g. weETH/ETH) multiplied by any underlying IAaveV4PriceFeed.
  • StablePriceLib: shared snap of USD-stable prices to 1 USD.
  • All feeds fail closed: latestAnswer reverts on a stale, paused, non-positive, or reverting source.

Why

Split out of #153 so a second auditor can audit the feed contracts in parallel with the rest of the lend logic. The files are verbatim from feat/lend; #153 is now stacked on this branch and carries the wiring and consumers (the Aave v4 oracle setup and deploy scripts).

Testing

Three fork test suites on Optimism (test/price-provider/), running under the default profile in CI. They cover both modes per feed, staleness bounds, decimal normalization, and the fail-closed paths.


Note

High Risk
These feeds directly determine collateral USD values for Aave v4; misconfiguration of staleness bounds, underlying feed wiring, or decimal composition could misprice assets or allow stale prices.

Overview
Adds Aave v4–compatible price feeds (IAaveV4PriceFeed) so receipt and wrapped assets can be used as collateral, split from the broader lend stack for parallel audit.

BaseAaveV4PriceFeed centralizes USD composition: either scale a USD-quoted rate to feed decimals, or multiply a rate by an optional underlying IAaveV4PriceFeed (composite feeds must be staleness-aware feeds, not raw Chainlink aggregators). StablePriceLib snaps stablecoins to exactly $1 within a 1% band. All feeds fail closedlatestAnswer reverts on stale, zero/negative, paused, or missing data.

Four source-specific implementations wrap Chainlink (ChainlinkPriceFeed), LayerZero-relayed OracleSink prices (OracleSinkPriceFeed, staleness on source-chain updatedAt), Morpho Pyth pair adapters on OP (PythPriceFeed, direct Pyth publish-time checks), and Veda vault accountants (VedaAccountantPriceFeed). MIT interfaces mirror external ABIs without vendoring BUSL code.

Fork and unit tests under test/price-provider/ cover both pricing modes, staleness edges, stable snapping, and revert paths on Optimism (and mocks for sink/Pyth).

Reviewed by Cursor Bugbot for commit 3c93207. Bugbot is set up for automated code reviews on this repo. Configure here.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

Comment thread src/oracle/ChainlinkPriceFeed.sol Outdated

@certora-run certora-run Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verification Results

  • Group ID: 7347dc76-c826-4537-9397-5b16ab179086
  • Commit: 590c934
JobResultVERIFIED
EtherFiSafe.…14
CashModuleCo…2

Comment thread src/oracle/BaseAaveV4PriceFeed.sol Outdated
Comment thread src/oracle/BaseAaveV4PriceFeed.sol Outdated

@certora-run certora-run Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verification Results

  • Group ID: 8cf6e95e-3b27-4e53-8221-eb6ae2c454e8
  • Commit: 5b63be6
JobResultVERIFIED
EtherFiSafe.…14
CashModuleCo…2

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 454f0c0. Configure here.

Comment thread src/oracle/ChainlinkPriceFeed.sol
Comment thread src/oracle/ChainlinkPriceFeed.sol

@certora-run certora-run Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verification Results

  • Group ID: e1bfa874-9247-4c7a-8581-c6d8312965e7
  • Commit: 454f0c0
JobResultVERIFIED
EtherFiSafe.…14
CashModuleCo…2

Prices a token for the Aave v4 oracle from the OracleSink (the OP-side
store of prices relayed from mainnet over LayerZero), one instance per
token since the sink's latestRoundData is token-keyed. Enforces its own
immutable staleness bound against the source-chain read time the relay
stamped, so a delayed LayerZero delivery cannot present a stale price
as fresh. Two modes like the sibling feeds: USD-quoted, or a rate
composed on an underlying IAaveV4PriceFeed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@certora-run certora-run Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verification Results

  • Group ID: 3b5fd14b-1f30-4fba-8df1-61a0d8d554ca
  • Commit: 3c93207
JobResultVERIFIED
EtherFiSafe.…14
CashModuleCo…2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants