Skip to content

feat(perps): update latest hyperliquid sdk#28672

Merged
abretonc7s merged 18 commits intomainfrom
feat/tat-2906-update-latest-hyperliquid-sdk
Apr 15, 2026
Merged

feat(perps): update latest hyperliquid sdk#28672
abretonc7s merged 18 commits intomainfrom
feat/tat-2906-update-latest-hyperliquid-sdk

Conversation

@abretonc7s
Copy link
Copy Markdown
Contributor

@abretonc7s abretonc7s commented Apr 10, 2026

Description

Bumps @nktkas/hyperliquid from 0.30.2 to 0.32.2 (latest).

What changed in the SDK:

  • @nktkas/rews 1.2.3 → 2.1.0 (WebSocket reconnection library)
  • valibot 1.2.0 → 1.3.1 (request validation)
  • micro-eth-signer removed (signing now fully delegated to wallet adapter)

What this PR changes:

  • package.json / yarn.lock — version bump
  • shim.js — Added CloseEvent and MessageEvent polyfills for React Native/Hermes. @nktkas/rews v2 uses new CloseEvent(...) and new MessageEvent(...) which are standard Web APIs but not available as constructors in Hermes. Without these polyfills, every WebSocket close/message event crashes the transport.

No changes to HyperLiquidClientService, HyperLiquidProvider, or any other app code.

Changelog

CHANGELOG entry: null

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/TAT-2906

Manual testing steps

Feature: Hyperliquid SDK upgrade validation

  Scenario: Full BTC trade lifecycle on testnet
    Given wallet is unlocked and perps feature is enabled

    When user navigates to Perps and switches to testnet
    Then market data loads (BTC, ETH, SOL visible with prices)

    When user opens a BTC long market order ($10, 2x leverage)
    Then position appears in portfolio

    When user creates TP/SL (+25% / -10%)
    Then TP and SL orders are confirmed

    When user closes the position
    Then position is removed from portfolio

Reproduce via recipe:

bash scripts/perps/agentic/validate-recipe.sh \
  scripts/perps/agentic/teams/perps/recipes/full-trade-lifecycle.json \
  --testnet

Screenshots/Recordings

Before

No UI changes — dependency update only.

After

Full trade lifecycle validated (14/14 steps pass): navigate → testnet → open BTC long → TP/SL → close → verify.

sdk-upgrade-validation.mp4

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Medium Risk
Updates the Hyperliquid perps dependency and its WebSocket stack, which can affect trading connectivity and runtime behavior. Adds global CloseEvent/MessageEvent constructors to prevent Hermes crashes, but changes occur in app-wide shims.

Overview
Upgrades @nktkas/hyperliquid to 0.32.2, pulling in @nktkas/rews v2 and updated validation deps, and updating the lockfile accordingly.

Adds React Native/Hermes polyfills in shim.js for global CloseEvent and MessageEvent to support the SDK’s updated WebSocket transport and avoid crashes when handling close/message events.

Reviewed by Cursor Bugbot for commit e109022. Bugbot is set up for automated code reviews on this repo. Configure here.

@abretonc7s abretonc7s added DO-NOT-MERGE Pull requests that should not be merged agentic labels Apr 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

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.

@metamaskbot metamaskbot added the team-perps Perps team label Apr 10, 2026
@socket-security
Copy link
Copy Markdown

socket-security Bot commented Apr 10, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatednpm/​@​nktkas/​hyperliquid@​0.30.2 ⏵ 0.32.298100100 +796100

View full report

@abretonc7s
Copy link
Copy Markdown
Contributor Author

Automated dev run — TAT-2906

Metric Value
Run 7d9c7333
Duration ?
Model claude/sonnet
Nudges 0
Cost estimate $4.86
Worker report

Report — TAT-2906: Update Hyperliquid SDK

Summary

Updated @nktkas/hyperliquid from 0.30.2 to 0.32.2. No API-breaking changes were found affecting the codebase — all existing type imports and method signatures remain compatible. All 288 perps test suites pass (1467 controller + 5503 UI tests).

Changes

File Change
package.json Bumped @nktkas/hyperliquid from ^0.30.2 to ^0.32.2
yarn.lock Updated lock entry; @nktkas/rews bumped from 1.2.3 → 2.1.0, valibot from 1.2.0 → 1.3.1, micro-eth-signer removed (no longer a dep), CLI bin removed

Test Plan

  • TypeScript: tsc --noEmit — no errors
  • Unit tests: yarn jest app/controllers/perps/ — 29 suites, 1467 tests passed
  • Unit tests: yarn jest app/components/UI/Perps/ — 259 suites, 5503 tests passed
  • Recipe: 5/5 steps passed (navigate → wait route → wait market data → assert BTC found → screenshot)

Evidence Artifacts

  • evidence-market-loaded.png — markets list loaded successfully with SDK 0.32.2

Ticket

https://consensyssoftware.atlassian.net/browse/TAT-2906

