Pyth Core
Pyth Core is the flagship product. The decentralized, permissionless, pull-based price feeds that anyone can read on 100+ chains. If you have heard of "Pyth price feeds", this is what people mean. The on-chain price is a struct with four fields. Once you can read those fields correctly, you have everything you need to settle a trade, value collateral, or settle an option.
The four fields
struct Price {
int64 price; // signed integer
uint64 conf; // confidence interval, always positive
int32 expo; // exponent. real_value = price * 10^expo
uint publishTime; // unix seconds
}To get the real number you multiply price by 10^expo. The exponent is almost always negative for crypto pairs — typical value is -8, so the integer price = 67_43215000000 with expo = -8 means $67,432.15.
Why fixed-point
Asset classes
The Core catalog is the largest on-chain price universe in production: 3,059 active feeds as of this writing. It is grouped into six broad classes — exact counts grow weekly, so the Pythfeeds feeds page is the live source of truth.
- Crypto. Spot and perp benchmarks for majors, alts, memes, LSTs, LRTs, and stablecoins.
- Equities. US stocks, ETFs, and indices. NASDAQ and NYSE primary listings. Pre-market and after-hours coverage on most names.
- FX. Majors and most crosses. EUR/USD, USD/JPY, GBP/USD, and the rest.
- Metals. XAU, XAG, XPT, XPD against USD.
- Commodities. Oil, natural gas, agricultural futures.
- Rates. US Treasury benchmarks, SOFR.
Confidence interval
The conf field is the single most important thing that sets Pyth apart from older oracle designs. It is a one-sigma error bar. A price of 67,432 ± 3.20 says publishers mostly agree, but the next print could plausibly land anywhere in the range [67,428.80, 67,435.20].
You should use it. Two common patterns:
// LENDING: be cautious. Value collateral at the lower bound,
// value debt at the upper bound. You can never get liquidated
// by a momentary spread.
uint collateralValue = (uint(p.price) - p.conf) * scale;
uint debtValue = (uint(p.price) + p.conf) * scale;
// PERPS: refuse to trade when the market is unusually noisy.
// A 1% confidence-to-price ratio is a reasonable circuit breaker.
require(p.conf * 100 < uint64(uint(p.price)), "spread too wide");Staleness
Pyth Core has two read functions. Use only one of them.
getPriceUnsafe(feedId)— returns the most recent price the contract has, no matter how old. Do not use this in user-facing code.getPriceNoOlderThan(feedId, maxAge)— reverts if the stored update is older thanmaxAgeseconds. Use this.
A reasonable maxAge is between 10 and 60 seconds. Shorter for trading, longer for lending. The right choice is the longest delay your business logic survives without arbitrage.
Update fees
Posting an update on-chain costs gas plus a small protocol fee. The fee scales with how many feeds you bundle:
bytes[] memory updates = abi.decode(/* … */);
uint fee = pyth.getUpdateFee(updates);
pyth.updatePriceFeeds{value: fee}(updates);Always call getUpdateFee. The protocol fee is a few thousand wei on most chains, but it changes per network and is updated by governance, so hard-coding it is a guaranteed bug six months from now.
Sponsored feeds
getPriceNoOlderThan costs only the read gas. Check the Pyth docs for the sponsored list on your chain.Historical prices (Benchmarks)
Core also covers past prices. The Benchmarks endpoint returns a signed price update for an exact past timestamp, in the same binary format your contract already accepts. That makes retrospective settlement, audits, and on-chain proofs of historical values trivial.
// One historical snapshot — BTC/USD at exactly 1716000000 unix
const url = `https://benchmarks.pyth.network/v1/updates/price/${timestamp}`;
const res = await fetch(`${url}?ids[]=${BTC_USD_FEED_ID}`);
const { binary } = await res.json();
const updateData = binary.data.map(d => "0x" + d);
await contract.settleFromHistory(timestamp, updateData, { value: fee });Feed IDs
Every feed has a 32-byte ID. They look like this:
ETH/USD: 0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace
BTC/USD: 0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43
SOL/USD: 0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56dThe same ID works on every chain. You can browse the full list, search by ticker, and copy IDs at the Hermes feed catalog, or query it dynamically.