IPyth
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
| Name | Type | Description |
|---|---|---|
updateData | bytes[] | 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
| Name | Type | Description |
|---|---|---|
updateData | bytes[] | Array of price update data. |
Returns
| Name | Type | Description |
|---|---|---|
feeAmount | uint256 | The 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
| Name | Type | Description |
|---|---|---|
id | bytes32 | The Pyth Price Feed ID of which to fetch the price and confidence interval. |
Returns
| Name | Type | Description |
|---|---|---|
price | Price | - please read the documentation of PythStructs.Price to understand how to use this safely. |
Structs
Price
struct Price {
// Price
int64 price;
// Confidence interval around the price
uint64 conf;
// Price exponent
int32 expo;
// Unix timestamp describing when the price was published
uint256 publishTime;
}
PriceFeed
struct PriceFeed {
// The price ID.
bytes32 id;
// Latest available price
Price price;
// Latest available exponentially-weighted moving average price
Price emaPrice;
}