feat(transaction-pay-controller): add HyperLiquid source quote support for Perps Withdraw#8285
Merged
feat(transaction-pay-controller): add HyperLiquid source quote support for Perps Withdraw#8285
Conversation
dan437
commented
Mar 24, 2026
matthewwalsh0
previously approved these changes
Mar 24, 2026
packages/transaction-pay-controller/src/strategy/relay/relay-max-gas-station.ts
Outdated
Show resolved
Hide resolved
packages/transaction-pay-controller/src/strategy/relay/relay-quotes.ts
Outdated
Show resolved
Hide resolved
packages/transaction-pay-controller/src/strategy/relay/relay-quotes.ts
Outdated
Show resolved
Hide resolved
c6e2d66 to
f1735c0
Compare
f1735c0 to
4c7c632
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
…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>
449cf5e to
581aa20
Compare
matthewwalsh0
approved these changes
Mar 25, 2026
4 tasks
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>
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.

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
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
isHyperliquidSourceflag that is persisted viasetTransactionConfigand propagated into quote requests.When
isHyperliquidSourceis 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 (
signatureand HyperLiquid deposit shapes) and updates gas/submit logic to only processtransactionsteps 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.