From 31c78c0bef287832507b162acbab78a616359f0a Mon Sep 17 00:00:00 2001 From: TaprootFreak <142087526+TaprootFreak@users.noreply.github.com> Date: Fri, 15 May 2026 19:52:33 +0200 Subject: [PATCH] Remove daily CoinGecko quota probe (now owned by pricing-proxy) The pricing-proxy ships with its own quota monitor (DFXswiss/pricing-proxy PR #7 + #9): it probes /api/v3/key every 30 min and alerts via the dedicated @dfx_pricing_proxy_bot at 80 % (warning) and 95 % (critical) of the monthly credit, with a recovery message on healthy. That makes this service's daily probe redundant. Drop the cron, its state field and its two constants; the unused CoingeckoKeyInfo interface goes with them. The BTC-staleness watchdog and the cache plumbing are untouched. Mirror of d-EURO/monitoring#68. Update the README to drop the 'daily Pro quota probe' clause from the CoinGecko section. --- README.md | 4 +-- src/monitoringV2/price.service.ts | 45 ------------------------------- 2 files changed, 2 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index ad7cdba..11738cb 100644 --- a/README.md +++ b/README.md @@ -91,8 +91,8 @@ Swagger documentation available at: `http://localhost:3001/swagger` ## CoinGecko The monitoring service needs a CoinGecko-compatible endpoint for BTC spot -prices (drives the WCBTC suspicious-liq-price watchdog) and the daily Pro -quota probe. Configuration is two env vars: +prices — they drive the WCBTC suspicious-liq-price watchdog. Configuration +is two env vars: | Var | Required | Purpose | |---|---|---| diff --git a/src/monitoringV2/price.service.ts b/src/monitoringV2/price.service.ts index 63fd721..b4963a0 100644 --- a/src/monitoringV2/price.service.ts +++ b/src/monitoringV2/price.service.ts @@ -29,17 +29,8 @@ interface CoingeckoEndpoint { headers: Record; } -interface CoingeckoKeyInfo { - plan?: string; - monthly_call_credit?: number; - current_total_monthly_calls?: number; - current_remaining_monthly_calls?: number; -} - const STALENESS_ALERT_THRESHOLD_MS = 60 * 60 * 1000; const STALENESS_ALERT_REPEAT_MS = 6 * 60 * 60 * 1000; -const QUOTA_REMAINING_ALERT_THRESHOLD = 25_000; -const QUOTA_ALERT_REPEAT_MS = 24 * 60 * 60 * 1000; @Injectable() export class PriceService { @@ -53,7 +44,6 @@ export class PriceService { // the alert indefinitely. private btcLastSuccessMs: number = Date.now(); private btcStalenessAlertedAt: number | null = null; - private quotaAlertedAt: number | null = null; constructor( private readonly providerService: ProviderService, @@ -186,41 +176,6 @@ export class PriceService { ); } - /** - * Daily probe of /api/v3/key through the pricing proxy. Emits a critical - * alert when the monthly remaining call credit drops below - * QUOTA_REMAINING_ALERT_THRESHOLD. - */ - @Cron(CronExpression.EVERY_DAY_AT_NOON) - async checkCoingeckoQuota(): Promise { - try { - const { baseUrl, headers } = this.resolveCoingeckoEndpoint(); - const response = await axios.get(`${baseUrl}/api/v3/key`, { - headers, - timeout: 10000, - }); - const { current_remaining_monthly_calls: remaining, monthly_call_credit: credit } = response.data; - if (typeof remaining !== 'number' || typeof credit !== 'number' || credit <= 0) return; - - const pct = Math.round((remaining / credit) * 100); - this.logger.log(`CoinGecko quota: ${remaining} of ${credit} calls remaining (${pct}%)`); - - if (remaining >= QUOTA_REMAINING_ALERT_THRESHOLD) { - this.quotaAlertedAt = null; - return; - } - if (this.quotaAlertedAt && Date.now() - this.quotaAlertedAt < QUOTA_ALERT_REPEAT_MS) return; - - this.quotaAlertedAt = Date.now(); - await this.telegramService.sendCriticalAlert( - `CoinGecko monthly quota almost exhausted: ${remaining.toLocaleString()} of ` + - `${credit.toLocaleString()} calls remaining (${pct}%).` - ); - } catch (error) { - this.logger.warn(`CoinGecko quota probe failed: ${error.message ?? error}`); - } - } - private async getGeckoTerminalPricesInUSD(addresses: string[]): Promise<{ [key: string]: string }> { if (addresses.length === 0) return {};