Updating Price Feeds

Push fresh price data for on-demand oracles (Pyth, Redstone).

For SDK implementation, see Updating Price Feeds.

Why

You update price feeds when:

  • Using on-demand oracles - Pyth and Redstone require fresh data with each transaction

  • Multicalls fail - "Stale price" errors indicate missing price updates

  • Withdrawals - Reserve price feeds may also need updates under safe pricing

Some tokens use "pull-based" oracles that don't update automatically. You must push fresh price data before operations that need it.

What

onDemandPriceUpdate pushes oracle data to the price feed:

  1. You obtain signed price data from the oracle provider (off-chain)

  2. You include the price update as the FIRST call in your multicall

  3. Credit Facade forwards the data to the price feed contract

  4. The price feed validates the signature and updates

Critical rule: All price updates must be at the beginning of the calls array. Any onDemandPriceUpdate after another call type will revert.

How

Basic Price Update

Multiple Price Updates

Update several tokens at once (all must be at the start):

Updating Reserve Feed (For Withdrawals)

Withdrawals trigger safe pricing, which uses both main and reserve feeds:

Contract Architecture for Price Updates

Your contract must accept price data as a parameter since it cannot fetch oracle data on-chain:

Gotchas

Price Updates MUST Be First

This is the most common mistake. Price updates after any other call type revert:

Fresh Data Required

Price data has a short validity window (usually a few minutes). Fetch fresh data right before the transaction:

Not All Tokens Need Updates

Only tokens with on-demand price feeds need updates. Tokens using Chainlink or other push-based oracles don't need onDemandPriceUpdate:

Disabled Tokens Don't Need Updates

If a token will be disabled by the end of the multicall, you don't need to update its price:

Contracts Cannot Fetch Price Data

The oracle's API must be called off-chain. Your smart contract receives price data as a parameter:

See Also

Last updated