From ad91f49167ccc3805cc6f8d3801f8e69a0b9c90f Mon Sep 17 00:00:00 2001 From: TaprootFreak <142087526+TaprootFreak@users.noreply.github.com> Date: Wed, 3 Jun 2026 16:41:07 +0200 Subject: [PATCH] Retry transient RPC errors on equity price reads --- src/monitoringV2/price.service.ts | 4 ++-- src/monitoringV2/provider.service.ts | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) 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);