Skip to content

Commit bf11ef9

Browse files
committed
fix: Mark price feeds fields as optional
1 parent e204c9f commit bf11ef9

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

apps/insights/src/schemas/pyth/price-feeds-schema.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const priceFeedsSchema = z.array(
77
display_symbol: z.string(),
88
asset_type: z.string(),
99
description: z.string(),
10-
price_account: z.string(),
10+
price_account: z.string().optional(),
1111
base: z.string().optional(),
1212
country: z.string().optional(),
1313
quote_currency: z.string().optional(),
@@ -21,12 +21,12 @@ export const priceFeedsSchema = z.array(
2121
contract_id: z.string().optional(),
2222
}),
2323
price: z.object({
24-
exponent: z.number(),
25-
numComponentPrices: z.number(),
26-
numQuoters: z.number(),
27-
minPublishers: z.number(),
28-
lastSlot: z.bigint(),
29-
validSlot: z.bigint(),
24+
exponent: z.number().optional(),
25+
numComponentPrices: z.number().optional(),
26+
numQuoters: z.number().optional(),
27+
minPublishers: z.number().optional(),
28+
lastSlot: z.bigint().optional(),
29+
validSlot: z.bigint().optional(),
3030
priceComponents: z.array(
3131
z.object({
3232
publisher: z.string(),

apps/insights/src/services/pyth/get-feeds.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ const _getFeeds = async (cluster: Cluster) => {
77
const unfilteredData = await getPythMetadata(cluster);
88
const filtered = unfilteredData.symbols
99
.filter(
10-
(symbol) =>
11-
unfilteredData.productFromSymbol.get(symbol)?.display_symbol !==
12-
undefined,
10+
(symbol) => {
11+
const product = unfilteredData.productFromSymbol.get(symbol)
12+
const hasDisplaySymbol = product?.display_symbol !== undefined
13+
const hasPriceAccount = product?.price_account !== undefined
14+
15+
return hasDisplaySymbol && hasPriceAccount
16+
}
1317
)
1418
.map((symbol) => ({
1519
symbol,

0 commit comments

Comments
 (0)