Skip to content

oracle: add coingecko demo and pro tier support#10

Merged
martonp merged 2 commits intobisoncraft:masterfrom
dnldd:add-coingecko-source
Mar 13, 2026
Merged

oracle: add coingecko demo and pro tier support#10
martonp merged 2 commits intobisoncraft:masterfrom
dnldd:add-coingecko-source

Conversation

@dnldd
Copy link
Copy Markdown
Contributor

@dnldd dnldd commented Feb 22, 2026

This implements unified CoinGecko provider supporting demo (file-based quota) and pro (API-based quota) tiers. Demo tier persists 9,800 monthly credits in local JSON with automatic monthly reset. Pro tier tracks quota via /api/v3/key endpoint. Both tiers use MinPeriod=30s for consistent fetch ordering. New FileTrackedSource utility manages file-based quota state with thread-safe credit consumption. Includes comprehensive unit and integration tests for both tiers.

@dnldd dnldd changed the title oracle: add coingecko price source with quota tracking oracle: add coingecko price source Feb 22, 2026
Copy link
Copy Markdown
Contributor

@martonp martonp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some untested suggestions: 57fd504

There is a free demo tier with an API key. I think we should prefer this one over a public API key version. This gives us confidence that we get 10k requests per month. The key endpoint is disabled on the demo tier, so we can track the usage locally, saving to a file to persist usage across restarts. I hardcoded 9500 (it's actually 10k, 9500 for safety) for the monthly quota, but maybe this should be configured rather than hardcoded.

The way you have it currently, combining the unlimited tier with the tracked tier, with two different minimum periods, will not allow the deterministic fetch ordering to work properly. The deterministic ordering requires the minimum period to be the same for all nodes on the network. Also, unlimited nodes will basically never be selected to fetch first if anyone is on a pro tier.

@dnldd dnldd force-pushed the add-coingecko-source branch from 4591a1a to 4ae30ab Compare February 25, 2026 00:48
@dnldd dnldd changed the title oracle: add coingecko price source oracle: add coingecko demo and pro tier support Feb 25, 2026
@dnldd dnldd force-pushed the add-coingecko-source branch from 4ae30ab to d51095d Compare February 25, 2026 01:02
@dnldd
Copy link
Copy Markdown
Contributor Author

dnldd commented Feb 25, 2026

Good catch, made the suggested changes and covered with more tests. The monthly limit is configurable now and defaults to 9800 (bumped it up from 9500).

Comment thread oracle/sources/providers/coingecko.go Outdated
Comment thread oracle/sources/utils/file_tracked.go Outdated
Comment thread oracle/sources/utils/file_tracked.go Outdated
Comment thread oracle/sources/utils/file_tracked.go
Comment thread oracle/oracle.go Outdated
Comment thread tatanka/tatanka.go Outdated
Comment thread oracle/sources/utils/file_tracked.go
@dnldd dnldd force-pushed the add-coingecko-source branch 3 times, most recently from 5937f46 to 0286abf Compare February 26, 2026 15:09
Comment thread tatanka/tatanka.go
Comment thread oracle/sources/utils/file_tracked.go Outdated
dnldd added 2 commits March 12, 2026 10:20
… tracking

Implement unified CoinGecko provider supporting demo (file-based quota) and pro (API-based quota) tiers. Demo tier persists 9,800 monthly
credits in local JSON with automatic monthly reset. Pro tier tracks quota via /api/v3/key endpoint. Both tiers use MinPeriod=30s for
consistent fetch ordering. New FileTrackedSource utility manages file-based quota state with thread-safe credit consumption. Includes
comprehensive unit and integration tests for both tiers.
- move AtomicWriteFile to oracle/sources/utils/file.go for shared use
- update saveQuotaToFile to use AtomicWriteFile instead of os.WriteFile
@dnldd dnldd force-pushed the add-coingecko-source branch from 74cc0a1 to d0313d4 Compare March 12, 2026 10:22
@martonp martonp merged commit 376d256 into bisoncraft:master Mar 13, 2026
1 check 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.

2 participants