Updating Price Feeds

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

For Solidity implementation, see Updating On-Demand 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

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:

Detecting Which Feeds Need Updates

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). Generate 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:

Off-Chain Data Retrieval

You need to fetch price data from the oracle's API before building your transaction. This is protocol-specific:

Your contract or frontend must handle this off-chain step.

Contracts Need Price Data Input

If you're building a contract that interacts with Gearbox, it must accept price data as an input parameter:

Contracts cannot fetch price data themselves - it must come from off-chain.

See Also

Last updated