@abretonc7s abretonc7s marked this pull request as ready for review April 10, 2026 15:14
@abretonc7s abretonc7s enabled auto-merge April 10, 2026 15:20
@abretonc7s abretonc7s removed the DO-NOT-MERGE Pull requests that should not be merged label Apr 10, 2026
@github-actions github-actions Bot added the risk-medium Moderate testing recommended · Possible bug introduction risk label Apr 10, 2026
@abretonc7s abretonc7s force-pushed the feat/tat-2906-update-latest-hyperliquid-sdk branch from c703bba to 9727fc2 Compare April 11, 2026 07:05
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 11, 2026
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 11, 2026
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 13, 2026
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 13, 2026
…nsport

@nktkas/rews v2 (dependency of @nktkas/hyperliquid 0.32.2) uses
`new CloseEvent(...)` which is not available in React Native/Hermes.
This caused the WebSocket transport to crash on initialization,
preventing perps from loading in E2E tests.
Comment thread app/controllers/perps/services/HyperLiquidClientService.ts Outdated
Revert all HyperLiquidClientService changes — the HTTP fallback,
isInitialized, and disconnect changes were causing E2E test regressions
by interfering with the E2E controller mixin. The CloseEvent polyfill
in shim.js is the only change needed for the SDK upgrade; the WebSocket
connects to the real API in CI so no fallback logic is required.
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 14, 2026
When rews v2 + CloseEvent polyfill properly terminates after failed
reconnection attempts, ready() rejects and the catch block was
destroying ALL clients. Now HTTP clients survive: exchangeClient and
infoClientHttp stay alive, infoClient falls back to HTTP, and
Connected state is reported to prevent controller polling fallback
from overwriting E2E mock data.
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 15, 2026
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 15, 2026
Comment thread app/controllers/perps/services/HyperLiquidClientService.ts Outdated
rews v2 also uses `new MessageEvent(...)` which doesn't exist in
React Native/Hermes — every WebSocket message dispatch crashed,
breaking all WS subscriptions and data flow.

Revert HyperLiquidClientService changes — the polyfills (CloseEvent +
MessageEvent) are the only fixes needed. With both polyfills, rews v2
works correctly in React Native and the WebSocket connects normally.
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 15, 2026
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit aa71f14. Configure here.

Comment thread shim.js Outdated
Bugbot correctly flagged that `||` drops falsy-but-valid values
like `0`, `""`, `false` in CloseEvent/MessageEvent polyfills.
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 15, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokePerps, SmokeWalletPlatform, SmokeConfirmations
  • Selected Performance tags: @PerformancePreps
  • Risk Level: medium
  • AI Confidence: 88%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes consist of:

  1. package.json: Bumps @nktkas/hyperliquid from ^0.30.2 to ^0.32.2 — a minor version bump of the Hyperliquid SDK used exclusively by the Perps feature.
  2. shim.js: Adds CloseEvent and MessageEvent polyfills required by @nktkas/rews v2 (the WebSocket transport library used by the updated Hyperliquid SDK). React Native/Hermes doesn't provide these globals natively, so without these polyfills the WebSocket transport would fail.
  3. yarn.lock: Updated to reflect the new dependency resolution.

The Hyperliquid SDK is used in HyperLiquidClientService.ts, HyperLiquidSubscriptionService.ts, standaloneInfoClient.ts, and related perps utilities. The WebSocket transport is critical for real-time order book data and subscription events in the Perps feature.

Tag selection rationale:

  • SmokePerps: Directly impacted — the Hyperliquid SDK version bump and WebSocket polyfills affect the core Perps trading functionality (Add Funds, balance verification, market data).
  • SmokeWalletPlatform: Required per SmokePerps tag description — Perps is a section inside the Trending tab, so changes to Perps affect Trending.
  • SmokeConfirmations: Required per SmokePerps tag description — Add Funds deposits are on-chain transactions that go through the confirmation flow.

The shim polyfills are low-level but critical — if CloseEvent or MessageEvent constructors are missing, WebSocket connections in the Perps feature would fail silently or throw errors. The version bump from 0.30.x to 0.32.x may include breaking API changes that need validation.

Performance Test Selection:
The Hyperliquid SDK version bump (0.30.x → 0.32.x) updates the WebSocket transport layer used for real-time perps market data. The new shim polyfills for CloseEvent and MessageEvent affect how WebSocket connections are established and managed. These changes could impact perps market loading times, order book subscription performance, and the Add Funds flow — all covered by @PerformancePreps.

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown
Contributor

E2E Fixture Validation — Schema is up to date
11 value mismatches detected (expected — fixture represents an existing user).
View details

@abretonc7s abretonc7s added DO-NOT-MERGE Pull requests that should not be merged and removed DO-NOT-MERGE Pull requests that should not be merged labels Apr 15, 2026
@abretonc7s abretonc7s added this pull request to the merge queue Apr 15, 2026
Merged via the queue into main with commit a8d7daf Apr 15, 2026
196 of 199 checks passed
@abretonc7s abretonc7s deleted the feat/tat-2906-update-latest-hyperliquid-sdk branch April 15, 2026 12:07
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 15, 2026
@metamaskbot metamaskbot added the release-7.74.0 Issue or pull request that will be included in release 7.74.0 label Apr 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

agentic release-7.74.0 Issue or pull request that will be included in release 7.74.0 risk-medium Moderate testing recommended · Possible bug introduction risk size-S team-perps Perps team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants