Fix: batch CoinGecko token price requests - #91
Open
munikes wants to merge 1 commit into
Open
Conversation
coingeckoPriceLookup was making one HTTP request per token address in a loop with a 250ms delay, despite CoinGecko's simple/token_price endpoint natively supporting comma-separated contract_addresses in a single call. For a broadcaster running 3 networks with ~6-8 tokens each, this meant ~20 requests per refresh cycle (every ~60s) instead of 3 — burning through the free Demo tier's 10,000 requests/month quota in about 10 hours of uptime. Also lowered batchSize from 50 to 30 to match CoinGecko's documented Demo tier limit of 30 addresses per request (50 would only be safe on paid tiers).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
coingeckoPriceLookupfetches each token's price with a separate HTTP request, looping through addresses one by one with a 250ms delay between each — even though CoinGecko'ssimple/token_price/{id}endpoint natively supports comma-separatedcontract_addressesin a single call (confirmed: up to 30 addresses per request on the free Demo tier).For a broadcaster running 3 active networks (~6-8 tokens each), this means ~20 requests per refresh cycle. With the default 60-second refresh interval, that's roughly 970 requests/hour — enough to exhaust the Demo tier's 10,000 requests/month quota in about 10 hours of uptime.
Fix
contract_addressesparam, cutting requests-per-cycle from ~N tokens to 1 per network.batchSizefrom 50 to 30 to match CoinGecko's documented Demo tier limit (50 addresses/request would only be safe on paid tiers).Impact
For a typical 3-network broadcaster, this drops CoinGecko usage from ~20 requests/cycle to ~3 requests/cycle (~85% reduction), making the free Demo tier actually viable for continuous operation.