diff --git a/src/monitoringV2/price.service.ts b/src/monitoringV2/price.service.ts index 20bee81..0745b96 100644 --- a/src/monitoringV2/price.service.ts +++ b/src/monitoringV2/price.service.ts @@ -152,9 +152,9 @@ export class PriceService { const underlying = specialTokens.get(formattedAddress); if (!underlying) continue; // Not a special token - // Fetch price from underlying equity contract + // Fetch price from underlying equity contract (with transient-error retry) const equityContract = new ethers.Contract(underlying, EquityABI, this.providerService.provider); - const nativePrice = await equityContract.price(); + const nativePrice = await this.providerService.call(() => equityContract.price()); let formattedPrice = ethers.formatUnits(nativePrice, 18); // For WFPS, convert CHF to EUR diff --git a/src/monitoringV2/provider.service.ts b/src/monitoringV2/provider.service.ts index c463efa..027d7ab 100644 --- a/src/monitoringV2/provider.service.ts +++ b/src/monitoringV2/provider.service.ts @@ -141,6 +141,10 @@ export class ProviderService { return results; } + async call(thunk: () => Promise, retries = 5): Promise { + return this.withRetry(thunk, { retries }); + } + async getBlock(blockNumber: number): Promise { if (this.blockCache.has(blockNumber)) { return this.blockCache.get(blockNumber);