Also store portfolio snapshots in USD#9
Merged
Conversation
- Add database migration (003_usd_networth.ts) to add usdValue column - Update cron job to fetch ETH/USD rate and store USD value in snapshots - Update frontend to use usdValue directly without conversion - Show chart for all currency settings (not just ETH) - Format chart tooltip values as USD
Since the chart data is now stored in USD, it only makes sense to display it when the user has selected USD as their viewing currency.
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.
| }) | ||
| // Convert ETH value to USD: ethValue / usdcRateToEth | ||
| // (usdcRateToEth is how much ETH 1 USDC is worth, so we divide) | ||
| usdValue = ethValue / usdcRateToEth |
There was a problem hiding this comment.
Division by zero when USDC rate is zero
The usdcRateToEth value is used as a divisor without checking if it's zero or very small. If getRateToEth returns 0 (e.g., if the price oracle returns 0 for an unlisted or problematic token), this would result in Infinity or NaN being stored as usdValue in the database. While unlikely for USDC specifically, there's no guard against this edge case.
- Update useNetworthTimeSeries hook to accept currency parameter - Show chart for both USD and ETH currency settings - Format chart tooltip values based on selected currency
Remove server-side usdValue filter to preserve historical ETH-only records. Filter on client instead: ETH mode shows all records, USD mode filters for records with usdValue.
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.
Note
Introduces USD-denominated net worth snapshots and updates the UI to consume and display them.
usdValuefrom totalethValueusinggetRateToEth(USDC on mainnet), saves bothethValueandusdValuetonetworthusdValuecolumn tonetworthwith migration and updates types; migrator includes new migrationuseNetworthTimeSeries(currency)filters/derivesvaluefromethValueorusdValue;Homewires currency into the hook, enables chart for USD/ETH, and formats tooltip values by selected currencyWritten by Cursor Bugbot for commit 4d112cc. This will update automatically on new commits. Configure here.