Skip to content

feat(price): ChainlinkPriceAdapter — multi-feed chaining for asset/USDC precision #163

Description

@ojasarora77

Feature: Multi-Feed ChainlinkPriceAdapter for USDC-Normalised Pricing

Background

ChainlinkPriceAdapter currently accepts a single Chainlink feed per asset.

All production feeds are USD-denominated (e.g. ETH/USD, BTC/USD), while the protocol’s protocolUnderlying is USDC.

The adapter implicitly assumes:

USD = USDC (1:1 peg)

This assumption is acceptable on testnet, but introduces a correctness gap in production.

Failure Mode During USDC Depeg

During a USDC depeg:

  • estimatedUnderlying returned by getPrice() is USD-denominated
  • Actual execution through Uniswap returns USDC

This causes a mismatch:

estimatedUnderlying ≠ actualUnderlying

As a result:

  • The slippage budget may be consumed prematurely
  • Buy-leg operations may exceed allowed slippage or revert

Proposed Change

Add an optional quoteFeed parameter to configureFeed.

Example quote feed:

USDC/USD
0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6

The adapter computes a USDC-normalised price when the quote feed is provided.

Price Formula

price = baseFeed.latestAnswer() × 10^quoteFeed.decimals
─────────────────────────────────────────────
quoteFeed.latestAnswer() × 10^baseFeed.decimals

Performance

  • scaleFactor computed once during configureFeed()
  • Runtime cost remains minimal:

1–2 latestRoundData() calls


Reference Design


Feed Configurations

Asset baseFeed quoteFeed Result
WETH ETH/USD ETH/USD (current behaviour)
WETH ETH/USD USDC/USD ETH/USDC
WBTC BTC/USD USDC/USD BTC/USDC

Backward Compatibility

Existing integrations remain unchanged.

If:

quoteFeed = address(0)

Then the adapter behaves exactly as today:

price = baseFeed.latestAnswer()

This ensures:

  • No breaking changes
  • Existing deployments remain compatible
  • IChainlinkPriceAdapter interface unchanged

Acceptance Criteria

Adapter Changes

  • configureFeed accepts optional quoteFeed
  • scaleFactor computed and stored at configuration time
  • Runtime pricing supports 1 or 2 feeds

Behaviour

  • If quoteFeed == address(0) → existing behaviour
  • If quoteFeed == USDC/USD → return asset/USDC price

Validation

validatePriceAdapter should ensure:

  • latestAnswer != 0 for all configured feeds
  • Feed decimals are valid

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions