Skip to content

API ReferenceErrorsClass

StalePythPriceError

Error thrown when the Pyth price service returns a price that is unsafe to use because its publish time is too far from now, in the past or the future. The limit is oracleConfig.maxPriceAgeSeconds in AnvilDependencies, 300 seconds by default.

It’s separate from PriceServerError, so you can tell a price service that is unavailable from one that answered with an unsafe price.

Extends

Constructors

Constructor

new StalePythPriceError(
feedId,
publishTime,
maxAgeSeconds
): StalePythPriceError;

Parameters

ParameterTypeDescription
feedIdstringThe Pyth price feed ID of the rejected price, or an empty string when the feed ID was not known.
publishTimebigintWhen Pyth published the rejected price, in Unix seconds.
maxAgeSecondsnumberThe maximum age, in seconds, the price was checked against: the configured oracleConfig.maxPriceAgeSeconds, or 300 by default.

Returns

StalePythPriceError

Overrides

BaseError.constructor

Properties

feedId

readonly feedId: string;

The Pyth price feed ID of the rejected price, or an empty string when the feed ID was not known.


maxAgeSeconds

readonly maxAgeSeconds: number;

The maximum age, in seconds, the price was checked against: the configured oracleConfig.maxPriceAgeSeconds, or 300 by default.


publishTime

readonly publishTime: bigint;

When Pyth published the rejected price, in Unix seconds.

Methods

walk()

walk<T>(errorType): T | undefined;

Finds an error of the given class in this error’s cause chain. The search starts with this error itself, then follows each cause in turn.

Type Parameters

Type ParameterDescription
T extends ErrorThe error class being searched for.

Parameters

ParameterTypeDescription
errorType(…args) => TThe error class to find, such as UserRejectedRequestError.

Returns

T | undefined

The first error in the chain that is an instance of errorType, or undefined if there is none.

Example

const rejected = error.walk(UserRejectedRequestError);
if (rejected) return; // the user declined in their wallet

Inherited from

BaseError.walk