Exchange endpoint userPortfolioMargin, info endpoint exchangeStatus - #155
Merged
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #155 +/- ##
==========================================
+ Coverage 70.02% 70.17% +0.15%
==========================================
Files 53 54 +1
Lines 8640 8782 +142
Branches 533 534 +1
==========================================
+ Hits 6050 6163 +113
- Misses 2587 2616 +29
Partials 3 3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
exchangeStatus: no-argument /info endpoint returning operational status
(specialStatuses, time). Response shape confirmed live against both
api.hyperliquid-testnet.xyz/info and api.hyperliquid.xyz/info
({"specialStatuses":null,"time":<ms>}); specialStatuses' element shape
when non-null is inferred (assumed array of strings), never observed live.
userPortfolioMargin: EIP-712 user-signed /exchange action (user, enabled)
toggling portfolio margin mode, modeled directly on the existing
userDexAbstraction/userSetAbstraction pattern. Request shape cross-checked
against nktkas/hyperliquid's userPortfolioMargin.ts; the generic
{status,response} response shape is inferred from that same source and
from the shape shared by every other simple exchange action - not
independently confirmed against a live response (no funded testnet wallet
available in this environment).
Both endpoints get RestApi and WebsocketApi methods, request-builder and
response-parser tests, an example, and README coverage table updates.
Closes #128, #129
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Le73N2EZjGLsCqmCScAse
TuxedoFish
force-pushed
the
endpoint/portfolio-margin-exchange-status
branch
from
September 8, 2026 13:31
fc3e5de to
3d443a3
Compare
Replaces the TS-SDK-inferred success fixture (which happened to already match) and the placeholder error message with real testnet responses: enabling failed with a genuine business-rule error on this test wallet, disabling (a no-op, already off) succeeded. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018Le73N2EZjGLsCqmCScAse
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.
Summary
exchangeStatus- a no-argument/infoendpoint returning operational status (RestApi::exchangeStatus,WebsocketApi::exchangeStatus).userPortfolioMargin- an EIP-712 user-signed/exchangeaction toggling portfolio margin mode (RestApi::userPortfolioMargin,WebsocketApi::userPortfolioMargin).RestApi/WebsocketApimethods, tests, README coverage tables, examples).Closes #128
Closes #129
Verification notes - both endpoints now confirmed live
exchangeStatus: rancurl -X POST .../info -d '{"type":"exchangeStatus"}'against bothapi.hyperliquid-testnet.xyzandapi.hyperliquid.xyz. Both returned the identical shape:{"specialStatuses":null,"time":1788859210259}specialStatuseswas null in both captures. Its element shape when non-null is inferred, not confirmed - assumed to be an array of strings by analogy with every other "list of status/message" field in this API (e.g.ApprovedBuildersResponse).timeis a raw (non-string-encoded) millisecond timestamp, parsed viaget_uint64().userPortfolioMargin: ran both directions live against testnet with a real signed request from this repo's test wallet:The
enabled=truerequest was accepted and parsed by the server, then rejected on a genuine business rule (this wallet's account value/volume) - not a schema error, confirming the EIP-712 action shape (type/user/enabled,HyperliquidTransaction:UserPortfolioMargin) is correct. Theenabled=falserequest (disabling an already-disabled setting, a no-op) actually succeeded end-to-end - a full confirmed round trip, not just a business-rule rejection.tests/user_portfolio_margin_test.cpp's success/error fixtures now use these real captures instead of the TS-SDK-inferred ones (the success shape happened to already match exactly; the error message did not, and has been corrected to the real wording).Test plan
cmake -S . -B build -DHYPERLIQUID_WARNINGS_AS_ERRORS=ON -DHYPERLIQUID_BUILD_TESTS=ON -DHYPERLIQUID_BUILD_EXAMPLES=ON -DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"- clean configurecmake --build build -j"$(nproc)"- zero warnings/errors (warnings-as-errors on), examples includedctest --test-dir build- 100% pass, 29/29 test binariesmain(post-Exchange endpoint: createSubAccount, subAccountTransfer #153/Info endpoints: userBorrowLendInterest, liquidatable #154/Info endpoints: twapHistory, userTwapSliceFillsByTime, activeAssetData #157) - README coverage counts and an example-file conflict resolved (both were "keep both" adjacent insertions, not real conflicts of intent), full clean rebuild/retest after rebasingbuild/removed before committing🤖 Generated with Claude Code
https://claude.ai/code/session_018Le73N2EZjGLsCqmCScAse