feat(pricing): public CoinGecko simple/price proxy endpoint#3714
feat(pricing): public CoinGecko simple/price proxy endpoint#3714TaprootFreak wants to merge 2 commits into
Conversation
Expose GET /pricing/simple-price as a cached, unauthenticated pass-through to CoinGecko's /simple/price, routing wallet traffic through the central CoinGecko Pro key. Caps ids at 100, whitelists vs_currencies against CoinGecko's supported list, and caches responses for 60s. Closes #3712
Move the vs_currencies whitelist check from the controller into CoinGeckoService.getSimplePrice so the controller stays a thin pass-through, drop the duplicate lowercasing pass, restore the alphabetical import order in coin-gecko.service.ts and document the response shape via @ApiOkResponse.
Review feedback1. Cache key granularityThe current cache key is the full request combination ( Consider caching per individual 2. Unbounded cache + no rate limit = memory/cost vulnerabilityThis is a public, unauthenticated endpoint proxying a paid CoinGecko Pro key. The Since every unique combination of ids/currencies creates a new entry, a single client can:
Every other endpoint on this controller requires |
Summary
Adds a public, unauthenticated
GET /pricing/simple-priceendpoint that proxies CoinGecko's/simple/pricethroughapi.dfx.swiss, using the central CoinGecko Pro key and a 60 s in-memory cache. Closes #3712.SimplePriceRequestDTO (comma-listids&vs_currencies,idscapped at 100).CoinGeckoService.getSimplePrice()+getSupportedCurrencies(); responses cached viaAsyncCache(60 s TTL).vs_currenciesagainst the supported list and returns CoinGecko's raw shape unchanged so the wallet only needs to swap the base URL.Test plan
curl https://dev.api.dfx.swiss/v1/pricing/simple-price?ids=bitcoin,ethereum&vs_currencies=usd,eurreturns CoinGecko's standard shape400 Bad Request>100ids →400 Bad Requestdfx-wallet) swap ofCOINGECKO_SIMPLE_PRICEto the new endpoint works end-to-endOut of scope
/coins/listendpoint (separate issue)getRawPricecovers backend consumers)