@metamask-previews/perps-controller 8.0.0-preview-2fc626b → 8.1.0-preview-fe651cdb3
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 +20 -6
- package/dist/constants/hyperLiquidConfig.cjs +166 -1
- package/dist/constants/hyperLiquidConfig.cjs.map +1 -1
- package/dist/constants/hyperLiquidConfig.d.cts +33 -0
- package/dist/constants/hyperLiquidConfig.d.cts.map +1 -1
- package/dist/constants/hyperLiquidConfig.d.mts +33 -0
- package/dist/constants/hyperLiquidConfig.d.mts.map +1 -1
- package/dist/constants/hyperLiquidConfig.mjs +163 -0
- package/dist/constants/hyperLiquidConfig.mjs.map +1 -1
- package/dist/index.cjs +48 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/dist/providers/HyperLiquidProvider.cjs +2 -2
- package/dist/providers/HyperLiquidProvider.cjs.map +1 -1
- package/dist/providers/HyperLiquidProvider.d.cts +1 -1
- package/dist/providers/HyperLiquidProvider.d.cts.map +1 -1
- package/dist/providers/HyperLiquidProvider.d.mts +1 -1
- package/dist/providers/HyperLiquidProvider.d.mts.map +1 -1
- package/dist/providers/HyperLiquidProvider.mjs +3 -3
- package/dist/providers/HyperLiquidProvider.mjs.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.cjs +109 -185
- package/dist/services/HyperLiquidSubscriptionService.cjs.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.d.cts +3 -3
- package/dist/services/HyperLiquidSubscriptionService.d.cts.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.d.mts +3 -3
- package/dist/services/HyperLiquidSubscriptionService.d.mts.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.mjs +109 -185
- package/dist/services/HyperLiquidSubscriptionService.mjs.map +1 -1
- package/dist/utils/index.cjs +1 -0
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +1 -0
- package/dist/utils/index.d.cts.map +1 -1
- package/dist/utils/index.d.mts +1 -0
- package/dist/utils/index.d.mts.map +1 -1
- package/dist/utils/index.mjs +1 -0
- package/dist/utils/index.mjs.map +1 -1
- package/dist/utils/marketDataTransform.cjs +5 -2
- package/dist/utils/marketDataTransform.cjs.map +1 -1
- package/dist/utils/marketDataTransform.d.cts +4 -1
- package/dist/utils/marketDataTransform.d.cts.map +1 -1
- package/dist/utils/marketDataTransform.d.mts +4 -1
- package/dist/utils/marketDataTransform.d.mts.map +1 -1
- package/dist/utils/marketDataTransform.mjs +6 -3
- package/dist/utils/marketDataTransform.mjs.map +1 -1
- package/dist/utils/marketSearch.cjs +85 -0
- package/dist/utils/marketSearch.cjs.map +1 -0
- package/dist/utils/marketSearch.d.cts +47 -0
- package/dist/utils/marketSearch.d.cts.map +1 -0
- package/dist/utils/marketSearch.d.mts +47 -0
- package/dist/utils/marketSearch.d.mts.map +1 -0
- package/dist/utils/marketSearch.mjs +80 -0
- package/dist/utils/marketSearch.mjs.map +1 -0
- package/package.json +3 -3
|
@@ -80,7 +80,7 @@ export declare class HyperLiquidSubscriptionService {
|
|
|
80
80
|
subscribeToPositions(params: SubscribePositionsParams): () => void;
|
|
81
81
|
/**
|
|
82
82
|
* Subscribe to open interest cap updates
|
|
83
|
-
* OI caps are extracted from
|
|
83
|
+
* OI caps are extracted from the shared webData3 subscription (zero additional overhead)
|
|
84
84
|
*
|
|
85
85
|
* @param params - The subscription parameters including callback and account ID.
|
|
86
86
|
* @returns A cleanup function to unsubscribe from OI cap updates.
|
|
@@ -103,7 +103,7 @@ export declare class HyperLiquidSubscriptionService {
|
|
|
103
103
|
subscribeToOrderFills(params: SubscribeOrderFillsParams): () => void;
|
|
104
104
|
/**
|
|
105
105
|
* Subscribe to live order updates
|
|
106
|
-
* Uses the shared
|
|
106
|
+
* Uses the shared per-DEX subscriptions to avoid duplicate connections
|
|
107
107
|
*
|
|
108
108
|
* @param params - The subscription parameters including callback and account ID.
|
|
109
109
|
* @returns A cleanup function to unsubscribe from order updates.
|
|
@@ -111,7 +111,7 @@ export declare class HyperLiquidSubscriptionService {
|
|
|
111
111
|
subscribeToOrders(params: SubscribeOrdersParams): () => void;
|
|
112
112
|
/**
|
|
113
113
|
* Subscribe to live account updates
|
|
114
|
-
* Uses the shared
|
|
114
|
+
* Uses the shared per-DEX subscriptions to avoid duplicate connections
|
|
115
115
|
*
|
|
116
116
|
* @param params - The subscription parameters including callback and account ID.
|
|
117
117
|
* @returns A cleanup function to unsubscribe from account updates.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HyperLiquidSubscriptionService.d.cts","sourceRoot":"","sources":["../../src/services/HyperLiquidSubscriptionService.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"HyperLiquidSubscriptionService.d.cts","sourceRoot":"","sources":["../../src/services/HyperLiquidSubscriptionService.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EASV,gBAAgB,EAKjB,4BAA4B;AAQ7B,OAAO,KAAK,EAEV,QAAQ,EACR,SAAS,EACT,KAAK,EAEL,qBAAqB,EACrB,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,EAGxB,yBAAyB,EAE1B,2BAAiB;AAClB,OAAO,KAAK,EAEV,0BAA0B,EAE3B,uCAAmC;AAgBpC,OAAO,KAAK,EAAE,wBAAwB,EAAE,uCAAmC;AAC3E,OAAO,KAAK,EAAE,wBAAwB,EAAE,uCAAmC;AAE3E;;;GAGG;AACH,qBAAa,8BAA8B;;gBA4PvC,aAAa,EAAE,wBAAwB,EACvC,aAAa,EAAE,wBAAwB,EACvC,oBAAoB,EAAE,yBAAyB,EAC/C,WAAW,CAAC,EAAE,OAAO,EACrB,WAAW,CAAC,EA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AE,qBAAqB,GAAG,MAAM,IAAI;IA8BnE;;;;;;OAMG;IACI,kBAAkB,CAAC,MAAM,EAAE,sBAAsB,GAAG,MAAM,IAAI;IAgDrE;;;;OAIG;IACI,wBAAwB,IAAI,OAAO;IAI1C;;;;OAIG;IACI,2BAA2B,IAAI,OAAO;IAI7C;;;;OAIG;IACI,kBAAkB,IAAI,QAAQ,EAAE,GAAG,IAAI;IAI9C;;;;OAIG;IACI,eAAe,IAAI,KAAK,EAAE,GAAG,IAAI;IAIxC;;;;;OAKG;IACI,2BAA2B,IAAI,KAAK,EAAE,GAAG,IAAI;IAOpD;;;;;;OAMG;IACI,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIlD,sBAAsB,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAS1E;;;;;OAKG;IACI,cAAc,IAAI,SAAS,EAAE,GAAG,IAAI;IAI3C;;;;;;;;OAQG;IACI,0BAA0B,IAAI,SAAS,EAAE,GAAG,IAAI;IAm0BvD;;;;;;;OAOG;IACI,oBAAoB,CAAC,MAAM,EAAE,wBAAwB,GAAG,MAAM,IAAI;IAmNzE;;;;;;OAMG;IACU,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAsMlD;;OAEG;IACI,QAAQ,IAAI,IAAI;CAiMxB"}
|
|
@@ -80,7 +80,7 @@ export declare class HyperLiquidSubscriptionService {
|
|
|
80
80
|
subscribeToPositions(params: SubscribePositionsParams): () => void;
|
|
81
81
|
/**
|
|
82
82
|
* Subscribe to open interest cap updates
|
|
83
|
-
* OI caps are extracted from
|
|
83
|
+
* OI caps are extracted from the shared webData3 subscription (zero additional overhead)
|
|
84
84
|
*
|
|
85
85
|
* @param params - The subscription parameters including callback and account ID.
|
|
86
86
|
* @returns A cleanup function to unsubscribe from OI cap updates.
|
|
@@ -103,7 +103,7 @@ export declare class HyperLiquidSubscriptionService {
|
|
|
103
103
|
subscribeToOrderFills(params: SubscribeOrderFillsParams): () => void;
|
|
104
104
|
/**
|
|
105
105
|
* Subscribe to live order updates
|
|
106
|
-
* Uses the shared
|
|
106
|
+
* Uses the shared per-DEX subscriptions to avoid duplicate connections
|
|
107
107
|
*
|
|
108
108
|
* @param params - The subscription parameters including callback and account ID.
|
|
109
109
|
* @returns A cleanup function to unsubscribe from order updates.
|
|
@@ -111,7 +111,7 @@ export declare class HyperLiquidSubscriptionService {
|
|
|
111
111
|
subscribeToOrders(params: SubscribeOrdersParams): () => void;
|
|
112
112
|
/**
|
|
113
113
|
* Subscribe to live account updates
|
|
114
|
-
* Uses the shared
|
|
114
|
+
* Uses the shared per-DEX subscriptions to avoid duplicate connections
|
|
115
115
|
*
|
|
116
116
|
* @param params - The subscription parameters including callback and account ID.
|
|
117
117
|
* @returns A cleanup function to unsubscribe from account updates.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HyperLiquidSubscriptionService.d.mts","sourceRoot":"","sources":["../../src/services/HyperLiquidSubscriptionService.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"HyperLiquidSubscriptionService.d.mts","sourceRoot":"","sources":["../../src/services/HyperLiquidSubscriptionService.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EASV,gBAAgB,EAKjB,4BAA4B;AAQ7B,OAAO,KAAK,EAEV,QAAQ,EACR,SAAS,EACT,KAAK,EAEL,qBAAqB,EACrB,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,EAGxB,yBAAyB,EAE1B,2BAAiB;AAClB,OAAO,KAAK,EAEV,0BAA0B,EAE3B,uCAAmC;AAgBpC,OAAO,KAAK,EAAE,wBAAwB,EAAE,uCAAmC;AAC3E,OAAO,KAAK,EAAE,wBAAwB,EAAE,uCAAmC;AAE3E;;;GAGG;AACH,qBAAa,8BAA8B;;gBA4PvC,aA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AI1C;;;;;;OAMG;IACI,qBAAqB,CAAC,MAAM,EAAE,yBAAyB,GAAG,MAAM,IAAI;IAkJ3E;;;;;;OAMG;IACI,iBAAiB,CAAC,MAAM,EAAE,qBAAqB,GAAG,MAAM,IAAI;IA8BnE;;;;;;OAMG;IACI,kBAAkB,CAAC,MAAM,EAAE,sBAAsB,GAAG,MAAM,IAAI;IAgDrE;;;;OAIG;IACI,wBAAwB,IAAI,OAAO;IAI1C;;;;OAIG;IACI,2BAA2B,IAAI,OAAO;IAI7C;;;;OAIG;IACI,kBAAkB,IAAI,QAAQ,EAAE,GAAG,IAAI;IAI9C;;;;OAIG;IACI,eAAe,IAAI,KAAK,EAAE,GAAG,IAAI;IAIxC;;;;;OAKG;IACI,2BAA2B,IAAI,KAAK,EAAE,GAAG,IAAI;IAOpD;;;;;;OAMG;IACI,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIlD,sBAAsB,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAS1E;;;;;OAKG;IACI,cAAc,IAAI,SAAS,EAAE,GAAG,IAAI;IAI3C;;;;;;;;OAQG;IACI,0BAA0B,IAAI,SAAS,EAAE,GAAG,IAAI;IAm0BvD;;;;;;;OAOG;IACI,oBAAoB,CAAC,MAAM,EAAE,wBAAwB,GAAG,MAAM,IAAI;IAmNzE;;;;;;OAMG;IACU,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAsMlD;;OAEG;IACI,QAAQ,IAAI,IAAI;CAiMxB"}
|
|
@@ -423,7 +423,7 @@ export class HyperLiquidSubscriptionService {
|
|
|
423
423
|
}
|
|
424
424
|
/**
|
|
425
425
|
* Subscribe to open interest cap updates
|
|
426
|
-
* OI caps are extracted from
|
|
426
|
+
* OI caps are extracted from the shared webData3 subscription (zero additional overhead)
|
|
427
427
|
*
|
|
428
428
|
* @param params - The subscription parameters including callback and account ID.
|
|
429
429
|
* @returns A cleanup function to unsubscribe from OI cap updates.
|
|
@@ -490,7 +490,7 @@ export class HyperLiquidSubscriptionService {
|
|
|
490
490
|
}
|
|
491
491
|
/**
|
|
492
492
|
* Subscribe to live order updates
|
|
493
|
-
* Uses the shared
|
|
493
|
+
* Uses the shared per-DEX subscriptions to avoid duplicate connections
|
|
494
494
|
*
|
|
495
495
|
* @param params - The subscription parameters including callback and account ID.
|
|
496
496
|
* @returns A cleanup function to unsubscribe from order updates.
|
|
@@ -516,7 +516,7 @@ export class HyperLiquidSubscriptionService {
|
|
|
516
516
|
}
|
|
517
517
|
/**
|
|
518
518
|
* Subscribe to live account updates
|
|
519
|
-
* Uses the shared
|
|
519
|
+
* Uses the shared per-DEX subscriptions to avoid duplicate connections
|
|
520
520
|
*
|
|
521
521
|
* @param params - The subscription parameters including callback and account ID.
|
|
522
522
|
* @returns A cleanup function to unsubscribe from account updates.
|
|
@@ -750,11 +750,11 @@ export class HyperLiquidSubscriptionService {
|
|
|
750
750
|
// Clear existing subscription references (they're dead after reconnection)
|
|
751
751
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_webData3Subscriptions, "f").clear();
|
|
752
752
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_webData3SubscriptionPromise, undefined, "f");
|
|
753
|
-
// Clear individual subscriptions (clearinghouseState + openOrders)
|
|
753
|
+
// Clear individual subscriptions (clearinghouseState + openOrders)
|
|
754
754
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_clearinghouseStateSubscriptions, "f").clear();
|
|
755
755
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_openOrdersSubscriptions, "f").clear();
|
|
756
756
|
// Re-establish the subscription (will use current account)
|
|
757
|
-
// This
|
|
757
|
+
// This sets up per-DEX clearinghouseState + openOrders subscriptions plus webData3 (OI caps only)
|
|
758
758
|
await __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_ensureSharedWebData3Subscription).call(this);
|
|
759
759
|
}
|
|
760
760
|
// Re-establish activeAsset subscriptions if there are market data subscribers
|
|
@@ -1610,12 +1610,18 @@ async function _HyperLiquidSubscriptionService_ensureSharedWebData3Subscription(
|
|
|
1610
1610
|
// Note: webData3 includes all DEX data, so no separate HIP-3 subscriptions needed
|
|
1611
1611
|
}, _HyperLiquidSubscriptionService_createUserDataSubscription =
|
|
1612
1612
|
/**
|
|
1613
|
-
* Create WebSocket subscription for user data (positions, orders, account)
|
|
1614
|
-
* - Uses webData2 when HIP-3 disabled (main DEX only)
|
|
1615
|
-
* - Uses webData3 when HIP-3 enabled (main + HIP-3 DEXs)
|
|
1613
|
+
* Create WebSocket subscription for user data (positions, orders, account).
|
|
1616
1614
|
*
|
|
1617
|
-
*
|
|
1618
|
-
*
|
|
1615
|
+
* Positions, orders, and account/spot balance are always delivered via
|
|
1616
|
+
* per-DEX `clearinghouseState` + `openOrders` subscriptions (sub-second
|
|
1617
|
+
* updates). webData3 is used only for OI caps extraction (not
|
|
1618
|
+
* latency-sensitive). The deprecated webData2 snapshot channel is no longer
|
|
1619
|
+
* used (TAT-3332).
|
|
1620
|
+
*
|
|
1621
|
+
* - HIP-3 disabled: subscribe to the main DEX only (`dexsToSubscribe = ['']`).
|
|
1622
|
+
* - HIP-3 enabled: subscribe to the main DEX plus each enabled HIP-3 DEX.
|
|
1623
|
+
*
|
|
1624
|
+
* webData3 provides perpDexStates[] array containing OI caps for all DEXs:
|
|
1619
1625
|
* - Index 0: Main DEX (dexName = '')
|
|
1620
1626
|
* - Index 1+: HIP-3 DEXs in order of enabledDexs array
|
|
1621
1627
|
*
|
|
@@ -1644,187 +1650,105 @@ async function _HyperLiquidSubscriptionService_createUserDataSubscription(accoun
|
|
|
1644
1650
|
});
|
|
1645
1651
|
}
|
|
1646
1652
|
return new Promise((resolve, reject) => {
|
|
1647
|
-
//
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1653
|
+
// Use per-DEX clearinghouseState + openOrders subscriptions for
|
|
1654
|
+
// positions/orders/account on every path. webData3 is used only for OI
|
|
1655
|
+
// caps extraction. The deprecated webData2 channel is no longer used.
|
|
1656
|
+
// Determine which DEXs to subscribe to:
|
|
1657
|
+
// - HIP-3 enabled: main DEX + each enabled HIP-3 DEX.
|
|
1658
|
+
// - HIP-3 disabled: main DEX only.
|
|
1659
|
+
const dexsToSubscribe = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_hip3Enabled, "f")
|
|
1660
|
+
? [
|
|
1661
|
+
'',
|
|
1654
1662
|
...__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_enabledDexs, "f").filter((dexId) => __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_isDexEnabled).call(this, dexId)),
|
|
1655
|
-
]
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
// Only process DEXs we care about (skip others silently)
|
|
1684
|
-
if (!__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_isDexEnabled).call(this, dexIdentifier ?? null)) {
|
|
1685
|
-
return; // Skip this DEX - not enabled in our configuration
|
|
1686
|
-
}
|
|
1687
|
-
const currentDexName = dexIdentifier ?? '';
|
|
1688
|
-
const oiCaps = dexState.perpsAtOpenInterestCap ?? [];
|
|
1689
|
-
// Add DEX prefix for HIP-3 symbols (e.g., "xyz:TSLA")
|
|
1690
|
-
if (currentDexName) {
|
|
1691
|
-
allOICaps.push(...oiCaps.map((symbol) => `${currentDexName}:${symbol}`));
|
|
1692
|
-
}
|
|
1693
|
-
else {
|
|
1694
|
-
// Main DEX - no prefix needed
|
|
1695
|
-
allOICaps.push(...oiCaps);
|
|
1696
|
-
}
|
|
1697
|
-
});
|
|
1698
|
-
// Update OI caps cache and notify if changed
|
|
1699
|
-
const oiCapsHash = [...allOICaps]
|
|
1700
|
-
.sort((a, b) => a.localeCompare(b))
|
|
1701
|
-
.join(',');
|
|
1702
|
-
if (oiCapsHash !== __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedOICapsHash, "f")) {
|
|
1703
|
-
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedOICaps, allOICaps, "f");
|
|
1704
|
-
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedOICapsHash, oiCapsHash, "f");
|
|
1705
|
-
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_oiCapsCacheInitialized, true, "f");
|
|
1706
|
-
// Notify all subscribers
|
|
1707
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_oiCapSubscribers, "f").forEach((callback) => callback(allOICaps));
|
|
1708
|
-
}
|
|
1709
|
-
}
|
|
1710
|
-
catch (error) {
|
|
1711
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_logErrorUnlessClearing).call(this, ensureError(error, 'HyperLiquidSubscriptionService.createUserDataSubscription'), __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getErrorContext).call(this, 'webData3 callback error', {
|
|
1712
|
-
user: userAddress,
|
|
1713
|
-
hasPerpDexStates: data?.perpDexStates !== undefined,
|
|
1714
|
-
perpDexStatesLength: data?.perpDexStates?.length ?? 0,
|
|
1715
|
-
}));
|
|
1716
|
-
}
|
|
1717
|
-
})
|
|
1718
|
-
.then((sub) => {
|
|
1719
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_webData3Subscriptions, "f").set(dexName, sub);
|
|
1720
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_deps, "f").debugLogger.log(`webData3 subscription established for OI caps (main + HIP-3)`);
|
|
1721
|
-
return undefined;
|
|
1722
|
-
})
|
|
1723
|
-
.catch((error) => {
|
|
1724
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_logErrorUnlessClearing).call(this, ensureError(error, 'HyperLiquidSubscriptionService.createUserDataSubscription'), __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getErrorContext).call(this, 'createUserDataSubscription (webData3)', {
|
|
1725
|
-
dex: dexName,
|
|
1726
|
-
}));
|
|
1727
|
-
throw error;
|
|
1728
|
-
});
|
|
1729
|
-
subscriptionPromises.push(webData3Promise);
|
|
1730
|
-
// Wait for all subscriptions to be established
|
|
1731
|
-
Promise.all(subscriptionPromises)
|
|
1732
|
-
.then(() => {
|
|
1733
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_deps, "f").debugLogger.log(`HIP-3 user data subscriptions established for ${dexsToSubscribe.length} DEXs`);
|
|
1734
|
-
resolve();
|
|
1735
|
-
return undefined;
|
|
1736
|
-
})
|
|
1737
|
-
.catch((error) => {
|
|
1738
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_logErrorUnlessClearing).call(this, ensureError(error, 'HyperLiquidSubscriptionService.createUserDataSubscription'), __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getErrorContext).call(this, 'createUserDataSubscription (HIP-3)', {
|
|
1739
|
-
dexs: dexsToSubscribe,
|
|
1740
|
-
}));
|
|
1741
|
-
reject(ensureError(error, 'HyperLiquidSubscriptionService.createUserDataSubscription'));
|
|
1742
|
-
});
|
|
1743
|
-
}
|
|
1744
|
-
else {
|
|
1745
|
-
// HIP-3 disabled: Use webData2 (main DEX only)
|
|
1746
|
-
subscriptionClient
|
|
1747
|
-
.webData2({ user: userAddress }, (data) => {
|
|
1748
|
-
try {
|
|
1749
|
-
// webData2 returns clearinghouseState for main DEX only
|
|
1750
|
-
const currentDexName = ''; // Main DEX
|
|
1751
|
-
// Check for removed fields before accessing
|
|
1752
|
-
if (!data.clearinghouseState) {
|
|
1753
|
-
return;
|
|
1754
|
-
}
|
|
1755
|
-
// Extract and process positions from clearinghouseState
|
|
1756
|
-
const positions = data.clearinghouseState.assetPositions
|
|
1757
|
-
.filter((assetPos) => assetPos.position.szi !== '0')
|
|
1758
|
-
.map((assetPos) => adaptPositionFromSDK(assetPos));
|
|
1759
|
-
// Extract TP/SL from orders
|
|
1760
|
-
const { tpslMap, tpslCountMap, processedOrders: orders, } = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_extractTPSLFromOrders).call(this, data.openOrders || [], positions);
|
|
1761
|
-
// Merge TP/SL data into positions
|
|
1762
|
-
const positionsWithTPSL = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_mergeTPSLIntoPositions).call(this, positions, tpslMap, tpslCountMap);
|
|
1763
|
-
// Extract account data (webData2 provides clearinghouseState)
|
|
1764
|
-
const accountState = adaptAccountStateFromSDK(data.clearinghouseState);
|
|
1765
|
-
// Store in caches (main DEX only)
|
|
1766
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexPositionsCache, "f").set(currentDexName, positionsWithTPSL);
|
|
1767
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexOrdersCache, "f").set(currentDexName, orders);
|
|
1768
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAccountCache, "f").set(currentDexName, accountState);
|
|
1769
|
-
// OI caps (main DEX only)
|
|
1770
|
-
const oiCaps = data.perpsAtOpenInterestCap ?? [];
|
|
1771
|
-
const oiCapsHash = [...oiCaps]
|
|
1772
|
-
.sort((a, b) => a.localeCompare(b))
|
|
1773
|
-
.join(',');
|
|
1774
|
-
if (oiCapsHash !== __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedOICapsHash, "f")) {
|
|
1775
|
-
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedOICaps, oiCaps, "f");
|
|
1776
|
-
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedOICapsHash, oiCapsHash, "f");
|
|
1777
|
-
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_oiCapsCacheInitialized, true, "f");
|
|
1778
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_oiCapSubscribers, "f").forEach((callback) => callback(oiCaps));
|
|
1663
|
+
]
|
|
1664
|
+
: [''];
|
|
1665
|
+
// Track expected DEXs for synchronized notifications
|
|
1666
|
+
// Clear previous tracking and set new expected DEXs
|
|
1667
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_expectedDexs, new Set(dexsToSubscribe), "f");
|
|
1668
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_initializedDexs, new Set(), "f");
|
|
1669
|
+
// Set up individual subscriptions for each DEX
|
|
1670
|
+
const subscriptionPromises = [];
|
|
1671
|
+
for (const currentDexName of dexsToSubscribe) {
|
|
1672
|
+
// Set up clearinghouseState subscription for positions + account
|
|
1673
|
+
subscriptionPromises.push(__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_ensureClearinghouseStateSubscription).call(this, userAddress, currentDexName));
|
|
1674
|
+
// Set up openOrders subscription for orders
|
|
1675
|
+
subscriptionPromises.push(__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_ensureOpenOrdersSubscription).call(this, userAddress, currentDexName));
|
|
1676
|
+
}
|
|
1677
|
+
// Also set up webData3 for OI caps only
|
|
1678
|
+
const webData3Promise = subscriptionClient
|
|
1679
|
+
.webData3({ user: userAddress }, (data) => {
|
|
1680
|
+
try {
|
|
1681
|
+
// webData3 is ONLY used for OI caps extraction
|
|
1682
|
+
// Positions, orders, and account data come from individual subscriptions
|
|
1683
|
+
const allOICaps = [];
|
|
1684
|
+
data.perpDexStates.forEach((dexState, index) => {
|
|
1685
|
+
// Map webData3 index to DEX name
|
|
1686
|
+
// Index 0 = main DEX (null), Index 1+ = HIP-3 DEXs from discoveredDexNames
|
|
1687
|
+
const dexIdentifier = index === 0 ? null : __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_discoveredDexNames, "f")[index - 1];
|
|
1688
|
+
// Skip unknown DEXs (not in discoveredDexNames) to prevent main DEX cache corruption
|
|
1689
|
+
if (index > 0 && dexIdentifier === undefined) {
|
|
1690
|
+
return; // Unknown DEX - skip to prevent misidentifying as main DEX
|
|
1779
1691
|
}
|
|
1780
|
-
//
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
const spotAdjustedAccount = addSpotBalanceToAccountState(accountState, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedSpotState, "f"), __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getSpotBalanceOptions).call(this));
|
|
1784
|
-
const positionsHash = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_hashPositions).call(this, positionsWithTPSL);
|
|
1785
|
-
const ordersHash = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_hashOrders).call(this, orders);
|
|
1786
|
-
const accountHash = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_hashAccountState).call(this, spotAdjustedAccount);
|
|
1787
|
-
if (positionsHash !== __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedPositionsHash, "f")) {
|
|
1788
|
-
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedPositions, positionsWithTPSL, "f");
|
|
1789
|
-
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedPositionsHash, positionsHash, "f");
|
|
1790
|
-
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_positionsCacheInitialized, true, "f");
|
|
1791
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_positionSubscribers, "f").forEach((callback) => callback(positionsWithTPSL));
|
|
1692
|
+
// Only process DEXs we care about (skip others silently)
|
|
1693
|
+
if (!__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_isDexEnabled).call(this, dexIdentifier ?? null)) {
|
|
1694
|
+
return; // Skip this DEX - not enabled in our configuration
|
|
1792
1695
|
}
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1696
|
+
const currentDexName = dexIdentifier ?? '';
|
|
1697
|
+
const oiCaps = dexState.perpsAtOpenInterestCap ?? [];
|
|
1698
|
+
// Add DEX prefix for HIP-3 symbols (e.g., "xyz:TSLA")
|
|
1699
|
+
if (currentDexName) {
|
|
1700
|
+
allOICaps.push(...oiCaps.map((symbol) => `${currentDexName}:${symbol}`));
|
|
1798
1701
|
}
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_accountSubscribers, "f").forEach((callback) => callback(spotAdjustedAccount));
|
|
1702
|
+
else {
|
|
1703
|
+
// Main DEX - no prefix needed
|
|
1704
|
+
allOICaps.push(...oiCaps);
|
|
1803
1705
|
}
|
|
1706
|
+
});
|
|
1707
|
+
// Update OI caps cache and notify if changed
|
|
1708
|
+
const oiCapsHash = [...allOICaps]
|
|
1709
|
+
.sort((a, b) => a.localeCompare(b))
|
|
1710
|
+
.join(',');
|
|
1711
|
+
if (oiCapsHash !== __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedOICapsHash, "f")) {
|
|
1712
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedOICaps, allOICaps, "f");
|
|
1713
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedOICapsHash, oiCapsHash, "f");
|
|
1714
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_oiCapsCacheInitialized, true, "f");
|
|
1715
|
+
// Notify all subscribers
|
|
1716
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_oiCapSubscribers, "f").forEach((callback) => callback(allOICaps));
|
|
1804
1717
|
}
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
hasPerpsAtOpenInterestCap: data?.perpsAtOpenInterestCap !== undefined,
|
|
1812
|
-
}));
|
|
1813
|
-
}
|
|
1814
|
-
})
|
|
1815
|
-
.then((subscription) => {
|
|
1816
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_webData3Subscriptions, "f").set(dexName, subscription);
|
|
1817
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_deps, "f").debugLogger.log('webData2 subscription established for main DEX only');
|
|
1818
|
-
resolve();
|
|
1819
|
-
return undefined;
|
|
1820
|
-
})
|
|
1821
|
-
.catch((error) => {
|
|
1822
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_logErrorUnlessClearing).call(this, ensureError(error, 'HyperLiquidSubscriptionService.createUserDataSubscription'), __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getErrorContext).call(this, 'createUserDataSubscription (webData2)', {
|
|
1823
|
-
dex: dexName,
|
|
1718
|
+
}
|
|
1719
|
+
catch (error) {
|
|
1720
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_logErrorUnlessClearing).call(this, ensureError(error, 'HyperLiquidSubscriptionService.createUserDataSubscription'), __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getErrorContext).call(this, 'webData3 callback error', {
|
|
1721
|
+
user: userAddress,
|
|
1722
|
+
hasPerpDexStates: data?.perpDexStates !== undefined,
|
|
1723
|
+
perpDexStatesLength: data?.perpDexStates?.length ?? 0,
|
|
1824
1724
|
}));
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1725
|
+
}
|
|
1726
|
+
})
|
|
1727
|
+
.then((sub) => {
|
|
1728
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_webData3Subscriptions, "f").set(dexName, sub);
|
|
1729
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_deps, "f").debugLogger.log(`webData3 subscription established for OI caps (main + HIP-3)`);
|
|
1730
|
+
return undefined;
|
|
1731
|
+
})
|
|
1732
|
+
.catch((error) => {
|
|
1733
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_logErrorUnlessClearing).call(this, ensureError(error, 'HyperLiquidSubscriptionService.createUserDataSubscription'), __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getErrorContext).call(this, 'createUserDataSubscription (webData3)', {
|
|
1734
|
+
dex: dexName,
|
|
1735
|
+
}));
|
|
1736
|
+
throw error;
|
|
1737
|
+
});
|
|
1738
|
+
subscriptionPromises.push(webData3Promise);
|
|
1739
|
+
// Wait for all subscriptions to be established
|
|
1740
|
+
Promise.all(subscriptionPromises)
|
|
1741
|
+
.then(() => {
|
|
1742
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_deps, "f").debugLogger.log(`User data subscriptions established for ${dexsToSubscribe.length} DEX(s)`);
|
|
1743
|
+
resolve();
|
|
1744
|
+
return undefined;
|
|
1745
|
+
})
|
|
1746
|
+
.catch((error) => {
|
|
1747
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_logErrorUnlessClearing).call(this, ensureError(error, 'HyperLiquidSubscriptionService.createUserDataSubscription'), __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getErrorContext).call(this, 'createUserDataSubscription', {
|
|
1748
|
+
dexs: dexsToSubscribe,
|
|
1749
|
+
}));
|
|
1750
|
+
reject(ensureError(error, 'HyperLiquidSubscriptionService.createUserDataSubscription'));
|
|
1751
|
+
});
|
|
1828
1752
|
});
|
|
1829
1753
|
}, _HyperLiquidSubscriptionService_ensureClearinghouseStateSubscription =
|
|
1830
1754
|
/**
|
|
@@ -2145,7 +2069,7 @@ async function _HyperLiquidSubscriptionService_createOpenOrdersSubscription(user
|
|
|
2145
2069
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedPositionsHash, '', "f");
|
|
2146
2070
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedOrdersHash, '', "f");
|
|
2147
2071
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedAccountHash, '', "f");
|
|
2148
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_deps, "f").debugLogger.log('All multi-DEX subscriptions cleaned up (
|
|
2072
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_deps, "f").debugLogger.log('All multi-DEX subscriptions cleaned up (webData3 + individual subscriptions)');
|
|
2149
2073
|
}
|
|
2150
2074
|
}, _HyperLiquidSubscriptionService_ensureOrderFillISubscription =
|
|
2151
2075
|
/**
|