Skip to content

Conversation

@michalconsensys
Copy link
Contributor

@michalconsensys michalconsensys commented Nov 11, 2025

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

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

Before

After

Pre-merge author checklist

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.

Note

Enable live PnL by passing useLivePnl: true to usePerpsLivePositions within PerpsMarketTabs.tsx.

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

@github-actions
Copy link
Contributor

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.

@metamaskbot metamaskbot added the team-perps Perps team label Nov 11, 2025
@sonarqubecloud
Copy link

@michalconsensys michalconsensys marked this pull request as ready for review November 11, 2025 14:26
@michalconsensys michalconsensys requested a review from a team as a code owner November 11, 2025 14:26
const { positions } = usePerpsLivePositions({
throttleMs: 0,
useLivePnl: true,
});
Copy link

Choose a reason for hiding this comment

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

Bug: Unthrottled Live PnL impacts performance.

Enabling useLivePnl: true with throttleMs: 0 causes the component to re-render on every WebSocket price tick, potentially degrading performance. Other components using live PnL (like PerpsPositionsView) throttle updates to 1000ms. Consider adding throttling to balance real-time updates with performance, especially since the component already uses memoization to isolate price updates in StatisticsTabContent.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants