Skip to content

Commit 6fe856c

Browse files
fix(perps): enable live PnL in perps position card cp-7.59.0 (#22487)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** This PR enables live PnL (Profit and Loss) updates in the Perps Market Tabs by subscribing to real-time price updates from the WebSocket stream. ## **Changelog** CHANGELOG entry: Fixed live PnL updates in Perps market tabs to reflect real-time price changes ## **Related issues** Fixes: https://consensyssoftware.atlassian.net/browse/TAT-1946 ## **Manual testing steps** ```gherkin Feature: Live PnL updates in Perps Market Tabs Scenario: user views position with live PnL updates Given user has an open perpetual position And user is on the Perps Market Tabs screen When market price changes Then the unrealized PnL and ROE values update in real-time And the position card reflects current market conditions ``` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** No visible changes ### **After** No visible changes ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Enable live PnL updates by passing `useLivePnl: true` to `usePerpsLivePositions` in `PerpsMarketTabs.tsx`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 32657d9. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: Nicholas Smith <nick.smith@consensys.net>
1 parent ce4c851 commit 6fe856c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

app/components/UI/Perps/components/PerpsMarketTabs/PerpsMarketTabs.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,10 @@ const PerpsMarketTabs: React.FC<PerpsMarketTabsProps> = ({
218218
);
219219

220220
// Subscribe to data internally (marketStats moved to StatisticsTabContent to isolate price updates)
221-
const { positions } = usePerpsLivePositions({ throttleMs: 0 });
221+
const { positions } = usePerpsLivePositions({
222+
throttleMs: 0,
223+
useLivePnl: true,
224+
});
222225
const { orders: allOrders } = usePerpsLiveOrders({ throttleMs: 0 });
223226

224227
const position = useMemo(

0 commit comments

Comments
 (0)