Skip to content

bgd-labs/aave-price-feeds

Repository files navigation

Aave Price Feeds

Price oracle adapter smart contracts with upper-bound price protection for assets used by the Aave protocol. These adapters wrap Chainlink price feeds and cap prices to prevent oracle manipulation or malfunction from affecting Aave pools.

Overview

Aave protocol relies on external oracles for asset prices. If an oracle returns a negative, zero, or an abnormally high price (due to bugs, manipulation, or errors), it could lead to protocol exploits. This repository provides protective wrappers that:

  1. Fetches prices from Chainlink oracles
  2. Validates prices against configured maximum bounds
  3. Returns capped prices if bounds are exceeded

Price Cap Adapters Architecture

Adapter Types

RatioCapAdapter (LSTs)

For Liquid Staking Tokens (wstETH, rETH, weETH, etc.) that grow in value over time.

  • Price capped based on maximum allowed yearly growth rate
  • Uses snapshot ratio and timestamp as reference values to determine growth since then
  • Returns capped ratio if current ratio exceeds calculated maximum

Base contract: PriceCapAdapterBase—see detailed documentation

FixCapAdapter (Stablecoins)

For USD-pegged stablecoins (USDC, USDT, DAI) with fixed 1:1 peg.

  • Price capped at a single configured maximum value (e.g., $1.04 for 4% cap)
  • Returns capped price if current price exceeds the fixed maximum

Contract: PriceCapAdapterStable

Synchronicity Adapters

Combine two price feeds to derive a third pair.

  • Does not cap the price derived from the feed's composition
Adapter Input Feeds Output
CLSynchronicityPriceAdapterBaseToPeg Asset/USD + ETH/USD Asset/ETH
CLSynchronicityPriceAdapterPegToBase Asset/ETH + ETH/USD Asset/USD

Specialized Adapters

Adapter Purpose
PendlePriceCapAdapter PT tokens with linear discount decay
CLRatePriceCapAdapter Generic Chainlink rate-based cap
DiscountedMKRSKYAdapter MKR price from SKY with dynamic discount
FixedPriceAdapter Hardcoded fixed price

See misc-adapters documentation for details.

Repository Structure

├── src/
│   ├── contracts/                       # Core adapters
│   │   ├── lst-adapters/                # Asset-specific LST adapters (22 files)
│   │   └── misc-adapters/               # Specialized adapters
│   └── interfaces/
├── scripts/                             # Deployment scripts per network
├── tests/                               # Test suite per network
├── reports/                             # CAPO snapshots, report generator, and markdown outputs
└── security/                            # Audit reports

Development

Note

The contracts in this repository use the Shanghai EVM version, please check network support before deploying.

# Install dependencies
make install

# Run tests (unit and adapter/fork tests)
make test

# Run report generator tests
pnpm run vitest

CAPO Report Generator

BaseTest generates CAPO markdown reports during retrospective tests.

  • Input snapshot: ./reports/out/<REPORT_NAME>.json (temporary)
  • Output report: ./reports/out/<REPORT_NAME>.md

The generator script is reports/capo-report.ts and is executed through FFI:

pnpm exec tsx ./reports/capo-report.ts -i ./reports/mocks/capo.json -o ./reports/out/capo.md

Adding New Adapters

See how-to.md for detailed instructions on adding LST or stablecoin adapters.

Aave V4 Compatibility

The currently audited adapters expose only latestAnswer(), which is used by Aave v3 Oracle. Aave v4 Oracle uses latestRoundData() instead.

For v4 compatibility:

  1. Add the latestRoundData() method to the ICLSynchronicityPriceAdapter interface:
function latestRoundData()
  external
  view
  returns (
    uint80 roundId,
    int256 answer,
    uint256 startedAt,
    uint256 updatedAt,
    uint80 answeredInRound
  );

Security

Audits

Related Documentation

Repository History

License

Copyright © 2026, Aave DAO, represented by its governance smart contracts.

Created by BGD Labs.

The default license of this repository is BUSL1.1, but all interfaces are open source, MIT-licensed.

IMPORTANT. The BUSL1.1 license of this repository allows for any usage of the software, if respecting the Additional Use Grant limitations, forbidding any use case damaging anyhow the Aave DAO's interests.

About

Correlated-assets price oracle

Resources

License

Stars

Watchers

Forks

Packages