@metamask-previews/perps-controller 15.1.0-preview-00a181c → 15.1.0-preview-cfd35b8dd
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 +0 -14
- package/dist/PerpsController-method-action-types.cjs.map +1 -1
- package/dist/PerpsController-method-action-types.d.cts +1 -20
- package/dist/PerpsController-method-action-types.d.cts.map +1 -1
- package/dist/PerpsController-method-action-types.d.mts +1 -20
- 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 +154 -65
- package/dist/PerpsController.cjs.map +1 -1
- package/dist/PerpsController.d.cts +43 -37
- package/dist/PerpsController.d.cts.map +1 -1
- package/dist/PerpsController.d.mts +43 -37
- package/dist/PerpsController.d.mts.map +1 -1
- package/dist/PerpsController.mjs +151 -64
- 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 +1 -0
- package/dist/constants/index.cjs.map +1 -1
- package/dist/constants/index.d.cts +1 -0
- package/dist/constants/index.d.cts.map +1 -1
- package/dist/constants/index.d.mts +1 -0
- package/dist/constants/index.d.mts.map +1 -1
- package/dist/constants/index.mjs +1 -0
- package/dist/constants/index.mjs.map +1 -1
- package/dist/constants/myxConfig.cjs +253 -0
- package/dist/constants/myxConfig.cjs.map +1 -0
- package/dist/constants/myxConfig.d.cts +145 -0
- package/dist/constants/myxConfig.d.cts.map +1 -0
- package/dist/constants/myxConfig.d.mts +145 -0
- package/dist/constants/myxConfig.d.mts.map +1 -0
- package/dist/constants/myxConfig.mjs +243 -0
- package/dist/constants/myxConfig.mjs.map +1 -0
- package/dist/constants/perpsConfig.cjs +9 -4
- package/dist/constants/perpsConfig.cjs.map +1 -1
- package/dist/constants/perpsConfig.d.cts +5 -3
- package/dist/constants/perpsConfig.d.cts.map +1 -1
- package/dist/constants/perpsConfig.d.mts +5 -3
- package/dist/constants/perpsConfig.d.mts.map +1 -1
- package/dist/constants/perpsConfig.mjs +9 -4
- package/dist/constants/perpsConfig.mjs.map +1 -1
- package/dist/index.cjs +175 -146
- 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 +1 -0
- package/dist/index.mjs.map +1 -1
- package/dist/providers/AggregatedPerpsProvider.cjs +2 -8
- package/dist/providers/AggregatedPerpsProvider.cjs.map +1 -1
- package/dist/providers/AggregatedPerpsProvider.d.cts +2 -3
- package/dist/providers/AggregatedPerpsProvider.d.cts.map +1 -1
- package/dist/providers/AggregatedPerpsProvider.d.mts +2 -3
- package/dist/providers/AggregatedPerpsProvider.d.mts.map +1 -1
- package/dist/providers/AggregatedPerpsProvider.mjs +2 -8
- package/dist/providers/AggregatedPerpsProvider.mjs.map +1 -1
- package/dist/providers/HyperLiquidProvider.cjs +22 -118
- package/dist/providers/HyperLiquidProvider.cjs.map +1 -1
- package/dist/providers/HyperLiquidProvider.d.cts +0 -31
- package/dist/providers/HyperLiquidProvider.d.cts.map +1 -1
- package/dist/providers/HyperLiquidProvider.d.mts +0 -31
- package/dist/providers/HyperLiquidProvider.d.mts.map +1 -1
- package/dist/providers/HyperLiquidProvider.mjs +22 -118
- 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 +16 -26
- package/dist/services/HyperLiquidClientService.d.cts.map +1 -1
- package/dist/services/HyperLiquidClientService.d.mts +16 -26
- package/dist/services/HyperLiquidClientService.d.mts.map +1 -1
- package/dist/services/HyperLiquidClientService.mjs.map +1 -1
- package/dist/services/HyperLiquidWalletService.cjs +30 -80
- package/dist/services/HyperLiquidWalletService.cjs.map +1 -1
- package/dist/services/HyperLiquidWalletService.d.cts +22 -48
- package/dist/services/HyperLiquidWalletService.d.cts.map +1 -1
- package/dist/services/HyperLiquidWalletService.d.mts +22 -48
- package/dist/services/HyperLiquidWalletService.d.mts.map +1 -1
- package/dist/services/HyperLiquidWalletService.mjs +30 -80
- 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 +16 -10
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.mts +16 -10
- package/dist/types/index.d.mts.map +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/dist/types/myx-types.cjs +41 -0
- package/dist/types/myx-types.cjs.map +1 -0
- package/dist/types/myx-types.d.cts +94 -0
- package/dist/types/myx-types.d.cts.map +1 -0
- package/dist/types/myx-types.d.mts +94 -0
- package/dist/types/myx-types.d.mts.map +1 -0
- package/dist/types/myx-types.mjs +26 -0
- package/dist/types/myx-types.mjs.map +1 -0
- package/dist/utils/lighterAdapter.cjs +2 -1
- package/dist/utils/lighterAdapter.cjs.map +1 -1
- package/dist/utils/lighterAdapter.d.cts +2 -1
- package/dist/utils/lighterAdapter.d.cts.map +1 -1
- package/dist/utils/lighterAdapter.d.mts +2 -1
- package/dist/utils/lighterAdapter.d.mts.map +1 -1
- package/dist/utils/lighterAdapter.mjs +2 -1
- package/dist/utils/lighterAdapter.mjs.map +1 -1
- package/dist/utils/myxAdapter.cjs +569 -0
- package/dist/utils/myxAdapter.cjs.map +1 -0
- package/dist/utils/myxAdapter.d.cts +168 -0
- package/dist/utils/myxAdapter.d.cts.map +1 -0
- package/dist/utils/myxAdapter.d.mts +168 -0
- package/dist/utils/myxAdapter.d.mts.map +1 -0
- package/dist/utils/myxAdapter.mjs +548 -0
- package/dist/utils/myxAdapter.mjs.map +1 -0
- package/package.json +8 -2
|
@@ -2,7 +2,6 @@ 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";
|
|
6
5
|
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";
|
|
7
6
|
import type { PerpsControllerMessengerBase } from "../types/messenger.cjs";
|
|
8
7
|
type ChaseOrderMaxDistanceReachedHandler = (event: ChaseOrderMaxDistanceReached) => void;
|
|
@@ -21,7 +20,6 @@ type HyperLiquidProviderOptions = {
|
|
|
21
20
|
subscriptionBuilderAddressTestnet?: string;
|
|
22
21
|
subscriptionBuilderAddressMainnet?: string;
|
|
23
22
|
onChaseOrderMaxDistanceReached?: ChaseOrderMaxDistanceReachedHandler;
|
|
24
|
-
getAgentSigner?: (masterAccountAddress: string) => Promise<AgentSigner | null>;
|
|
25
23
|
};
|
|
26
24
|
/**
|
|
27
25
|
* HyperLiquid provider implementation
|
|
@@ -56,18 +54,6 @@ export declare class HyperLiquidProvider implements PerpsProvider {
|
|
|
56
54
|
* @throws When the ladder count or normalized range is invalid.
|
|
57
55
|
*/
|
|
58
56
|
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>;
|
|
71
57
|
/**
|
|
72
58
|
* Get fills using WebSocket cache first, falling back to REST API
|
|
73
59
|
* OPTIMIZATION: Uses cached fills when available (0 API weight), only calls REST on cache miss
|
|
@@ -558,23 +544,6 @@ export declare class HyperLiquidProvider implements PerpsProvider {
|
|
|
558
544
|
* @returns Discriminated preview; margin and liquidation are independently available.
|
|
559
545
|
*/
|
|
560
546
|
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>;
|
|
578
547
|
/**
|
|
579
548
|
* Calculate liquidation price using HyperLiquid's formula
|
|
580
549
|
* 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;AAqBjD,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,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AK,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,7 +2,6 @@ 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";
|
|
6
5
|
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";
|
|
7
6
|
import type { PerpsControllerMessengerBase } from "../types/messenger.mjs";
|
|
8
7
|
type ChaseOrderMaxDistanceReachedHandler = (event: ChaseOrderMaxDistanceReached) => void;
|
|
@@ -21,7 +20,6 @@ type HyperLiquidProviderOptions = {
|
|
|
21
20
|
subscriptionBuilderAddressTestnet?: string;
|
|
22
21
|
subscriptionBuilderAddressMainnet?: string;
|
|
23
22
|
onChaseOrderMaxDistanceReached?: ChaseOrderMaxDistanceReachedHandler;
|
|
24
|
-
getAgentSigner?: (masterAccountAddress: string) => Promise<AgentSigner | null>;
|
|
25
23
|
};
|
|
26
24
|
/**
|
|
27
25
|
* HyperLiquid provider implementation
|
|
@@ -56,18 +54,6 @@ export declare class HyperLiquidProvider implements PerpsProvider {
|
|
|
56
54
|
* @throws When the ladder count or normalized range is invalid.
|
|
57
55
|
*/
|
|
58
56
|
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>;
|
|
71
57
|
/**
|
|
72
58
|
* Get fills using WebSocket cache first, falling back to REST API
|
|
73
59
|
* OPTIMIZATION: Uses cached fills when available (0 API weight), only calls REST on cache miss
|
|
@@ -558,23 +544,6 @@ export declare class HyperLiquidProvider implements PerpsProvider {
|
|
|
558
544
|
* @returns Discriminated preview; margin and liquidation are independently available.
|
|
559
545
|
*/
|
|
560
546
|
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>;
|
|
578
547
|
/**
|
|
579
548
|
* Calculate liquidation price using HyperLiquid's formula
|
|
580
549
|
* 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,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AAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA0EpD;;;;;;;;;OASG;IACG,aAAa,CACjB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,oBAAoB,CAAC;IA0YhC;;;;OAIG;IACI,aAAa,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI;IAUhD;;;;;;;;OAQG;IACU,iBAAiB,IAAI,OAAO,CAAC,cAAc,CAAC;IAIzD;;;;OAIG;IACG,UAAU,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAqJ7C;;;;;;OAMG;IACG,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoD7C;;;;;OAKG;IACH,2BAA2B,IAAI,wBAAwB;IAIvD;;;;;;OAMG;IACH,0BAA0B,CACxB,QAAQ,EAAE,CACR,KAAK,EAAE,wBAAwB,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"}
|
|
@@ -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,
|
|
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;
|
|
13
13
|
import { hasProperty, isHexString } from "@metamask/utils";
|
|
14
14
|
import { HyperliquidError } from "@nktkas/hyperliquid";
|
|
15
15
|
import { BigNumber } from "bignumber.js";
|
|
@@ -705,16 +705,6 @@ 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);
|
|
718
708
|
_HyperLiquidProvider_messenger.set(this, void 0);
|
|
719
709
|
_HyperLiquidProvider_builderAddressTestnet.set(this, void 0);
|
|
720
710
|
_HyperLiquidProvider_builderAddressMainnet.set(this, void 0);
|
|
@@ -750,7 +740,6 @@ export class HyperLiquidProvider {
|
|
|
750
740
|
__classPrivateFieldSet(this, _HyperLiquidProvider_subscriptionBuilderAddressTestnet, options.subscriptionBuilderAddressTestnet, "f");
|
|
751
741
|
__classPrivateFieldSet(this, _HyperLiquidProvider_subscriptionBuilderAddressMainnet, options.subscriptionBuilderAddressMainnet, "f");
|
|
752
742
|
__classPrivateFieldSet(this, _HyperLiquidProvider_onChaseOrderMaxDistanceReached, options.onChaseOrderMaxDistanceReached, "f");
|
|
753
|
-
__classPrivateFieldSet(this, _HyperLiquidProvider_getAgentSigner, options.getAgentSigner, "f");
|
|
754
743
|
__classPrivateFieldSet(this, _HyperLiquidProvider_priceDeviationLimit, options.priceDeviationLimit ??
|
|
755
744
|
HYPERLIQUID_CONFIG.OraclePriceDeviationLimit, "f");
|
|
756
745
|
const isTestnet = options.isTestnet ?? false;
|
|
@@ -844,22 +833,6 @@ export class HyperLiquidProvider {
|
|
|
844
833
|
});
|
|
845
834
|
return { status: 'ready', providerId: this.protocolId, prices };
|
|
846
835
|
}
|
|
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
|
-
}
|
|
863
836
|
/**
|
|
864
837
|
* Get fills using WebSocket cache first, falling back to REST API
|
|
865
838
|
* OPTIMIZATION: Uses cached fills when available (0 API weight), only calls REST on cache miss
|
|
@@ -5084,25 +5057,6 @@ export class HyperLiquidProvider {
|
|
|
5084
5057
|
marginTiers,
|
|
5085
5058
|
});
|
|
5086
5059
|
}
|
|
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
|
-
}
|
|
5106
5060
|
/**
|
|
5107
5061
|
* Calculate liquidation price using HyperLiquid's formula
|
|
5108
5062
|
* Formula: liq_price = price - side * margin_available / position_size / (1 - maintenanceMarginRatio * side)
|
|
@@ -5704,7 +5658,7 @@ export class HyperLiquidProvider {
|
|
|
5704
5658
|
return `${baseUrl}/explorer`;
|
|
5705
5659
|
}
|
|
5706
5660
|
}
|
|
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(),
|
|
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) {
|
|
5708
5662
|
const fallbackPolicy = Object.prototype.hasOwnProperty.call(HYPERLIQUID_ORDER_FEE_CONFIG, params.orderType)
|
|
5709
5663
|
? HYPERLIQUID_ORDER_FEE_CONFIG[params.orderType]
|
|
5710
5664
|
: undefined;
|
|
@@ -5865,12 +5819,30 @@ async function _HyperLiquidProvider_ensureClientsInitialized() {
|
|
|
5865
5819
|
if (__classPrivateFieldGet(this, _HyperLiquidProvider_disconnectOperationsInFlight, "f") > 0) {
|
|
5866
5820
|
throw new Error(PERPS_ERROR_CODES.PROVIDER_LIFECYCLE_STALE);
|
|
5867
5821
|
}
|
|
5868
|
-
const wallet =
|
|
5822
|
+
const wallet = __classPrivateFieldGet(this, _HyperLiquidProvider_walletService, "f").createWalletAdapter();
|
|
5869
5823
|
await __classPrivateFieldGet(this, _HyperLiquidProvider_clientService, "f").initialize(wallet);
|
|
5870
5824
|
if (__classPrivateFieldGet(this, _HyperLiquidProvider_disconnectOperationsInFlight, "f") > 0) {
|
|
5871
5825
|
throw new Error(PERPS_ERROR_CODES.PROVIDER_LIFECYCLE_STALE);
|
|
5872
5826
|
}
|
|
5873
|
-
|
|
5827
|
+
// Set termination callback for logging when WebSocket terminates
|
|
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
|
+
});
|
|
5874
5846
|
// Only set flag AFTER successful initialization
|
|
5875
5847
|
__classPrivateFieldSet(this, _HyperLiquidProvider_clientsInitialized, true, "f");
|
|
5876
5848
|
__classPrivateFieldGet(this, _HyperLiquidProvider_deps, "f").debugLogger.log('[HyperLiquidProvider] Clients initialized lazily');
|
|
@@ -5883,74 +5855,6 @@ async function _HyperLiquidProvider_ensureClientsInitialized() {
|
|
|
5883
5855
|
// so future calls can retry if needed
|
|
5884
5856
|
__classPrivateFieldSet(this, _HyperLiquidProvider_initializationPromise, null, "f");
|
|
5885
5857
|
}
|
|
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");
|
|
5954
5858
|
}, _HyperLiquidProvider_isWalletOnHyperliquid =
|
|
5955
5859
|
/**
|
|
5956
5860
|
* Decide whether the wallet has a Hyperliquid account.
|