Skip to content

Conversation

@michalconsensys
Copy link
Contributor

@michalconsensys michalconsensys commented Nov 20, 2025

Description

This PR fixes a missing returnOnEquity calculation in the HyperLiquidSubscriptionService.aggregateAccountStates() method.

Changelog

CHANGELOG entry: Fixed a bug where the PnL % would not show

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/TAT-2086

Manual testing steps

Feature: Return on Equity calculation in Perps account aggregation

  Scenario: user views account state with open HIP3 positions
    Given user has open perpetual positions with unrealized PnL
    
    Then the returnOnEquity field should be correctly calculated as (unrealizedPnl / marginUsed) * 100
    And the value should be formatted to one decimal place

Screenshots/Recordings

Before

IMG_954DF8480A63-1

After

Simulator Screenshot - iPhone 16e - 2025-11-20 at 09 47 15

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

Computes returnOnEquity in HyperLiquidSubscriptionService.aggregateAccountStates and adds unit tests covering multiple scenarios and rounding.

  • Service:
    • Compute returnOnEquity in HyperLiquidSubscriptionService.aggregateAccountStates as ((totalUnrealizedPnl / totalMarginUsed) * 100).toFixed(1) and include it in the aggregated AccountState.
  • Tests:
    • Add ROE test suite in HyperLiquidSubscriptionService.test.ts validating positive, negative, zero-margin, mixed PnL, large gains, and one-decimal rounding; mock adapter accordingly.

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

@michalconsensys michalconsensys added the team-perps Perps team label Nov 20, 2025
@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.

@michalconsensys michalconsensys marked this pull request as ready for review November 20, 2025 08:49
@michalconsensys michalconsensys requested a review from a team as a code owner November 20, 2025 08:49
@github-actions
Copy link
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeAccounts, SmokeCore, SmokeConfirmationsRedesigned, SmokeIdentity, SmokeNetworkAbstractions, SmokeNetworkExpansion, SmokeTrade, SmokeWalletPlatform, SmokeWalletUX, SmokeAssets, SmokeSwaps, SmokeStake, SmokeCard, SmokeNotifications, SmokeRewards, SmokePerps, SmokeRamps, SmokeMultiChainPermissions, SmokeAnalytics, SmokeMultiChainAPI, SmokePredictions
  • Risk Level: high
  • AI Confidence: %
click to see 🤖 AI reasoning details

Fallback: AI analysis did not complete successfully. Running all tests.

View GitHub Actions results

@michalconsensys michalconsensys changed the title fix(perps): add missing returnOnEquity calculation in HyperLiquidSubscriptionService fix(perps): add missing returnOnEquity calculation in HyperLiquidSubscriptionService cp-7.60.0 Nov 20, 2025
@sonarqubecloud
Copy link

@michalconsensys michalconsensys added this pull request to the merge queue Nov 20, 2025
Merged via the queue into main with commit 6427f22 Nov 20, 2025
89 of 90 checks passed
@michalconsensys michalconsensys deleted the fix/perps/pnl branch November 20, 2025 12:18
@github-actions github-actions bot locked and limited conversation to collaborators Nov 20, 2025
@metamaskbot metamaskbot added the release-7.61.0 Issue or pull request that will be included in release 7.61.0 label Nov 20, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.61.0 Issue or pull request that will be included in release 7.61.0 size-M team-perps Perps team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants