@metamask-previews/perps-controller 15.1.0-preview-6b7c25c → 15.1.0-preview-00a181c
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 +14 -0
- package/dist/PerpsController-method-action-types.cjs.map +1 -1
- package/dist/PerpsController-method-action-types.d.cts +20 -1
- package/dist/PerpsController-method-action-types.d.cts.map +1 -1
- package/dist/PerpsController-method-action-types.d.mts +20 -1
- package/dist/PerpsController-method-action-types.d.mts.map +1 -1
- package/dist/PerpsController-method-action-types.mjs.map +1 -1
- package/dist/PerpsController.cjs +65 -154
- package/dist/PerpsController.cjs.map +1 -1
- package/dist/PerpsController.d.cts +37 -43
- package/dist/PerpsController.d.cts.map +1 -1
- package/dist/PerpsController.d.mts +37 -43
- package/dist/PerpsController.d.mts.map +1 -1
- package/dist/PerpsController.mjs +64 -151
- package/dist/PerpsController.mjs.map +1 -1
- package/dist/aggregation/SubscriptionMultiplexer.cjs +1 -1
- package/dist/aggregation/SubscriptionMultiplexer.cjs.map +1 -1
- package/dist/aggregation/SubscriptionMultiplexer.d.cts +1 -1
- package/dist/aggregation/SubscriptionMultiplexer.d.mts +1 -1
- package/dist/aggregation/SubscriptionMultiplexer.mjs +1 -1
- package/dist/aggregation/SubscriptionMultiplexer.mjs.map +1 -1
- package/dist/constants/index.cjs +0 -1
- package/dist/constants/index.cjs.map +1 -1
- package/dist/constants/index.d.cts +0 -1
- package/dist/constants/index.d.cts.map +1 -1
- package/dist/constants/index.d.mts +0 -1
- package/dist/constants/index.d.mts.map +1 -1
- package/dist/constants/index.mjs +0 -1
- package/dist/constants/index.mjs.map +1 -1
- package/dist/constants/perpsConfig.cjs +4 -9
- package/dist/constants/perpsConfig.cjs.map +1 -1
- package/dist/constants/perpsConfig.d.cts +3 -5
- package/dist/constants/perpsConfig.d.cts.map +1 -1
- package/dist/constants/perpsConfig.d.mts +3 -5
- package/dist/constants/perpsConfig.d.mts.map +1 -1
- package/dist/constants/perpsConfig.mjs +4 -9
- package/dist/constants/perpsConfig.mjs.map +1 -1
- package/dist/index.cjs +146 -175
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +0 -1
- package/dist/index.mjs.map +1 -1
- package/dist/providers/AggregatedPerpsProvider.cjs +8 -2
- package/dist/providers/AggregatedPerpsProvider.cjs.map +1 -1
- package/dist/providers/AggregatedPerpsProvider.d.cts +3 -2
- package/dist/providers/AggregatedPerpsProvider.d.cts.map +1 -1
- package/dist/providers/AggregatedPerpsProvider.d.mts +3 -2
- package/dist/providers/AggregatedPerpsProvider.d.mts.map +1 -1
- package/dist/providers/AggregatedPerpsProvider.mjs +8 -2
- package/dist/providers/AggregatedPerpsProvider.mjs.map +1 -1
- package/dist/providers/HyperLiquidProvider.cjs +118 -22
- package/dist/providers/HyperLiquidProvider.cjs.map +1 -1
- package/dist/providers/HyperLiquidProvider.d.cts +31 -0
- package/dist/providers/HyperLiquidProvider.d.cts.map +1 -1
- package/dist/providers/HyperLiquidProvider.d.mts +31 -0
- package/dist/providers/HyperLiquidProvider.d.mts.map +1 -1
- package/dist/providers/HyperLiquidProvider.mjs +118 -22
- package/dist/providers/HyperLiquidProvider.mjs.map +1 -1
- package/dist/providers/LighterProvider.cjs +1 -1
- package/dist/providers/LighterProvider.cjs.map +1 -1
- package/dist/providers/LighterProvider.mjs +1 -1
- package/dist/providers/LighterProvider.mjs.map +1 -1
- package/dist/routing/ProviderRouter.cjs +1 -1
- package/dist/routing/ProviderRouter.cjs.map +1 -1
- package/dist/routing/ProviderRouter.d.cts +1 -1
- package/dist/routing/ProviderRouter.d.mts +1 -1
- package/dist/routing/ProviderRouter.mjs +1 -1
- package/dist/routing/ProviderRouter.mjs.map +1 -1
- package/dist/services/HyperLiquidClientService.cjs.map +1 -1
- package/dist/services/HyperLiquidClientService.d.cts +26 -16
- package/dist/services/HyperLiquidClientService.d.cts.map +1 -1
- package/dist/services/HyperLiquidClientService.d.mts +26 -16
- package/dist/services/HyperLiquidClientService.d.mts.map +1 -1
- package/dist/services/HyperLiquidClientService.mjs.map +1 -1
- package/dist/services/HyperLiquidWalletService.cjs +80 -30
- package/dist/services/HyperLiquidWalletService.cjs.map +1 -1
- package/dist/services/HyperLiquidWalletService.d.cts +48 -22
- package/dist/services/HyperLiquidWalletService.d.cts.map +1 -1
- package/dist/services/HyperLiquidWalletService.d.mts +48 -22
- package/dist/services/HyperLiquidWalletService.d.mts.map +1 -1
- package/dist/services/HyperLiquidWalletService.mjs +80 -30
- package/dist/services/HyperLiquidWalletService.mjs.map +1 -1
- package/dist/services/LighterWalletService.cjs +1 -1
- package/dist/services/LighterWalletService.cjs.map +1 -1
- package/dist/services/LighterWalletService.d.cts +1 -1
- package/dist/services/LighterWalletService.d.mts +1 -1
- package/dist/services/LighterWalletService.mjs +1 -1
- package/dist/services/LighterWalletService.mjs.map +1 -1
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +10 -16
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.mts +10 -16
- package/dist/types/index.d.mts.map +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/dist/utils/lighterAdapter.cjs +1 -2
- package/dist/utils/lighterAdapter.cjs.map +1 -1
- package/dist/utils/lighterAdapter.d.cts +1 -2
- package/dist/utils/lighterAdapter.d.cts.map +1 -1
- package/dist/utils/lighterAdapter.d.mts +1 -2
- package/dist/utils/lighterAdapter.d.mts.map +1 -1
- package/dist/utils/lighterAdapter.mjs +1 -2
- package/dist/utils/lighterAdapter.mjs.map +1 -1
- package/package.json +2 -8
- package/dist/constants/myxConfig.cjs +0 -253
- package/dist/constants/myxConfig.cjs.map +0 -1
- package/dist/constants/myxConfig.d.cts +0 -145
- package/dist/constants/myxConfig.d.cts.map +0 -1
- package/dist/constants/myxConfig.d.mts +0 -145
- package/dist/constants/myxConfig.d.mts.map +0 -1
- package/dist/constants/myxConfig.mjs +0 -243
- package/dist/constants/myxConfig.mjs.map +0 -1
- package/dist/types/myx-types.cjs +0 -41
- package/dist/types/myx-types.cjs.map +0 -1
- package/dist/types/myx-types.d.cts +0 -94
- package/dist/types/myx-types.d.cts.map +0 -1
- package/dist/types/myx-types.d.mts +0 -94
- package/dist/types/myx-types.d.mts.map +0 -1
- package/dist/types/myx-types.mjs +0 -26
- package/dist/types/myx-types.mjs.map +0 -1
- package/dist/utils/myxAdapter.cjs +0 -569
- package/dist/utils/myxAdapter.cjs.map +0 -1
- package/dist/utils/myxAdapter.d.cts +0 -168
- package/dist/utils/myxAdapter.d.cts.map +0 -1
- package/dist/utils/myxAdapter.d.mts +0 -168
- package/dist/utils/myxAdapter.d.mts.map +0 -1
- package/dist/utils/myxAdapter.mjs +0 -548
- package/dist/utils/myxAdapter.mjs.map +0 -1
|
@@ -2,6 +2,7 @@ import { CaipAccountId } from "@metamask/utils";
|
|
|
2
2
|
import type { ExchangeClient } from "@nktkas/hyperliquid";
|
|
3
3
|
import type { CandlePeriod } from "../constants/chartConfig.cjs";
|
|
4
4
|
import { WebSocketConnectionState } from "../services/HyperLiquidClientService.cjs";
|
|
5
|
+
import type { AgentSigner } from "../services/HyperLiquidWalletService.cjs";
|
|
5
6
|
import type { AccountState, AssetRoute, BatchCancelOrdersParams, CancelOrderParams, CancelOrderResult, CancelOrdersResult, ChaseOrder, ChaseOrderMaxDistanceReached, CandleData, ClosePositionParams, ClosePositionsParams, ClosePositionsResult, DepositParams, DisconnectResult, EditOrderParams, FeeCalculationParams, FeeCalculationResult, Funding, GetAccountStateParams, GetAvailableDexsParams, GetFundingParams, GetHistoricalPortfolioParams, GetMarketsParams, GetOrderCapabilitiesParams, GetScalePriceLadderParams, GetOrderFillsParams, GetOrdersParams, GetOrFetchFillsParams, GetPositionsParams, GetSupportedPathsParams, GetUserDataSnapshotParams, HistoricalPortfolioResult, InitializeResult, PerpsPlatformDependencies, PerpsProvider, PerpsScalePriceLadder, LiquidationPriceParams, LiveDataConfig, MaintenanceMarginParams, PositionModifyPreviewParams, PositionModifyPreviewResult, MarginResult, MarketInfo, Order, OrderFill, OrderParams, OrderResult, PerpsMarketData, DirectProviderOrderCapabilities, Position, ReadyToTradeResult, SubscribeAccountParams, SubscribeCandlesParams, SubscribeOICapsParams, SubscribeOrderBookParams, SubscribeOrderFillsParams, SubscribeOrdersParams, SubscribeTwapOrdersParams, SubscribePositionsParams, SubscribePricesParams, ToggleTestnetResult, TransferBetweenDexsParams, TransferBetweenDexsResult, TwapOrder, UpdateMarginParams, UpdatePositionTPSLParams, UserHistoryItem, WithdrawParams, WithdrawResult, RawLedgerUpdate, PerpsReadOptions, PerpsUserDataSnapshot, PerpsFeeResolution } from "../types/index.cjs";
|
|
6
7
|
import type { PerpsControllerMessengerBase } from "../types/messenger.cjs";
|
|
7
8
|
type ChaseOrderMaxDistanceReachedHandler = (event: ChaseOrderMaxDistanceReached) => void;
|
|
@@ -20,6 +21,7 @@ type HyperLiquidProviderOptions = {
|
|
|
20
21
|
subscriptionBuilderAddressTestnet?: string;
|
|
21
22
|
subscriptionBuilderAddressMainnet?: string;
|
|
22
23
|
onChaseOrderMaxDistanceReached?: ChaseOrderMaxDistanceReachedHandler;
|
|
24
|
+
getAgentSigner?: (masterAccountAddress: string) => Promise<AgentSigner | null>;
|
|
23
25
|
};
|
|
24
26
|
/**
|
|
25
27
|
* HyperLiquid provider implementation
|
|
@@ -54,6 +56,18 @@ export declare class HyperLiquidProvider implements PerpsProvider {
|
|
|
54
56
|
* @throws When the ladder count or normalized range is invalid.
|
|
55
57
|
*/
|
|
56
58
|
getScalePriceLadder(params: GetScalePriceLadderParams): Promise<PerpsScalePriceLadder>;
|
|
59
|
+
/**
|
|
60
|
+
* Override (or clear) the trading wallet used for signing.
|
|
61
|
+
*
|
|
62
|
+
* Called when an agent wallet activates (pass the local agent signer) and
|
|
63
|
+
* when the keyring locks (pass null, restoring the master path). Reconnects
|
|
64
|
+
* the SDK clients so every subsequent action signs with the new wallet.
|
|
65
|
+
* Calls are serialized so concurrent events cannot interleave the
|
|
66
|
+
* disconnect/initialize pair.
|
|
67
|
+
*
|
|
68
|
+
* @param signer - The agent signer to sign with, or null to restore the master path.
|
|
69
|
+
*/
|
|
70
|
+
setTradingWalletOverride(signer: AgentSigner | null): Promise<void>;
|
|
57
71
|
/**
|
|
58
72
|
* Get fills using WebSocket cache first, falling back to REST API
|
|
59
73
|
* OPTIMIZATION: Uses cached fills when available (0 API weight), only calls REST on cache miss
|
|
@@ -544,6 +558,23 @@ export declare class HyperLiquidProvider implements PerpsProvider {
|
|
|
544
558
|
* @returns Discriminated preview; margin and liquidation are independently available.
|
|
545
559
|
*/
|
|
546
560
|
previewPositionModify(params: PositionModifyPreviewParams): Promise<PositionModifyPreviewResult>;
|
|
561
|
+
/**
|
|
562
|
+
* Drive the deferred trading-readiness steps ahead of the first order.
|
|
563
|
+
*
|
|
564
|
+
* Runs the exact sequence the order path uses (see `#ensureReadyForTrading`):
|
|
565
|
+
* unified account enablement with user signing allowed, builder fee approval,
|
|
566
|
+
* and referral setup. Calling this before the first order means hardware
|
|
567
|
+
* wallet users complete every master device prompt in one guided session
|
|
568
|
+
* (e.g. during agent wallet setup) instead of hitting a surprise prompt on
|
|
569
|
+
* their first trade.
|
|
570
|
+
*
|
|
571
|
+
* Safe to call repeatedly: readiness results are cached (globally and per
|
|
572
|
+
* session), so an already-approved wallet never sees a second prompt.
|
|
573
|
+
* Builder-fee failures are swallowed by the underlying sequence (trading
|
|
574
|
+
* retries at order time), but initialization and migration errors propagate
|
|
575
|
+
* to the caller.
|
|
576
|
+
*/
|
|
577
|
+
prepareTradingWallet(): Promise<void>;
|
|
547
578
|
/**
|
|
548
579
|
* Calculate liquidation price using HyperLiquid's formula
|
|
549
580
|
* Formula: liq_price = price - side * margin_available / position_size / (1 - maintenanceMarginRatio * side)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HyperLiquidProvider.d.cts","sourceRoot":"","sources":["../../src/providers/HyperLiquidProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA4B,wBAAwB;AAE1E,OAAO,KAAK,EACV,cAAc,EAGf,4BAA4B;AAK7B,OAAO,KAAK,EAAE,YAAY,EAAE,qCAAoC;AAwChE,OAAO,EAEL,wBAAwB,EACzB,iDAAgD;
|
|
1
|
+
{"version":3,"file":"HyperLiquidProvider.d.cts","sourceRoot":"","sources":["../../src/providers/HyperLiquidProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA4B,wBAAwB;AAE1E,OAAO,KAAK,EACV,cAAc,EAGf,4BAA4B;AAK7B,OAAO,KAAK,EAAE,YAAY,EAAE,qCAAoC;AAwChE,OAAO,EAEL,wBAAwB,EACzB,iDAAgD;AAIjD,OAAO,KAAK,EAAE,WAAW,EAAE,iDAAgD;AAmB3E,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,EACV,4BAA4B,EAE5B,UAAU,EACV,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,OAAO,EACP,qBAAqB,EACrB,sBAAsB,EACtB,gBAAgB,EAChB,4BAA4B,EAC5B,gBAAgB,EAChB,0BAA0B,EAC1B,yBAAyB,EACzB,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,EACzB,yBAAyB,EACzB,gBAAgB,EAChB,yBAAyB,EACzB,aAAa,EAEb,qBAAqB,EACrB,sBAAsB,EACtB,cAAc,EACd,uBAAuB,EACvB,2BAA2B,EAC3B,2BAA2B,EAC3B,YAAY,EACZ,UAAU,EACV,KAAK,EACL,SAAS,EACT,WAAW,EACX,WAAW,EAEX,eAAe,EACf,+BAA+B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,EAC/B,mBAAmB,EAAE,MAAM,KACxB,IAAI,GACR,MAAM,IAAI;IAIb;;;;;OAKG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAIhC;;;;;OAKG;IACG,gBAAgB,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAyBrE,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;IAYvB;;;;;OAKG;IACH,mBAAmB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM;CAmX9C"}
|
|
@@ -2,6 +2,7 @@ import { CaipAccountId } from "@metamask/utils";
|
|
|
2
2
|
import type { ExchangeClient } from "@nktkas/hyperliquid";
|
|
3
3
|
import type { CandlePeriod } from "../constants/chartConfig.mjs";
|
|
4
4
|
import { WebSocketConnectionState } from "../services/HyperLiquidClientService.mjs";
|
|
5
|
+
import type { AgentSigner } from "../services/HyperLiquidWalletService.mjs";
|
|
5
6
|
import type { AccountState, AssetRoute, BatchCancelOrdersParams, CancelOrderParams, CancelOrderResult, CancelOrdersResult, ChaseOrder, ChaseOrderMaxDistanceReached, CandleData, ClosePositionParams, ClosePositionsParams, ClosePositionsResult, DepositParams, DisconnectResult, EditOrderParams, FeeCalculationParams, FeeCalculationResult, Funding, GetAccountStateParams, GetAvailableDexsParams, GetFundingParams, GetHistoricalPortfolioParams, GetMarketsParams, GetOrderCapabilitiesParams, GetScalePriceLadderParams, GetOrderFillsParams, GetOrdersParams, GetOrFetchFillsParams, GetPositionsParams, GetSupportedPathsParams, GetUserDataSnapshotParams, HistoricalPortfolioResult, InitializeResult, PerpsPlatformDependencies, PerpsProvider, PerpsScalePriceLadder, LiquidationPriceParams, LiveDataConfig, MaintenanceMarginParams, PositionModifyPreviewParams, PositionModifyPreviewResult, MarginResult, MarketInfo, Order, OrderFill, OrderParams, OrderResult, PerpsMarketData, DirectProviderOrderCapabilities, Position, ReadyToTradeResult, SubscribeAccountParams, SubscribeCandlesParams, SubscribeOICapsParams, SubscribeOrderBookParams, SubscribeOrderFillsParams, SubscribeOrdersParams, SubscribeTwapOrdersParams, SubscribePositionsParams, SubscribePricesParams, ToggleTestnetResult, TransferBetweenDexsParams, TransferBetweenDexsResult, TwapOrder, UpdateMarginParams, UpdatePositionTPSLParams, UserHistoryItem, WithdrawParams, WithdrawResult, RawLedgerUpdate, PerpsReadOptions, PerpsUserDataSnapshot, PerpsFeeResolution } from "../types/index.mjs";
|
|
6
7
|
import type { PerpsControllerMessengerBase } from "../types/messenger.mjs";
|
|
7
8
|
type ChaseOrderMaxDistanceReachedHandler = (event: ChaseOrderMaxDistanceReached) => void;
|
|
@@ -20,6 +21,7 @@ type HyperLiquidProviderOptions = {
|
|
|
20
21
|
subscriptionBuilderAddressTestnet?: string;
|
|
21
22
|
subscriptionBuilderAddressMainnet?: string;
|
|
22
23
|
onChaseOrderMaxDistanceReached?: ChaseOrderMaxDistanceReachedHandler;
|
|
24
|
+
getAgentSigner?: (masterAccountAddress: string) => Promise<AgentSigner | null>;
|
|
23
25
|
};
|
|
24
26
|
/**
|
|
25
27
|
* HyperLiquid provider implementation
|
|
@@ -54,6 +56,18 @@ export declare class HyperLiquidProvider implements PerpsProvider {
|
|
|
54
56
|
* @throws When the ladder count or normalized range is invalid.
|
|
55
57
|
*/
|
|
56
58
|
getScalePriceLadder(params: GetScalePriceLadderParams): Promise<PerpsScalePriceLadder>;
|
|
59
|
+
/**
|
|
60
|
+
* Override (or clear) the trading wallet used for signing.
|
|
61
|
+
*
|
|
62
|
+
* Called when an agent wallet activates (pass the local agent signer) and
|
|
63
|
+
* when the keyring locks (pass null, restoring the master path). Reconnects
|
|
64
|
+
* the SDK clients so every subsequent action signs with the new wallet.
|
|
65
|
+
* Calls are serialized so concurrent events cannot interleave the
|
|
66
|
+
* disconnect/initialize pair.
|
|
67
|
+
*
|
|
68
|
+
* @param signer - The agent signer to sign with, or null to restore the master path.
|
|
69
|
+
*/
|
|
70
|
+
setTradingWalletOverride(signer: AgentSigner | null): Promise<void>;
|
|
57
71
|
/**
|
|
58
72
|
* Get fills using WebSocket cache first, falling back to REST API
|
|
59
73
|
* OPTIMIZATION: Uses cached fills when available (0 API weight), only calls REST on cache miss
|
|
@@ -544,6 +558,23 @@ export declare class HyperLiquidProvider implements PerpsProvider {
|
|
|
544
558
|
* @returns Discriminated preview; margin and liquidation are independently available.
|
|
545
559
|
*/
|
|
546
560
|
previewPositionModify(params: PositionModifyPreviewParams): Promise<PositionModifyPreviewResult>;
|
|
561
|
+
/**
|
|
562
|
+
* Drive the deferred trading-readiness steps ahead of the first order.
|
|
563
|
+
*
|
|
564
|
+
* Runs the exact sequence the order path uses (see `#ensureReadyForTrading`):
|
|
565
|
+
* unified account enablement with user signing allowed, builder fee approval,
|
|
566
|
+
* and referral setup. Calling this before the first order means hardware
|
|
567
|
+
* wallet users complete every master device prompt in one guided session
|
|
568
|
+
* (e.g. during agent wallet setup) instead of hitting a surprise prompt on
|
|
569
|
+
* their first trade.
|
|
570
|
+
*
|
|
571
|
+
* Safe to call repeatedly: readiness results are cached (globally and per
|
|
572
|
+
* session), so an already-approved wallet never sees a second prompt.
|
|
573
|
+
* Builder-fee failures are swallowed by the underlying sequence (trading
|
|
574
|
+
* retries at order time), but initialization and migration errors propagate
|
|
575
|
+
* to the caller.
|
|
576
|
+
*/
|
|
577
|
+
prepareTradingWallet(): Promise<void>;
|
|
547
578
|
/**
|
|
548
579
|
* Calculate liquidation price using HyperLiquid's formula
|
|
549
580
|
* Formula: liq_price = price - side * margin_available / position_size / (1 - maintenanceMarginRatio * side)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HyperLiquidProvider.d.mts","sourceRoot":"","sources":["../../src/providers/HyperLiquidProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA4B,wBAAwB;AAE1E,OAAO,KAAK,EACV,cAAc,EAGf,4BAA4B;AAK7B,OAAO,KAAK,EAAE,YAAY,EAAE,qCAAoC;AAwChE,OAAO,EAEL,wBAAwB,EACzB,iDAAgD;
|
|
1
|
+
{"version":3,"file":"HyperLiquidProvider.d.mts","sourceRoot":"","sources":["../../src/providers/HyperLiquidProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA4B,wBAAwB;AAE1E,OAAO,KAAK,EACV,cAAc,EAGf,4BAA4B;AAK7B,OAAO,KAAK,EAAE,YAAY,EAAE,qCAAoC;AAwChE,OAAO,EAEL,wBAAwB,EACzB,iDAAgD;AAIjD,OAAO,KAAK,EAAE,WAAW,EAAE,iDAAgD;AAmB3E,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,EACV,4BAA4B,EAE5B,UAAU,EACV,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,OAAO,EACP,qBAAqB,EACrB,sBAAsB,EACtB,gBAAgB,EAChB,4BAA4B,EAC5B,gBAAgB,EAChB,0BAA0B,EAC1B,yBAAyB,EACzB,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,EACzB,yBAAyB,EACzB,gBAAgB,EAChB,yBAAyB,EACzB,aAAa,EAEb,qBAAqB,EACrB,sBAAsB,EACtB,cAAc,EACd,uBAAuB,EACvB,2BAA2B,EAC3B,2BAA2B,EAC3B,YAAY,EACZ,UAAU,EACV,KAAK,EACL,SAAS,EACT,WAAW,EACX,WAAW,EAEX,eAAe,EACf,+BAA+B,EAE/B,QAAQ,EAER,kBAAkB,EAClB,sBAAsB,EACtB,sB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IAAI;IAIb;;;;;OAKG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAIhC;;;;;OAKG;IACG,gBAAgB,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAyBrE,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;IAYvB;;;;;OAKG;IACH,mBAAmB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM;CAmX9C"}
|
|
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _HyperLiquidProvider_instances, _a, _HyperLiquidProvider_deps, _HyperLiquidProvider_clientService, _HyperLiquidProvider_walletService, _HyperLiquidProvider_subscriptionService, _HyperLiquidProvider_symbolToAssetId, _HyperLiquidProvider_userFeeCache, _HyperLiquidProvider_maxLeverageCache, _HyperLiquidProvider_cachedMetaByDex, _HyperLiquidProvider_orderCapabilitiesMarketsByDex, _HyperLiquidProvider_orderCapabilitiesRefreshByDex, _HyperLiquidProvider_isDisconnected, _HyperLiquidProvider_disconnectOperationsInFlight, _HyperLiquidProvider_disconnectOperationPromise, _HyperLiquidProvider_lifecycleGeneration, _HyperLiquidProvider_cachedMarketDataWithPrices, _HyperLiquidProvider_cachedSpotMeta, _HyperLiquidProvider_dexDiscoveryCache, _HyperLiquidProvider_referralCheckCache, _HyperLiquidProvider_builderFeeCheckCache, _HyperLiquidProvider_ensureReadyPromise, _HyperLiquidProvider_pendingBuilderFeeApprovals, _HyperLiquidProvider_subscriptionBuilderApprovalEpoch, _HyperLiquidProvider_approvedBuilderAddresses, _HyperLiquidProvider_compiledAllowlistPatterns, _HyperLiquidProvider_compiledBlocklistPatterns, _HyperLiquidProvider_userFeeDiscountBips, _HyperLiquidProvider_userFeeResolution, _HyperLiquidProvider_hip3Enabled, _HyperLiquidProvider_allowlistMarkets, _HyperLiquidProvider_blocklistMarkets, _HyperLiquidProvider_useUnifiedAccount, _HyperLiquidProvider_dexDiscoveryComplete, _HyperLiquidProvider_unifiedAccountSetupNeedsRetry, _HyperLiquidProvider_pendingValidatedDexsPromise, _HyperLiquidProvider_cachedUsdcTokenId, _HyperLiquidProvider_errorMappings, _HyperLiquidProvider_scaleOrderGroups, _HyperLiquidProvider_cancelledScaleOrderGroups, _HyperLiquidProvider_trackedTwapOrdersByMessenger, _HyperLiquidProvider_trackedTwapOrders, _HyperLiquidProvider_chaseSessions, _HyperLiquidProvider_chaseTerminations, _HyperLiquidProvider_terminatedChaseHandles, _HyperLiquidProvider_chasePlacementsInFlight, _HyperLiquidProvider_chasePlacementWaiters, _HyperLiquidProvider_chaseTickQueue, _HyperLiquidProvider_strategyGeneration, _HyperLiquidProvider_chasePlacementBlockers, _HyperLiquidProvider_clientsInitialized, _HyperLiquidProvider_initializationPromise, _HyperLiquidProvider_messenger, _HyperLiquidProvider_builderAddressTestnet, _HyperLiquidProvider_builderAddressMainnet, _HyperLiquidProvider_subscriptionBuilderAddressTestnet, _HyperLiquidProvider_subscriptionBuilderAddressMainnet, _HyperLiquidProvider_priceDeviationLimit, _HyperLiquidProvider_onChaseOrderMaxDistanceReached, _HyperLiquidProvider_resolveOrderFeePolicy, _HyperLiquidProvider_getOrderCapabilityMarket, _HyperLiquidProvider_assertProviderLifecycleCurrent, _HyperLiquidProvider_assertCacheWriteLifecycleCurrent, _HyperLiquidProvider_isCacheWriteLifecycleCurrent, _HyperLiquidProvider_getFreshOrderCapabilityMarkets, _HyperLiquidProvider_compilePatternsSafely, _HyperLiquidProvider_ensureClientsInitialized, _HyperLiquidProvider_isWalletOnHyperliquid, _HyperLiquidProvider_isHyperliquidMultiSigAccount, _HyperLiquidProvider_ensureUnifiedAccountEnabled, _HyperLiquidProvider_ensureReady, _HyperLiquidProvider_tradingSetupPromise, _HyperLiquidProvider_tradingSetupComplete, _HyperLiquidProvider_builderFeeSetupPromises, _HyperLiquidProvider_ensureBuilderFeeSetup, _HyperLiquidProvider_ensureReadyForTrading, _HyperLiquidProvider_getOrFetchPrice, _HyperLiquidProvider_filterFills, _HyperLiquidProvider_getAllAvailableDexs, _HyperLiquidProvider_getValidatedDexs, _HyperLiquidProvider_fetchValidatedDexsInternal, _HyperLiquidProvider_getValidatedDexsStrict, _HyperLiquidProvider_getCachedMeta, _HyperLiquidProvider_fetchMeta, _HyperLiquidProvider_cacheDexMetadata, _HyperLiquidProvider_cacheDexMetadataFromRead, _HyperLiquidProvider_backfillAssetMapForDex, _HyperLiquidProvider_getAssetIdWithRepair, _HyperLiquidProvider_getCachedSpotMeta, _HyperLiquidProvider_getCachedPerpDexs, _HyperLiquidProvider_calculateHip3FeeMultiplier, _HyperLiquidProvider_getCacheKey, _HyperLiquidProvider_getApprovedBuilderKey, _HyperLiquidProvider_fetchMarketsForDex, _HyperLiquidProvider_getUsdcTokenId, _HyperLiquidProvider_isUsdcCollateralDex, _HyperLiquidProvider_buildAssetMapping, _HyperLiquidProvider_queryUserDataAcrossDexs, _HyperLiquidProvider_mapError, _HyperLiquidProvider_getErrorContext, _HyperLiquidProvider_isMappedAccountModeExchangeError, _HyperLiquidProvider_getTradingErrorContext, _HyperLiquidProvider_checkBuilderFeeApproval, _HyperLiquidProvider_ensureBuilderFeeApproval, _HyperLiquidProvider_checkBuilderFeeStatus, _HyperLiquidProvider_getBalanceForDex, _HyperLiquidProvider_findSourceDexWithBalance, _HyperLiquidProvider_autoTransferForHip3Order, _HyperLiquidProvider_autoTransferBackAfterClose, _HyperLiquidProvider_calculateHip3RequiredMargin, _HyperLiquidProvider_handleHip3PostOrderRebalance, _HyperLiquidProvider_handleHip3OrderRollback, _HyperLiquidProvider_validateOrderBeforePlacement, _HyperLiquidProvider_getAssetInfo, _HyperLiquidProvider_prepareAssetForTrading, _HyperLiquidProvider_handleHip3PreOrder, _HyperLiquidProvider_submitOrderWithRollback, _HyperLiquidProvider_handleOrderError, _HyperLiquidProvider_placeStrategyOrder, _HyperLiquidProvider_submitPreparedStrategy, _HyperLiquidProvider_prepareStrategyPlacement, _HyperLiquidProvider_getMinimumOrderSize, _HyperLiquidProvider_buildScaleLadder, _HyperLiquidProvider_placeTwapOrder, _HyperLiquidProvider_placeScaleOrder, _HyperLiquidProvider_startChaseSession, _HyperLiquidProvider_getChaseQuotePrice, _HyperLiquidProvider_restChaseOrder, _HyperLiquidProvider_scheduleChaseTick, _HyperLiquidProvider_pauseChaseTicksForPlacement, _HyperLiquidProvider_resumeChaseTicksAfterPlacement, _HyperLiquidProvider_recoverFailedChaseTick, _HyperLiquidProvider_runChaseTick, _HyperLiquidProvider_resolveOwnRestingSizes, _HyperLiquidProvider_readOrderRemainder, _HyperLiquidProvider_cancelChaseChild, _HyperLiquidProvider_retractOrphanedChaseOrder, _HyperLiquidProvider_stopChaseSession, _HyperLiquidProvider_rebalanceChaseSession, _HyperLiquidProvider_adaptTwapOrder, _HyperLiquidProvider_rebalanceTrackedTwapOrder, _HyperLiquidProvider_rebalanceTerminalHip3Twaps, _HyperLiquidProvider_cancelStrategyOrder, _HyperLiquidProvider_cancelTwapOrder, _HyperLiquidProvider_cancelScaleOrder, _HyperLiquidProvider_cancelChaseOrder, _HyperLiquidProvider_performChaseTermination, _HyperLiquidProvider_cancelOrderRequests, _HyperLiquidProvider_cancelOrderCloidRequests, _HyperLiquidProvider_cancelOrderRequestBatch, _HyperLiquidProvider_readOrderPlacementOutcome, _HyperLiquidProvider_readTpslOrderPlacementOutcome, _HyperLiquidProvider_reconcileTpslOrderPlacementOutcomes, _HyperLiquidProvider_readOrderIdFromStatus, _HyperLiquidProvider_getDiscountedBuilderFee, _HyperLiquidProvider_getBuilderOrderContext, _HyperLiquidProvider_fetchOpenOrders, _HyperLiquidProvider_resolveReplacementOrderId, _HyperLiquidProvider_getStandaloneValidatedDexs, _HyperLiquidProvider_getPositionsForOperation, _HyperLiquidProvider_queryAllDexPositionsStrict, _HyperLiquidProvider_queryDexPositions, _HyperLiquidProvider_restoreScaleOrderGroups, _HyperLiquidProvider_getAllMids, _HyperLiquidProvider_fetchSingleDexFresh, _HyperLiquidProvider_excludeNonUsdcCollateralResults, _HyperLiquidProvider_mergeDexResultsInto, _HyperLiquidProvider_cacheFreshMarketDataSnapshot, _HyperLiquidProvider_getStaleMarketDataSnapshot, _HyperLiquidProvider_rebalanceStreamedTerminalTwaps, _HyperLiquidProvider_isFeeCacheValid, _HyperLiquidProvider_performDisconnect, _HyperLiquidProvider_getBuilderAddress, _HyperLiquidProvider_getSubscriptionBuilderAddress, _HyperLiquidProvider_getReferralCode, _HyperLiquidProvider_ensureReferralSet, _HyperLiquidProvider_isReferralCodeReady, _HyperLiquidProvider_checkReferralSet, _HyperLiquidProvider_setReferralCode;
|
|
12
|
+
var _HyperLiquidProvider_instances, _a, _HyperLiquidProvider_deps, _HyperLiquidProvider_clientService, _HyperLiquidProvider_walletService, _HyperLiquidProvider_subscriptionService, _HyperLiquidProvider_symbolToAssetId, _HyperLiquidProvider_userFeeCache, _HyperLiquidProvider_maxLeverageCache, _HyperLiquidProvider_cachedMetaByDex, _HyperLiquidProvider_orderCapabilitiesMarketsByDex, _HyperLiquidProvider_orderCapabilitiesRefreshByDex, _HyperLiquidProvider_isDisconnected, _HyperLiquidProvider_disconnectOperationsInFlight, _HyperLiquidProvider_disconnectOperationPromise, _HyperLiquidProvider_lifecycleGeneration, _HyperLiquidProvider_cachedMarketDataWithPrices, _HyperLiquidProvider_cachedSpotMeta, _HyperLiquidProvider_dexDiscoveryCache, _HyperLiquidProvider_referralCheckCache, _HyperLiquidProvider_builderFeeCheckCache, _HyperLiquidProvider_ensureReadyPromise, _HyperLiquidProvider_pendingBuilderFeeApprovals, _HyperLiquidProvider_subscriptionBuilderApprovalEpoch, _HyperLiquidProvider_approvedBuilderAddresses, _HyperLiquidProvider_compiledAllowlistPatterns, _HyperLiquidProvider_compiledBlocklistPatterns, _HyperLiquidProvider_userFeeDiscountBips, _HyperLiquidProvider_userFeeResolution, _HyperLiquidProvider_hip3Enabled, _HyperLiquidProvider_allowlistMarkets, _HyperLiquidProvider_blocklistMarkets, _HyperLiquidProvider_useUnifiedAccount, _HyperLiquidProvider_dexDiscoveryComplete, _HyperLiquidProvider_unifiedAccountSetupNeedsRetry, _HyperLiquidProvider_pendingValidatedDexsPromise, _HyperLiquidProvider_cachedUsdcTokenId, _HyperLiquidProvider_errorMappings, _HyperLiquidProvider_scaleOrderGroups, _HyperLiquidProvider_cancelledScaleOrderGroups, _HyperLiquidProvider_trackedTwapOrdersByMessenger, _HyperLiquidProvider_trackedTwapOrders, _HyperLiquidProvider_chaseSessions, _HyperLiquidProvider_chaseTerminations, _HyperLiquidProvider_terminatedChaseHandles, _HyperLiquidProvider_chasePlacementsInFlight, _HyperLiquidProvider_chasePlacementWaiters, _HyperLiquidProvider_chaseTickQueue, _HyperLiquidProvider_strategyGeneration, _HyperLiquidProvider_chasePlacementBlockers, _HyperLiquidProvider_clientsInitialized, _HyperLiquidProvider_initializationPromise, _HyperLiquidProvider_agentSignerOverride, _HyperLiquidProvider_overridePromise, _HyperLiquidProvider_getAgentSigner, _HyperLiquidProvider_messenger, _HyperLiquidProvider_builderAddressTestnet, _HyperLiquidProvider_builderAddressMainnet, _HyperLiquidProvider_subscriptionBuilderAddressTestnet, _HyperLiquidProvider_subscriptionBuilderAddressMainnet, _HyperLiquidProvider_priceDeviationLimit, _HyperLiquidProvider_onChaseOrderMaxDistanceReached, _HyperLiquidProvider_resolveOrderFeePolicy, _HyperLiquidProvider_getOrderCapabilityMarket, _HyperLiquidProvider_assertProviderLifecycleCurrent, _HyperLiquidProvider_assertCacheWriteLifecycleCurrent, _HyperLiquidProvider_isCacheWriteLifecycleCurrent, _HyperLiquidProvider_getFreshOrderCapabilityMarkets, _HyperLiquidProvider_compilePatternsSafely, _HyperLiquidProvider_ensureClientsInitialized, _HyperLiquidProvider_registerConnectionCallbacks, _HyperLiquidProvider_buildWallet, _HyperLiquidProvider_applyTradingWalletOverride, _HyperLiquidProvider_isWalletOnHyperliquid, _HyperLiquidProvider_isHyperliquidMultiSigAccount, _HyperLiquidProvider_ensureUnifiedAccountEnabled, _HyperLiquidProvider_ensureReady, _HyperLiquidProvider_tradingSetupPromise, _HyperLiquidProvider_tradingSetupComplete, _HyperLiquidProvider_builderFeeSetupPromises, _HyperLiquidProvider_ensureBuilderFeeSetup, _HyperLiquidProvider_ensureReadyForTrading, _HyperLiquidProvider_getOrFetchPrice, _HyperLiquidProvider_filterFills, _HyperLiquidProvider_getAllAvailableDexs, _HyperLiquidProvider_getValidatedDexs, _HyperLiquidProvider_fetchValidatedDexsInternal, _HyperLiquidProvider_getValidatedDexsStrict, _HyperLiquidProvider_getCachedMeta, _HyperLiquidProvider_fetchMeta, _HyperLiquidProvider_cacheDexMetadata, _HyperLiquidProvider_cacheDexMetadataFromRead, _HyperLiquidProvider_backfillAssetMapForDex, _HyperLiquidProvider_getAssetIdWithRepair, _HyperLiquidProvider_getCachedSpotMeta, _HyperLiquidProvider_getCachedPerpDexs, _HyperLiquidProvider_calculateHip3FeeMultiplier, _HyperLiquidProvider_getCacheKey, _HyperLiquidProvider_getApprovedBuilderKey, _HyperLiquidProvider_fetchMarketsForDex, _HyperLiquidProvider_getUsdcTokenId, _HyperLiquidProvider_isUsdcCollateralDex, _HyperLiquidProvider_buildAssetMapping, _HyperLiquidProvider_queryUserDataAcrossDexs, _HyperLiquidProvider_mapError, _HyperLiquidProvider_getErrorContext, _HyperLiquidProvider_isMappedAccountModeExchangeError, _HyperLiquidProvider_getTradingErrorContext, _HyperLiquidProvider_checkBuilderFeeApproval, _HyperLiquidProvider_ensureBuilderFeeApproval, _HyperLiquidProvider_checkBuilderFeeStatus, _HyperLiquidProvider_getBalanceForDex, _HyperLiquidProvider_findSourceDexWithBalance, _HyperLiquidProvider_autoTransferForHip3Order, _HyperLiquidProvider_autoTransferBackAfterClose, _HyperLiquidProvider_calculateHip3RequiredMargin, _HyperLiquidProvider_handleHip3PostOrderRebalance, _HyperLiquidProvider_handleHip3OrderRollback, _HyperLiquidProvider_validateOrderBeforePlacement, _HyperLiquidProvider_getAssetInfo, _HyperLiquidProvider_prepareAssetForTrading, _HyperLiquidProvider_handleHip3PreOrder, _HyperLiquidProvider_submitOrderWithRollback, _HyperLiquidProvider_handleOrderError, _HyperLiquidProvider_placeStrategyOrder, _HyperLiquidProvider_submitPreparedStrategy, _HyperLiquidProvider_prepareStrategyPlacement, _HyperLiquidProvider_getMinimumOrderSize, _HyperLiquidProvider_buildScaleLadder, _HyperLiquidProvider_placeTwapOrder, _HyperLiquidProvider_placeScaleOrder, _HyperLiquidProvider_startChaseSession, _HyperLiquidProvider_getChaseQuotePrice, _HyperLiquidProvider_restChaseOrder, _HyperLiquidProvider_scheduleChaseTick, _HyperLiquidProvider_pauseChaseTicksForPlacement, _HyperLiquidProvider_resumeChaseTicksAfterPlacement, _HyperLiquidProvider_recoverFailedChaseTick, _HyperLiquidProvider_runChaseTick, _HyperLiquidProvider_resolveOwnRestingSizes, _HyperLiquidProvider_readOrderRemainder, _HyperLiquidProvider_cancelChaseChild, _HyperLiquidProvider_retractOrphanedChaseOrder, _HyperLiquidProvider_stopChaseSession, _HyperLiquidProvider_rebalanceChaseSession, _HyperLiquidProvider_adaptTwapOrder, _HyperLiquidProvider_rebalanceTrackedTwapOrder, _HyperLiquidProvider_rebalanceTerminalHip3Twaps, _HyperLiquidProvider_cancelStrategyOrder, _HyperLiquidProvider_cancelTwapOrder, _HyperLiquidProvider_cancelScaleOrder, _HyperLiquidProvider_cancelChaseOrder, _HyperLiquidProvider_performChaseTermination, _HyperLiquidProvider_cancelOrderRequests, _HyperLiquidProvider_cancelOrderCloidRequests, _HyperLiquidProvider_cancelOrderRequestBatch, _HyperLiquidProvider_readOrderPlacementOutcome, _HyperLiquidProvider_readTpslOrderPlacementOutcome, _HyperLiquidProvider_reconcileTpslOrderPlacementOutcomes, _HyperLiquidProvider_readOrderIdFromStatus, _HyperLiquidProvider_getDiscountedBuilderFee, _HyperLiquidProvider_getBuilderOrderContext, _HyperLiquidProvider_fetchOpenOrders, _HyperLiquidProvider_resolveReplacementOrderId, _HyperLiquidProvider_getStandaloneValidatedDexs, _HyperLiquidProvider_getPositionsForOperation, _HyperLiquidProvider_queryAllDexPositionsStrict, _HyperLiquidProvider_queryDexPositions, _HyperLiquidProvider_restoreScaleOrderGroups, _HyperLiquidProvider_getAllMids, _HyperLiquidProvider_fetchSingleDexFresh, _HyperLiquidProvider_excludeNonUsdcCollateralResults, _HyperLiquidProvider_mergeDexResultsInto, _HyperLiquidProvider_cacheFreshMarketDataSnapshot, _HyperLiquidProvider_getStaleMarketDataSnapshot, _HyperLiquidProvider_rebalanceStreamedTerminalTwaps, _HyperLiquidProvider_isFeeCacheValid, _HyperLiquidProvider_performDisconnect, _HyperLiquidProvider_getBuilderAddress, _HyperLiquidProvider_getSubscriptionBuilderAddress, _HyperLiquidProvider_getReferralCode, _HyperLiquidProvider_ensureReferralSet, _HyperLiquidProvider_isReferralCodeReady, _HyperLiquidProvider_checkReferralSet, _HyperLiquidProvider_setReferralCode;
|
|
13
13
|
import { hasProperty, isHexString } from "@metamask/utils";
|
|
14
14
|
import { HyperliquidError } from "@nktkas/hyperliquid";
|
|
15
15
|
import { BigNumber } from "bignumber.js";
|
|
@@ -705,6 +705,16 @@ export class HyperLiquidProvider {
|
|
|
705
705
|
_HyperLiquidProvider_clientsInitialized.set(this, false);
|
|
706
706
|
// Promise-based lock to prevent race conditions in concurrent initialization
|
|
707
707
|
_HyperLiquidProvider_initializationPromise.set(this, null);
|
|
708
|
+
// Active agent signer override; consulted by every wallet (re)build so the
|
|
709
|
+
// override survives lazy initializations and network toggles.
|
|
710
|
+
_HyperLiquidProvider_agentSignerOverride.set(this, void 0);
|
|
711
|
+
// Serializes setTradingWalletOverride calls so a lock event cannot interleave
|
|
712
|
+
// with an activation event mid disconnect/initialize.
|
|
713
|
+
_HyperLiquidProvider_overridePromise.set(this, Promise.resolve());
|
|
714
|
+
// Resolves an already-active agent on first client init when the host has
|
|
715
|
+
// not yet called setTradingWalletOverride. Explicit override clears skip
|
|
716
|
+
// this lookup so a lock event cannot pick the agent back up.
|
|
717
|
+
_HyperLiquidProvider_getAgentSigner.set(this, void 0);
|
|
708
718
|
_HyperLiquidProvider_messenger.set(this, void 0);
|
|
709
719
|
_HyperLiquidProvider_builderAddressTestnet.set(this, void 0);
|
|
710
720
|
_HyperLiquidProvider_builderAddressMainnet.set(this, void 0);
|
|
@@ -740,6 +750,7 @@ export class HyperLiquidProvider {
|
|
|
740
750
|
__classPrivateFieldSet(this, _HyperLiquidProvider_subscriptionBuilderAddressTestnet, options.subscriptionBuilderAddressTestnet, "f");
|
|
741
751
|
__classPrivateFieldSet(this, _HyperLiquidProvider_subscriptionBuilderAddressMainnet, options.subscriptionBuilderAddressMainnet, "f");
|
|
742
752
|
__classPrivateFieldSet(this, _HyperLiquidProvider_onChaseOrderMaxDistanceReached, options.onChaseOrderMaxDistanceReached, "f");
|
|
753
|
+
__classPrivateFieldSet(this, _HyperLiquidProvider_getAgentSigner, options.getAgentSigner, "f");
|
|
743
754
|
__classPrivateFieldSet(this, _HyperLiquidProvider_priceDeviationLimit, options.priceDeviationLimit ??
|
|
744
755
|
HYPERLIQUID_CONFIG.OraclePriceDeviationLimit, "f");
|
|
745
756
|
const isTestnet = options.isTestnet ?? false;
|
|
@@ -833,6 +844,22 @@ export class HyperLiquidProvider {
|
|
|
833
844
|
});
|
|
834
845
|
return { status: 'ready', providerId: this.protocolId, prices };
|
|
835
846
|
}
|
|
847
|
+
/**
|
|
848
|
+
* Override (or clear) the trading wallet used for signing.
|
|
849
|
+
*
|
|
850
|
+
* Called when an agent wallet activates (pass the local agent signer) and
|
|
851
|
+
* when the keyring locks (pass null, restoring the master path). Reconnects
|
|
852
|
+
* the SDK clients so every subsequent action signs with the new wallet.
|
|
853
|
+
* Calls are serialized so concurrent events cannot interleave the
|
|
854
|
+
* disconnect/initialize pair.
|
|
855
|
+
*
|
|
856
|
+
* @param signer - The agent signer to sign with, or null to restore the master path.
|
|
857
|
+
*/
|
|
858
|
+
async setTradingWalletOverride(signer) {
|
|
859
|
+
const run = __classPrivateFieldGet(this, _HyperLiquidProvider_overridePromise, "f").then(() => __classPrivateFieldGet(this, _HyperLiquidProvider_instances, "m", _HyperLiquidProvider_applyTradingWalletOverride).call(this, signer));
|
|
860
|
+
__classPrivateFieldSet(this, _HyperLiquidProvider_overridePromise, run.catch(() => undefined), "f");
|
|
861
|
+
await run;
|
|
862
|
+
}
|
|
836
863
|
/**
|
|
837
864
|
* Get fills using WebSocket cache first, falling back to REST API
|
|
838
865
|
* OPTIMIZATION: Uses cached fills when available (0 API weight), only calls REST on cache miss
|
|
@@ -5057,6 +5084,25 @@ export class HyperLiquidProvider {
|
|
|
5057
5084
|
marginTiers,
|
|
5058
5085
|
});
|
|
5059
5086
|
}
|
|
5087
|
+
/**
|
|
5088
|
+
* Drive the deferred trading-readiness steps ahead of the first order.
|
|
5089
|
+
*
|
|
5090
|
+
* Runs the exact sequence the order path uses (see `#ensureReadyForTrading`):
|
|
5091
|
+
* unified account enablement with user signing allowed, builder fee approval,
|
|
5092
|
+
* and referral setup. Calling this before the first order means hardware
|
|
5093
|
+
* wallet users complete every master device prompt in one guided session
|
|
5094
|
+
* (e.g. during agent wallet setup) instead of hitting a surprise prompt on
|
|
5095
|
+
* their first trade.
|
|
5096
|
+
*
|
|
5097
|
+
* Safe to call repeatedly: readiness results are cached (globally and per
|
|
5098
|
+
* session), so an already-approved wallet never sees a second prompt.
|
|
5099
|
+
* Builder-fee failures are swallowed by the underlying sequence (trading
|
|
5100
|
+
* retries at order time), but initialization and migration errors propagate
|
|
5101
|
+
* to the caller.
|
|
5102
|
+
*/
|
|
5103
|
+
async prepareTradingWallet() {
|
|
5104
|
+
await __classPrivateFieldGet(this, _HyperLiquidProvider_instances, "m", _HyperLiquidProvider_ensureReadyForTrading).call(this, { requiresBuilderFee: true });
|
|
5105
|
+
}
|
|
5060
5106
|
/**
|
|
5061
5107
|
* Calculate liquidation price using HyperLiquid's formula
|
|
5062
5108
|
* Formula: liq_price = price - side * margin_available / position_size / (1 - maintenanceMarginRatio * side)
|
|
@@ -5658,7 +5704,7 @@ export class HyperLiquidProvider {
|
|
|
5658
5704
|
return `${baseUrl}/explorer`;
|
|
5659
5705
|
}
|
|
5660
5706
|
}
|
|
5661
|
-
_a = HyperLiquidProvider, _HyperLiquidProvider_deps = new WeakMap(), _HyperLiquidProvider_clientService = new WeakMap(), _HyperLiquidProvider_walletService = new WeakMap(), _HyperLiquidProvider_subscriptionService = new WeakMap(), _HyperLiquidProvider_symbolToAssetId = new WeakMap(), _HyperLiquidProvider_userFeeCache = new WeakMap(), _HyperLiquidProvider_maxLeverageCache = new WeakMap(), _HyperLiquidProvider_cachedMetaByDex = new WeakMap(), _HyperLiquidProvider_orderCapabilitiesMarketsByDex = new WeakMap(), _HyperLiquidProvider_orderCapabilitiesRefreshByDex = new WeakMap(), _HyperLiquidProvider_isDisconnected = new WeakMap(), _HyperLiquidProvider_disconnectOperationsInFlight = new WeakMap(), _HyperLiquidProvider_disconnectOperationPromise = new WeakMap(), _HyperLiquidProvider_lifecycleGeneration = new WeakMap(), _HyperLiquidProvider_cachedMarketDataWithPrices = new WeakMap(), _HyperLiquidProvider_cachedSpotMeta = new WeakMap(), _HyperLiquidProvider_dexDiscoveryCache = new WeakMap(), _HyperLiquidProvider_referralCheckCache = new WeakMap(), _HyperLiquidProvider_builderFeeCheckCache = new WeakMap(), _HyperLiquidProvider_ensureReadyPromise = new WeakMap(), _HyperLiquidProvider_pendingBuilderFeeApprovals = new WeakMap(), _HyperLiquidProvider_subscriptionBuilderApprovalEpoch = new WeakMap(), _HyperLiquidProvider_approvedBuilderAddresses = new WeakMap(), _HyperLiquidProvider_compiledAllowlistPatterns = new WeakMap(), _HyperLiquidProvider_compiledBlocklistPatterns = new WeakMap(), _HyperLiquidProvider_userFeeDiscountBips = new WeakMap(), _HyperLiquidProvider_userFeeResolution = new WeakMap(), _HyperLiquidProvider_hip3Enabled = new WeakMap(), _HyperLiquidProvider_allowlistMarkets = new WeakMap(), _HyperLiquidProvider_blocklistMarkets = new WeakMap(), _HyperLiquidProvider_useUnifiedAccount = new WeakMap(), _HyperLiquidProvider_dexDiscoveryComplete = new WeakMap(), _HyperLiquidProvider_unifiedAccountSetupNeedsRetry = new WeakMap(), _HyperLiquidProvider_pendingValidatedDexsPromise = new WeakMap(), _HyperLiquidProvider_cachedUsdcTokenId = new WeakMap(), _HyperLiquidProvider_errorMappings = new WeakMap(), _HyperLiquidProvider_scaleOrderGroups = new WeakMap(), _HyperLiquidProvider_cancelledScaleOrderGroups = new WeakMap(), _HyperLiquidProvider_trackedTwapOrders = new WeakMap(), _HyperLiquidProvider_chaseSessions = new WeakMap(), _HyperLiquidProvider_chaseTerminations = new WeakMap(), _HyperLiquidProvider_terminatedChaseHandles = new WeakMap(), _HyperLiquidProvider_chasePlacementsInFlight = new WeakMap(), _HyperLiquidProvider_chasePlacementWaiters = new WeakMap(), _HyperLiquidProvider_chaseTickQueue = new WeakMap(), _HyperLiquidProvider_strategyGeneration = new WeakMap(), _HyperLiquidProvider_chasePlacementBlockers = new WeakMap(), _HyperLiquidProvider_clientsInitialized = new WeakMap(), _HyperLiquidProvider_initializationPromise = new WeakMap(), _HyperLiquidProvider_messenger = new WeakMap(), _HyperLiquidProvider_builderAddressTestnet = new WeakMap(), _HyperLiquidProvider_builderAddressMainnet = new WeakMap(), _HyperLiquidProvider_subscriptionBuilderAddressTestnet = new WeakMap(), _HyperLiquidProvider_subscriptionBuilderAddressMainnet = new WeakMap(), _HyperLiquidProvider_priceDeviationLimit = new WeakMap(), _HyperLiquidProvider_onChaseOrderMaxDistanceReached = new WeakMap(), _HyperLiquidProvider_tradingSetupPromise = new WeakMap(), _HyperLiquidProvider_tradingSetupComplete = new WeakMap(), _HyperLiquidProvider_builderFeeSetupPromises = new WeakMap(), _HyperLiquidProvider_instances = new WeakSet(), _HyperLiquidProvider_resolveOrderFeePolicy = function _HyperLiquidProvider_resolveOrderFeePolicy(params) {
|
|
5707
|
+
_a = HyperLiquidProvider, _HyperLiquidProvider_deps = new WeakMap(), _HyperLiquidProvider_clientService = new WeakMap(), _HyperLiquidProvider_walletService = new WeakMap(), _HyperLiquidProvider_subscriptionService = new WeakMap(), _HyperLiquidProvider_symbolToAssetId = new WeakMap(), _HyperLiquidProvider_userFeeCache = new WeakMap(), _HyperLiquidProvider_maxLeverageCache = new WeakMap(), _HyperLiquidProvider_cachedMetaByDex = new WeakMap(), _HyperLiquidProvider_orderCapabilitiesMarketsByDex = new WeakMap(), _HyperLiquidProvider_orderCapabilitiesRefreshByDex = new WeakMap(), _HyperLiquidProvider_isDisconnected = new WeakMap(), _HyperLiquidProvider_disconnectOperationsInFlight = new WeakMap(), _HyperLiquidProvider_disconnectOperationPromise = new WeakMap(), _HyperLiquidProvider_lifecycleGeneration = new WeakMap(), _HyperLiquidProvider_cachedMarketDataWithPrices = new WeakMap(), _HyperLiquidProvider_cachedSpotMeta = new WeakMap(), _HyperLiquidProvider_dexDiscoveryCache = new WeakMap(), _HyperLiquidProvider_referralCheckCache = new WeakMap(), _HyperLiquidProvider_builderFeeCheckCache = new WeakMap(), _HyperLiquidProvider_ensureReadyPromise = new WeakMap(), _HyperLiquidProvider_pendingBuilderFeeApprovals = new WeakMap(), _HyperLiquidProvider_subscriptionBuilderApprovalEpoch = new WeakMap(), _HyperLiquidProvider_approvedBuilderAddresses = new WeakMap(), _HyperLiquidProvider_compiledAllowlistPatterns = new WeakMap(), _HyperLiquidProvider_compiledBlocklistPatterns = new WeakMap(), _HyperLiquidProvider_userFeeDiscountBips = new WeakMap(), _HyperLiquidProvider_userFeeResolution = new WeakMap(), _HyperLiquidProvider_hip3Enabled = new WeakMap(), _HyperLiquidProvider_allowlistMarkets = new WeakMap(), _HyperLiquidProvider_blocklistMarkets = new WeakMap(), _HyperLiquidProvider_useUnifiedAccount = new WeakMap(), _HyperLiquidProvider_dexDiscoveryComplete = new WeakMap(), _HyperLiquidProvider_unifiedAccountSetupNeedsRetry = new WeakMap(), _HyperLiquidProvider_pendingValidatedDexsPromise = new WeakMap(), _HyperLiquidProvider_cachedUsdcTokenId = new WeakMap(), _HyperLiquidProvider_errorMappings = new WeakMap(), _HyperLiquidProvider_scaleOrderGroups = new WeakMap(), _HyperLiquidProvider_cancelledScaleOrderGroups = new WeakMap(), _HyperLiquidProvider_trackedTwapOrders = new WeakMap(), _HyperLiquidProvider_chaseSessions = new WeakMap(), _HyperLiquidProvider_chaseTerminations = new WeakMap(), _HyperLiquidProvider_terminatedChaseHandles = new WeakMap(), _HyperLiquidProvider_chasePlacementsInFlight = new WeakMap(), _HyperLiquidProvider_chasePlacementWaiters = new WeakMap(), _HyperLiquidProvider_chaseTickQueue = new WeakMap(), _HyperLiquidProvider_strategyGeneration = new WeakMap(), _HyperLiquidProvider_chasePlacementBlockers = new WeakMap(), _HyperLiquidProvider_clientsInitialized = new WeakMap(), _HyperLiquidProvider_initializationPromise = new WeakMap(), _HyperLiquidProvider_agentSignerOverride = new WeakMap(), _HyperLiquidProvider_overridePromise = new WeakMap(), _HyperLiquidProvider_getAgentSigner = new WeakMap(), _HyperLiquidProvider_messenger = new WeakMap(), _HyperLiquidProvider_builderAddressTestnet = new WeakMap(), _HyperLiquidProvider_builderAddressMainnet = new WeakMap(), _HyperLiquidProvider_subscriptionBuilderAddressTestnet = new WeakMap(), _HyperLiquidProvider_subscriptionBuilderAddressMainnet = new WeakMap(), _HyperLiquidProvider_priceDeviationLimit = new WeakMap(), _HyperLiquidProvider_onChaseOrderMaxDistanceReached = new WeakMap(), _HyperLiquidProvider_tradingSetupPromise = new WeakMap(), _HyperLiquidProvider_tradingSetupComplete = new WeakMap(), _HyperLiquidProvider_builderFeeSetupPromises = new WeakMap(), _HyperLiquidProvider_instances = new WeakSet(), _HyperLiquidProvider_resolveOrderFeePolicy = function _HyperLiquidProvider_resolveOrderFeePolicy(params) {
|
|
5662
5708
|
const fallbackPolicy = Object.prototype.hasOwnProperty.call(HYPERLIQUID_ORDER_FEE_CONFIG, params.orderType)
|
|
5663
5709
|
? HYPERLIQUID_ORDER_FEE_CONFIG[params.orderType]
|
|
5664
5710
|
: undefined;
|
|
@@ -5819,30 +5865,12 @@ async function _HyperLiquidProvider_ensureClientsInitialized() {
|
|
|
5819
5865
|
if (__classPrivateFieldGet(this, _HyperLiquidProvider_disconnectOperationsInFlight, "f") > 0) {
|
|
5820
5866
|
throw new Error(PERPS_ERROR_CODES.PROVIDER_LIFECYCLE_STALE);
|
|
5821
5867
|
}
|
|
5822
|
-
const wallet = __classPrivateFieldGet(this,
|
|
5868
|
+
const wallet = await __classPrivateFieldGet(this, _HyperLiquidProvider_instances, "m", _HyperLiquidProvider_buildWallet).call(this);
|
|
5823
5869
|
await __classPrivateFieldGet(this, _HyperLiquidProvider_clientService, "f").initialize(wallet);
|
|
5824
5870
|
if (__classPrivateFieldGet(this, _HyperLiquidProvider_disconnectOperationsInFlight, "f") > 0) {
|
|
5825
5871
|
throw new Error(PERPS_ERROR_CODES.PROVIDER_LIFECYCLE_STALE);
|
|
5826
5872
|
}
|
|
5827
|
-
|
|
5828
|
-
// Note: Do NOT restore subscriptions here - termination means connection failed permanently
|
|
5829
|
-
__classPrivateFieldGet(this, _HyperLiquidProvider_clientService, "f").setOnTerminateCallback((error) => {
|
|
5830
|
-
__classPrivateFieldGet(this, _HyperLiquidProvider_deps, "f").debugLogger.log('[HyperLiquidProvider] WebSocket terminated', {
|
|
5831
|
-
error: error.message,
|
|
5832
|
-
});
|
|
5833
|
-
});
|
|
5834
|
-
// Set reconnection callback to restore subscriptions after successful reconnection
|
|
5835
|
-
// This is called in handleConnectionDrop() after the WebSocket reconnects successfully
|
|
5836
|
-
__classPrivateFieldGet(this, _HyperLiquidProvider_clientService, "f").setOnReconnectCallback(async () => {
|
|
5837
|
-
try {
|
|
5838
|
-
__classPrivateFieldGet(this, _HyperLiquidProvider_deps, "f").debugLogger.log('[HyperLiquidProvider] WebSocket reconnected, restoring subscriptions');
|
|
5839
|
-
await __classPrivateFieldGet(this, _HyperLiquidProvider_subscriptionService, "f").restoreSubscriptions();
|
|
5840
|
-
__classPrivateFieldGet(this, _HyperLiquidProvider_deps, "f").streamManager.clearAllChannels();
|
|
5841
|
-
}
|
|
5842
|
-
catch (restoreError) {
|
|
5843
|
-
__classPrivateFieldGet(this, _HyperLiquidProvider_deps, "f").debugLogger.log('[HyperLiquidProvider] Failed to restore subscriptions', restoreError);
|
|
5844
|
-
}
|
|
5845
|
-
});
|
|
5873
|
+
__classPrivateFieldGet(this, _HyperLiquidProvider_instances, "m", _HyperLiquidProvider_registerConnectionCallbacks).call(this);
|
|
5846
5874
|
// Only set flag AFTER successful initialization
|
|
5847
5875
|
__classPrivateFieldSet(this, _HyperLiquidProvider_clientsInitialized, true, "f");
|
|
5848
5876
|
__classPrivateFieldGet(this, _HyperLiquidProvider_deps, "f").debugLogger.log('[HyperLiquidProvider] Clients initialized lazily');
|
|
@@ -5855,6 +5883,74 @@ async function _HyperLiquidProvider_ensureClientsInitialized() {
|
|
|
5855
5883
|
// so future calls can retry if needed
|
|
5856
5884
|
__classPrivateFieldSet(this, _HyperLiquidProvider_initializationPromise, null, "f");
|
|
5857
5885
|
}
|
|
5886
|
+
}, _HyperLiquidProvider_registerConnectionCallbacks = function _HyperLiquidProvider_registerConnectionCallbacks() {
|
|
5887
|
+
// Set termination callback for logging when WebSocket terminates
|
|
5888
|
+
// Note: Do NOT restore subscriptions here - termination means connection failed permanently
|
|
5889
|
+
__classPrivateFieldGet(this, _HyperLiquidProvider_clientService, "f").setOnTerminateCallback((error) => {
|
|
5890
|
+
__classPrivateFieldGet(this, _HyperLiquidProvider_deps, "f").debugLogger.log('[HyperLiquidProvider] WebSocket terminated', {
|
|
5891
|
+
error: error.message,
|
|
5892
|
+
});
|
|
5893
|
+
});
|
|
5894
|
+
// Set reconnection callback to restore subscriptions after successful reconnection
|
|
5895
|
+
// This is called in handleConnectionDrop() after the WebSocket reconnects successfully
|
|
5896
|
+
__classPrivateFieldGet(this, _HyperLiquidProvider_clientService, "f").setOnReconnectCallback(async () => {
|
|
5897
|
+
try {
|
|
5898
|
+
__classPrivateFieldGet(this, _HyperLiquidProvider_deps, "f").debugLogger.log('[HyperLiquidProvider] WebSocket reconnected, restoring subscriptions');
|
|
5899
|
+
await __classPrivateFieldGet(this, _HyperLiquidProvider_subscriptionService, "f").restoreSubscriptions();
|
|
5900
|
+
__classPrivateFieldGet(this, _HyperLiquidProvider_deps, "f").streamManager.clearAllChannels();
|
|
5901
|
+
}
|
|
5902
|
+
catch (restoreError) {
|
|
5903
|
+
__classPrivateFieldGet(this, _HyperLiquidProvider_deps, "f").debugLogger.log('[HyperLiquidProvider] Failed to restore subscriptions', restoreError);
|
|
5904
|
+
}
|
|
5905
|
+
});
|
|
5906
|
+
}, _HyperLiquidProvider_buildWallet =
|
|
5907
|
+
/**
|
|
5908
|
+
* Build the wallet the SDK clients should sign with.
|
|
5909
|
+
*
|
|
5910
|
+
* An explicit `signer` (including `null` to restore the master path) wins.
|
|
5911
|
+
* Otherwise the stored override is used. On lazy init with neither, an
|
|
5912
|
+
* already-active agent is resolved via `getAgentSigner` so the first
|
|
5913
|
+
* initialize does not wait for `setTradingWalletOverride`.
|
|
5914
|
+
*
|
|
5915
|
+
* @param signer - Optional explicit signer; defaults to the stored override.
|
|
5916
|
+
* @returns The wallet adapter for the client service.
|
|
5917
|
+
*/
|
|
5918
|
+
async function _HyperLiquidProvider_buildWallet(signer) {
|
|
5919
|
+
const effectiveSigner = signer === undefined ? __classPrivateFieldGet(this, _HyperLiquidProvider_agentSignerOverride, "f") : signer;
|
|
5920
|
+
if (effectiveSigner) {
|
|
5921
|
+
return __classPrivateFieldGet(this, _HyperLiquidProvider_walletService, "f").createAgentWalletAdapter(effectiveSigner);
|
|
5922
|
+
}
|
|
5923
|
+
// Explicit clear (`null`) must restore the master path and not re-query
|
|
5924
|
+
// getAgentSigner; a lock event can race the in-memory key still being set.
|
|
5925
|
+
if (signer === undefined && __classPrivateFieldGet(this, _HyperLiquidProvider_getAgentSigner, "f")) {
|
|
5926
|
+
const masterWallet = __classPrivateFieldGet(this, _HyperLiquidProvider_walletService, "f").createWalletAdapter();
|
|
5927
|
+
// The master adapter always carries the selected account address; if
|
|
5928
|
+
// it is somehow absent, fall through to the master path.
|
|
5929
|
+
if (masterWallet.address) {
|
|
5930
|
+
const agentSigner = await __classPrivateFieldGet(this, _HyperLiquidProvider_getAgentSigner, "f").call(this, masterWallet.address);
|
|
5931
|
+
if (agentSigner) {
|
|
5932
|
+
return __classPrivateFieldGet(this, _HyperLiquidProvider_walletService, "f").createAgentWalletAdapter(agentSigner);
|
|
5933
|
+
}
|
|
5934
|
+
}
|
|
5935
|
+
return masterWallet;
|
|
5936
|
+
}
|
|
5937
|
+
return __classPrivateFieldGet(this, _HyperLiquidProvider_walletService, "f").createWalletAdapter();
|
|
5938
|
+
}, _HyperLiquidProvider_applyTradingWalletOverride =
|
|
5939
|
+
/**
|
|
5940
|
+
* Apply a trading wallet override: store it, disconnect, and re-initialize
|
|
5941
|
+
* the client service with an adapter built from it.
|
|
5942
|
+
*
|
|
5943
|
+
* @param signer - The agent signer to sign with, or null for the master path.
|
|
5944
|
+
*/
|
|
5945
|
+
async function _HyperLiquidProvider_applyTradingWalletOverride(signer) {
|
|
5946
|
+
__classPrivateFieldSet(this, _HyperLiquidProvider_agentSignerOverride, signer ?? undefined, "f");
|
|
5947
|
+
await __classPrivateFieldGet(this, _HyperLiquidProvider_clientService, "f").disconnect();
|
|
5948
|
+
const wallet = await __classPrivateFieldGet(this, _HyperLiquidProvider_instances, "m", _HyperLiquidProvider_buildWallet).call(this, signer);
|
|
5949
|
+
await __classPrivateFieldGet(this, _HyperLiquidProvider_clientService, "f").initialize(wallet);
|
|
5950
|
+
__classPrivateFieldGet(this, _HyperLiquidProvider_instances, "m", _HyperLiquidProvider_registerConnectionCallbacks).call(this);
|
|
5951
|
+
// Mark initialized so the lazy path does not rebuild (and discard) the
|
|
5952
|
+
// override wallet on the next action.
|
|
5953
|
+
__classPrivateFieldSet(this, _HyperLiquidProvider_clientsInitialized, true, "f");
|
|
5858
5954
|
}, _HyperLiquidProvider_isWalletOnHyperliquid =
|
|
5859
5955
|
/**
|
|
5860
5956
|
* Decide whether the wallet has a Hyperliquid account.
|