feat(social-controllers): expose perp metadata on Position and Trade types#9094
Open
joaosantos15 wants to merge 2 commits into
Open
feat(social-controllers): expose perp metadata on Position and Trade types#9094joaosantos15 wants to merge 2 commits into
joaosantos15 wants to merge 2 commits into
Conversation
…ypes Adds optional Hyperliquid/perp fields to the `SocialService` response types and their superstruct validation schemas so consumers (mobile) get typed, validated access to the perp metadata that social-api now returns: - `Trade`: `classification`, `perpPositionType`, `perpLeverage` - `Position`: `perpPositionType`, `perpLeverage`, `positionAmountWithLeverage` All fields are optional and nullable, so spot responses remain backward compatible. Part of the Hyperliquid perps leaderboard/positions work (TSA-629). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Author
|
@metamaskbot publish-previews |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
5 tasks
zone-live
approved these changes
Jun 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
The mobile Perps leaderboard/position UX needs typed, validated access to the perp metadata that social-api now returns for Hyperliquid (and other perp) positions. Today
@metamask/social-controllersdrops those fields on the floor because they aren't declared on the response types or their superstruct schemas.This PR extends the
SocialServiceresponse types and validation schemas with the optional perp fields:Trade(andTradeStruct): addsclassification('spot' | 'perp' | 'send' | 'receive' | null),perpPositionType('long' | 'short' | null), andperpLeverage(number | null).Position(andPositionStruct): addsperpPositionType,perpLeverage, andpositionAmountWithLeverage(the leveraged position size / capital at risk — Hyperliquid/perp only).All fields are optional and nullable, so spot responses validate exactly as before — this is a purely additive, non-breaking change. This is the client-side half of the Hyperliquid perps work; the matching server-side passthrough lives in social-api.
References
Checklist
Note
Low Risk
Additive optional/nullable fields and stricter validation only when new perp keys are present; spot payloads without those fields behave as before.
Overview
Adds optional, nullable perp/Hyperliquid metadata to social position and trade models so
SocialServiceno longer strips fields the API already returns.Trade/TradeStructnow includeclassification(spot|perp|send|receive),perpPositionType, andperpLeverage.Position/PositionStructaddperpPositionType,perpLeverage, andpositionAmountWithLeverage(leveraged size / capital at risk). Matching superstruct rules onPositionStructvalidate these on open/closed positions andfetchPositionById.Tests cover passthrough of perp payloads, explicit
nullfor spot, and rejection of invalid enum values (e.g. badperpPositionType). Changelog documents the additive API surface for consumers (e.g. mobile Perps UI).Reviewed by Cursor Bugbot for commit a3e0ef7. Bugbot is set up for automated code reviews on this repo. Configure here.