Skip to content

feat(transaction-pay-controller): add HyperLiquid source quote support for Perps Withdraw#8285

Merged
dan437 merged 14 commits intomainfrom
perps-withdraw-quote
Mar 25, 2026
Merged

feat(transaction-pay-controller): add HyperLiquid source quote support for Perps Withdraw#8285
dan437 merged 14 commits intomainfrom
perps-withdraw-quote

Conversation

@dan437
Copy link
Copy Markdown
Contributor

@dan437 dan437 commented Mar 24, 2026

Explanation

Adds HyperLiquid source quote support for Perps Withdraw. With this we will be able to show a quote for Perps Withdraw on a client.

References

Fixes https://consensyssoftware.atlassian.net/browse/CONF-1089

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Extends Relay quote normalization and fee/gas estimation with HyperLiquid-specific behavior (chain/token overrides, decimal shifting, gasless fees), which could affect quote accuracy and submission behavior for related flows if misapplied.

Overview
Adds an isHyperliquidSource flag that is persisted via setTransactionConfig and propagated into quote requests.

When isHyperliquidSource is set, Relay quoting now normalizes the source to HyperCore Perps USDC, shifts amounts for the 8→6 decimal mismatch, uses Arbitrum USDC pricing for fiat rates, and zeros out source network fees/gas limits for gasless withdrawals.

Also refines Relay step typing to support non-transaction steps (signature and HyperLiquid deposit shapes) and updates gas/submit logic to only process transaction steps while rejecting unsupported kinds; tests and the changelog are updated accordingly.

Written by Cursor Bugbot for commit 581aa20. This will update automatically on new commits. Configure here.

@dan437 dan437 requested a review from a team as a code owner March 24, 2026 14:36
matthewwalsh0
matthewwalsh0 previously approved these changes Mar 24, 2026
@dan437 dan437 force-pushed the perps-withdraw-quote branch from f1735c0 to 4c7c632 Compare March 25, 2026 12:55
Copy link
Copy Markdown

@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.

dan437 added 14 commits March 25, 2026 15:00
…t for Perps Withdraw

Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
…l shift

Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
@dan437 dan437 force-pushed the perps-withdraw-quote branch from 449cf5e to 581aa20 Compare March 25, 2026 14:01
@dan437 dan437 requested a review from a team as a code owner March 25, 2026 14:01
@dan437 dan437 enabled auto-merge March 25, 2026 14:10
@dan437 dan437 added this pull request to the merge queue Mar 25, 2026
Merged via the queue into main with commit 45aa4e2 Mar 25, 2026
326 checks passed
@dan437 dan437 deleted the perps-withdraw-quote branch March 25, 2026 16:21
github-merge-queue bot pushed a commit that referenced this pull request Mar 27, 2026
…on via Relay (#8314)

## Explanation

The quote support for Perps Withdraw was added in #8285. This PR
completes the feature by adding the **submission flow** — the 2-step
gasless withdrawal from HyperLiquid via Relay.

When `isHyperliquidSource` is set on the transaction config,
`executeSingleQuote` now routes to `submitHyperliquidWithdraw` instead
of `submitTransactions`. This function executes two EIP-712 signing
steps:

1. **Authorize** — signs a nonce-mapping message and POSTs the signature
to Relay's `/authorize` endpoint, linking the HyperLiquid withdrawal to
the Relay order.
2. **Deposit** — signs a HyperLiquid `sendAsset` action and POSTs it to
the HyperLiquid exchange API, instructing HL to transfer funds to the
Relay solver.

After both steps complete, the existing `waitForRelayCompletion` polling
takes over to track the cross-chain fill on the destination chain.

### Key changes

- **New file `hyperliquid-withdraw.ts`** — implements
`submitHyperliquidWithdraw` with the 2-step authorize + deposit flow,
EIP-712 domain derivation, and signature `r/s/v` parsing for the
HyperLiquid exchange API format.
- **`relay-submit.ts`** — routes to `submitHyperliquidWithdraw` when
`isHyperliquidSource` is true; no changes to `waitForRelayCompletion` or
existing submission logic.
- **`types.ts`** — adds `KeyringControllerSignTypedMessageAction` to
`AllowedActions` (required for silent EIP-712 signing via the keyring
controller messenger).
- **`constants.ts`** — adds `RELAY_AUTHORIZE_URL` and
`HYPERLIQUID_EXCHANGE_URL` endpoints.

## References

- Follows up on #8285 (HyperLiquid source quote support)
- Related to MetaMask/MetaMask-planning#6805,
MetaMask/MetaMask-planning#6806

## Checklist

- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [ ] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md)
- [ ] I've introduced [breaking
changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md)
in this PR and have prepared draft pull requests for clients and
consumer packages to resolve them

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **High Risk**
> Adds a new HyperLiquid withdrawal submission path that performs
*silent* EIP-712 signing and posts signatures to external
Relay/HyperLiquid endpoints, plus a breaking messenger permission
expansion. Incorrect step parsing/signature construction or permission
wiring could cause failed withdrawals or unintended signing behavior.
> 
> **Overview**
> Adds a new **HyperLiquid withdrawal submission flow** for the Relay
strategy: when `quote.request.isHyperliquidSource` is set,
`relay-submit` skips on-chain `TransactionController` submissions and
instead runs a two-step `submitHyperliquidWithdraw` flow (Relay
`/authorize` EIP-712 signature, then HyperLiquid exchange `sendAsset`
EIP-712 signature + `r/s/v` POST), before continuing with the existing
Relay status polling.
> 
> Introduces new endpoints (`RELAY_AUTHORIZE_URL`,
`HYPERLIQUID_EXCHANGE_URL`), adds comprehensive unit tests for the new
withdraw module and the new routing branch, and **expands
`AllowedActions` with `KeyringControllerSignTypedMessageAction`
(breaking)** so clients must grant `KeyringController:signTypedMessage`
when constructing the controller messenger.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
3240f3d. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants