feat: display Hyperliquid perp positions in Social Leaderboard (TSA-628)#31570
feat: display Hyperliquid perp positions in Social Leaderboard (TSA-628)#31570joaosantos15 wants to merge 1 commit into
Conversation
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>
|
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. |
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. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
|
||
| /** | ||
| * Resolves the side (long/short) of a perp trade. Prefers `perpPositionType`; | ||
| * for perp-classified fills that omit it, infers from `direction` |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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.
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-controllersand the social API.What changed
PerpBadgescomponent (leverage pill +LONG/SHORTpill) andutils/perp.tshelpers (isPerpPosition/isPerpTrade+ long/short direction resolution), so perp classification lives in one place.getPositionNetworkBadgeresolves the Hyperliquid network logo (HyperEVM image source) for the token avatar badge, without addinghyperliquidtochainNameToId(so the spot price/QuickBuy paths still treat it as unsupported).@metamask/social-controllersto the perps preview build so the newPosition/Tradeperp 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:
@metamask/social-controllersperp fields — pinned here as a preview build until released)chains=all+ gated perp notifications)Manual testing steps
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 SHORTrows + HL badge, and the position detail with leverage/direction badges and Long/Short footer).Pre-merge author checklist