IPyth

Git Source

Functions

updatePriceFeeds

Update price feeds with given update messages. This method requires the caller to pay a fee in wei; the required fee can be computed by calling getUpdateFee with the length of the updateData array. Prices will be updated if they are more recent than the current stored prices. The call will succeed even if the update is not the most recent.

Reverts if the transferred fee is not sufficient or the updateData is invalid.

function updatePriceFeeds(bytes[] calldata updateData) external payable;

Parameters

NameTypeDescription
updateDatabytes[]Array of price update data.

getUpdateFee

Returns the required fee to update an array of price updates.

function getUpdateFee(bytes[] calldata updateData) external view returns (uint256 feeAmount);

Parameters

NameTypeDescription
updateDatabytes[]Array of price update data.

Returns

NameTypeDescription
feeAmountuint256The required fee in Wei.

getPrice

Returns the price and confidence interval.

Reverts if the price has not been updated within the last getValidTimePeriod() seconds.

function getPrice(bytes32 id) external view returns (Price memory price);

Parameters

NameTypeDescription
idbytes32The Pyth Price Feed ID of which to fetch the price and confidence interval.

Returns

NameTypeDescription
pricePrice- please read the documentation of PythStructs.Price to understand how to use this safely.

Structs

Price

struct Price {
    int64 price;
    uint64 conf;
    int32 expo;
    uint256 publishTime;
}

PriceFeed

struct PriceFeed {
    bytes32 id;
    Price price;
    Price emaPrice;
}