Skip to content

API ReferencePricing and oraclesType Alias

UsdPriceOutcome

type UsdPriceOutcome =
| {
feedId?: string;
kind: 'address';
price: Price;
publishTime: bigint;
status: 'fresh';
token: Address;
}
| {
feedId?: string;
kind: 'address';
price: Price;
publishTime: bigint;
status: 'stale';
token: Address;
}
| {
feedId?: string;
kind: 'address';
publishTime?: bigint;
reason: UsdPriceUnavailableReason;
status: 'unavailable';
token: Address;
}
| {
feedId: string;
key: string;
kind: 'feed';
price: Price;
publishTime: bigint;
status: 'fresh';
}
| {
feedId: string;
key: string;
kind: 'feed';
price: Price;
publishTime: bigint;
status: 'stale';
}
| {
feedId: string;
key: string;
kind: 'feed';
publishTime?: bigint;
reason: UsdPriceUnavailableReason;
status: 'unavailable';
};

One token’s display-pricing state, discriminated on kind (an address entry vs. a direct UsdPriceFeedEntry) and status. Narrow on kind before reading identity: the address branch carries token typed as Address, exactly as supplied in params.tokens; the feed branch carries key (the caller’s key when supplied, otherwise feedId) and has no token field at all. outcome.status === 'fresh' narrows to a value with price for either kind.

fresh and stale both carry a usable Price; stale means the publish time is outside oracleConfig.maxPriceAgeSeconds (300 seconds by default), so a consumer that shows it should say so. unavailable carries a UsdPriceUnavailableReason and never a price. A feed entry’s feedId is always required because it names its feed directly rather than resolving one; an address entry’s feedId is optional and absent only when feed resolution itself failed.

Union Members

Type Literal

{
feedId?: string;
kind: "address";
price: Price;
publishTime: bigint;
status: "fresh";
token: Address;
}

feedId?

optional feedId?: string;

The resolved Pyth feed ID.

kind

kind: 'address';

price

price: Price;

USD price in cents per most-granular token unit.

publishTime

publishTime: bigint;

Pyth publish time in seconds; the same value as price.publishTime.

status

status: 'fresh';

Published within the configured freshness window.

token

token: Address;

The address exactly as supplied in params.tokens.


Type Literal

{
feedId?: string;
kind: "address";
price: Price;
publishTime: bigint;
status: "stale";
token: Address;
}

feedId?

optional feedId?: string;

The resolved Pyth feed ID.

kind

kind: 'address';

price

price: Price;

USD price in cents per most-granular token unit.

publishTime

publishTime: bigint;

Pyth publish time in seconds; the same value as price.publishTime.

status

status: 'stale';

Published outside the configured freshness window.

token

token: Address;

The address exactly as supplied in params.tokens.


Type Literal

{
feedId?: string;
kind: "address";
publishTime?: bigint;
reason: UsdPriceUnavailableReason;
status: "unavailable";
token: Address;
}

feedId?

optional feedId?: string;

The resolved Pyth feed ID, when feed resolution succeeded.

kind

kind: 'address';

publishTime?

optional publishTime?: bigint;

Publish time of the rejected Hermes entry, when one was returned.

reason

reason: UsdPriceUnavailableReason;

status

status: 'unavailable';

No usable price; see reason.

token

token: Address;

The address exactly as supplied in params.tokens.


Type Literal

{
feedId: string;
key: string;
kind: 'feed';
price: Price;
publishTime: bigint;
status: 'fresh';
}

feedId

feedId: string;

The feed ID exactly as supplied; a feed entry names its feed directly rather than resolving one, so this is always present.

key

key: string;

The caller’s key, or the feed’s feedId when key was omitted.

kind

kind: 'feed';

price

price: Price;

USD price in cents per most-granular unit, using the entry’s own decimals.

publishTime

publishTime: bigint;

Pyth publish time in seconds; the same value as price.publishTime.

status

status: 'fresh';

Published within the configured freshness window.


Type Literal

{
feedId: string;
key: string;
kind: 'feed';
price: Price;
publishTime: bigint;
status: 'stale';
}

feedId

feedId: string;

The feed ID exactly as supplied; a feed entry names its feed directly rather than resolving one, so this is always present.

key

key: string;

The caller’s key, or the feed’s feedId when key was omitted.

kind

kind: 'feed';

price

price: Price;

USD price in cents per most-granular unit, using the entry’s own decimals.

publishTime

publishTime: bigint;

Pyth publish time in seconds; the same value as price.publishTime.

status

status: 'stale';

Published outside the configured freshness window.


Type Literal

{
feedId: string;
key: string;
kind: "feed";
publishTime?: bigint;
reason: UsdPriceUnavailableReason;
status: "unavailable";
}

feedId

feedId: string;

The feed ID exactly as supplied; a feed entry names its feed directly rather than resolving one, so this is always present.

key

key: string;

The caller’s key, or the feed’s feedId when key was omitted.

kind

kind: 'feed';

publishTime?

optional publishTime?: bigint;

Publish time of the rejected Hermes entry, when one was returned.

reason

reason: UsdPriceUnavailableReason;

status

status: 'unavailable';

No usable price; see reason.