Skip to content

feat: display Hyperliquid perp positions in Social Leaderboard (TSA-628)#31570

Draft
joaosantos15 wants to merge 1 commit into
mainfrom
TSA-hyperliquid
Draft

feat: display Hyperliquid perp positions in Social Leaderboard (TSA-628)#31570
joaosantos15 wants to merge 1 commit into
mainfrom
TSA-hyperliquid

Conversation

@joaosantos15

Copy link
Copy Markdown
Contributor

Description

Adds Hyperliquid (perps) support to the Social Leaderboard UI — the second step of the perps work, consuming the perp fields now exposed by @metamask/social-controllers and the social API.

What changed

  • New shared primitives: a PerpBadges component (leverage pill + LONG/SHORT pill) and utils/perp.ts helpers (isPerpPosition/isPerpTrade + long/short direction resolution), so perp classification lives in one place.
  • getPositionNetworkBadge resolves the Hyperliquid network logo (HyperEVM image source) for the token avatar badge, without adding hyperliquid to chainNameToId (so the spot price/QuickBuy paths still treat it as unsupported).
  • Trader profile position rows show the HL network badge + leverage + long/short for perps; spot rows are unchanged.
  • Position detail header shows the same badges; trade rows read "opened/closed" with leverage + direction for perp fills.
  • The position detail footer swaps the single Buy CTA for Long/Short buttons on perps (intentional placeholders — not wired to a trade flow yet). The chart shows its existing no-data placeholder since perp pricing isn't available yet.
  • Pins @metamask/social-controllers to the perps preview build so the new Position/Trade perp fields are typed/available.

Motivation: unblock the mobile Perps leaderboard/position UX (perp metadata was being dropped because the client types/UI didn't model it).

Changelog

CHANGELOG entry: Added Hyperliquid perpetuals to the Social Leaderboard — trader profiles and position details now show leverage, long/short direction, and the Hyperliquid network badge.

Related issues

Fixes: TSA-628

Depends on:

Manual testing steps

Feature: Hyperliquid perps in the Social Leaderboard

  Scenario: viewing a trader's perp positions
    Given a trader has open Hyperliquid perp positions
    When I open their profile in the Social Leaderboard
    Then each perp position shows the Hyperliquid network badge, its leverage (e.g. 5x), and LONG/SHORT
    And spot positions render unchanged

  Scenario: opening a perp position detail
    Given I am on a trader profile with a perp position
    When I tap that position
    Then the header shows the token with its leverage and long/short badges
    And the trades list shows "opened"/"closed" rows with leverage + direction
    And the footer shows Long and Short buttons (placeholders) instead of Buy
    And the chart shows the no-data placeholder

Local setup: point SOCIAL_API_URL at a social-api running the perps branch (va-mmcx-social-api#86), which serves Hyperliquid positions via chains=all.

Screenshots/Recordings

Before

Spot-only positions; no leverage/direction/HL badge.

After

To be captured on-device before marking Ready for review — matches the approved designs (profile list with 5x LONG / 8x SHORT rows + HL badge, and the position detail with leverage/direction badges and Long/Short footer).

Pre-merge author checklist

Render perp metadata across the Social Leaderboard trader profile and
position detail screens, consuming the new perp fields exposed by
@metamask/social-controllers.

- Add a shared PerpBadges component (leverage pill + LONG/SHORT pill) and
  perp helpers (isPerpPosition / direction resolution for positions and
  trades).
- Trader profile position rows and the position detail header show the
  Hyperliquid network badge, leverage, and long/short direction for perps;
  spot rows are unchanged.
- Trade rows read "opened/closed" with leverage + direction badges for perp
  fills.
- The position detail footer swaps the single Buy CTA for Long/Short buttons
  on perps (placeholders — not wired to a flow yet); the chart shows its
  existing no-data placeholder since perp pricing isn't available.
- Pin @metamask/social-controllers to the perps preview build so the new
  Position/Trade perp fields are available (paired with MetaMask/core#9094).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
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.

@github-actions github-actions Bot added the pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. label Jun 11, 2026
@mm-token-exchange-service mm-token-exchange-service Bot added the team-social-ai Social & AI team label Jun 11, 2026
@mm-token-exchange-service mm-token-exchange-service Bot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Jun 11, 2026
@mm-token-exchange-service

Copy link
Copy Markdown

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.

@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatednpm/​@​metamask/​social-controllers@​2.2.0 ⏵ 2.2.1-preview-a3e0ef7eb00000

View full report


/**
* Resolves the side (long/short) of a perp trade. Prefers `perpPositionType`;
* for perp-classified fills that omit it, infers from `direction`

@bengotow bengotow Jun 12, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

hmm afaik there shouldn't be perp-classified fills that don't have a perpPositionType - if you saw some in the API responses let's sync up about it! There are a lot of event types on HL because the chain natively implements several forms of liquidation but I think we assign a perpPositionType to all of those.

return position.perpPositionType;
}
if (position.chain?.toLowerCase() === HYPERLIQUID_CHAIN_NAME) {
return (position.positionAmount ?? 0) < 0 ? 'short' : 'long';

@bengotow bengotow Jun 12, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

hmm I think this could work but I generally worry that the multiple paths in the data => display mapping here could make things hard to debug. Maybe we can do some data integrity checks on the clicker side and/or add stronger perp data types so that this isn't necessary.

This defensiveness may be here because perpPositionType is nullable in Clicker API schema, but it'd really be better expressed as a union type - for the perps side of the union, it is always populated.

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

Labels

INVALID-PR-TEMPLATE PR's body doesn't match template pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. size-L team-social-ai Social & AI team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants