IPyth
Title: IPyth
Author: Vendored minimal subset of Pyth Network (https://github.com/pyth-network/pyth-crosschain/blob/main/target_chains/ethereum/sdk/solidity/IPyth.sol).
Upstream license: Apache-2.0.
Minimal interface for the Pyth on-chain price oracle.
Vendored subset — do not add a @pythnetwork/pyth-sdk-solidity dependency. Pyth is pull-based:
a caller submits a signed updateData blob (paying getUpdateFee) via updatePriceFeeds,
which stores the latest price on-chain; reads then use getPriceUnsafe (raw, no staleness check
— the consumer validates publish time itself).
Functions
getPriceUnsafe
Returns the latest price for id WITHOUT a staleness check.
Reverts if no price has ever been posted for id. The caller MUST check publishTime.
function getPriceUnsafe(bytes32 id) external view returns (Price memory price);Parameters
| Name | Type | Description |
|---|---|---|
| id | bytes32 | The Pyth price-feed id. |
Returns
| Name | Type | Description |
|---|---|---|
| price | Price | The latest stored price. |
getUpdateFee
Returns the fee (in wei) required to submit updateData.
function getUpdateFee(bytes[] calldata updateData) external view returns (uint256 feeAmount);Parameters
| Name | Type | Description |
|---|---|---|
| updateData | bytes[] | The signed price-update blobs. |
Returns
| Name | Type | Description |
|---|---|---|
| feeAmount | uint256 | The required fee. |
updatePriceFeeds
Submits updateData to update the on-chain prices; msg.value must be >= getUpdateFee.
function updatePriceFeeds(bytes[] calldata updateData) external payable;Parameters
| Name | Type | Description |
|---|---|---|
| updateData | bytes[] | The signed price-update blobs. |
Structs
Price
A Pyth price with its confidence interval and exponent.
struct Price {
int64 price;
uint64 conf;
int32 expo;
uint256 publishTime;
}Properties
| Name | Type | Description |
|---|---|---|
| price | int64 | The price (scale 10^expo). |
| conf | uint64 | The confidence interval around price (same scale). |
| expo | int32 | The price exponent (usually negative, e.g. -8). |
| publishTime | uint256 | The unix timestamp the price was published. |