Skip to content

fix(perps): skip unified migration for multi-sig accounts - #9764

Closed
abretonc7s wants to merge 3 commits into
mainfrom
fix/perps/skip-unified-migration-for-multisig
Closed

fix(perps): skip unified migration for multi-sig accounts#9764
abretonc7s wants to merge 3 commits into
mainfrom
fix/perps/skip-unified-migration-for-multisig

Conversation

@abretonc7s

@abretonc7s abretonc7s commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Explanation

Opening Perps for a HyperLiquid multi-sig account attempted a single-signer unified-account migration on every entry, producing Multi-sig required and recurring error reports.

This change detects the account signer set before that write, skips migration for multi-sig accounts, and caches the final non-unified readiness state. It also handles a conversion race by classifying the same rejection in the write fallback.

Validation

  • Real HyperLiquid testnet account, same driver and signer:
    • main: reproduced Multi-sig required and Unified Account setup failed.
    • This branch: logged the multi-sig migration skip with neither failure.
    • The account was returned to its original single-sig/default state afterward.
  • Provider regression target: 36 passed, 24 skipped.
  • Error-classifier target: 19 passed.
  • Provider suites: 13 suites passed; 569 tests passed, 36 skipped.
  • Full @metamask/perps-controller suite and root build passed before the final rebase. Required GitHub checks provide the authoritative post-rebase validation.

This is a headless controller change, so visual evidence does not apply.

References

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 the package changelog
  • I've introduced breaking changes in this PR and have prepared client updates

Note

Low Risk
Scoped to unified-account setup in HyperLiquidProvider with fail-open probing and extensive tests; no changes to order placement or auth beyond skipping an impossible migration.

Overview
Fixes recurring Multi-sig required failures when opening Perps for HyperLiquid accounts that were converted to multi-sig, where each visit retried a single-signer unified-account migration that the venue cannot accept.

The provider now calls userToMultiSigSigners immediately before a migration write would run (only on paths that need migration, so already-unified accounts are unchanged). Multi-sig accounts skip agentSetAbstraction / userSetAbstraction, record trading readiness as { attempted: true, enabled: false }, and emit account-setup analytics with not_applicable / multi_sig_account instead of treating setup as failed.

A new exported helper isHyperLiquidMultiSigRequiredError classifies HyperLiquid’s multi-sig rejection (both hyphen spellings). The migration catch path uses it as a fallback when the probe fails open on network errors or the account flips multi-sig between probe and write, so those cases are not logged as setup failures or retried endlessly.

Unified mode stays off for these users; HIP-3 collateral continues via the existing programmatic transfer fallback.

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

Opening the Perps tab with a HyperLiquid multi-sig account raised
`ApiRequestError: Multi-sig required` on every entry.
`#ensureUnifiedAccountEnabled` migrates legacy abstraction modes with a
single-signer `agentSetAbstraction` / `userSetAbstraction` write, which
HyperLiquid rejects outright for a converted multi-sig account. Nothing
classified the account shape before the write or the rejection after it,
so it fell through to the generic failure handler: no cache entry, retry
flag set, error reported.

Query `userToMultiSigSigners` immediately before the migration write and
skip it for a multi-sig account, recording the setup as not applicable
and caching `{ attempted: true, enabled: false }` so it is not retried.
The lookup only runs when a write would otherwise be made, so accounts
already on a compatible mode and deferred accounts pay no extra round
trip, and it fails open so a transient info-API error cannot block
migration for a single-signer account.

Add `isHyperLiquidMultiSigRequiredError` and apply it in the same
method's catch block, covering the conversion racing the write and the
failed-open probe. Both `multi-sig required` and `multisig required`
spellings are matched.

Fixes TAT-3214
The Unreleased entry documented the classifier as exported from
`@metamask/perps-controller/utils`, but the package exports map declares
`./utils/*` with no bare `./utils`, so that specifier fails to resolve
with ERR_PACKAGE_PATH_NOT_EXPORTED. Point it at `utils/*`, matching the
neighbouring floorToSizeDecimals entry.

Refs TAT-3214
@abretonc7s abretonc7s added team-perps bug Something isn't working labels Aug 3, 2026
@abretonc7s
abretonc7s marked this pull request as ready for review August 4, 2026 13:43
@abretonc7s
abretonc7s requested review from a team as code owners August 4, 2026 13:43
@abretonc7s abretonc7s closed this Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working team-perps

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant