Skip to content

Commit 3e1e23b

Browse files
committed
fix: pyth edge-case
1 parent 77bfb5d commit 3e1e23b

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/sdk/market/pricefeeds/updates/PythUpdater.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,13 @@ export class PythUpdater
256256
},
257257
{ attempts: 3, exponent: 2, interval: 200 },
258258
);
259-
return respToCalldata(resp);
259+
const result = respToCalldata(resp);
260+
if (!this.#ignoreMissingFeeds && result.length !== dataFeedsIds.size) {
261+
throw new Error(
262+
`expected ${dataFeedsIds.size} price feeds, got ${result.length}`,
263+
);
264+
}
265+
return result;
260266
}
261267
}
262268

@@ -265,8 +271,12 @@ function isPyth(pf: IPriceFeedContract): pf is IPythPriceFeedContract {
265271
}
266272

267273
function respToCalldata(resp: PythPriceUpdatesResp): TimestampedCalldata[] {
268-
const updates = splitAccumulatorUpdates(resp.binary.data[0]);
274+
// edge case when ignoreMissingFeeds is true and we requesting exactly one feed which fails
275+
if (resp.binary.data.length === 0) {
276+
return [];
277+
}
269278

279+
const updates = splitAccumulatorUpdates(resp.binary.data[0]);
270280
return updates.map(({ data, dataFeedId, timestamp }) => {
271281
return {
272282
dataFeedId,

0 commit comments

Comments
 (0)