Skip to content

Pricing and oracles

Read Pyth oracle prices between tokens, feed IDs, and price-update fees.

sdk.pricing.getPrice returns the Pyth rate between two tokens in smallest units, with both tokens’ decimals already folded in, so on-chain math can use it as-is. getUsdPrice reads a single token’s USD price the same way, while getUsdPrices batches a display read for a set of token addresses and/or direct Pyth feed entries and returns a fresh, stale, or unavailable outcome for each. getPriceFeedId returns the underlying Pyth feed identifier for a token when you need it directly.

A price update is a signed payload the oracle contract needs before it will report a value — getOraclePriceUpdate fetches one from Pyth Hermes, getOraclePriceUpdateFee is what posting it costs, and resolveOraclePriceUpdate is the shared step every price-dependent write threads through so it is fetched at most once per call.

PricingModule documents all of the above; each read also exists as a standalone function taking the SDK context explicitly, listed with this group in the sidebar. What a price means for collateral sizing and risk is in Vaults and collateral; price staleness is covered in Prices and the oracle.

USDC per whole WETH:

const { price, exponent } = await sdk.pricing.getPrice({
inputToken: WETH,
outputToken: USDC,
});
// price * 10**exponent = USDC smallest units per 1 wei; both tokens'
// decimals are already folded in, so on-chain math uses it as-is. Rescale
// by (18 - 6) only to show USDC per whole WETH.
const usdcPerWholeWeth =
Number(price) * 10 ** (Number(exponent) + 18 - 6);

Primary APIs

Interfaces

  • PricingModule — Pricing operations: oracle prices, price feed IDs, and update fees.

Supporting types and functions in this group are not listed here; each has its own page, listed with the group in the sidebar.