Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,108 changes: 0 additions & 2,108 deletions .yarn/patches/@nktkas-hyperliquid-npm-0.33.1-6a541fdd1d.patch

This file was deleted.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@
"yargs": "^17.7.3"
},
"resolutions": {
"@nktkas/hyperliquid@npm:^0.33.1": "patch:@nktkas/hyperliquid@npm%3A0.33.1#~/.yarn/patches/@nktkas-hyperliquid-npm-0.33.1-6a541fdd1d.patch",
"@typescript/old": "patch:typescript@npm%3A6.0.3#~/.yarn/patches/typescript-npm-6.0.3-585eecd158.patch"
},
"simple-git-hooks": {
Expand Down
15 changes: 13 additions & 2 deletions packages/perps-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Add `TWAP_SLICE`, `VAULT_CLOSE` and `SPOT_DUST_CONVERSION` to `DETAILED_ORDER_TYPES` for the HyperLiquid order types added in `@nktkas/hyperliquid` 0.33.3 ([#10591](https://github.com/MetaMask/core/pull/10591))
- Add `PerpsController.getMarginModeLock` (and the `PerpsController:getMarginModeLock` messenger action) plus the optional `PerpsProvider.getMarginModeLock`, reporting the margin mode an asset is locked to by an open position or resting order/TWAP so clients can keep their margin-mode picker in sync with what order placement will accept. HyperLiquid implements it; other providers report `not_implemented`. ([#10414](https://github.com/MetaMask/core/pull/10414))
- Implement `getMarginModeLock` for Lighter, reporting the mode an open position binds to its market. ([#10414](https://github.com/MetaMask/core/pull/10414))
- Add optional `supportedMarginModes` to ready order capabilities; HyperLiquid reports `['isolated', 'cross']` for main-DEX markets and `['isolated']` for HIP-3 or isolated-only assets, so clients stop inferring margin-mode support from the provider. ([#10414](https://github.com/MetaMask/core/pull/10414))
Expand All @@ -30,23 +31,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- An agent the venue rejects as unknown (revoked or expired, for example after the user approves another unnamed agent) is dropped, together with a `setAgentSigner` binding to it, so the next L1 action asks `getAgentSigner` again; the rejected action fails with `KEYRING_LOCKED` instead of `EXCHANGE_ACCOUNT_NOT_FOUND`
- Add optional `providerCredentials.hyperliquid.onAgentRejected(account, agentAddress)`, called with the agent's address as the client supplied it for each write the venue rejects with that agent, so the client can re-check its approval
- The exported `HyperLiquidProvider` accepts the matching optional `getAgentSigner` and `onAgentRejected` constructor options and implements `clearAgentSigners`
- An agent only ever signs for the main account and network it was set or resolved for, and user-signed actions (builder fee, withdraw, the user-signed migration from `dexAbstraction`, ...) always stay on the main account; approving the agent remains the client's job
- An agent only ever signs for the main account and network it was set or resolved for, and user-signed actions (builder fee, withdraw, ...) always stay on the main account; approving the agent remains the client's job
- Export `HYPERLIQUID_L1_ACTION_PRIMARY_TYPE` and `HYPERLIQUID_L1_ACTION_DOMAIN_NAME`, the EIP-712 shape that marks an L1 action
- Add `PerpsController:prepareTradingWallet` (`PerpsControllerPrepareTradingWalletAction`) and optional `PerpsProvider.prepareTradingWallet` to run the deferred trading setup before the first order, so its signatures happen in a guided session: account migration, builder fee and referral on HyperLiquid, venue-key registration on Lighter ([#10559](https://github.com/MetaMask/core/pull/10559))
- The builder fee, the migration from `dexAbstraction` and the Lighter registration are signed by the main account; with an agent, the HyperLiquid referral and silent migration are signed by the agent
- The builder fee and the Lighter registration are signed by the main account; with an agent, the HyperLiquid referral and unified-account migration are signed by the agent
- Resolves a `ReadyToTradeResult` that is `ready: true` once an account is selected, the main-account signer is ready and none of these steps will need a signature again before the first order, and `ready: false` while one will be retried, including after an agent could not sign; `ready: false` carries `KEYRING_LOCKED` while the signer is not ready, `EXCHANGE_ACCOUNT_NOT_FOUND` for a wallet with no account on the venue yet, `NO_ACCOUNT_SELECTED`, `PROVIDER_LIFECYCLE_STALE` when the provider or account changed during setup, or the message of the logged error that stopped setup; the aggregated provider prepares every provider in turn
- A HyperLiquid referral whose MetaMask referral code is not ready yet does not hold the result back; the next `prepareTradingWallet` checks the code again, and orders do not
- Implemented by the exported `HyperLiquidProvider` and by the Lighter provider, which resolves `ready: true` at once when it is read-only (no signer bridge), an account is selected and the main-account signer is ready
- Add optional `isTestnet` to `AggregatedProviderConfig`, which tags the errors the aggregated provider logs with the network ([#10559](https://github.com/MetaMask/core/pull/10559))

### Changed

- **BREAKING:** `OrderFill.liquidation.liquidatedUser` is now optional, since HyperLiquid omits it on some liquidation fills ([#10591](https://github.com/MetaMask/core/pull/10591))
- **BREAKING:** The exported `FrontendOrder.orderType` union adds `Twap Slice`, `Vault Close` and `Spot Dust Conversion`, so exhaustive handling of it must cover these values; historical orders of these types report `orderType: 'market'` ([#10591](https://github.com/MetaMask/core/pull/10591))
- Bump `@nktkas/hyperliquid` from `^0.33.1` to `^0.33.3` ([#10591](https://github.com/MetaMask/core/pull/10591))
- Drop the yarn patch on the SDK, which `0.33.3` no longer needs

### Removed

- **BREAKING:** Remove the `LighterPersonalSigner` type and the `personalSigner` and `l1Address` fields of `LighterAuthConfig` ([#10559](https://github.com/MetaMask/core/pull/10559))
- `PerpsController` never forwarded these fields to the Lighter provider, so they had no effect for controller clients
- To sign Lighter L1 messages without a `KeyringController`, set `PerpsPlatformDependencies.accountSigner.signPersonalMessage`; the L1 address comes from the messenger's selected account
- Remove the HyperLiquid `dexAbstraction` to Unified Account migration, which prompted the main wallet through `userSetAbstraction`; HyperLiquid retired the `dexAbstraction` mode, and `default` / `disabled` accounts still migrate through `agentSetAbstraction` ([#10591](https://github.com/MetaMask/core/pull/10591))

### Fixed

- HyperLiquid historical orders report `rejected` for the venue's specific rejection statuses (`tickRejected`, `perpMarginRejected`, `tooManyOpenOrdersRejected`, ...) and `canceled` for `outcomeSettledCanceled` and `internalCancel`, instead of `queued` ([#10591](https://github.com/MetaMask/core/pull/10591))
- Only one HyperLiquid unified-account migration runs at a time when several callers wait on an attempt that ends without a cached result, such as a migration deferred at init for a hardware wallet ([#10591](https://github.com/MetaMask/core/pull/10591))
- HyperLiquid writes that fail because the keyring is locked now fail with `KEYRING_LOCKED` and are no longer reported as errors by the provider or `TradingService` ([#10559](https://github.com/MetaMask/core/pull/10559))
- Before, they failed with the SDK's "Failed to sign the typed data using the wallet" message, or with `TPSL_UPDATE_FAILED` for a TP/SL update whose builder fee was not approved yet
- Covers orders, edits, single and batch cancels (TWAP, scale and chase cancels included), position closes, TP/SL updates and clears, margin updates, withdrawals and transfers between DEXs, including the HIP-3 transfers around an order
Expand Down
2 changes: 1 addition & 1 deletion packages/perps-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"@metamask/messenger": "^3.0.0",
"@metamask/superstruct": "^3.4.1",
"@metamask/utils": "^12.0.0",
"@nktkas/hyperliquid": "^0.33.1",
"@nktkas/hyperliquid": "^0.33.3",
"bignumber.js": "^9.1.2",
"reselect": "^5.1.1",
"uuid": "^11.1.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -955,21 +955,19 @@ export type PerpsControllerClearAgentSignersAction = {
* Run the active provider's deferred trading setup ahead of the first order
* (HyperLiquid account migration, builder fee and referral; Lighter
* venue-key registration), so its signatures happen in one guided session,
* such as agent setup, instead of at order time. The builder fee, the
* migration from `dexAbstraction` and Lighter's registration are signed by
* the main account; with an agent, the referral and the silent migration
* are L1 actions the agent signs.
* such as agent setup, instead of at order time. The builder fee and
* Lighter's registration are signed by the main account; with an agent,
* the referral and the account migration are L1 actions the agent signs.
*
* @returns `ready: true` when none of these steps will need a signature
* again before the first order, and only while an account is selected and
* the main account can sign, whichever provider answered (including
* providers without deferred setup, for example in aggregated mode). A
* declined HyperLiquid migration is not asked again, and a HyperLiquid
* referral whose MetaMask referral code is not ready yet is checked again at
* the next call, not before orders, so neither holds it back. Otherwise
* `ready: false`, without an error while a step will be asked again (a
* declined builder fee or Lighter registration, or a step the agent could
* not sign), or with:
* HyperLiquid referral whose MetaMask referral code is not ready yet is
* checked again at the next call, not before orders, so it does not hold
* it back. Otherwise `ready: false`, without an error while a step will
* be asked again (a declined HyperLiquid migration, builder fee or Lighter
* registration, or a step the agent could not sign), or with:
* - `KEYRING_LOCKED` when the main account cannot sign, before or during
* setup;
* - `EXCHANGE_ACCOUNT_NOT_FOUND` for a wallet with no account on the venue
Expand Down
18 changes: 8 additions & 10 deletions packages/perps-controller/src/PerpsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6071,21 +6071,19 @@ export class PerpsController extends BaseController<
* Run the active provider's deferred trading setup ahead of the first order
* (HyperLiquid account migration, builder fee and referral; Lighter
* venue-key registration), so its signatures happen in one guided session,
* such as agent setup, instead of at order time. The builder fee, the
* migration from `dexAbstraction` and Lighter's registration are signed by
* the main account; with an agent, the referral and the silent migration
* are L1 actions the agent signs.
* such as agent setup, instead of at order time. The builder fee and
* Lighter's registration are signed by the main account; with an agent,
* the referral and the account migration are L1 actions the agent signs.
*
* @returns `ready: true` when none of these steps will need a signature
* again before the first order, and only while an account is selected and
* the main account can sign, whichever provider answered (including
* providers without deferred setup, for example in aggregated mode). A
* declined HyperLiquid migration is not asked again, and a HyperLiquid
* referral whose MetaMask referral code is not ready yet is checked again at
* the next call, not before orders, so neither holds it back. Otherwise
* `ready: false`, without an error while a step will be asked again (a
* declined builder fee or Lighter registration, or a step the agent could
* not sign), or with:
* HyperLiquid referral whose MetaMask referral code is not ready yet is
* checked again at the next call, not before orders, so it does not hold
* it back. Otherwise `ready: false`, without an error while a step will
* be asked again (a declined HyperLiquid migration, builder fee or Lighter
* registration, or a step the agent could not sign), or with:
* - `KEYRING_LOCKED` when the main account cannot sign, before or during
* setup;
* - `EXCHANGE_ACCOUNT_NOT_FOUND` for a wallet with no account on the venue
Expand Down
3 changes: 3 additions & 0 deletions packages/perps-controller/src/constants/orderTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export const DETAILED_ORDER_TYPES = {
STOP_MARKET: 'Stop Market',
TAKE_PROFIT_LIMIT: 'Take Profit Limit',
TAKE_PROFIT_MARKET: 'Take Profit Market',
TWAP_SLICE: 'Twap Slice',
VAULT_CLOSE: 'Vault Close',
SPOT_DUST_CONVERSION: 'Spot Dust Conversion',
} as const;

/**
Expand Down
Loading
Loading