getPriceUnsafe

This method returns a Pyth price object containing the last updated price for the given price feed identifier.

The price returned may be from arbitrarily far in the past. It is the callers responsibility to check the prices publishTime to ensure that the update is recent enough for their particular use case. To ensure the price has been updated sufficiently recently, consider using getPriceNoOlderThan instead.

Arguments

This method expects the following arguments:

ArgumentDescription

id

Unique Pyth price feed identifier. See Supported Price Feeds.

Returned Price

The Pyth price object contains the following fields:

FieldDescription

price

Latest price of the price feed.

conf

Confidence level of the price feed.

expo

Exponent of the price feed.

publishTime

Time when the price feed was last updated.

A sample price object returned by this method may look as follows:

{
    price: 123456789n,
    conf: 180726074n,
    expo: -8,
    publishTime: 1721765108n
}

The price above is of the format price * 10 ^ expo. So, the above price represents the number 123456789 * 10(-8) = 1.23456789 in this case.

Error Response

This method can return the following error response:

ErrorDescription

PriceFeedNotFound

The specified price feed has never received a price update or does not exist.

Last updated