@metamask-previews/perps-controller 19.0.0-preview-c2be02bd4 → 19.0.0-preview-3b264bf6d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -14,6 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
14
14
|
### Fixed
|
|
15
15
|
|
|
16
16
|
- Accept Lighter trades that omit position-sign flags, preserve omitted account PnL as unknown, and reject known reductions without realized PnL. Retain side-only fill directions when lifecycle context is ambiguous ([#10605](https://github.com/MetaMask/core/pull/10605))
|
|
17
|
+
- Stop reporting HyperLiquid WebSocket transport failures (a closed or terminated socket, request timeout or abort) during the unified-account setup as errors ([#10651](https://github.com/MetaMask/core/pull/10651))
|
|
18
|
+
- After such a failure, provider entry waits one minute before running the setup again instead of retrying every time; `reconnect()` or `disconnect()` ends the wait, and trading and withdraw still run the setup
|
|
19
|
+
- Venue rejections, signing failures and other setup errors are still reported
|
|
17
20
|
|
|
18
21
|
## [19.0.0]
|
|
19
22
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HyperLiquidProvider.d.ts","sourceRoot":"","sources":["../../src/providers/HyperLiquidProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA4B,MAAM,iBAAiB,CAAC;AAE1E,OAAO,KAAK,EACV,cAAc,EAGf,MAAM,qBAAqB,CAAC;AAK7B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"HyperLiquidProvider.d.ts","sourceRoot":"","sources":["../../src/providers/HyperLiquidProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA4B,MAAM,iBAAiB,CAAC;AAE1E,OAAO,KAAK,EACV,cAAc,EAGf,MAAM,qBAAqB,CAAC;AAK7B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;A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AE,MAAM,KACxB,IAAI,GACR,MAAM,IAAI,CAEZ;IAED;;;;;OAKG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAI/B;IAED;;;;;OAKG;IACG,gBAAgB,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAuB1E;IAEK,sBAAsB,CAAC,OAAO,EAAE;QACpC,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,YAAY,CAAC;QACvB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,UAAU,CAAC,CAUtB;IAED;;;;;OAKG;IACH,mBAAmB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAY5C;CAoYF"}
|
|
@@ -9,6 +9,7 @@ import { CHASE_ORDER_CONFIG, CHASE_ORDER_STATUS, HYPERLIQUID_TWAP_LIMITS, ORDER_
|
|
|
9
9
|
import { PERPS_TRANSACTIONS_HISTORY_CONSTANTS } from '../constants/transactionsHistoryConfig.js';
|
|
10
10
|
import { PERPS_ERROR_CODES } from '../perpsErrorCodes.js';
|
|
11
11
|
import { AgentSignerUnavailableError, getAgentAccountKey, isAgentSignerUnavailableError, } from '../services/agentSigner.js';
|
|
12
|
+
import { hasErrorInCauseChain } from '../services/causeChain.js';
|
|
12
13
|
import { DexDiscoveryCacheManager } from '../services/DexDiscoveryCacheManager.js';
|
|
13
14
|
import { HyperLiquidClientService, } from '../services/HyperLiquidClientService.js';
|
|
14
15
|
import { HyperLiquidSubscriptionService } from '../services/HyperLiquidSubscriptionService.js';
|
|
@@ -548,6 +549,46 @@ const HYPERLIQUID_ORDER_FEE_CONFIG = {
|
|
|
548
549
|
};
|
|
549
550
|
const MILLISECONDS_PER_MINUTE = 60_000;
|
|
550
551
|
const MILLISECONDS_PER_SECOND = 1_000;
|
|
552
|
+
/**
|
|
553
|
+
* How long #ensureReady waits before running the unified-account setup again
|
|
554
|
+
* after its lookup failed on the WebSocket transport. A socket that exhausted
|
|
555
|
+
* its reconnect budget rejects every request until reconnect() or reinit, so
|
|
556
|
+
* retrying on every #ensureReady entry only repeats the same failure.
|
|
557
|
+
*/
|
|
558
|
+
const UNIFIED_ACCOUNT_TRANSPORT_RETRY_COOLDOWN_MS = MILLISECONDS_PER_MINUTE;
|
|
559
|
+
/**
|
|
560
|
+
* Fixed messages the SDK gives a `WebSocketRequestError` raised on the client
|
|
561
|
+
* side of the socket. Error frames the server sends back for a request carry
|
|
562
|
+
* the server's own text instead.
|
|
563
|
+
*/
|
|
564
|
+
const WEBSOCKET_CLIENT_FAILURE_MESSAGES = [
|
|
565
|
+
'WebSocket connection permanently terminated',
|
|
566
|
+
'WebSocket connection closed',
|
|
567
|
+
'Request timed out after',
|
|
568
|
+
'Request aborted',
|
|
569
|
+
'Unknown error while making a WebSocket request',
|
|
570
|
+
];
|
|
571
|
+
/**
|
|
572
|
+
* Whether the WebSocket transport, rather than the venue or the signer, failed
|
|
573
|
+
* the request. The SDK raises `WebSocketRequestError` for client-side failures
|
|
574
|
+
* (closed or terminated socket, timeout, abort), usually with the cause
|
|
575
|
+
* attached, e.g. the `ReconnectingWebSocketError` (`RECONNECTION_LIMIT`,
|
|
576
|
+
* `TERMINATED_BY_USER`) behind a terminated socket. It also uses
|
|
577
|
+
* `WebSocketRequestError` for error frames the server sends back; those are
|
|
578
|
+
* the venue's answer, have no cause and keep the server's text, so they are
|
|
579
|
+
* not transport errors. The fixed messages cover client-side failures that
|
|
580
|
+
* have no cause, including on engines that ignore `Error` `cause`.
|
|
581
|
+
* `HyperLiquidSubscriptionService` keeps its own check for the same SDK errors
|
|
582
|
+
* on the subscription paths.
|
|
583
|
+
*
|
|
584
|
+
* @param error - The caught error.
|
|
585
|
+
* @returns True when the error, or one in its cause chain, is a WebSocket
|
|
586
|
+
* transport error.
|
|
587
|
+
*/
|
|
588
|
+
const isWebSocketTransportError = (error) => hasErrorInCauseChain(error, (current) => current.name === 'ReconnectingWebSocketError' ||
|
|
589
|
+
(current.name === 'WebSocketRequestError' &&
|
|
590
|
+
(current.cause !== undefined ||
|
|
591
|
+
WEBSOCKET_CLIENT_FAILURE_MESSAGES.some((message) => current.message.startsWith(message)))));
|
|
551
592
|
/**
|
|
552
593
|
* Normalize the TWAP history timestamp documented in seconds while tolerating
|
|
553
594
|
* an already-millisecond value from a future SDK response.
|
|
@@ -710,6 +751,9 @@ export class HyperLiquidProvider {
|
|
|
710
751
|
// its memoized promise when this is set so the next entry retries the
|
|
711
752
|
// migration instead of returning the cached resolved promise.
|
|
712
753
|
#unifiedAccountSetupNeedsRetry = false;
|
|
754
|
+
// Earliest Date.now() at which #ensureReady runs the unified-account setup
|
|
755
|
+
// again after its lookup failed on the WebSocket transport. 0 = no cooldown.
|
|
756
|
+
#unifiedAccountTransportRetryAt = 0;
|
|
713
757
|
// Pending promise to deduplicate concurrent getValidatedDexs() calls
|
|
714
758
|
#pendingValidatedDexsPromise = null;
|
|
715
759
|
// Cache for USDC token ID from spot metadata
|
|
@@ -1725,6 +1769,24 @@ export class HyperLiquidProvider {
|
|
|
1725
1769
|
completeInFlight();
|
|
1726
1770
|
return;
|
|
1727
1771
|
}
|
|
1772
|
+
// The WebSocket transport could not carry the lookup, typically a
|
|
1773
|
+
// socket that exhausted its reconnect budget (Sentry METAMASK-ZHT9).
|
|
1774
|
+
// That is connectivity, not a migration failure: keep it out of Sentry
|
|
1775
|
+
// and analytics, keep the retry flag, and have #ensureReady wait out a
|
|
1776
|
+
// cooldown instead of repeating the lookup on every entry.
|
|
1777
|
+
if (isWebSocketTransportError(error)) {
|
|
1778
|
+
this.#unifiedAccountTransportRetryAt =
|
|
1779
|
+
Date.now() + UNIFIED_ACCOUNT_TRANSPORT_RETRY_COOLDOWN_MS;
|
|
1780
|
+
this.#deps.debugLogger.log('[ensureUnifiedAccountEnabled] WebSocket transport unavailable, will retry after cooldown', {
|
|
1781
|
+
user: userAddress,
|
|
1782
|
+
network,
|
|
1783
|
+
error: ensureError(error, 'HyperLiquidProvider.ensureUnifiedAccountEnabled').message,
|
|
1784
|
+
cooldownMs: UNIFIED_ACCOUNT_TRANSPORT_RETRY_COOLDOWN_MS,
|
|
1785
|
+
});
|
|
1786
|
+
this.#unifiedAccountSetupNeedsRetry = true;
|
|
1787
|
+
completeInFlight();
|
|
1788
|
+
return;
|
|
1789
|
+
}
|
|
1728
1790
|
// Agent-path failures and read-only userAbstraction lookup failures
|
|
1729
1791
|
// are not final: signal #ensureReady to drop its memoized promise and
|
|
1730
1792
|
// retry on the next entry instead of pinning the user in the
|
|
@@ -1785,9 +1847,15 @@ export class HyperLiquidProvider {
|
|
|
1785
1847
|
// signing-backed migration during initial setup so the first trade sees
|
|
1786
1848
|
// the unified balance. Hardware wallets remain deferred to action time to
|
|
1787
1849
|
// avoid repeated signing prompts while browsing.
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1850
|
+
// After a WebSocket transport failure, skip it until the cooldown is
|
|
1851
|
+
// over. The memoized promise is dropped while the cooldown is active
|
|
1852
|
+
// (see below), so a later entry retries. Action-time callers are not
|
|
1853
|
+
// gated.
|
|
1854
|
+
if (Date.now() >= this.#unifiedAccountTransportRetryAt) {
|
|
1855
|
+
await this.#ensureUnifiedAccountEnabled({
|
|
1856
|
+
allowUserSigning: !this.#walletService.requiresSignatureConfirmation(),
|
|
1857
|
+
});
|
|
1858
|
+
}
|
|
1791
1859
|
})();
|
|
1792
1860
|
// Await initialization - keep the promise so subsequent calls resolve immediately
|
|
1793
1861
|
// The promise is only reset in disconnect() for clean reconnection,
|
|
@@ -1805,11 +1873,16 @@ export class HyperLiquidProvider {
|
|
|
1805
1873
|
// will be re-discovered on the next #ensureReady() call.
|
|
1806
1874
|
this.#ensureReadyPromise = null;
|
|
1807
1875
|
}
|
|
1808
|
-
else if (this.#unifiedAccountSetupNeedsRetry
|
|
1876
|
+
else if (this.#unifiedAccountSetupNeedsRetry ||
|
|
1877
|
+
Date.now() < this.#unifiedAccountTransportRetryAt) {
|
|
1809
1878
|
// Silent migration / lookup / keyring-locked failure left the cache
|
|
1810
1879
|
// empty. Without resetting the memoized promise, subsequent
|
|
1811
1880
|
// #ensureReady calls would skip retry and the user would be stuck
|
|
1812
1881
|
// in the deprecated mode for the provider's lifetime.
|
|
1882
|
+
// A run skipped by the transport cooldown must not be memoized
|
|
1883
|
+
// either: the shared flag can read false while an action-time
|
|
1884
|
+
// attempt is in flight, and the setup has to run once the cooldown
|
|
1885
|
+
// is over.
|
|
1813
1886
|
this.#ensureReadyPromise = null;
|
|
1814
1887
|
}
|
|
1815
1888
|
this.#deps.debugLogger.log('[ensureReady] Initialization complete');
|
|
@@ -11630,6 +11703,10 @@ export class HyperLiquidProvider {
|
|
|
11630
11703
|
// Reset client initialization flag so wallet adapter will be recreated with new account
|
|
11631
11704
|
// This fixes account synchronization issue where old account's address persists in wallet adapter
|
|
11632
11705
|
this.#clientsInitialized = false;
|
|
11706
|
+
// Only after the pending setups above settled: a lookup that failed on
|
|
11707
|
+
// the transport while they were awaited must not carry its cooldown
|
|
11708
|
+
// into the next session.
|
|
11709
|
+
this.#unifiedAccountTransportRetryAt = 0;
|
|
11633
11710
|
// Disconnect client service
|
|
11634
11711
|
await this.#clientService.disconnect();
|
|
11635
11712
|
this.#deps.debugLogger.log('HyperLiquid: Provider fully disconnected', {
|
|
@@ -11714,7 +11791,9 @@ export class HyperLiquidProvider {
|
|
|
11714
11791
|
* @returns A promise that resolves when the operation completes.
|
|
11715
11792
|
*/
|
|
11716
11793
|
async reconnect() {
|
|
11717
|
-
|
|
11794
|
+
await this.#clientService.reconnect();
|
|
11795
|
+
// The socket was rebuilt: the unified-account setup can run again now.
|
|
11796
|
+
this.#unifiedAccountTransportRetryAt = 0;
|
|
11718
11797
|
}
|
|
11719
11798
|
/**
|
|
11720
11799
|
* Get list of available HIP-3 builder-deployed DEXs
|