Skip to content

Route GeckoTerminal via pricing-proxy#66

Merged
TaprootFreak merged 2 commits into
developfrom
feature/route-geckoterminal-via-proxy
May 12, 2026
Merged

Route GeckoTerminal via pricing-proxy#66
TaprootFreak merged 2 commits into
developfrom
feature/route-geckoterminal-via-proxy

Conversation

@TaprootFreak

@TaprootFreak TaprootFreak commented May 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds the required `GECKOTERMINAL_BASE_URL` env var to point the GeckoTerminal upstream at the in-cluster pricing-proxy (DFXswiss/pricing-proxy) instead of `api.geckoterminal.com` directly. Mirrors the `COINGECKO_BASE_URL` plumbing from #31 — same construction-time hard-fail, same .env wording, same getter shape.

Why

GeckoTerminal's free tier shares a single 30 req/min IP quota across every consumer on the host. Three monitoring stacks (d-EURO, JuiceDollar testnet, JuiceDollar mainnet) plus restart-bursts already produce visible 429s on dfxdev:

```
deuro-deuro-monitoring-1 | ERROR [PriceService] AxiosError: Request failed with status code 429
deuro-deuro-monitoring-1 | WARN [PriceService] Returning expired cached prices due to API error
```

The pricing-proxy now exposes a `/geckoterminal/` route (pricing-proxy#3) with the same 60 s shared cache, request coalescing and validation pipeline already in front of CoinGecko Pro. Pointing this service at it collapses the three independent streams into one upstream call per 60 s.

What changes

  • `src/config/monitoring.config.ts` — new `geckoTerminalBaseUrl?: string` field plumbed from `GECKOTERMINAL_BASE_URL`.
  • `src/config/config.service.ts` — getter, same shape as `coingeckoBaseUrl`.
  • `src/monitoringV2/price.service.ts` —
    • Constructor hard-fails when `GECKOTERMINAL_BASE_URL` is unset, same as for `COINGECKO_BASE_URL`. No silent anonymous fallback.
    • Misnomer fix: `getCoinGeckoPricesInUSD` → `getGeckoTerminalPricesInUSD` (and the local `coinGeckoPrices` variable in `getTokenPricesInEur`). The function has always called `api.geckoterminal.com`, not CoinGecko — the name was a relic from before the GT path was split out. Matches the helper name already in use in the downstream fork at `JuiceDollar/monitoring`.
  • `.env.example` — documents the new var as required, parallel to `COINGECKO_BASE_URL`.

Breaking — rollout order matters

`GECKOTERMINAL_BASE_URL` is required. A container started without it now refuses to construct and the deploy will roll back. The server-side compose update on `DFXswiss/server` (adding the env to `deuro-monitoring` on dfxdev + dfxprd) must therefore be in place before the Auto-Release-PR for this repo lands on `main` and the `:latest` image rebuilds.

Recommended order:

  1. Merge this PR → `:beta` rebuilds. dfxdev's `deuro-monitoring` stack will not auto-deploy because the env var isn't set yet; that's fine, the existing container keeps serving.
  2. Land the server-repo compose change adding `GECKOTERMINAL_BASE_URL: http://pricing-proxy:8080/geckoterminal\` to `deuro-monitoring` on dfxdev + dfxprd, plus the auto-release PR to `main`. After that deploys, the existing `:latest` container restarts with the env set and keeps working (env is read at startup, old code just ignores the var).
  3. Approve the Auto-Release-PR for this repo (develop → main). `:latest` rebuilds. Next `deuro-monitoring` deploy picks up the new image, constructor sees the env, traffic now flows through the proxy.

Test plan

  • CI green (build + lint)
  • After server-repo compose change lands on dfxdev: existing `deuro-monitoring` container restarts cleanly with `GECKOTERMINAL_BASE_URL` set; logs still show `Fetched prices for N tokens from GeckoTerminal` (old code, still direct path).
  • After this PR's auto-release lands on main and the resulting `:latest` deploys: pricing-proxy logs on dfxdev show `/geckoterminal/api/v2/...` traffic from the `deuro-monitoring` container IP, and the 429 lines stop.
  • Same verification on dfxprd after the prd-side compose + deploy.

Mirrors the COINGECKO_BASE_URL plumbing already in place (PR #31): the
GeckoTerminal upstream URL becomes a config-driven base path rather than
a hardcoded api.geckoterminal.com literal. Defaults to the public host so
existing deployments without the env var keep working; setting
GECKOTERMINAL_BASE_URL points the service at the in-cluster pricing-proxy
on https://github.com/DFXswiss/pricing-proxy, which adds a 60 s shared
cache, request coalescing and validation on top of the shared free-tier
30 req/min IP quota.

This addresses the periodic 429s observed on deuro-monitoring (dfxdev)
when the free-tier quota is exhausted across all consumers competing for
the same anonymous IP: with the proxy in front, three monitoring stacks
collapse to one upstream call every 60 s instead of three independent
streams.

Non-breaking: the literal default keeps every existing deployment on the
direct path until its compose adds GECKOTERMINAL_BASE_URL.
@TaprootFreak TaprootFreak marked this pull request as ready for review May 12, 2026 21:05
Two consistency fixes on top of the initial commit:

1. Hard-fail at construction when GECKOTERMINAL_BASE_URL is unset,
   mirroring the existing COINGECKO_BASE_URL check in the same
   constructor. The previous `?? 'https://api.geckoterminal.com'`
   default silently fell back to the public host — the exact pattern
   the CoinGecko refactor (#31) was meant to remove for that route.
   Treating both upstreams the same way removes a class of silent
   anonymous fallbacks that surface later as sporadic 429s.

2. Rename `getCoinGeckoPricesInUSD` to `getGeckoTerminalPricesInUSD`
   (and its local caller variable `coinGeckoPrices` to
   `geckoTerminalPrices`). The function has always called
   `api.geckoterminal.com`, not CoinGecko — the name was a relic from
   before the GT path was split out. Matches the equivalent helper in
   d-EURO/monitoring's downstream fork (JuiceDollar/monitoring) where
   it is already correctly named.

`.env.example` upgraded from optional comment to required entry, again
matching the COINGECKO_BASE_URL phrasing in the same file.
@TaprootFreak TaprootFreak merged commit cc40524 into develop May 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant