fix: musd-1128 prevent apy from disappearing#33193
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
PR template — items to address before "Ready for review"Warnings — informational, address before merging:
See docs/readme/ready-for-review.md for the full Definition of Ready for Review. |
🧪 Flaky unit test detectionRun history flaky detectionHistorical failure rate is a hint, not proof — review each suggestion in context. See the flaky-test-detection skill for the full pattern reference and manual audit workflow. Failures / runs sampled per window:
AI-detected flaky patterns
|
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
The remaining 4 files are test files ( The changes are contained within the Money/Card feature area and fix a UI flickering issue with APY loading states. SmokeMoney covers the MetaMask Card home screen, balance display, and related flows - exactly what's being modified here. No other feature areas are impacted (no navigation changes, no shared components, no Engine/controller changes, no confirmation flows). The test files are unit tests, not E2E smoke tests, so they don't affect tag selection directly. Performance Test Selection: |
|



Description
This is a fix to prevent the APY row from disappearing after users sat on the money home page for a while.
The root cause of that bug is that the @metamask/react-data-query library removes data from its cache even when UI components still observe that data. Because the money home re-renders every 30s when balances are fetched, when this data is removed the APY would disappear. We poll for APY every 5 minutes, so it would eventually re-appear - but there was a gap where no data exists.
I think the long term fix is to prevent the core library from removing observed data from the cache - but in the interest of fixing this user facing bug, we are now storing the most recently observed APY value in component state and using that if the value disappears.
Changelog
CHANGELOG entry: fix disappearing money account APY row
Related issues
Fixes: MUSD-1128
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Note
Medium Risk
Changes how APY is derived and when loading skeletons show across Money surfaces; incorrect carry or loading logic could misstate APY briefly, but scope is localized with new tests.
Overview
Fixes the Money home APY row vanishing after users stay on the screen while the vault APY query cache is cleared under active observers (react-data-query /
BaseDataServicebehavior).useMoneyAccountBalancenow keeps the last successful live vault APY in a ref and uses it when querydatadrops toundefined, while still honoring override/fallback rules. It exposesisApyLoading(loading only when no APY is available from any source) so skeletons do not flicker during transient reloads.Money home, balance card, and balance projection switch from
vaultApyQuery.isLoadingtoisApyLoading. Hook tests cover last-known carry, override precedence, and loading semantics.Reviewed by Cursor Bugbot for commit 8932391. Bugbot is set up for automated code reviews on this repo. Configure here.