feat: adds DB fallback to oracle pricing in market-data endpoint#3082
feat: adds DB fallback to oracle pricing in market-data endpoint#3082
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughWraps oracle/RPC calls in try/catch and checks oracle price health; when unhealthy or RPC fails, DenomExchangeService falls back to latest AKT price from DayRepository. Constructor now accepts DayRepository and LoggerService. Tests and functional fixtures updated to cover these failure modes and logging. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ailable Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
b6e6999 to
a309942
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3082 +/- ##
==========================================
- Coverage 60.94% 60.06% -0.89%
==========================================
Files 1023 983 -40
Lines 24491 23503 -988
Branches 6055 5894 -161
==========================================
- Hits 14927 14117 -810
+ Misses 8352 8186 -166
+ Partials 1212 1200 -12
*This pull request uses carry forward flags. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/api/src/chain/services/denom-exchange/denom-exchange.service.ts`:
- Around line 44-60: The calls to the async fallback are returned without
awaiting, so rejections bypass the outer try/catch in getExchangeRateToUSD;
update both return statements that return this.#getFallbackExchangeRateToUSD()
to use await this.#getFallbackExchangeRateToUSD() so failures are caught by the
surrounding try/catch, and additionally add internal error handling inside the
private method `#getFallbackExchangeRateToUSD`() to catch DB errors and return a
safe default object (zeros) to guarantee a valid response.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a08c7013-91d1-424d-96bf-3792b7258c7a
📒 Files selected for processing (3)
apps/api/src/chain/services/denom-exchange/denom-exchange.service.spec.tsapps/api/src/chain/services/denom-exchange/denom-exchange.service.tsapps/api/src/gpu/repositories/day.repository.ts
… test Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
87600b4 to
029f493
Compare
Why
DenomExchangeService.getExchangeRateToUSD()calls the on-chain oracle with no fallback — if the oracle reports unhealthy or the RPC call fails,/v1/market-dataerrors out. Ref CON-106What
This adds a persistent DB fallback using
day.aktPriceso pricing remains available during oracle downtime.DenomExchangeService: Wrapped oracle RPC calls in try/catch. On success, checkspriceHealth?.isHealthy— iffalse, logsORACLE_PRICE_UNHEALTHYand falls back to DB. On RPC exception, logsORACLE_RPC_FAILEDand falls back to DB. Fallback reads the latestday.aktPriceviaDayRepositoryand returns zeroed-out 24h change metrics.DayRepository: AddedgetLatestAktPrice()— queries most recentdayrow with non-nullaktPrice./v1/market-dataresponse shape.Summary by CodeRabbit
Tests
Bug Fixes