feat(wallet): show per-position margin in the HL balance view#70
Open
psmiratisu wants to merge 1 commit into
Open
feat(wallet): show per-position margin in the HL balance view#70psmiratisu wants to merge 1 commit into
psmiratisu wants to merge 1 commit into
Conversation
A unified/HIP-3 Hyperliquid account can show a large account value but little free USDC because open positions hold the collateral as margin. Surface it so the tie-up is visible instead of surprising. - HyperliquidPerpPosition gains `marginUsed` - `acp wallet balance` PERPS table gains a MARGIN column Pairs with internal-trading-bot#138 (adds marginUsed to /trade/hl-status and names the culprit position in HL insufficient-funds errors). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Why
A unified/HIP-3 Hyperliquid account can show a large account value but very little free USDC, because open positions hold the collateral as margin (it reports as the spot USDC
hold). Todayacp wallet balanceshows the account value and positions but not the margin each position consumes, so a low free balance looks surprising.Context: wallet
0x4252…showed ~$10 value but ~$0.27 available — correct, because an openxyz:AAPLlong holds ~$8.49 of margin. This makes that visible.What
HyperliquidPerpPositiongainsmarginUsed.acp wallet balancePERPS table gains a MARGIN column:Additive display-only change. Pairs with Virtual-Protocol/internal-trading-bot#138, which adds
marginUsedto/trade/hl-statusand names the culprit position in the HL insufficient-funds errors.Notes
main(not the in-flightfeat/20260717) so it can merge independently.tscshows only pre-existingacp-node-v2version-skew errors in Solana transfer / tokenize code (main pins^0.1.8; the dev tree had0.1.7-sol-beta.2installed) — none in the changed regions. CI installs main's lockfile.🤖 Generated with Claude Code
Note
Low Risk
Small, additive display and type updates in the wallet balance view with no auth, signing, or transfer logic touched.
Overview
Adds
marginUsedtoHyperliquidPerpPosition(flat and nestedpositionshapes) so collateral locked in open perps can be typed from the assets API.acp wallet balanceHyperliquid PERPS table gains a MARGIN column:hlPositionreadsmarginUsedand the TTY renderer prints it between VALUE and PnL, clarifying why free/withdrawable USDC can sit well below account value when margin is tied up in positions.Display-only CLI change; expects the backend to populate
marginUsed(paired backend PR).--jsonstill emits the fullhyperliquidpayload, so margin appears there when present. Piped TSVhl-perprows are unchanged and still omit margin.Reviewed by Cursor Bugbot for commit 5c848e9. Bugbot is set up for automated code reviews on this repo. Configure here.