Skip to content

Also store portfolio snapshots in USD#9

Merged
gskril merged 7 commits into
mainfrom
claude/portfolio-snapshots-usd-4KiME
Jan 5, 2026
Merged

Also store portfolio snapshots in USD#9
gskril merged 7 commits into
mainfrom
claude/portfolio-snapshots-usd-4KiME

Conversation

@gskril

@gskril gskril commented Jan 4, 2026

Copy link
Copy Markdown
Owner

Note

Introduces USD-denominated net worth snapshots and updates the UI to consume and display them.

  • Server: cron now computes usdValue from total ethValue using getRateToEth (USDC on mainnet), saves both ethValue and usdValue to networth
  • DB: adds nullable usdValue column to networth with migration and updates types; migrator includes new migration
  • Client: useNetworthTimeSeries(currency) filters/derives value from ethValue or usdValue; Home wires currency into the hook, enables chart for USD/ETH, and formats tooltip values by selected currency

Written by Cursor Bugbot for commit 4d112cc. This will update automatically on new commits. Configure here.

claude added 3 commits January 4, 2026 06:28
- 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.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread server/src/app.ts
})
// Convert ETH value to USD: ethValue / usdcRateToEth
// (usdcRateToEth is how much ETH 1 USDC is worth, so we divide)
usdValue = ethValue / usdcRateToEth

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Fix in Cursor Fix in Web

claude added 2 commits January 4, 2026 18:48
- Update useNetworthTimeSeries hook to accept currency parameter
- Show chart for both USD and ETH currency settings
- Format chart tooltip values based on selected currency
Comment thread server/src/handlers/balances.ts Outdated
gskril and others added 2 commits January 4, 2026 19:56
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.
@gskril gskril changed the title Switch portfolio snapshots from ETH to USD Also store portfolio snapshots in USD Jan 5, 2026
@gskril
gskril merged commit 3f85d6a into main Jan 5, 2026
2 checks passed
@gskril
gskril deleted the claude/portfolio-snapshots-usd-4KiME branch January 5, 2026 01:01
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