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
| Parameter | Type | Description |
|---|---|---|
feedId | string | The Pyth price feed ID of the rejected price, or an empty string when the feed ID was not known. |
publishTime | bigint | When Pyth published the rejected price, in Unix seconds. |
maxAgeSeconds | number | The maximum age, in seconds, the price was checked against: the configured oracleConfig.maxPriceAgeSeconds, or 300 by default. |
Returns
StalePythPriceError
Overrides
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 Parameter | Description |
|---|---|
T extends Error | The error class being searched for. |
Parameters
| Parameter | Type | Description |
|---|---|---|
errorType | (…args) => T | The 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