Skip to content

feat(wallet): show per-position margin in the HL balance view#70

Open
psmiratisu wants to merge 1 commit into
mainfrom
miratisu/hl-position-margin-column
Open

feat(wallet): show per-position margin in the HL balance view#70
psmiratisu wants to merge 1 commit into
mainfrom
miratisu/hl-position-margin-column

Conversation

@psmiratisu

@psmiratisu psmiratisu commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

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). Today acp wallet balance shows 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 open xyz:AAPL long holds ~$8.49 of margin. This makes that visible.

What

  • HyperliquidPerpPosition gains marginUsed.
  • The acp wallet balance PERPS table gains a MARGIN column:
  PERPS
  COIN       SIZE      ENTRY     VALUE     MARGIN    PnL
  xyz:AAPL   0.051     $313.31   $16.98    $8.49     +$1.00

Additive display-only change. Pairs with Virtual-Protocol/internal-trading-bot#138, which adds marginUsed to /trade/hl-status and names the culprit position in the HL insufficient-funds errors.

Notes

  • Branched off main (not the in-flight feat/20260717) so it can merge independently.
  • Local tsc shows only pre-existing acp-node-v2 version-skew errors in Solana transfer / tokenize code (main pins ^0.1.8; the dev tree had 0.1.7-sol-beta.2 installed) — 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 marginUsed to HyperliquidPerpPosition (flat and nested position shapes) so collateral locked in open perps can be typed from the assets API.

acp wallet balance Hyperliquid PERPS table gains a MARGIN column: hlPosition reads marginUsed and 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). --json still emits the full hyperliquid payload, so margin appears there when present. Piped TSV hl-perp rows 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.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant