Skip to content
Lattice

IPyth

Git Source

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

NameTypeDescription
idbytes32The Pyth price-feed id.

Returns

NameTypeDescription
pricePriceThe latest stored price.

getUpdateFee

Returns the fee (in wei) required to submit updateData.

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

Parameters

NameTypeDescription
updateDatabytes[]The signed price-update blobs.

Returns

NameTypeDescription
feeAmountuint256The required fee.

updatePriceFeeds

Submits updateData to update the on-chain prices; msg.value must be >= getUpdateFee.

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

Parameters

NameTypeDescription
updateDatabytes[]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

NameTypeDescription
priceint64The price (scale 10^expo).
confuint64The confidence interval around price (same scale).
expoint32The price exponent (usually negative, e.g. -8).
publishTimeuint256The unix timestamp the price was published.