feat: prioritize Jupiter Price API V3 for token price fetching with fallbacks#1
Merged
Hebx merged 19 commits intofix/wallet-price-fallback-sourcesfrom Nov 21, 2025
Conversation
7 tasks
256a355 to
1a0d8a9
Compare
…allback chain - Integrate Jupiter Price API V3 for efficient batch price fetching - Implement prioritized fallback chain: Jupiter → CoinGecko → Birdeye - Add support for arbitrary token price fetching (not just SOL) - Fix response parsing to handle Jupiter API V3 format (usdPrice field) - Add comprehensive logging for debugging price fetch failures - Improve error handling and fallback logic This ensures we get the most accurate real-time prices from Jupiter first, with reliable fallbacks for tokens Jupiter doesn't have prices for.
- Add tests for batch price fetching with Jupiter Price API V3 - Add tests for prioritized fallback chain (Jupiter -> CoinGecko -> Birdeye) - Add tests for arbitrary token price fetching from CoinGecko - Add tests for response format validation (usdPrice field) - Add tests for error handling and performance optimizations - Verify batch request efficiency vs individual requests
f0ecaf3 to
8dd09b0
Compare
✅ Changeset DetectedThanks for adding a changeset! This change will be included in the next release. |
- Fix hasApiKey check from !process.env.JUPITER_API_KEY to !!process.env.JUPITER_API_KEY - Update test to conditionally check for correct endpoint based on API key presence - Test now correctly verifies lite-api.jup.ag when no key, api.jup.ag when key is set Fixes test failure where inverted logic caused wrong endpoint to be tested
* chore: version packages * chore: clean up changelog and remove AI review artifacts - Remove PR darkresearch#92 reference, update to darkresearch#110 - Add missing PRs to changelog: darkresearch#102, darkresearch#104, darkresearch#105 - Remove AI-generated review markdown files - Add proper PR attributions throughout --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Bot <bot@example.com>
- Detect version bumps by checking if CHANGELOG.md was updated - Automatically create and push git tag - This triggers Vercel deployment and GitHub release workflows - No more manual tag creation needed
…ases - Changes release title from 'Release 0.1.1' to 'v0.1.1' - More concise and matches standard versioning conventions
- Install bun dependencies before Vercel build - Add required environment variables for Expo build - Should fix 'spawn sh ENOENT' error
- Replace manual Vercel CLI commands with vercel-action - Build using standard Expo export process - Should fix 'spawn sh ENOENT' error - Simplifies deployment workflow
- Fix tag auto-creation to detect CHANGELOG updates correctly - Simplify Vercel deployment to use platform builds (avoids spawn sh errors) - Only deploy on releases (tags), not every main commit - Remove pre-build steps, let Vercel handle building
- Use ./apps/client path instead of cd into directory - Prevents path doubling issue in Vercel CLI
- Add GRID_ENV: production to both integration and E2E test jobs - Add debug step to verify environment variables are set before server starts - Improve error messages with better logging when server fails to start - This should fix backend server startup failures in GitHub Actions The debug step will help identify if secrets are missing or empty, which was causing the server to crash immediately on startup.
- Remove path argument, let Vercel project settings define root directory - Vercel project is configured with apps/client as root
There was a problem hiding this comment.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
- Fix: Call fetchTokenPricesWithFallbacks instead of fetchMarketDataWithFallbacks This ensures Jupiter Price API V3 is prioritized as intended (Jupiter -> CoinGecko -> Birdeye) - Fix: Add isFinite check to price validation to prevent Infinity values This matches the test expectations and prevents calculation errors downstream Fixes the bug where the new Jupiter-first implementation was never called, and ensures price validation properly rejects Infinity values.
- Remove pre-build step and --build-env flags - Vercel will use environment variables from project settings - This ensures EXPO_PUBLIC_BACKEND_API_URL is available during Expo build - Fixes localhost:3001 being used in production
- Add CI-aware error messages in supabase.ts that detect GitHub Actions context - Configure dotenv to not override existing env vars (respects GitHub Actions secrets) - Add early validation checks in workflow before starting server - Improve error messages to help debug missing environment variables
The test was validating Jupiter's old swap/v1 endpoint, but the implementation now uses the price/v3 endpoint. Updated all endpoint references and validation logic to match the actual implementation: - Changed endpoint URLs from swap/v1 to price/v3 - Updated test descriptions to reference Price API V3 - Replaced outAmount validation with usdPrice validation - Added test for batch request URL construction with ids parameter - Updated fallback chain description to mention Price API V3 This ensures the test validates the actual production code and will catch regressions in the Jupiter Price API V3 integration.
Add isFinite() validation to prevent Infinity and -Infinity values from passing price validation checks. This fixes calculation errors downstream when computing token values. Fixed validation points: - CoinGecko SOL price validation - CoinGecko token price validation - Jupiter prices in result map - CoinGecko prices in result map - Birdeye prices in fallback chain - Birdeye prices in market data fetch - SOL price from fallbacks All price validations now follow the pattern: typeof price === 'number' && isFinite(price) && price > 0 This matches the test expectations in holdings-price-fallback.test.ts which explicitly tests for isFinite validation (line 71, 80).
- Add 'Validate required secrets' step in integration-tests and e2e-tests jobs - Check if GitHub secrets exist before attempting to start server - Provide clear error messages with instructions when secrets are missing - Fail fast with helpful guidance instead of generic environment variable errors This prevents the server from attempting to start with missing credentials and provides actionable error messages pointing to where secrets should be configured in GitHub Actions.
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.
Prioritized Token Price Fetching with Jupiter Price API V3
Description
This PR implements a prioritized price fetching system for wallet token holdings, prioritizing Jupiter's Price API V3 for real-time Solana token prices, with intelligent fallbacks to CoinGecko and Birdeye APIs.
Type of Change
What's Changed
🚀 New Features
1. Jupiter Price API V3 Integration
fetchTokenPricesFromJupiter()to fetch prices for multiple tokens in a single API call/price/v3endpoint instead of swap quote APIhttps://lite-api.jup.ag/price/v3(no API key required)https://api.jup.ag/price/v3(with API key)2. Prioritized Fallback Chain
Implemented intelligent fallback system with three tiers:
3. Arbitrary Token Support
fetchTokenPriceFromCoinGecko()for arbitrary Solana tokens🔧 Improvements
Enhanced Logging
Better Error Handling
Response Format Fix
{ data: {...} })usdPrice(notprice)Technical Details
API Endpoints Used
Jupiter Price API V3
GET /price/v3?ids=token1,token2,token3{ [mintAddress]: { usdPrice: number, blockId: number, decimals: number, priceChange24h: number } }CoinGecko API
GET /api/v3/simple/token_price/solana?contract_addresses={address}&vs_currencies=usd/simple/price?ids=solana)Birdeye API (existing, unchanged)
GET /defi/v3/token/market-data/multiple?list_address={addresses}Performance Improvements
Why Jupiter First?
Fallback Rationale
Testing
Tested Scenarios
✅ SOL price fetching (Jupiter → CoinGecko fallback)
✅ USDC price fetching (Jupiter → hardcoded fallback)
✅ Multiple tokens batch request
✅ Tokens not in Jupiter (fallback to CoinGecko/Birdeye)
✅ Rate-limited Birdeye (graceful degradation)
✅ Response format parsing (usdPrice field)
Breaking Changes
None - this is a non-breaking enhancement. Existing functionality remains unchanged, with improved price accuracy and performance.
Migration Notes
No migration required. The changes are backward compatible and automatically improve price fetching for all wallet holdings.
Note
Prioritizes Jupiter Price API V3 for wallet pricing with batch requests and fallbacks to CoinGecko/Birdeye, adds tests, improves env handling, and streamlines CI/CD and release tagging with version bumps.
price/v3withfetchTokenPricesFromJupiterand single-token wrappers; supports arbitrary SPL tokens and SOL.Jupiter → CoinGecko → Birdeye, plus stablecoin hardcoded prices; stricter price validation and detailed logging.apps/server/src/routes/wallet/holdings.tsto use new pricing flow and enrich holdings..envwithout overriding CI vars inapps/server/src/server.tsandsrc/lib/supabase.ts, with clearer missing-var errors.__tests__/jupiter-price-api-v3.test.tsand__tests__/holdings-price-fallback.test.ts.npx vercel deploystep in.github/workflows/deploy-vercel-production.yml.CHANGELOG.mdupdates; create tag to trigger Vercel deploy and GitHub release..github/workflows/release.yml.GRID_ENV, improve server health checks, and artifact uploads.0.1.1and add CHANGELOGs forapps/client,apps/server, andpackages/shared.Written by Cursor Bugbot for commit 5332a2a. This will update automatically on new commits. Configure here.