Price Feeds
update_price_feeds

Update Price Feeds

Update the on-chain price feeds using the provided update_data, which contains serialized and signed price update data from Pyth Network. This function updates the on-chain price if the provided update is more recent than the current on-chain price. Otherwise, the provided update will be ignored. The function call will succeed even if the update is ignored.

You can retrieve the latest price update_data for a given set of price feeds from the Hermes API (opens in a new tab). By default, the data is returned as a base64-encoded string that you must deserialize into a vector of bytes before calling this method.

This function requires the caller to pay a fee to perform the update. The required fee for a given set of updates can be computed by passing them to get_update_fee.

Reverts if the required fee is not paid, or the update_data is incorrectly signed or formatted.

ArgumentInputDescription

update_data*

vector<vector<u8>>

The price update data for the contract to verify.

fee*

Coin<AptosCoin>

The update fee in octa. This fee is transferred to the Pyth contract as an effect of the transaction.
Examples

Example Code

use pyth::pyth;
use pyth::price_identifier;
 
let coins = coin::withdraw<AptosCoin>(payer, <fee>)
pyth::update_price_feeds(
  vec![<update_data>],
  coins
);
Last updated on