feat: update Perps and Predictions sections to display unrealized P&L#27844
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. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
Tag selection rationale:
Risk is medium because these are UI display changes to existing features (not core logic), but they introduce new data subscriptions (hooks) and a new shared component that could affect rendering behavior across multiple homepage sections. Performance Test Selection: |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
|
✅ E2E Fixture Validation — Schema is up to date |
|
aganglada
left a comment
There was a problem hiding this comment.
LGTM, one non-blocking nit
| {/* Value + muted label: same row as wallet homepage unrealized P&L (8px gap). */} | ||
| {subtitle && subtitleSuffix ? ( | ||
| <HomepageSectionUnrealizedPnlRow | ||
| label={subtitleSuffix} | ||
| valueText={subtitle} | ||
| valueColor={subtitleColor} | ||
| paddingHorizontal={0} | ||
| marginTop={1} | ||
| valueTestID={subtitleTestID} | ||
| labelTestID={ | ||
| subtitleTestID ? `${subtitleTestID}-suffix` : undefined | ||
| } | ||
| /> | ||
| ) : subtitle ? ( | ||
| <Box marginTop={1}> | ||
| <Text | ||
| variant={TextVariant.BodyMd} | ||
| color={subtitleColor} | ||
| fontWeight={FontWeight.Medium} | ||
| testID={subtitleTestID} | ||
| > | ||
| {subtitle} | ||
| </Text> | ||
| </Box> | ||
| ) : null} |
There was a problem hiding this comment.
[nit] We could exact this to it's own component (non-blocking)
There was a problem hiding this comment.
Good point, I think we could do that at some point, now I'm pretty sure we will be still changing things around here, so I think we could leave this subtitle thing separated for now




Description
Users with open Perpetuals or Predict positions could not see aggregate unrealized P&L on the wallet homepage next to those sections, and the Perps tab “Your positions” subtitle duplicated similar layout logic.
This PR:
useUnrealizedPnL); pull-to-refresh also invalidates that query. Respects privacy mode.HomepageSectionUnrealizedPnlRowfor the value + “Unrealized P&L” line so layout matches the homepage spec (4px under title, 8px between value and label).HomepageSectionUnrealizedPnlRowunder homepage components (used by homepage sections +PerpsHomeSection).formatPredictUnrealizedPnLStringPartsinformat.tscentralizes i18n interpolation for unrealized P&L strings;PredictPositionsHeaderandPredictionsSectionboth use it.Changelog
CHANGELOG entry: Added unrealized P&L summary on the wallet homepage for Perpetuals and Predictions, and aligned the Perps home “Your positions” subtitle with the same layout.
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/TMCU-584
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Medium risk: adds new homepage UI rows driven by live Perps account state and Predict react-query data (including query invalidation on refresh), which could affect loading/visibility states and performance but does not touch auth or funds movement.
Overview
Adds a shared
HomepageSectionUnrealizedPnlRowcomponent and uses it to display aggregate unrealized P&L under the Wallet homepage Perpetuals and Predictions section titles when the user has open positions (and not in privacy mode), including loading placeholders and tone-based coloring.Refactors Perps tab
PerpsHomeSection/PerpsHomeViewto reuse the same value+label row, switch to design-systemTextColortokens, and keep the positions subtitle visible whenever positions exist (including flat P&L). Predict’s positions header and homepage section now share a centralizedformatPredictUnrealizedPnLStringPartsformatter, and Predictions pull-to-refresh also invalidates the unrealized P&L query; tests were updated/added accordingly.Written by Cursor Bugbot for commit 50ae867. This will update automatically on new commits. Configure here.