Commit a8d7daf
feat(perps): update latest hyperliquid sdk (#28672)
## **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**
```gherkin
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
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.
https://github.com/user-attachments/assets/50e6ef61-57b1-442a-913b-75daad07d1bb
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **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.
<!-- CURSOR_SUMMARY -->
---
> [!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.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
e109022. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Alejandro Garcia Anglada <aganglada@gmail.com>1 parent c87c5a1 commit a8d7daf
3 files changed
Lines changed: 45 additions & 58 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
330 | 330 | | |
331 | 331 | | |
332 | 332 | | |
333 | | - | |
| 333 | + | |
334 | 334 | | |
335 | 335 | | |
336 | 336 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
133 | 159 | | |
134 | 160 | | |
135 | 161 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10381 | 10381 | | |
10382 | 10382 | | |
10383 | 10383 | | |
10384 | | - | |
10385 | | - | |
10386 | | - | |
10387 | | - | |
10388 | | - | |
10389 | | - | |
10390 | | - | |
10391 | | - | |
10392 | | - | |
10393 | | - | |
10394 | | - | |
| 10384 | + | |
| 10385 | + | |
| 10386 | + | |
| 10387 | + | |
| 10388 | + | |
| 10389 | + | |
| 10390 | + | |
| 10391 | + | |
10395 | 10392 | | |
10396 | 10393 | | |
10397 | 10394 | | |
10398 | | - | |
10399 | | - | |
10400 | | - | |
10401 | | - | |
| 10395 | + | |
| 10396 | + | |
| 10397 | + | |
| 10398 | + | |
10402 | 10399 | | |
10403 | 10400 | | |
10404 | 10401 | | |
| |||
10497 | 10494 | | |
10498 | 10495 | | |
10499 | 10496 | | |
10500 | | - | |
10501 | | - | |
10502 | | - | |
10503 | | - | |
10504 | | - | |
10505 | | - | |
10506 | | - | |
10507 | | - | |
10508 | | - | |
10509 | 10497 | | |
10510 | 10498 | | |
10511 | 10499 | | |
| |||
10541 | 10529 | | |
10542 | 10530 | | |
10543 | 10531 | | |
10544 | | - | |
| 10532 | + | |
10545 | 10533 | | |
10546 | 10534 | | |
10547 | 10535 | | |
| |||
13132 | 13120 | | |
13133 | 13121 | | |
13134 | 13122 | | |
13135 | | - | |
13136 | | - | |
13137 | | - | |
13138 | | - | |
13139 | | - | |
13140 | | - | |
13141 | | - | |
13142 | 13123 | | |
13143 | 13124 | | |
13144 | 13125 | | |
| |||
35685 | 35666 | | |
35686 | 35667 | | |
35687 | 35668 | | |
35688 | | - | |
| 35669 | + | |
35689 | 35670 | | |
35690 | 35671 | | |
35691 | 35672 | | |
| |||
36327 | 36308 | | |
36328 | 36309 | | |
36329 | 36310 | | |
36330 | | - | |
36331 | | - | |
36332 | | - | |
36333 | | - | |
36334 | | - | |
36335 | | - | |
36336 | | - | |
36337 | | - | |
36338 | | - | |
36339 | | - | |
36340 | | - | |
36341 | 36311 | | |
36342 | 36312 | | |
36343 | 36313 | | |
36344 | 36314 | | |
36345 | 36315 | | |
36346 | 36316 | | |
36347 | 36317 | | |
36348 | | - | |
36349 | | - | |
36350 | | - | |
36351 | | - | |
36352 | | - | |
36353 | | - | |
36354 | | - | |
36355 | | - | |
36356 | | - | |
36357 | 36318 | | |
36358 | 36319 | | |
36359 | 36320 | | |
| |||
46734 | 46695 | | |
46735 | 46696 | | |
46736 | 46697 | | |
46737 | | - | |
46738 | | - | |
46739 | | - | |
| 46698 | + | |
| 46699 | + | |
| 46700 | + | |
46740 | 46701 | | |
46741 | 46702 | | |
46742 | 46703 | | |
46743 | 46704 | | |
46744 | 46705 | | |
46745 | | - | |
| 46706 | + | |
46746 | 46707 | | |
46747 | 46708 | | |
46748 | 46709 | | |
| |||
0 commit comments