@metamask-previews/perps-controller 3.2.0-preview-6ce5d58fa → 4.0.0-preview-1e2fe74a0
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 +29 -1
- package/dist/PerpsController-method-action-types.cjs.map +1 -1
- package/dist/PerpsController-method-action-types.d.cts +9 -0
- package/dist/PerpsController-method-action-types.d.cts.map +1 -1
- package/dist/PerpsController-method-action-types.d.mts +9 -0
- 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 +15 -3
- package/dist/PerpsController.cjs.map +1 -1
- package/dist/PerpsController.d.cts +18 -3
- package/dist/PerpsController.d.cts.map +1 -1
- package/dist/PerpsController.d.mts +18 -3
- package/dist/PerpsController.d.mts.map +1 -1
- package/dist/PerpsController.mjs +15 -3
- package/dist/PerpsController.mjs.map +1 -1
- package/dist/constants/perpsConfig.cjs +28 -0
- package/dist/constants/perpsConfig.cjs.map +1 -1
- package/dist/constants/perpsConfig.d.cts +3 -0
- package/dist/constants/perpsConfig.d.cts.map +1 -1
- package/dist/constants/perpsConfig.d.mts +3 -0
- package/dist/constants/perpsConfig.d.mts.map +1 -1
- package/dist/constants/perpsConfig.mjs +28 -0
- package/dist/constants/perpsConfig.mjs.map +1 -1
- package/dist/providers/AggregatedPerpsProvider.cjs +16 -6
- package/dist/providers/AggregatedPerpsProvider.cjs.map +1 -1
- package/dist/providers/AggregatedPerpsProvider.d.cts +12 -4
- package/dist/providers/AggregatedPerpsProvider.d.cts.map +1 -1
- package/dist/providers/AggregatedPerpsProvider.d.mts +12 -4
- package/dist/providers/AggregatedPerpsProvider.d.mts.map +1 -1
- package/dist/providers/AggregatedPerpsProvider.mjs +16 -6
- package/dist/providers/AggregatedPerpsProvider.mjs.map +1 -1
- package/dist/providers/HyperLiquidProvider.cjs +56 -20
- package/dist/providers/HyperLiquidProvider.cjs.map +1 -1
- package/dist/providers/HyperLiquidProvider.d.cts +29 -4
- package/dist/providers/HyperLiquidProvider.d.cts.map +1 -1
- package/dist/providers/HyperLiquidProvider.d.mts +29 -4
- package/dist/providers/HyperLiquidProvider.d.mts.map +1 -1
- package/dist/providers/HyperLiquidProvider.mjs +57 -21
- package/dist/providers/HyperLiquidProvider.mjs.map +1 -1
- package/dist/services/HyperLiquidClientService.cjs +131 -60
- package/dist/services/HyperLiquidClientService.cjs.map +1 -1
- package/dist/services/HyperLiquidClientService.d.cts +23 -0
- package/dist/services/HyperLiquidClientService.d.cts.map +1 -1
- package/dist/services/HyperLiquidClientService.d.mts +23 -0
- package/dist/services/HyperLiquidClientService.d.mts.map +1 -1
- package/dist/services/HyperLiquidClientService.mjs +132 -61
- package/dist/services/HyperLiquidClientService.mjs.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.cjs +193 -11
- package/dist/services/HyperLiquidSubscriptionService.cjs.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.d.cts.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.d.mts.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.mjs +194 -12
- package/dist/services/HyperLiquidSubscriptionService.mjs.map +1 -1
- package/dist/services/MarketDataService.cjs +89 -6
- package/dist/services/MarketDataService.cjs.map +1 -1
- package/dist/services/MarketDataService.d.cts +19 -0
- package/dist/services/MarketDataService.d.cts.map +1 -1
- package/dist/services/MarketDataService.d.mts +19 -0
- package/dist/services/MarketDataService.d.mts.map +1 -1
- package/dist/services/MarketDataService.mjs +89 -6
- package/dist/services/MarketDataService.mjs.map +1 -1
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +21 -3
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.mts +21 -3
- package/dist/types/index.d.mts.map +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/dist/utils/accountUtils.cjs +74 -1
- package/dist/utils/accountUtils.cjs.map +1 -1
- package/dist/utils/accountUtils.d.cts +4 -0
- package/dist/utils/accountUtils.d.cts.map +1 -1
- package/dist/utils/accountUtils.d.mts +4 -0
- package/dist/utils/accountUtils.d.mts.map +1 -1
- package/dist/utils/accountUtils.mjs +70 -0
- package/dist/utils/accountUtils.mjs.map +1 -1
- package/dist/utils/coalescePerpsRestRequest.cjs +71 -0
- package/dist/utils/coalescePerpsRestRequest.cjs.map +1 -0
- package/dist/utils/coalescePerpsRestRequest.d.cts +32 -0
- package/dist/utils/coalescePerpsRestRequest.d.cts.map +1 -0
- package/dist/utils/coalescePerpsRestRequest.d.mts +32 -0
- package/dist/utils/coalescePerpsRestRequest.d.mts.map +1 -0
- package/dist/utils/coalescePerpsRestRequest.mjs +66 -0
- package/dist/utils/coalescePerpsRestRequest.mjs.map +1 -0
- package/dist/utils/hyperLiquidAdapter.cjs +7 -7
- package/dist/utils/hyperLiquidAdapter.cjs.map +1 -1
- package/dist/utils/hyperLiquidAdapter.d.cts +2 -2
- package/dist/utils/hyperLiquidAdapter.d.cts.map +1 -1
- package/dist/utils/hyperLiquidAdapter.d.mts +2 -2
- package/dist/utils/hyperLiquidAdapter.d.mts.map +1 -1
- package/dist/utils/hyperLiquidAdapter.mjs +7 -7
- package/dist/utils/hyperLiquidAdapter.mjs.map +1 -1
- package/dist/utils/perpsFormatters.cjs +5 -1
- package/dist/utils/perpsFormatters.cjs.map +1 -1
- package/dist/utils/perpsFormatters.d.cts.map +1 -1
- package/dist/utils/perpsFormatters.d.mts.map +1 -1
- package/dist/utils/perpsFormatters.mjs +5 -1
- package/dist/utils/perpsFormatters.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { CaipAccountId } from "@metamask/utils";
|
|
2
|
+
import type { ExchangeClient } from "@nktkas/hyperliquid";
|
|
2
3
|
import type { CandlePeriod } from "../constants/chartConfig.cjs";
|
|
3
4
|
import { WebSocketConnectionState } from "../services/HyperLiquidClientService.cjs";
|
|
4
|
-
import type { AccountState, AssetRoute, BatchCancelOrdersParams, CancelOrderParams, CancelOrderResult, CancelOrdersResult, CandleData, ClosePositionParams, ClosePositionsParams, ClosePositionsResult, DepositParams, DisconnectResult, EditOrderParams, FeeCalculationParams, FeeCalculationResult, Funding, GetAccountStateParams, GetAvailableDexsParams, GetFundingParams, GetHistoricalPortfolioParams, GetMarketsParams, GetOrderFillsParams, GetOrdersParams, GetOrFetchFillsParams, GetPositionsParams, GetSupportedPathsParams, HistoricalPortfolioResult, InitializeResult, PerpsPlatformDependencies, PerpsProvider, LiquidationPriceParams, LiveDataConfig, MaintenanceMarginParams, MarginResult, MarketInfo, Order, OrderFill, OrderParams, OrderResult, PerpsMarketData, Position, ReadyToTradeResult, SubscribeAccountParams, SubscribeCandlesParams, SubscribeOICapsParams, SubscribeOrderBookParams, SubscribeOrderFillsParams, SubscribeOrdersParams, SubscribePositionsParams, SubscribePricesParams, ToggleTestnetResult, TransferBetweenDexsParams, TransferBetweenDexsResult, UpdateMarginParams, UpdatePositionTPSLParams, UserHistoryItem, WithdrawParams, WithdrawResult, RawLedgerUpdate } from "../types/index.cjs";
|
|
5
|
+
import type { AccountState, AssetRoute, BatchCancelOrdersParams, CancelOrderParams, CancelOrderResult, CancelOrdersResult, CandleData, ClosePositionParams, ClosePositionsParams, ClosePositionsResult, DepositParams, DisconnectResult, EditOrderParams, FeeCalculationParams, FeeCalculationResult, Funding, GetAccountStateParams, GetAvailableDexsParams, GetFundingParams, GetHistoricalPortfolioParams, GetMarketsParams, GetOrderFillsParams, GetOrdersParams, GetOrFetchFillsParams, GetPositionsParams, GetSupportedPathsParams, HistoricalPortfolioResult, InitializeResult, PerpsPlatformDependencies, PerpsProvider, LiquidationPriceParams, LiveDataConfig, MaintenanceMarginParams, MarginResult, MarketInfo, Order, OrderFill, OrderParams, OrderResult, PerpsMarketData, Position, ReadyToTradeResult, SubscribeAccountParams, SubscribeCandlesParams, SubscribeOICapsParams, SubscribeOrderBookParams, SubscribeOrderFillsParams, SubscribeOrdersParams, SubscribePositionsParams, SubscribePricesParams, ToggleTestnetResult, TransferBetweenDexsParams, TransferBetweenDexsResult, UpdateMarginParams, UpdatePositionTPSLParams, UserHistoryItem, WithdrawParams, WithdrawResult, RawLedgerUpdate, PerpsReadOptions } from "../types/index.cjs";
|
|
5
6
|
import type { PerpsControllerMessengerBase } from "../types/messenger.cjs";
|
|
6
7
|
/**
|
|
7
8
|
* HyperLiquid provider implementation
|
|
@@ -166,16 +167,18 @@ export declare class HyperLiquidProvider implements PerpsProvider {
|
|
|
166
167
|
* Get historical user fills (trade executions)
|
|
167
168
|
*
|
|
168
169
|
* @param params - The operation parameters.
|
|
170
|
+
* @param options - Optional cache-control modifiers for this read.
|
|
169
171
|
* @returns A promise that resolves to the result.
|
|
170
172
|
*/
|
|
171
|
-
getOrderFills(params?: GetOrderFillsParams): Promise<OrderFill[]>;
|
|
173
|
+
getOrderFills(params?: GetOrderFillsParams, options?: PerpsReadOptions): Promise<OrderFill[]>;
|
|
172
174
|
/**
|
|
173
175
|
* Get historical orders (order lifecycle)
|
|
174
176
|
*
|
|
175
177
|
* @param params - The operation parameters.
|
|
178
|
+
* @param options - Optional cache-control modifiers for this read.
|
|
176
179
|
* @returns A promise that resolves to the result.
|
|
177
180
|
*/
|
|
178
|
-
getOrders(params?: GetOrdersParams): Promise<Order[]>;
|
|
181
|
+
getOrders(params?: GetOrdersParams, options?: PerpsReadOptions): Promise<Order[]>;
|
|
179
182
|
/**
|
|
180
183
|
* Get currently open orders (real-time status)
|
|
181
184
|
* Uses frontendOpenOrders API to get only currently active orders
|
|
@@ -189,9 +192,11 @@ export declare class HyperLiquidProvider implements PerpsProvider {
|
|
|
189
192
|
* Get user funding history
|
|
190
193
|
*
|
|
191
194
|
* @param params - The operation parameters.
|
|
195
|
+
* @param _options - Cache-control modifiers (unused — funding has no
|
|
196
|
+
* provider-internal cache; coalescing happens at MarketDataService).
|
|
192
197
|
* @returns A promise that resolves to the result.
|
|
193
198
|
*/
|
|
194
|
-
getFunding(params?: GetFundingParams): Promise<Funding[]>;
|
|
199
|
+
getFunding(params?: GetFundingParams, _options?: PerpsReadOptions): Promise<Funding[]>;
|
|
195
200
|
/**
|
|
196
201
|
* Get user non-funding ledger updates (deposits, transfers, withdrawals)
|
|
197
202
|
*
|
|
@@ -206,6 +211,16 @@ export declare class HyperLiquidProvider implements PerpsProvider {
|
|
|
206
211
|
startTime?: number;
|
|
207
212
|
endTime?: number;
|
|
208
213
|
}): Promise<RawLedgerUpdate[]>;
|
|
214
|
+
/**
|
|
215
|
+
* Resolve the provider's currently active CAIP account identifier.
|
|
216
|
+
* Used by the MarketDataService REST coalesce layer so cached payloads
|
|
217
|
+
* are keyed by the actual resolved address rather than a shared
|
|
218
|
+
* "default" sentinel — prevents one account's data from being served
|
|
219
|
+
* after an account switch within the coalesce TTL window.
|
|
220
|
+
*
|
|
221
|
+
* @returns CAIP account id for the currently selected HyperLiquid account.
|
|
222
|
+
*/
|
|
223
|
+
getCurrentAccountId(): Promise<CaipAccountId>;
|
|
209
224
|
/**
|
|
210
225
|
* Get user history (deposits, withdrawals, transfers)
|
|
211
226
|
*
|
|
@@ -465,6 +480,16 @@ export declare class HyperLiquidProvider implements PerpsProvider {
|
|
|
465
480
|
* @param userAddress - Optional address to clear cache for
|
|
466
481
|
*/
|
|
467
482
|
clearFeeCache(userAddress?: string): void;
|
|
483
|
+
/**
|
|
484
|
+
* Escape hatch for agentic validation flows and test harnesses that drive
|
|
485
|
+
* HL mutations directly. NOT part of the PerpsProvider interface.
|
|
486
|
+
* Production code paths must go through the provider's own methods.
|
|
487
|
+
*
|
|
488
|
+
* @returns A promise resolving to the underlying HyperLiquid SDK
|
|
489
|
+
* ExchangeClient. Promise shape matches the existing agentic flows
|
|
490
|
+
* (hl-provision-fixture) that chain `.then` on the result.
|
|
491
|
+
*/
|
|
492
|
+
getExchangeClient(): Promise<ExchangeClient>;
|
|
468
493
|
/**
|
|
469
494
|
* Disconnect provider
|
|
470
495
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HyperLiquidProvider.d.cts","sourceRoot":"","sources":["../../src/providers/HyperLiquidProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAe,wBAAwB;
|
|
1
|
+
{"version":3,"file":"HyperLiquidProvider.d.cts","sourceRoot":"","sources":["../../src/providers/HyperLiquidProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAe,wBAAwB;AAE7D,OAAO,KAAK,EAAE,cAAc,EAAE,4BAA4B;AAG1D,OAAO,KAAK,EAAE,YAAY,EAAE,qCAAiC;AA2B7D,OAAO,EAEL,wBAAwB,EACzB,iDAA6C;AAO9C,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,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,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,EACzB,gBAAgB,EAChB,yBAAyB,EACzB,aAAa,EACb,sBAAsB,EACtB,cAAc,EACd,uBAAuB,EACvB,YAAY,EACZ,UAAU,EACV,KAAK,EACL,SAAS,EACT,WAAW,EACX,WAAW,EACX,eAAe,EACf,QAAQ,EACR,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACrB,wBAAwB,EACxB,qBAAqB,EACrB,mBAAmB,EACnB,yBAAyB,EACzB,yBAAyB,EACzB,kBAAkB,EAClB,wBAAwB,EACxB,eAAe,EACf,cAAc,EACd,cAAc,EACd,eAAe,EACf,gBAAgB,EACjB,2BAAiB;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;CAuT9C"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { CaipAccountId } from "@metamask/utils";
|
|
2
|
+
import type { ExchangeClient } from "@nktkas/hyperliquid";
|
|
2
3
|
import type { CandlePeriod } from "../constants/chartConfig.mjs";
|
|
3
4
|
import { WebSocketConnectionState } from "../services/HyperLiquidClientService.mjs";
|
|
4
|
-
import type { AccountState, AssetRoute, BatchCancelOrdersParams, CancelOrderParams, CancelOrderResult, CancelOrdersResult, CandleData, ClosePositionParams, ClosePositionsParams, ClosePositionsResult, DepositParams, DisconnectResult, EditOrderParams, FeeCalculationParams, FeeCalculationResult, Funding, GetAccountStateParams, GetAvailableDexsParams, GetFundingParams, GetHistoricalPortfolioParams, GetMarketsParams, GetOrderFillsParams, GetOrdersParams, GetOrFetchFillsParams, GetPositionsParams, GetSupportedPathsParams, HistoricalPortfolioResult, InitializeResult, PerpsPlatformDependencies, PerpsProvider, LiquidationPriceParams, LiveDataConfig, MaintenanceMarginParams, MarginResult, MarketInfo, Order, OrderFill, OrderParams, OrderResult, PerpsMarketData, Position, ReadyToTradeResult, SubscribeAccountParams, SubscribeCandlesParams, SubscribeOICapsParams, SubscribeOrderBookParams, SubscribeOrderFillsParams, SubscribeOrdersParams, SubscribePositionsParams, SubscribePricesParams, ToggleTestnetResult, TransferBetweenDexsParams, TransferBetweenDexsResult, UpdateMarginParams, UpdatePositionTPSLParams, UserHistoryItem, WithdrawParams, WithdrawResult, RawLedgerUpdate } from "../types/index.mjs";
|
|
5
|
+
import type { AccountState, AssetRoute, BatchCancelOrdersParams, CancelOrderParams, CancelOrderResult, CancelOrdersResult, CandleData, ClosePositionParams, ClosePositionsParams, ClosePositionsResult, DepositParams, DisconnectResult, EditOrderParams, FeeCalculationParams, FeeCalculationResult, Funding, GetAccountStateParams, GetAvailableDexsParams, GetFundingParams, GetHistoricalPortfolioParams, GetMarketsParams, GetOrderFillsParams, GetOrdersParams, GetOrFetchFillsParams, GetPositionsParams, GetSupportedPathsParams, HistoricalPortfolioResult, InitializeResult, PerpsPlatformDependencies, PerpsProvider, LiquidationPriceParams, LiveDataConfig, MaintenanceMarginParams, MarginResult, MarketInfo, Order, OrderFill, OrderParams, OrderResult, PerpsMarketData, Position, ReadyToTradeResult, SubscribeAccountParams, SubscribeCandlesParams, SubscribeOICapsParams, SubscribeOrderBookParams, SubscribeOrderFillsParams, SubscribeOrdersParams, SubscribePositionsParams, SubscribePricesParams, ToggleTestnetResult, TransferBetweenDexsParams, TransferBetweenDexsResult, UpdateMarginParams, UpdatePositionTPSLParams, UserHistoryItem, WithdrawParams, WithdrawResult, RawLedgerUpdate, PerpsReadOptions } from "../types/index.mjs";
|
|
5
6
|
import type { PerpsControllerMessengerBase } from "../types/messenger.mjs";
|
|
6
7
|
/**
|
|
7
8
|
* HyperLiquid provider implementation
|
|
@@ -166,16 +167,18 @@ export declare class HyperLiquidProvider implements PerpsProvider {
|
|
|
166
167
|
* Get historical user fills (trade executions)
|
|
167
168
|
*
|
|
168
169
|
* @param params - The operation parameters.
|
|
170
|
+
* @param options - Optional cache-control modifiers for this read.
|
|
169
171
|
* @returns A promise that resolves to the result.
|
|
170
172
|
*/
|
|
171
|
-
getOrderFills(params?: GetOrderFillsParams): Promise<OrderFill[]>;
|
|
173
|
+
getOrderFills(params?: GetOrderFillsParams, options?: PerpsReadOptions): Promise<OrderFill[]>;
|
|
172
174
|
/**
|
|
173
175
|
* Get historical orders (order lifecycle)
|
|
174
176
|
*
|
|
175
177
|
* @param params - The operation parameters.
|
|
178
|
+
* @param options - Optional cache-control modifiers for this read.
|
|
176
179
|
* @returns A promise that resolves to the result.
|
|
177
180
|
*/
|
|
178
|
-
getOrders(params?: GetOrdersParams): Promise<Order[]>;
|
|
181
|
+
getOrders(params?: GetOrdersParams, options?: PerpsReadOptions): Promise<Order[]>;
|
|
179
182
|
/**
|
|
180
183
|
* Get currently open orders (real-time status)
|
|
181
184
|
* Uses frontendOpenOrders API to get only currently active orders
|
|
@@ -189,9 +192,11 @@ export declare class HyperLiquidProvider implements PerpsProvider {
|
|
|
189
192
|
* Get user funding history
|
|
190
193
|
*
|
|
191
194
|
* @param params - The operation parameters.
|
|
195
|
+
* @param _options - Cache-control modifiers (unused — funding has no
|
|
196
|
+
* provider-internal cache; coalescing happens at MarketDataService).
|
|
192
197
|
* @returns A promise that resolves to the result.
|
|
193
198
|
*/
|
|
194
|
-
getFunding(params?: GetFundingParams): Promise<Funding[]>;
|
|
199
|
+
getFunding(params?: GetFundingParams, _options?: PerpsReadOptions): Promise<Funding[]>;
|
|
195
200
|
/**
|
|
196
201
|
* Get user non-funding ledger updates (deposits, transfers, withdrawals)
|
|
197
202
|
*
|
|
@@ -206,6 +211,16 @@ export declare class HyperLiquidProvider implements PerpsProvider {
|
|
|
206
211
|
startTime?: number;
|
|
207
212
|
endTime?: number;
|
|
208
213
|
}): Promise<RawLedgerUpdate[]>;
|
|
214
|
+
/**
|
|
215
|
+
* Resolve the provider's currently active CAIP account identifier.
|
|
216
|
+
* Used by the MarketDataService REST coalesce layer so cached payloads
|
|
217
|
+
* are keyed by the actual resolved address rather than a shared
|
|
218
|
+
* "default" sentinel — prevents one account's data from being served
|
|
219
|
+
* after an account switch within the coalesce TTL window.
|
|
220
|
+
*
|
|
221
|
+
* @returns CAIP account id for the currently selected HyperLiquid account.
|
|
222
|
+
*/
|
|
223
|
+
getCurrentAccountId(): Promise<CaipAccountId>;
|
|
209
224
|
/**
|
|
210
225
|
* Get user history (deposits, withdrawals, transfers)
|
|
211
226
|
*
|
|
@@ -465,6 +480,16 @@ export declare class HyperLiquidProvider implements PerpsProvider {
|
|
|
465
480
|
* @param userAddress - Optional address to clear cache for
|
|
466
481
|
*/
|
|
467
482
|
clearFeeCache(userAddress?: string): void;
|
|
483
|
+
/**
|
|
484
|
+
* Escape hatch for agentic validation flows and test harnesses that drive
|
|
485
|
+
* HL mutations directly. NOT part of the PerpsProvider interface.
|
|
486
|
+
* Production code paths must go through the provider's own methods.
|
|
487
|
+
*
|
|
488
|
+
* @returns A promise resolving to the underlying HyperLiquid SDK
|
|
489
|
+
* ExchangeClient. Promise shape matches the existing agentic flows
|
|
490
|
+
* (hl-provision-fixture) that chain `.then` on the result.
|
|
491
|
+
*/
|
|
492
|
+
getExchangeClient(): Promise<ExchangeClient>;
|
|
468
493
|
/**
|
|
469
494
|
* Disconnect provider
|
|
470
495
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HyperLiquidProvider.d.mts","sourceRoot":"","sources":["../../src/providers/HyperLiquidProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAe,wBAAwB;
|
|
1
|
+
{"version":3,"file":"HyperLiquidProvider.d.mts","sourceRoot":"","sources":["../../src/providers/HyperLiquidProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAe,wBAAwB;AAE7D,OAAO,KAAK,EAAE,cAAc,EAAE,4BAA4B;AAG1D,OAAO,KAAK,EAAE,YAAY,EAAE,qCAAiC;AA2B7D,OAAO,EAEL,wBAAwB,EACzB,iDAA6C;AAO9C,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,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,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,EACzB,gBAAgB,EAChB,yBAAyB,EACzB,aAAa,EACb,sBAAsB,EACtB,cAAc,EACd,uBAAuB,EACvB,YAAY,EACZ,UAAU,EACV,KAAK,EACL,SAAS,EACT,WAAW,EACX,WAAW,EACX,eAAe,EACf,QAAQ,EACR,kBAAkB,EA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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;CAuT9C"}
|
|
@@ -21,7 +21,7 @@ import { HyperLiquidClientService, WebSocketConnectionState } from "../services/
|
|
|
21
21
|
import { HyperLiquidSubscriptionService } from "../services/HyperLiquidSubscriptionService.mjs";
|
|
22
22
|
import { HyperLiquidWalletService } from "../services/HyperLiquidWalletService.mjs";
|
|
23
23
|
import { TradingReadinessCache, PerpsSigningCache } from "../services/TradingReadinessCache.mjs";
|
|
24
|
-
import { aggregateAccountStates } from "../utils/accountUtils.mjs";
|
|
24
|
+
import { addSpotBalanceToAccountState, aggregateAccountStates } from "../utils/accountUtils.mjs";
|
|
25
25
|
import { ensureError } from "../utils/errorUtils.mjs";
|
|
26
26
|
import { adaptAccountStateFromSDK, adaptHyperLiquidLedgerUpdateToUserHistoryItem, adaptMarketFromSDK, adaptOrderFromSDK, adaptPositionFromSDK, buildAssetMapping, formatHyperLiquidPrice, formatHyperLiquidSize, parseAssetName } from "../utils/hyperLiquidAdapter.mjs";
|
|
27
27
|
import { createErrorResult, getMaxOrderValue, getSupportedPaths, validateAssetSupport, validateBalance, validateCoinExists, validateDepositParams, validateOrderParams, validateWithdrawalParams } from "../utils/hyperLiquidValidation.mjs";
|
|
@@ -1435,9 +1435,10 @@ export class HyperLiquidProvider {
|
|
|
1435
1435
|
* Get historical user fills (trade executions)
|
|
1436
1436
|
*
|
|
1437
1437
|
* @param params - The operation parameters.
|
|
1438
|
+
* @param options - Optional cache-control modifiers for this read.
|
|
1438
1439
|
* @returns A promise that resolves to the result.
|
|
1439
1440
|
*/
|
|
1440
|
-
async getOrderFills(params) {
|
|
1441
|
+
async getOrderFills(params, options) {
|
|
1441
1442
|
try {
|
|
1442
1443
|
__classPrivateFieldGet(this, _HyperLiquidProvider_deps, "f").debugLogger.log('Getting user fills via HyperLiquid SDK:', params);
|
|
1443
1444
|
// Read-only operation: only need client initialization
|
|
@@ -1464,8 +1465,14 @@ export class HyperLiquidProvider {
|
|
|
1464
1465
|
// Start fetching historical orders in parallel with fill transformation.
|
|
1465
1466
|
// The fills API does not return order type, so we cross-reference
|
|
1466
1467
|
// with historical orders to enable TP/SL pill rendering in activity.
|
|
1467
|
-
|
|
1468
|
-
|
|
1468
|
+
// Routed through the client-service coalesce so the enrichment sidecar
|
|
1469
|
+
// rides the same cache as an explicit getOrders call, preventing a
|
|
1470
|
+
// second REST fire under rapid market switching.
|
|
1471
|
+
const historicalOrdersPromise = __classPrivateFieldGet(this, _HyperLiquidProvider_clientService, "f")
|
|
1472
|
+
.fetchHistoricalOrders(userAddress, {
|
|
1473
|
+
forceRefresh: options?.forceRefresh,
|
|
1474
|
+
})
|
|
1475
|
+
.catch((enrichError) => {
|
|
1469
1476
|
__classPrivateFieldGet(this, _HyperLiquidProvider_deps, "f").debugLogger.log('Warning: failed to enrich fills with order types:', enrichError);
|
|
1470
1477
|
return null;
|
|
1471
1478
|
});
|
|
@@ -1531,19 +1538,17 @@ export class HyperLiquidProvider {
|
|
|
1531
1538
|
* Get historical orders (order lifecycle)
|
|
1532
1539
|
*
|
|
1533
1540
|
* @param params - The operation parameters.
|
|
1541
|
+
* @param options - Optional cache-control modifiers for this read.
|
|
1534
1542
|
* @returns A promise that resolves to the result.
|
|
1535
1543
|
*/
|
|
1536
|
-
async getOrders(params) {
|
|
1544
|
+
async getOrders(params, options) {
|
|
1537
1545
|
try {
|
|
1538
1546
|
__classPrivateFieldGet(this, _HyperLiquidProvider_deps, "f").debugLogger.log('Getting user orders via HyperLiquid SDK:', params);
|
|
1539
1547
|
// Read-only operation: only need client initialization
|
|
1540
1548
|
await __classPrivateFieldGet(this, _HyperLiquidProvider_instances, "m", _HyperLiquidProvider_ensureClientsInitialized).call(this);
|
|
1541
1549
|
__classPrivateFieldGet(this, _HyperLiquidProvider_clientService, "f").ensureInitialized();
|
|
1542
|
-
const infoClient = __classPrivateFieldGet(this, _HyperLiquidProvider_clientService, "f").getInfoClient();
|
|
1543
1550
|
const userAddress = await __classPrivateFieldGet(this, _HyperLiquidProvider_walletService, "f").getUserAddressWithDefault(params?.accountId);
|
|
1544
|
-
const rawOrders = await
|
|
1545
|
-
user: userAddress,
|
|
1546
|
-
});
|
|
1551
|
+
const rawOrders = await __classPrivateFieldGet(this, _HyperLiquidProvider_clientService, "f").fetchHistoricalOrders(userAddress, { forceRefresh: options?.forceRefresh });
|
|
1547
1552
|
__classPrivateFieldGet(this, _HyperLiquidProvider_deps, "f").debugLogger.log('User orders received:', {
|
|
1548
1553
|
count: rawOrders?.length ?? 0,
|
|
1549
1554
|
});
|
|
@@ -1690,9 +1695,11 @@ export class HyperLiquidProvider {
|
|
|
1690
1695
|
* Get user funding history
|
|
1691
1696
|
*
|
|
1692
1697
|
* @param params - The operation parameters.
|
|
1698
|
+
* @param _options - Cache-control modifiers (unused — funding has no
|
|
1699
|
+
* provider-internal cache; coalescing happens at MarketDataService).
|
|
1693
1700
|
* @returns A promise that resolves to the result.
|
|
1694
1701
|
*/
|
|
1695
|
-
async getFunding(params) {
|
|
1702
|
+
async getFunding(params, _options) {
|
|
1696
1703
|
try {
|
|
1697
1704
|
__classPrivateFieldGet(this, _HyperLiquidProvider_deps, "f").debugLogger.log('Getting user funding via HyperLiquid SDK:', params);
|
|
1698
1705
|
// Read-only operation: only need client initialization
|
|
@@ -1811,6 +1818,18 @@ export class HyperLiquidProvider {
|
|
|
1811
1818
|
return [];
|
|
1812
1819
|
}
|
|
1813
1820
|
}
|
|
1821
|
+
/**
|
|
1822
|
+
* Resolve the provider's currently active CAIP account identifier.
|
|
1823
|
+
* Used by the MarketDataService REST coalesce layer so cached payloads
|
|
1824
|
+
* are keyed by the actual resolved address rather than a shared
|
|
1825
|
+
* "default" sentinel — prevents one account's data from being served
|
|
1826
|
+
* after an account switch within the coalesce TTL window.
|
|
1827
|
+
*
|
|
1828
|
+
* @returns CAIP account id for the currently selected HyperLiquid account.
|
|
1829
|
+
*/
|
|
1830
|
+
async getCurrentAccountId() {
|
|
1831
|
+
return __classPrivateFieldGet(this, _HyperLiquidProvider_walletService, "f").getCurrentAccountId();
|
|
1832
|
+
}
|
|
1814
1833
|
/**
|
|
1815
1834
|
* Get user history (deposits, withdrawals, transfers)
|
|
1816
1835
|
*
|
|
@@ -1913,10 +1932,21 @@ export class HyperLiquidProvider {
|
|
|
1913
1932
|
isTestnet: __classPrivateFieldGet(this, _HyperLiquidProvider_clientService, "f").isTestnetMode(),
|
|
1914
1933
|
});
|
|
1915
1934
|
const dexs = await __classPrivateFieldGet(this, _HyperLiquidProvider_instances, "m", _HyperLiquidProvider_getStandaloneValidatedDexs).call(this);
|
|
1916
|
-
const
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1935
|
+
const [standaloneSpotStateResult, standalonePerpsResults] = await Promise.all([
|
|
1936
|
+
standaloneInfoClient
|
|
1937
|
+
.spotClearinghouseState({ user: userAddress })
|
|
1938
|
+
.catch((error) => {
|
|
1939
|
+
__classPrivateFieldGet(this, _HyperLiquidProvider_deps, "f").debugLogger.log('Standalone spot state fetch failed — falling back to perps-only totals', {
|
|
1940
|
+
error: ensureError(error, 'HyperLiquidProvider.getAccountState.standalone.spot').message,
|
|
1941
|
+
});
|
|
1942
|
+
return null;
|
|
1943
|
+
}),
|
|
1944
|
+
queryStandaloneClearinghouseStates(standaloneInfoClient, userAddress, dexs),
|
|
1945
|
+
]);
|
|
1946
|
+
// Aggregate account states across all DEXs, then apply spot-backed
|
|
1947
|
+
// adjustments so streamed/standalone/full paths report the same totals.
|
|
1948
|
+
const dexAccountStates = standalonePerpsResults.map((perpsState) => adaptAccountStateFromSDK(perpsState));
|
|
1949
|
+
const aggregatedAccountState = addSpotBalanceToAccountState(aggregateAccountStates(dexAccountStates), standaloneSpotStateResult);
|
|
1920
1950
|
__classPrivateFieldGet(this, _HyperLiquidProvider_deps, "f").debugLogger.log('HyperLiquidProvider: standalone account state fetched', { totalBalance: aggregatedAccountState.totalBalance });
|
|
1921
1951
|
return aggregatedAccountState;
|
|
1922
1952
|
}
|
|
@@ -1981,13 +2011,7 @@ export class HyperLiquidProvider {
|
|
|
1981
2011
|
});
|
|
1982
2012
|
return dexAccountState;
|
|
1983
2013
|
});
|
|
1984
|
-
const aggregatedAccountState = aggregateAccountStates(dexAccountStates);
|
|
1985
|
-
// Add spot balance to totalBalance (spot is global, not per-DEX)
|
|
1986
|
-
let spotBalance = 0;
|
|
1987
|
-
if (spotState?.balances && Array.isArray(spotState.balances)) {
|
|
1988
|
-
spotBalance = spotState.balances.reduce((sum, balance) => sum + parseFloat(balance.total || '0'), 0);
|
|
1989
|
-
}
|
|
1990
|
-
aggregatedAccountState.totalBalance = (parseFloat(aggregatedAccountState.totalBalance) + spotBalance).toString();
|
|
2014
|
+
const aggregatedAccountState = addSpotBalanceToAccountState(aggregateAccountStates(dexAccountStates), spotState);
|
|
1991
2015
|
// Build per-sub-account breakdown (HIP-3 DEXs map to sub-accounts)
|
|
1992
2016
|
const subAccountBreakdown = {};
|
|
1993
2017
|
perpsStateResults.forEach((result) => {
|
|
@@ -3451,6 +3475,18 @@ export class HyperLiquidProvider {
|
|
|
3451
3475
|
__classPrivateFieldGet(this, _HyperLiquidProvider_deps, "f").debugLogger.log('Cleared all fee cache');
|
|
3452
3476
|
}
|
|
3453
3477
|
}
|
|
3478
|
+
/**
|
|
3479
|
+
* Escape hatch for agentic validation flows and test harnesses that drive
|
|
3480
|
+
* HL mutations directly. NOT part of the PerpsProvider interface.
|
|
3481
|
+
* Production code paths must go through the provider's own methods.
|
|
3482
|
+
*
|
|
3483
|
+
* @returns A promise resolving to the underlying HyperLiquid SDK
|
|
3484
|
+
* ExchangeClient. Promise shape matches the existing agentic flows
|
|
3485
|
+
* (hl-provision-fixture) that chain `.then` on the result.
|
|
3486
|
+
*/
|
|
3487
|
+
async getExchangeClient() {
|
|
3488
|
+
return __classPrivateFieldGet(this, _HyperLiquidProvider_clientService, "f").getExchangeClient();
|
|
3489
|
+
}
|
|
3454
3490
|
/**
|
|
3455
3491
|
* Disconnect provider
|
|
3456
3492
|
*
|