Skip to content

API ReferencePricing and oraclesFunction

getUsdPrice()

function getUsdPrice(ctx, params): Promise<Price>;

Gets the USD price of the provided token. Note: This price is the number of cents per most granular unit of the token. This differs from how prices are typically displayed.

Parameters

ParameterTypeDescription
ctxSDKContextThe SDK context.
paramsGetUsdPriceParamsThe parameters indicating which token is being priced.

Returns

Promise<Price>

The price object indicating the USD price.

Throws

StalePythPriceError If Hermes returns a price outside oracleConfig.maxPriceAgeSeconds.

Throws

PriceServerError If the price server cannot be reached, has no feed for the token, or returns an unusable price; the underlying error is preserved as cause.