@pear-protocol/hyperliquid-sdk 0.0.60-beta-usdh-1 → 0.0.60-beta-usdh-3
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/dist/clients/orders.d.ts +41 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useAuth.d.ts +1 -1
- package/dist/hooks/useSpotOrder.d.ts +13 -0
- package/dist/index.d.ts +73 -19
- package/dist/index.js +142 -47
- package/dist/provider.d.ts +1 -1
- package/dist/types.d.ts +19 -18
- package/dist/utils/account-summary-calculator.d.ts +1 -1
- package/package.json +1 -1
package/dist/clients/orders.d.ts
CHANGED
|
@@ -22,3 +22,44 @@ export interface CancelTwapResponseDto {
|
|
|
22
22
|
cancelledAt: string;
|
|
23
23
|
}
|
|
24
24
|
export declare function cancelTwapOrder(baseUrl: string, orderId: string): Promise<ApiResponse<CancelTwapResponseDto>>;
|
|
25
|
+
export interface SpotOrderRequestInput {
|
|
26
|
+
/** Asset to buy/sell (e.g., "USDH") */
|
|
27
|
+
asset: string;
|
|
28
|
+
/** Whether to buy (true) or sell (false) the asset */
|
|
29
|
+
isBuy: boolean;
|
|
30
|
+
/** Amount of asset to buy/sell (minimum: 11) */
|
|
31
|
+
amount: number;
|
|
32
|
+
}
|
|
33
|
+
/** Filled order status from Hyperliquid */
|
|
34
|
+
export interface SpotOrderFilledStatus {
|
|
35
|
+
filled: {
|
|
36
|
+
totalSz: string;
|
|
37
|
+
avgPx: string;
|
|
38
|
+
oid: number;
|
|
39
|
+
cloid: string;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** Hyperliquid order response data */
|
|
43
|
+
export interface SpotOrderHyperliquidData {
|
|
44
|
+
statuses: SpotOrderFilledStatus[];
|
|
45
|
+
}
|
|
46
|
+
/** Hyperliquid result from spot order execution */
|
|
47
|
+
export interface SpotOrderHyperliquidResult {
|
|
48
|
+
status: 'ok' | 'error';
|
|
49
|
+
response: {
|
|
50
|
+
type: 'order';
|
|
51
|
+
data: SpotOrderHyperliquidData;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export interface SpotOrderResponseDto {
|
|
55
|
+
orderId: string;
|
|
56
|
+
status: 'EXECUTED' | 'FAILED' | 'PENDING';
|
|
57
|
+
asset: string;
|
|
58
|
+
createdAt: string;
|
|
59
|
+
hyperliquidResult?: SpotOrderHyperliquidResult;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Execute a spot order (swap) using Pear Hyperliquid service
|
|
63
|
+
* POST /orders/spot
|
|
64
|
+
*/
|
|
65
|
+
export declare function executeSpotOrder(baseUrl: string, payload: SpotOrderRequestInput): Promise<ApiResponse<SpotOrderResponseDto>>;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export * from './useAgentWallet';
|
|
|
10
10
|
export * from './useAutoSyncFills';
|
|
11
11
|
export * from './usePosition';
|
|
12
12
|
export * from './useOrders';
|
|
13
|
+
export * from './useSpotOrder';
|
|
13
14
|
export * from './useTwap';
|
|
14
15
|
export * from './useNotifications';
|
|
15
16
|
export * from './useMarketData';
|
package/dist/hooks/useAuth.d.ts
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ApiResponse, ApiErrorResponse } from '../types';
|
|
2
|
+
import { type SpotOrderRequestInput, type SpotOrderResponseDto } from '../clients/orders';
|
|
3
|
+
export interface UseSpotOrderResult {
|
|
4
|
+
executeSpotOrder: (payload: SpotOrderRequestInput) => Promise<ApiResponse<SpotOrderResponseDto>>;
|
|
5
|
+
isLoading: boolean;
|
|
6
|
+
error: ApiErrorResponse | null;
|
|
7
|
+
resetError: () => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Hook for executing spot orders (swaps) on Hyperliquid
|
|
11
|
+
* Use this to swap between USDC and USDH or other spot assets
|
|
12
|
+
*/
|
|
13
|
+
export declare function useSpotOrder(): UseSpotOrderResult;
|
package/dist/index.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ interface ExternalFillDto {
|
|
|
47
47
|
coin: string;
|
|
48
48
|
px: string;
|
|
49
49
|
sz: string;
|
|
50
|
-
side:
|
|
50
|
+
side: "B" | "A";
|
|
51
51
|
time: number;
|
|
52
52
|
dir: string;
|
|
53
53
|
fee: string;
|
|
@@ -74,16 +74,16 @@ interface TwapSliceFillResponseItem {
|
|
|
74
74
|
/**
|
|
75
75
|
* WebSocket connection states
|
|
76
76
|
*/
|
|
77
|
-
type WebSocketConnectionState =
|
|
77
|
+
type WebSocketConnectionState = "connecting" | "connected" | "disconnected" | "error";
|
|
78
78
|
/**
|
|
79
79
|
* WebSocket channels
|
|
80
80
|
*/
|
|
81
|
-
type WebSocketChannel =
|
|
81
|
+
type WebSocketChannel = "trade-histories" | "open-positions" | "open-orders" | "account-summary" | "twap-details" | "notifications" | "market-data" | "market-data-all" | "webData3" | "allMids" | "activeAssetData";
|
|
82
82
|
/**
|
|
83
83
|
* WebSocket subscription message
|
|
84
84
|
*/
|
|
85
85
|
interface WebSocketSubscribeMessage {
|
|
86
|
-
action?:
|
|
86
|
+
action?: "subscribe" | "unsubscribe";
|
|
87
87
|
address: string;
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
@@ -113,7 +113,7 @@ interface WatchlistItemDto {
|
|
|
113
113
|
interface ToggleWatchlistResponseDto {
|
|
114
114
|
items: WatchlistItemDto[];
|
|
115
115
|
}
|
|
116
|
-
type NotificationCategory =
|
|
116
|
+
type NotificationCategory = "TRADE_OPENED_OUTSIDE_PEAR" | "TRADE_CLOSED_OUTSIDE_PEAR" | "POSITION_LIQUIDATED" | "LIMIT_ORDER_FILLED" | "LIMIT_ORDER_FAILED" | "TP_ORDER_FILLED" | "TP_ORDER_FAILED" | "SL_ORDER_FILLED" | "SL_ORDER_FAILED";
|
|
117
117
|
interface NotificationDto {
|
|
118
118
|
id: string;
|
|
119
119
|
address: string;
|
|
@@ -130,7 +130,7 @@ interface ChunkFillDto {
|
|
|
130
130
|
size: number;
|
|
131
131
|
executedAt: string;
|
|
132
132
|
}
|
|
133
|
-
type TwapChunkStatus =
|
|
133
|
+
type TwapChunkStatus = "PENDING" | "SCHEDULED" | "EXECUTING" | "COMPLETED" | "FAILED" | "CANCELLED";
|
|
134
134
|
interface TwapChunkStatusDto {
|
|
135
135
|
chunkId: string;
|
|
136
136
|
chunkIndex: number;
|
|
@@ -141,7 +141,7 @@ interface TwapChunkStatusDto {
|
|
|
141
141
|
fills: ChunkFillDto[];
|
|
142
142
|
errorMessage?: string;
|
|
143
143
|
}
|
|
144
|
-
type TwapOrderOverallStatus =
|
|
144
|
+
type TwapOrderOverallStatus = "OPEN" | "EXECUTING" | "COMPLETED" | "PARTIALLY_COMPLETED" | "FAILED" | "CANCELLED";
|
|
145
145
|
interface TwapMonitoringDto {
|
|
146
146
|
orderId: string;
|
|
147
147
|
positionId?: string;
|
|
@@ -232,7 +232,7 @@ interface PositionAssetDetailDto {
|
|
|
232
232
|
collateralToken?: CollateralToken;
|
|
233
233
|
}
|
|
234
234
|
interface TpSlThreshold {
|
|
235
|
-
type:
|
|
235
|
+
type: "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE";
|
|
236
236
|
value: number;
|
|
237
237
|
}
|
|
238
238
|
/**
|
|
@@ -267,16 +267,16 @@ interface OrderAssetDto {
|
|
|
267
267
|
/**
|
|
268
268
|
* Order status
|
|
269
269
|
*/
|
|
270
|
-
type OrderStatus =
|
|
270
|
+
type OrderStatus = "OPEN" | "PARTIALLY_FILLED" | "PROCESSING";
|
|
271
271
|
/**
|
|
272
272
|
* Order type
|
|
273
273
|
*/
|
|
274
|
-
type OrderType =
|
|
274
|
+
type OrderType = "TP" | "SL" | "LIMIT" | "MARKET" | "LIMIT_BTCDOM" | "TWAP";
|
|
275
275
|
/**
|
|
276
276
|
* TP/SL trigger type
|
|
277
277
|
*/
|
|
278
|
-
type TpSlTriggerType =
|
|
279
|
-
type OrderDirection =
|
|
278
|
+
type TpSlTriggerType = "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE";
|
|
279
|
+
type OrderDirection = "MORE_THAN" | "LESS_THAN" | null;
|
|
280
280
|
/**
|
|
281
281
|
* Open limit order data structure
|
|
282
282
|
*/
|
|
@@ -347,6 +347,7 @@ interface PlatformAccountSummaryResponseDto {
|
|
|
347
347
|
*/
|
|
348
348
|
interface AccountSummaryResponseDto {
|
|
349
349
|
balanceSummary: BalanceSummaryDto;
|
|
350
|
+
platformAccountSummary: PlatformAccountSummaryResponseDto | null;
|
|
350
351
|
agentWallet?: AgentWalletDto;
|
|
351
352
|
}
|
|
352
353
|
interface UseAuthOptions {
|
|
@@ -381,7 +382,7 @@ interface RefreshTokenResponse {
|
|
|
381
382
|
tokenType: string;
|
|
382
383
|
expiresIn: number;
|
|
383
384
|
}
|
|
384
|
-
type AgentWalletStatus =
|
|
385
|
+
type AgentWalletStatus = "ACTIVE" | "EXPIRED" | "NOT_FOUND";
|
|
385
386
|
interface CreateAgentWalletResponseDto {
|
|
386
387
|
agentWalletAddress: string;
|
|
387
388
|
message: string;
|
|
@@ -394,7 +395,7 @@ interface ExtraAgent {
|
|
|
394
395
|
interface AgentWalletState {
|
|
395
396
|
address: string | null;
|
|
396
397
|
name: string | null;
|
|
397
|
-
status: AgentWalletStatus |
|
|
398
|
+
status: AgentWalletStatus | "PENDING" | null;
|
|
398
399
|
isActive: boolean;
|
|
399
400
|
}
|
|
400
401
|
/**
|
|
@@ -414,7 +415,7 @@ interface WebSocketMessage {
|
|
|
414
415
|
/**
|
|
415
416
|
* WebSocket response from HyperLiquid native API
|
|
416
417
|
*/
|
|
417
|
-
type HLChannel =
|
|
418
|
+
type HLChannel = "webData3" | "allMids" | "activeAssetData" | "candle";
|
|
418
419
|
interface HLChannelDataMap {
|
|
419
420
|
webData3: WebData3Response;
|
|
420
421
|
allMids: WsAllMidsData;
|
|
@@ -623,7 +624,7 @@ interface TokenSelection {
|
|
|
623
624
|
*/
|
|
624
625
|
interface TokenConflict {
|
|
625
626
|
symbol: string;
|
|
626
|
-
conflictType:
|
|
627
|
+
conflictType: "long" | "short";
|
|
627
628
|
conflictMessage: string;
|
|
628
629
|
}
|
|
629
630
|
interface AssetMarketData {
|
|
@@ -685,7 +686,7 @@ interface ActiveAssetsAllResponse {
|
|
|
685
686
|
/**
|
|
686
687
|
* Candle interval options
|
|
687
688
|
*/
|
|
688
|
-
type CandleInterval =
|
|
689
|
+
type CandleInterval = "1m" | "3m" | "5m" | "15m" | "30m" | "1h" | "2h" | "4h" | "8h" | "12h" | "1d" | "3d" | "1w" | "1M";
|
|
689
690
|
/**
|
|
690
691
|
* Candle data structure from WebSocket
|
|
691
692
|
*/
|
|
@@ -922,6 +923,47 @@ interface CancelTwapResponseDto {
|
|
|
922
923
|
cancelledAt: string;
|
|
923
924
|
}
|
|
924
925
|
declare function cancelTwapOrder(baseUrl: string, orderId: string): Promise<ApiResponse<CancelTwapResponseDto>>;
|
|
926
|
+
interface SpotOrderRequestInput {
|
|
927
|
+
/** Asset to buy/sell (e.g., "USDH") */
|
|
928
|
+
asset: string;
|
|
929
|
+
/** Whether to buy (true) or sell (false) the asset */
|
|
930
|
+
isBuy: boolean;
|
|
931
|
+
/** Amount of asset to buy/sell (minimum: 11) */
|
|
932
|
+
amount: number;
|
|
933
|
+
}
|
|
934
|
+
/** Filled order status from Hyperliquid */
|
|
935
|
+
interface SpotOrderFilledStatus {
|
|
936
|
+
filled: {
|
|
937
|
+
totalSz: string;
|
|
938
|
+
avgPx: string;
|
|
939
|
+
oid: number;
|
|
940
|
+
cloid: string;
|
|
941
|
+
};
|
|
942
|
+
}
|
|
943
|
+
/** Hyperliquid order response data */
|
|
944
|
+
interface SpotOrderHyperliquidData {
|
|
945
|
+
statuses: SpotOrderFilledStatus[];
|
|
946
|
+
}
|
|
947
|
+
/** Hyperliquid result from spot order execution */
|
|
948
|
+
interface SpotOrderHyperliquidResult {
|
|
949
|
+
status: 'ok' | 'error';
|
|
950
|
+
response: {
|
|
951
|
+
type: 'order';
|
|
952
|
+
data: SpotOrderHyperliquidData;
|
|
953
|
+
};
|
|
954
|
+
}
|
|
955
|
+
interface SpotOrderResponseDto {
|
|
956
|
+
orderId: string;
|
|
957
|
+
status: 'EXECUTED' | 'FAILED' | 'PENDING';
|
|
958
|
+
asset: string;
|
|
959
|
+
createdAt: string;
|
|
960
|
+
hyperliquidResult?: SpotOrderHyperliquidResult;
|
|
961
|
+
}
|
|
962
|
+
/**
|
|
963
|
+
* Execute a spot order (swap) using Pear Hyperliquid service
|
|
964
|
+
* POST /orders/spot
|
|
965
|
+
*/
|
|
966
|
+
declare function executeSpotOrder(baseUrl: string, payload: SpotOrderRequestInput): Promise<ApiResponse<SpotOrderResponseDto>>;
|
|
925
967
|
|
|
926
968
|
type ExecutionType = "MARKET" | "LIMIT" | "TWAP" | "LADDER" | "LIMIT_BTCDOM";
|
|
927
969
|
type TpSlThresholdType = "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE";
|
|
@@ -1068,6 +1110,18 @@ declare function useOrders(): {
|
|
|
1068
1110
|
readonly isLoading: boolean;
|
|
1069
1111
|
};
|
|
1070
1112
|
|
|
1113
|
+
interface UseSpotOrderResult {
|
|
1114
|
+
executeSpotOrder: (payload: SpotOrderRequestInput) => Promise<ApiResponse<SpotOrderResponseDto>>;
|
|
1115
|
+
isLoading: boolean;
|
|
1116
|
+
error: ApiErrorResponse | null;
|
|
1117
|
+
resetError: () => void;
|
|
1118
|
+
}
|
|
1119
|
+
/**
|
|
1120
|
+
* Hook for executing spot orders (swaps) on Hyperliquid
|
|
1121
|
+
* Use this to swap between USDC and USDH or other spot assets
|
|
1122
|
+
*/
|
|
1123
|
+
declare function useSpotOrder(): UseSpotOrderResult;
|
|
1124
|
+
|
|
1071
1125
|
declare function useTwap(): {
|
|
1072
1126
|
readonly orders: TwapMonitoringDto[];
|
|
1073
1127
|
readonly cancelTwap: (orderId: string) => Promise<ApiResponse<CancelTwapResponseDto>>;
|
|
@@ -1392,5 +1446,5 @@ declare function isHip3Market(symbol: string): boolean;
|
|
|
1392
1446
|
|
|
1393
1447
|
declare const useMarketData: any;
|
|
1394
1448
|
|
|
1395
|
-
export { AccountSummaryCalculator, ConflictDetector, MINIMUM_ASSET_USD_VALUE, MinimumPositionSizeError, PearHyperliquidProvider, TokenMetadataExtractor, adjustAdvancePosition, adjustOrder, adjustPosition, calculateMinimumPositionValue, calculateWeightedRatio, cancelOrder, cancelTwap, cancelTwapOrder, closeAllPositions, closePosition, computeBasketCandles, createCandleLookups, createPosition, getAvailableMarkets, getCompleteTimestamps, getMarketPrefix, getPortfolio, isHip3Market, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, markNotificationReadById, markNotificationsRead, toBackendSymbol, toBackendSymbolWithMarket, toDisplaySymbol, toggleWatchlist, updateRiskParameters, useAccountSummary, useActiveBaskets, useAgentWallet, useAllBaskets, useAuth, useAutoSyncFills, useBasketCandles, useFindBasket, useHighlightedBaskets, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidNativeWebSocket, useHyperliquidWebSocket, useMarketData, useMarketDataAllPayload, useMarketDataPayload, useNotifications, useOpenOrders, useOrders, usePearHyperliquid, usePerformanceOverlays, usePerpMetaAssets, usePortfolio, usePosition, useTokenSelectionMetadata, useTopGainers, useTopLosers, useTradeHistories, useTwap, useUserSelection, useWatchlist, useWatchlistBaskets, useWebData, validateMinimumAssetSize, validatePositionSize };
|
|
1396
|
-
export type { AccountSummaryResponseDto, ActiveAssetGroupItem, ActiveAssetsResponse, AdjustAdvanceAssetInput, AdjustAdvanceItemInput, AdjustAdvanceResponseDto, AdjustExecutionType, AdjustOrderRequestInput, AdjustOrderResponseDto, AdjustPositionRequestInput, AdjustPositionResponseDto, AgentWalletDto, AgentWalletState, ApiErrorResponse, ApiResponse, AssetCtx, AssetInformationDetail, AssetMarketData, AssetPosition, AutoSyncFillsOptions, AutoSyncFillsState, BalanceSummaryDto, CancelOrderResponseDto, CancelTwapResponseDto, CandleChartData, CandleData, CandleInterval, CandleSnapshotRequest, ClearinghouseState, CloseAllPositionsResponseDto, CloseAllPositionsResultDto, CloseExecutionType, ClosePositionRequestInput, ClosePositionResponseDto, CollateralFilter, CollateralToken, CreatePositionRequestInput, CreatePositionResponseDto, CrossMarginSummaryDto, CumFundingDto, ExecutionType, ExtraAgent, HLWebSocketResponse, HistoricalRange, LadderConfigInput, MarginSummaryDto, MarketDataBySymbol, NotificationCategory, NotificationDto, OpenLimitOrderDto, OpenPositionDto, OrderAssetDto, OrderStatus, PairAssetDto, PairAssetInput, PerformanceOverlay, PlatformAccountSummaryResponseDto, PortfolioBucketDto, PortfolioInterval, PortfolioIntervalsDto, PortfolioOverallDto, PortfolioResponseDto, PositionAdjustmentType, PositionAssetDetailDto, PositionAssetSummaryDto, PositionResponseStatus, RealtimeBar, RealtimeBarsCallback, ToggleWatchlistResponseDto, TokenConflict, TokenHistoricalPriceData, TokenMetadata, TokenSelection, TpSlThresholdInput, TpSlThresholdType, TradeHistoryAssetDataDto, TradeHistoryDataDto, TwapChunkStatusDto, TwapMonitoringDto, TwapSliceFillResponseItem, UniverseAsset, UpdateRiskParametersRequestInput, UpdateRiskParametersResponseDto, UseAuthOptions, UseBasketCandlesReturn, UseHistoricalPriceDataReturn, UseNotificationsResult, UsePerformanceOverlaysReturn, UsePortfolioResult, UseTokenSelectionMetadataReturn, UserProfile, UserSelectionState, WatchlistItemDto, WebSocketAckResponse, WebSocketChannel, WebSocketConnectionState, WebSocketDataMessage, WebSocketMessage, WebSocketSubscribeMessage, WsAllMidsData };
|
|
1449
|
+
export { AccountSummaryCalculator, ConflictDetector, MINIMUM_ASSET_USD_VALUE, MinimumPositionSizeError, PearHyperliquidProvider, TokenMetadataExtractor, adjustAdvancePosition, adjustOrder, adjustPosition, calculateMinimumPositionValue, calculateWeightedRatio, cancelOrder, cancelTwap, cancelTwapOrder, closeAllPositions, closePosition, computeBasketCandles, createCandleLookups, createPosition, executeSpotOrder, getAvailableMarkets, getCompleteTimestamps, getMarketPrefix, getPortfolio, isHip3Market, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, markNotificationReadById, markNotificationsRead, toBackendSymbol, toBackendSymbolWithMarket, toDisplaySymbol, toggleWatchlist, updateRiskParameters, useAccountSummary, useActiveBaskets, useAgentWallet, useAllBaskets, useAuth, useAutoSyncFills, useBasketCandles, useFindBasket, useHighlightedBaskets, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidNativeWebSocket, useHyperliquidWebSocket, useMarketData, useMarketDataAllPayload, useMarketDataPayload, useNotifications, useOpenOrders, useOrders, usePearHyperliquid, usePerformanceOverlays, usePerpMetaAssets, usePortfolio, usePosition, useSpotOrder, useTokenSelectionMetadata, useTopGainers, useTopLosers, useTradeHistories, useTwap, useUserSelection, useWatchlist, useWatchlistBaskets, useWebData, validateMinimumAssetSize, validatePositionSize };
|
|
1450
|
+
export type { AccountSummaryResponseDto, ActiveAssetGroupItem, ActiveAssetsResponse, AdjustAdvanceAssetInput, AdjustAdvanceItemInput, AdjustAdvanceResponseDto, AdjustExecutionType, AdjustOrderRequestInput, AdjustOrderResponseDto, AdjustPositionRequestInput, AdjustPositionResponseDto, AgentWalletDto, AgentWalletState, ApiErrorResponse, ApiResponse, AssetCtx, AssetInformationDetail, AssetMarketData, AssetPosition, AutoSyncFillsOptions, AutoSyncFillsState, BalanceSummaryDto, CancelOrderResponseDto, CancelTwapResponseDto, CandleChartData, CandleData, CandleInterval, CandleSnapshotRequest, ClearinghouseState, CloseAllPositionsResponseDto, CloseAllPositionsResultDto, CloseExecutionType, ClosePositionRequestInput, ClosePositionResponseDto, CollateralFilter, CollateralToken, CreatePositionRequestInput, CreatePositionResponseDto, CrossMarginSummaryDto, CumFundingDto, ExecutionType, ExtraAgent, HLWebSocketResponse, HistoricalRange, LadderConfigInput, MarginSummaryDto, MarketDataBySymbol, NotificationCategory, NotificationDto, OpenLimitOrderDto, OpenPositionDto, OrderAssetDto, OrderStatus, PairAssetDto, PairAssetInput, PerformanceOverlay, PlatformAccountSummaryResponseDto, PortfolioBucketDto, PortfolioInterval, PortfolioIntervalsDto, PortfolioOverallDto, PortfolioResponseDto, PositionAdjustmentType, PositionAssetDetailDto, PositionAssetSummaryDto, PositionResponseStatus, RealtimeBar, RealtimeBarsCallback, SpotOrderFilledStatus, SpotOrderHyperliquidData, SpotOrderHyperliquidResult, SpotOrderRequestInput, SpotOrderResponseDto, ToggleWatchlistResponseDto, TokenConflict, TokenHistoricalPriceData, TokenMetadata, TokenSelection, TpSlThresholdInput, TpSlThresholdType, TradeHistoryAssetDataDto, TradeHistoryDataDto, TwapChunkStatusDto, TwapMonitoringDto, TwapSliceFillResponseItem, UniverseAsset, UpdateRiskParametersRequestInput, UpdateRiskParametersResponseDto, UseAuthOptions, UseBasketCandlesReturn, UseHistoricalPriceDataReturn, UseNotificationsResult, UsePerformanceOverlaysReturn, UsePortfolioResult, UseSpotOrderResult, UseTokenSelectionMetadataReturn, UserProfile, UserSelectionState, WatchlistItemDto, WebSocketAckResponse, WebSocketChannel, WebSocketConnectionState, WebSocketDataMessage, WebSocketMessage, WebSocketSubscribeMessage, WsAllMidsData };
|
package/dist/index.js
CHANGED
|
@@ -956,31 +956,40 @@ class AccountSummaryCalculator {
|
|
|
956
956
|
return null;
|
|
957
957
|
}
|
|
958
958
|
const clearinghouseState = this.clearinghouseState;
|
|
959
|
-
const withdrawableAmount = parseFloat(clearinghouseState.withdrawable ||
|
|
960
|
-
const adjustedWithdrawable = Math.max(0, withdrawableAmount -
|
|
959
|
+
const withdrawableAmount = parseFloat(clearinghouseState.withdrawable || "0");
|
|
960
|
+
const adjustedWithdrawable = Math.max(0, withdrawableAmount -
|
|
961
|
+
((_a = platformAccountSummary === null || platformAccountSummary === void 0 ? void 0 : platformAccountSummary.totalTwapChunkUsdValue) !== null && _a !== void 0 ? _a : 0) -
|
|
962
|
+
((_b = platformAccountSummary === null || platformAccountSummary === void 0 ? void 0 : platformAccountSummary.totalLimitOrderUsdValue) !== null && _b !== void 0 ? _b : 0));
|
|
961
963
|
const accountSummary = {
|
|
962
964
|
balanceSummary: {
|
|
963
|
-
crossMaintenanceMarginUsed: clearinghouseState.crossMaintenanceMarginUsed ||
|
|
965
|
+
crossMaintenanceMarginUsed: clearinghouseState.crossMaintenanceMarginUsed || "0",
|
|
964
966
|
crossMarginSummary: {
|
|
965
|
-
accountValue: ((_c = clearinghouseState.crossMarginSummary) === null || _c === void 0 ? void 0 : _c.accountValue) ||
|
|
966
|
-
totalMarginUsed: ((_d = clearinghouseState.crossMarginSummary) === null || _d === void 0 ? void 0 : _d.totalMarginUsed) ||
|
|
967
|
-
totalNtlPos: ((_e = clearinghouseState.crossMarginSummary) === null || _e === void 0 ? void 0 : _e.totalNtlPos) ||
|
|
968
|
-
totalRawUsd: ((_f = clearinghouseState.crossMarginSummary) === null || _f === void 0 ? void 0 : _f.totalRawUsd) ||
|
|
967
|
+
accountValue: ((_c = clearinghouseState.crossMarginSummary) === null || _c === void 0 ? void 0 : _c.accountValue) || "0",
|
|
968
|
+
totalMarginUsed: ((_d = clearinghouseState.crossMarginSummary) === null || _d === void 0 ? void 0 : _d.totalMarginUsed) || "0",
|
|
969
|
+
totalNtlPos: ((_e = clearinghouseState.crossMarginSummary) === null || _e === void 0 ? void 0 : _e.totalNtlPos) || "0",
|
|
970
|
+
totalRawUsd: ((_f = clearinghouseState.crossMarginSummary) === null || _f === void 0 ? void 0 : _f.totalRawUsd) || "0",
|
|
969
971
|
},
|
|
970
972
|
marginSummary: {
|
|
971
|
-
accountValue: ((_g = clearinghouseState.marginSummary) === null || _g === void 0 ? void 0 : _g.accountValue) ||
|
|
972
|
-
totalMarginUsed: ((_h = clearinghouseState.marginSummary) === null || _h === void 0 ? void 0 : _h.totalMarginUsed) ||
|
|
973
|
-
totalNtlPos: ((_j = clearinghouseState.marginSummary) === null || _j === void 0 ? void 0 : _j.totalNtlPos) ||
|
|
974
|
-
totalRawUsd: ((_k = clearinghouseState.marginSummary) === null || _k === void 0 ? void 0 : _k.totalRawUsd) ||
|
|
973
|
+
accountValue: ((_g = clearinghouseState.marginSummary) === null || _g === void 0 ? void 0 : _g.accountValue) || "0",
|
|
974
|
+
totalMarginUsed: ((_h = clearinghouseState.marginSummary) === null || _h === void 0 ? void 0 : _h.totalMarginUsed) || "0",
|
|
975
|
+
totalNtlPos: ((_j = clearinghouseState.marginSummary) === null || _j === void 0 ? void 0 : _j.totalNtlPos) || "0",
|
|
976
|
+
totalRawUsd: ((_k = clearinghouseState.marginSummary) === null || _k === void 0 ? void 0 : _k.totalRawUsd) || "0",
|
|
975
977
|
},
|
|
976
978
|
time: clearinghouseState.time || Date.now(),
|
|
977
|
-
withdrawable: adjustedWithdrawable.toString()
|
|
978
|
-
}
|
|
979
|
+
withdrawable: adjustedWithdrawable.toString(),
|
|
980
|
+
},
|
|
981
|
+
platformAccountSummary,
|
|
979
982
|
};
|
|
980
983
|
if (platformAccountSummary === null || platformAccountSummary === void 0 ? void 0 : platformAccountSummary.agentWalletAddress) {
|
|
981
984
|
accountSummary.agentWallet = {
|
|
982
985
|
address: platformAccountSummary.agentWalletAddress,
|
|
983
|
-
status: registeredAgentWallets.find((agent) => {
|
|
986
|
+
status: registeredAgentWallets.find((agent) => {
|
|
987
|
+
var _a;
|
|
988
|
+
return agent.address.toLowerCase() ===
|
|
989
|
+
((_a = platformAccountSummary.agentWalletAddress) === null || _a === void 0 ? void 0 : _a.toLowerCase());
|
|
990
|
+
})
|
|
991
|
+
? "ACTIVE"
|
|
992
|
+
: "EXPIRED",
|
|
984
993
|
};
|
|
985
994
|
}
|
|
986
995
|
return accountSummary;
|
|
@@ -6981,8 +6990,15 @@ function usePosition() {
|
|
|
6981
6990
|
async function adjustOrder(baseUrl, orderId, payload) {
|
|
6982
6991
|
const url = joinUrl(baseUrl, `/orders/${orderId}/adjust`);
|
|
6983
6992
|
try {
|
|
6984
|
-
const resp = await apiClient.put(url, payload, {
|
|
6985
|
-
|
|
6993
|
+
const resp = await apiClient.put(url, payload, {
|
|
6994
|
+
headers: { 'Content-Type': 'application/json' },
|
|
6995
|
+
timeout: 60000,
|
|
6996
|
+
});
|
|
6997
|
+
return {
|
|
6998
|
+
data: resp.data,
|
|
6999
|
+
status: resp.status,
|
|
7000
|
+
headers: resp.headers,
|
|
7001
|
+
};
|
|
6986
7002
|
}
|
|
6987
7003
|
catch (error) {
|
|
6988
7004
|
throw toApiError(error);
|
|
@@ -6991,8 +7007,14 @@ async function adjustOrder(baseUrl, orderId, payload) {
|
|
|
6991
7007
|
async function cancelOrder(baseUrl, orderId) {
|
|
6992
7008
|
const url = joinUrl(baseUrl, `/orders/${orderId}/cancel`);
|
|
6993
7009
|
try {
|
|
6994
|
-
const resp = await apiClient.delete(url, {
|
|
6995
|
-
|
|
7010
|
+
const resp = await apiClient.delete(url, {
|
|
7011
|
+
timeout: 60000,
|
|
7012
|
+
});
|
|
7013
|
+
return {
|
|
7014
|
+
data: resp.data,
|
|
7015
|
+
status: resp.status,
|
|
7016
|
+
headers: resp.headers,
|
|
7017
|
+
};
|
|
6996
7018
|
}
|
|
6997
7019
|
catch (error) {
|
|
6998
7020
|
throw toApiError(error);
|
|
@@ -7002,7 +7024,32 @@ async function cancelTwapOrder(baseUrl, orderId) {
|
|
|
7002
7024
|
const url = joinUrl(baseUrl, `/orders/${orderId}/twap/cancel`);
|
|
7003
7025
|
try {
|
|
7004
7026
|
const resp = await apiClient.post(url, {}, { headers: { 'Content-Type': 'application/json' }, timeout: 60000 });
|
|
7005
|
-
return {
|
|
7027
|
+
return {
|
|
7028
|
+
data: resp.data,
|
|
7029
|
+
status: resp.status,
|
|
7030
|
+
headers: resp.headers,
|
|
7031
|
+
};
|
|
7032
|
+
}
|
|
7033
|
+
catch (error) {
|
|
7034
|
+
throw toApiError(error);
|
|
7035
|
+
}
|
|
7036
|
+
}
|
|
7037
|
+
/**
|
|
7038
|
+
* Execute a spot order (swap) using Pear Hyperliquid service
|
|
7039
|
+
* POST /orders/spot
|
|
7040
|
+
*/
|
|
7041
|
+
async function executeSpotOrder(baseUrl, payload) {
|
|
7042
|
+
const url = joinUrl(baseUrl, '/orders/spot');
|
|
7043
|
+
try {
|
|
7044
|
+
const resp = await apiClient.post(url, payload, {
|
|
7045
|
+
headers: { 'Content-Type': 'application/json' },
|
|
7046
|
+
timeout: 60000,
|
|
7047
|
+
});
|
|
7048
|
+
return {
|
|
7049
|
+
data: resp.data,
|
|
7050
|
+
status: resp.status,
|
|
7051
|
+
headers: resp.headers,
|
|
7052
|
+
};
|
|
7006
7053
|
}
|
|
7007
7054
|
catch (error) {
|
|
7008
7055
|
throw toApiError(error);
|
|
@@ -7058,6 +7105,45 @@ function useOrders() {
|
|
|
7058
7105
|
return { adjustOrder: adjustOrder$1, cancelOrder: cancelOrder$1, cancelTwapOrder: cancelTwapOrder$1, openOrders: enrichedOpenOrders, isLoading };
|
|
7059
7106
|
}
|
|
7060
7107
|
|
|
7108
|
+
/**
|
|
7109
|
+
* Hook for executing spot orders (swaps) on Hyperliquid
|
|
7110
|
+
* Use this to swap between USDC and USDH or other spot assets
|
|
7111
|
+
*/
|
|
7112
|
+
function useSpotOrder() {
|
|
7113
|
+
const context = useContext(PearHyperliquidContext);
|
|
7114
|
+
if (!context) {
|
|
7115
|
+
throw new Error('useSpotOrder must be used within a PearHyperliquidProvider');
|
|
7116
|
+
}
|
|
7117
|
+
const { apiBaseUrl } = context;
|
|
7118
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
7119
|
+
const [error, setError] = useState(null);
|
|
7120
|
+
const resetError = useCallback(() => {
|
|
7121
|
+
setError(null);
|
|
7122
|
+
}, []);
|
|
7123
|
+
const executeSpotOrder$1 = useCallback(async (payload) => {
|
|
7124
|
+
setIsLoading(true);
|
|
7125
|
+
setError(null);
|
|
7126
|
+
try {
|
|
7127
|
+
const response = await executeSpotOrder(apiBaseUrl, payload);
|
|
7128
|
+
return response;
|
|
7129
|
+
}
|
|
7130
|
+
catch (err) {
|
|
7131
|
+
const apiError = err;
|
|
7132
|
+
setError(apiError);
|
|
7133
|
+
throw apiError;
|
|
7134
|
+
}
|
|
7135
|
+
finally {
|
|
7136
|
+
setIsLoading(false);
|
|
7137
|
+
}
|
|
7138
|
+
}, [apiBaseUrl]);
|
|
7139
|
+
return {
|
|
7140
|
+
executeSpotOrder: executeSpotOrder$1,
|
|
7141
|
+
isLoading,
|
|
7142
|
+
error,
|
|
7143
|
+
resetError,
|
|
7144
|
+
};
|
|
7145
|
+
}
|
|
7146
|
+
|
|
7061
7147
|
function useTwap() {
|
|
7062
7148
|
const twapDetails = useUserData(state => state.twapDetails);
|
|
7063
7149
|
const context = useContext(PearHyperliquidContext);
|
|
@@ -7483,7 +7569,7 @@ async function logout(baseUrl, refreshTokenVal) {
|
|
|
7483
7569
|
function useAuth() {
|
|
7484
7570
|
const context = useContext(PearHyperliquidContext);
|
|
7485
7571
|
if (!context) {
|
|
7486
|
-
throw new Error(
|
|
7572
|
+
throw new Error("usePortfolio must be used within a PearHyperliquidProvider");
|
|
7487
7573
|
}
|
|
7488
7574
|
const { apiBaseUrl, clientId } = context;
|
|
7489
7575
|
const [isReady, setIsReady] = useState(false);
|
|
@@ -7495,12 +7581,12 @@ function useAuth() {
|
|
|
7495
7581
|
const setIsAuthenticated = useUserData((s) => s.setIsAuthenticated);
|
|
7496
7582
|
const setAddress = useUserData((s) => s.setAddress);
|
|
7497
7583
|
useEffect(() => {
|
|
7498
|
-
if (typeof window ==
|
|
7584
|
+
if (typeof window == "undefined") {
|
|
7499
7585
|
return;
|
|
7500
7586
|
}
|
|
7501
|
-
const access = localStorage.getItem(
|
|
7502
|
-
const refresh = localStorage.getItem(
|
|
7503
|
-
const addr = localStorage.getItem(
|
|
7587
|
+
const access = localStorage.getItem("accessToken");
|
|
7588
|
+
const refresh = localStorage.getItem("refreshToken");
|
|
7589
|
+
const addr = localStorage.getItem("address");
|
|
7504
7590
|
setAccessToken(access);
|
|
7505
7591
|
setRefreshToken(refresh);
|
|
7506
7592
|
setAddress(addr);
|
|
@@ -7512,7 +7598,9 @@ function useAuth() {
|
|
|
7512
7598
|
const cleanup = addAuthInterceptors({
|
|
7513
7599
|
apiBaseUrl,
|
|
7514
7600
|
getAccessToken: () => {
|
|
7515
|
-
return typeof window !==
|
|
7601
|
+
return typeof window !== "undefined"
|
|
7602
|
+
? window.localStorage.getItem("accessToken")
|
|
7603
|
+
: null;
|
|
7516
7604
|
},
|
|
7517
7605
|
refreshTokens: async () => {
|
|
7518
7606
|
const data = await refreshTokens();
|
|
@@ -7533,14 +7621,14 @@ function useAuth() {
|
|
|
7533
7621
|
async function loginWithSignedMessage(address, signature, timestamp) {
|
|
7534
7622
|
try {
|
|
7535
7623
|
const { data } = await authenticate(apiBaseUrl, {
|
|
7536
|
-
method:
|
|
7624
|
+
method: "eip712",
|
|
7537
7625
|
address,
|
|
7538
7626
|
clientId,
|
|
7539
7627
|
details: { signature, timestamp },
|
|
7540
7628
|
});
|
|
7541
|
-
window.localStorage.setItem(
|
|
7542
|
-
window.localStorage.setItem(
|
|
7543
|
-
window.localStorage.setItem(
|
|
7629
|
+
window.localStorage.setItem("accessToken", data.accessToken);
|
|
7630
|
+
window.localStorage.setItem("refreshToken", data.refreshToken);
|
|
7631
|
+
window.localStorage.setItem("address", address);
|
|
7544
7632
|
setAccessToken(data.accessToken);
|
|
7545
7633
|
setRefreshToken(data.refreshToken);
|
|
7546
7634
|
setAddress(address);
|
|
@@ -7552,10 +7640,15 @@ function useAuth() {
|
|
|
7552
7640
|
}
|
|
7553
7641
|
async function loginWithPrivyToken(address, appId, privyAccessToken) {
|
|
7554
7642
|
try {
|
|
7555
|
-
const { data } = await authenticateWithPrivy(apiBaseUrl, {
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
7643
|
+
const { data } = await authenticateWithPrivy(apiBaseUrl, {
|
|
7644
|
+
address,
|
|
7645
|
+
clientId,
|
|
7646
|
+
appId,
|
|
7647
|
+
accessToken: privyAccessToken,
|
|
7648
|
+
});
|
|
7649
|
+
window.localStorage.setItem("accessToken", data.accessToken);
|
|
7650
|
+
window.localStorage.setItem("refreshToken", data.refreshToken);
|
|
7651
|
+
window.localStorage.setItem("address", address);
|
|
7559
7652
|
setAccessToken(data.accessToken);
|
|
7560
7653
|
setRefreshToken(data.refreshToken);
|
|
7561
7654
|
setAddress(address);
|
|
@@ -7566,28 +7659,30 @@ function useAuth() {
|
|
|
7566
7659
|
}
|
|
7567
7660
|
}
|
|
7568
7661
|
async function refreshTokens() {
|
|
7569
|
-
const refresh = window.localStorage.getItem(
|
|
7662
|
+
const refresh = window.localStorage.getItem("refreshToken");
|
|
7570
7663
|
if (!refresh)
|
|
7571
|
-
throw new Error(
|
|
7664
|
+
throw new Error("No refresh token");
|
|
7572
7665
|
const { data } = await refreshToken(apiBaseUrl, refresh);
|
|
7573
|
-
window.localStorage.setItem(
|
|
7574
|
-
window.localStorage.setItem(
|
|
7666
|
+
window.localStorage.setItem("accessToken", data.accessToken);
|
|
7667
|
+
window.localStorage.setItem("refreshToken", data.refreshToken);
|
|
7575
7668
|
setAccessToken(data.accessToken);
|
|
7576
7669
|
setRefreshToken(data.refreshToken);
|
|
7577
7670
|
setIsAuthenticated(true);
|
|
7578
7671
|
return data;
|
|
7579
7672
|
}
|
|
7580
7673
|
async function logout$1() {
|
|
7581
|
-
const refresh = window.localStorage.getItem(
|
|
7674
|
+
const refresh = window.localStorage.getItem("refreshToken");
|
|
7582
7675
|
if (refresh) {
|
|
7583
7676
|
try {
|
|
7584
7677
|
await logout(apiBaseUrl, refresh);
|
|
7585
7678
|
}
|
|
7586
|
-
catch (
|
|
7679
|
+
catch (_a) {
|
|
7680
|
+
/* ignore */
|
|
7681
|
+
}
|
|
7587
7682
|
}
|
|
7588
|
-
window.localStorage.removeItem(
|
|
7589
|
-
window.localStorage.removeItem(
|
|
7590
|
-
window.localStorage.removeItem(
|
|
7683
|
+
window.localStorage.removeItem("accessToken");
|
|
7684
|
+
window.localStorage.removeItem("refreshToken");
|
|
7685
|
+
window.localStorage.removeItem("address");
|
|
7591
7686
|
setAccessToken(null);
|
|
7592
7687
|
setRefreshToken(null);
|
|
7593
7688
|
setAddress(null);
|
|
@@ -7610,7 +7705,7 @@ const PearHyperliquidContext = createContext(undefined);
|
|
|
7610
7705
|
/**
|
|
7611
7706
|
* React Provider for PearHyperliquidClient
|
|
7612
7707
|
*/
|
|
7613
|
-
const PearHyperliquidProvider = ({ children, apiBaseUrl =
|
|
7708
|
+
const PearHyperliquidProvider = ({ children, apiBaseUrl = "https://hl-v2.pearprotocol.io", clientId = "PEARPROTOCOLUI", wsUrl = "wss://hl-v2.pearprotocol.io/ws", }) => {
|
|
7614
7709
|
const address = useUserData((s) => s.address);
|
|
7615
7710
|
const setAddress = useUserData((s) => s.setAddress);
|
|
7616
7711
|
const perpsMetaAssets = useHyperliquidData((state) => state.perpMetaAssets);
|
|
@@ -7638,10 +7733,10 @@ const PearHyperliquidProvider = ({ children, apiBaseUrl = 'https://hl-v2.pearpro
|
|
|
7638
7733
|
// Process each market group (different collateral tokens)
|
|
7639
7734
|
res.data.forEach((item) => {
|
|
7640
7735
|
// Convert numeric collateral token to human-readable name
|
|
7641
|
-
const collateralToken = item.collateralToken === 360 ?
|
|
7736
|
+
const collateralToken = item.collateralToken === 360 ? "USDH" : "USDC";
|
|
7642
7737
|
item.universe.forEach((asset) => {
|
|
7643
7738
|
var _a;
|
|
7644
|
-
const [maybePrefix, maybeMarket] = asset.name.split(
|
|
7739
|
+
const [maybePrefix, maybeMarket] = asset.name.split(":");
|
|
7645
7740
|
if (maybeMarket) {
|
|
7646
7741
|
// HIP-3 market with prefix (e.g., "xyz:TSLA")
|
|
7647
7742
|
const prefix = maybePrefix.toLowerCase();
|
|
@@ -7725,7 +7820,7 @@ const PearHyperliquidProvider = ({ children, apiBaseUrl = 'https://hl-v2.pearpro
|
|
|
7725
7820
|
function usePearHyperliquid() {
|
|
7726
7821
|
const ctx = useContext(PearHyperliquidContext);
|
|
7727
7822
|
if (!ctx)
|
|
7728
|
-
throw new Error(
|
|
7823
|
+
throw new Error("usePearHyperliquid must be used within a PearHyperliquidProvider");
|
|
7729
7824
|
return ctx;
|
|
7730
7825
|
}
|
|
7731
7826
|
|
|
@@ -7816,4 +7911,4 @@ function mapCandleIntervalToTradingViewInterval(interval) {
|
|
|
7816
7911
|
}
|
|
7817
7912
|
}
|
|
7818
7913
|
|
|
7819
|
-
export { AccountSummaryCalculator, ConflictDetector, MINIMUM_ASSET_USD_VALUE, MinimumPositionSizeError, PearHyperliquidProvider, TokenMetadataExtractor, adjustAdvancePosition, adjustOrder, adjustPosition, calculateMinimumPositionValue, calculateWeightedRatio, cancelOrder, cancelTwap, cancelTwapOrder, closeAllPositions, closePosition, computeBasketCandles, createCandleLookups, createPosition, getAvailableMarkets, getCompleteTimestamps, getMarketPrefix, getPortfolio, isHip3Market, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, markNotificationReadById, markNotificationsRead, toBackendSymbol, toBackendSymbolWithMarket, toDisplaySymbol, toggleWatchlist, updateRiskParameters, useAccountSummary, useActiveBaskets, useAgentWallet, useAllBaskets, useAuth, useAutoSyncFills, useBasketCandles, useFindBasket, useHighlightedBaskets, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidNativeWebSocket, useHyperliquidWebSocket, useMarketData, useMarketDataAllPayload, useMarketDataPayload, useNotifications, useOpenOrders, useOrders, usePearHyperliquid, usePerformanceOverlays, usePerpMetaAssets, usePortfolio, usePosition, useTokenSelectionMetadata, useTopGainers, useTopLosers, useTradeHistories, useTwap, useUserSelection, useWatchlist, useWatchlistBaskets, useWebData, validateMinimumAssetSize, validatePositionSize };
|
|
7914
|
+
export { AccountSummaryCalculator, ConflictDetector, MINIMUM_ASSET_USD_VALUE, MinimumPositionSizeError, PearHyperliquidProvider, TokenMetadataExtractor, adjustAdvancePosition, adjustOrder, adjustPosition, calculateMinimumPositionValue, calculateWeightedRatio, cancelOrder, cancelTwap, cancelTwapOrder, closeAllPositions, closePosition, computeBasketCandles, createCandleLookups, createPosition, executeSpotOrder, getAvailableMarkets, getCompleteTimestamps, getMarketPrefix, getPortfolio, isHip3Market, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, markNotificationReadById, markNotificationsRead, toBackendSymbol, toBackendSymbolWithMarket, toDisplaySymbol, toggleWatchlist, updateRiskParameters, useAccountSummary, useActiveBaskets, useAgentWallet, useAllBaskets, useAuth, useAutoSyncFills, useBasketCandles, useFindBasket, useHighlightedBaskets, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidNativeWebSocket, useHyperliquidWebSocket, useMarketData, useMarketDataAllPayload, useMarketDataPayload, useNotifications, useOpenOrders, useOrders, usePearHyperliquid, usePerformanceOverlays, usePerpMetaAssets, usePortfolio, usePosition, useSpotOrder, useTokenSelectionMetadata, useTopGainers, useTopLosers, useTradeHistories, useTwap, useUserSelection, useWatchlist, useWatchlistBaskets, useWebData, validateMinimumAssetSize, validatePositionSize };
|
package/dist/provider.d.ts
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface ExternalFillDto {
|
|
|
20
20
|
coin: string;
|
|
21
21
|
px: string;
|
|
22
22
|
sz: string;
|
|
23
|
-
side:
|
|
23
|
+
side: "B" | "A";
|
|
24
24
|
time: number;
|
|
25
25
|
dir: string;
|
|
26
26
|
fee: string;
|
|
@@ -52,7 +52,7 @@ export interface TwapSliceFillResponseItem {
|
|
|
52
52
|
/**
|
|
53
53
|
* WebSocket connection states
|
|
54
54
|
*/
|
|
55
|
-
export type WebSocketConnectionState =
|
|
55
|
+
export type WebSocketConnectionState = "connecting" | "connected" | "disconnected" | "error";
|
|
56
56
|
export declare enum ReadyState {
|
|
57
57
|
CONNECTING = 0,
|
|
58
58
|
OPEN = 1,
|
|
@@ -62,12 +62,12 @@ export declare enum ReadyState {
|
|
|
62
62
|
/**
|
|
63
63
|
* WebSocket channels
|
|
64
64
|
*/
|
|
65
|
-
export type WebSocketChannel =
|
|
65
|
+
export type WebSocketChannel = "trade-histories" | "open-positions" | "open-orders" | "account-summary" | "twap-details" | "notifications" | "market-data" | "market-data-all" | "webData3" | "allMids" | "activeAssetData";
|
|
66
66
|
/**
|
|
67
67
|
* WebSocket subscription message
|
|
68
68
|
*/
|
|
69
69
|
export interface WebSocketSubscribeMessage {
|
|
70
|
-
action?:
|
|
70
|
+
action?: "subscribe" | "unsubscribe";
|
|
71
71
|
address: string;
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
@@ -97,7 +97,7 @@ export interface WatchlistItemDto {
|
|
|
97
97
|
export interface ToggleWatchlistResponseDto {
|
|
98
98
|
items: WatchlistItemDto[];
|
|
99
99
|
}
|
|
100
|
-
export type NotificationCategory =
|
|
100
|
+
export type NotificationCategory = "TRADE_OPENED_OUTSIDE_PEAR" | "TRADE_CLOSED_OUTSIDE_PEAR" | "POSITION_LIQUIDATED" | "LIMIT_ORDER_FILLED" | "LIMIT_ORDER_FAILED" | "TP_ORDER_FILLED" | "TP_ORDER_FAILED" | "SL_ORDER_FILLED" | "SL_ORDER_FAILED";
|
|
101
101
|
export interface NotificationDto {
|
|
102
102
|
id: string;
|
|
103
103
|
address: string;
|
|
@@ -114,7 +114,7 @@ export interface ChunkFillDto {
|
|
|
114
114
|
size: number;
|
|
115
115
|
executedAt: string;
|
|
116
116
|
}
|
|
117
|
-
export type TwapChunkStatus =
|
|
117
|
+
export type TwapChunkStatus = "PENDING" | "SCHEDULED" | "EXECUTING" | "COMPLETED" | "FAILED" | "CANCELLED";
|
|
118
118
|
export interface TwapChunkStatusDto {
|
|
119
119
|
chunkId: string;
|
|
120
120
|
chunkIndex: number;
|
|
@@ -125,7 +125,7 @@ export interface TwapChunkStatusDto {
|
|
|
125
125
|
fills: ChunkFillDto[];
|
|
126
126
|
errorMessage?: string;
|
|
127
127
|
}
|
|
128
|
-
export type TwapOrderOverallStatus =
|
|
128
|
+
export type TwapOrderOverallStatus = "OPEN" | "EXECUTING" | "COMPLETED" | "PARTIALLY_COMPLETED" | "FAILED" | "CANCELLED";
|
|
129
129
|
export interface TwapMonitoringDto {
|
|
130
130
|
orderId: string;
|
|
131
131
|
positionId?: string;
|
|
@@ -216,7 +216,7 @@ export interface PositionAssetDetailDto {
|
|
|
216
216
|
collateralToken?: CollateralToken;
|
|
217
217
|
}
|
|
218
218
|
export interface TpSlThreshold {
|
|
219
|
-
type:
|
|
219
|
+
type: "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE";
|
|
220
220
|
value: number;
|
|
221
221
|
}
|
|
222
222
|
/**
|
|
@@ -251,16 +251,16 @@ export interface OrderAssetDto {
|
|
|
251
251
|
/**
|
|
252
252
|
* Order status
|
|
253
253
|
*/
|
|
254
|
-
export type OrderStatus =
|
|
254
|
+
export type OrderStatus = "OPEN" | "PARTIALLY_FILLED" | "PROCESSING";
|
|
255
255
|
/**
|
|
256
256
|
* Order type
|
|
257
257
|
*/
|
|
258
|
-
export type OrderType =
|
|
258
|
+
export type OrderType = "TP" | "SL" | "LIMIT" | "MARKET" | "LIMIT_BTCDOM" | "TWAP";
|
|
259
259
|
/**
|
|
260
260
|
* TP/SL trigger type
|
|
261
261
|
*/
|
|
262
|
-
export type TpSlTriggerType =
|
|
263
|
-
export type OrderDirection =
|
|
262
|
+
export type TpSlTriggerType = "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE";
|
|
263
|
+
export type OrderDirection = "MORE_THAN" | "LESS_THAN" | null;
|
|
264
264
|
/**
|
|
265
265
|
* Open limit order data structure
|
|
266
266
|
*/
|
|
@@ -331,6 +331,7 @@ export interface PlatformAccountSummaryResponseDto {
|
|
|
331
331
|
*/
|
|
332
332
|
export interface AccountSummaryResponseDto {
|
|
333
333
|
balanceSummary: BalanceSummaryDto;
|
|
334
|
+
platformAccountSummary: PlatformAccountSummaryResponseDto | null;
|
|
334
335
|
agentWallet?: AgentWalletDto;
|
|
335
336
|
}
|
|
336
337
|
/**
|
|
@@ -373,7 +374,7 @@ export interface PrivyAuthDetails {
|
|
|
373
374
|
accessToken: string;
|
|
374
375
|
}
|
|
375
376
|
export interface AuthenticateRequest {
|
|
376
|
-
method:
|
|
377
|
+
method: "eip712" | "api_key" | "privy_access_token";
|
|
377
378
|
address: string;
|
|
378
379
|
clientId: string;
|
|
379
380
|
details: {
|
|
@@ -406,7 +407,7 @@ export interface LogoutRequest {
|
|
|
406
407
|
export interface LogoutResponse {
|
|
407
408
|
message: string;
|
|
408
409
|
}
|
|
409
|
-
export type AgentWalletStatus =
|
|
410
|
+
export type AgentWalletStatus = "ACTIVE" | "EXPIRED" | "NOT_FOUND";
|
|
410
411
|
export interface GetAgentWalletResponseDto {
|
|
411
412
|
agentWalletAddress?: string;
|
|
412
413
|
agentName: string;
|
|
@@ -424,7 +425,7 @@ export interface ExtraAgent {
|
|
|
424
425
|
export interface AgentWalletState {
|
|
425
426
|
address: string | null;
|
|
426
427
|
name: string | null;
|
|
427
|
-
status: AgentWalletStatus |
|
|
428
|
+
status: AgentWalletStatus | "PENDING" | null;
|
|
428
429
|
isActive: boolean;
|
|
429
430
|
}
|
|
430
431
|
/**
|
|
@@ -444,7 +445,7 @@ export interface WebSocketMessage {
|
|
|
444
445
|
/**
|
|
445
446
|
* WebSocket response from HyperLiquid native API
|
|
446
447
|
*/
|
|
447
|
-
export type HLChannel =
|
|
448
|
+
export type HLChannel = "webData3" | "allMids" | "activeAssetData" | "candle";
|
|
448
449
|
export interface HLChannelDataMap {
|
|
449
450
|
webData3: WebData3Response;
|
|
450
451
|
allMids: WsAllMidsData;
|
|
@@ -671,7 +672,7 @@ export interface TokenSelection {
|
|
|
671
672
|
*/
|
|
672
673
|
export interface TokenConflict {
|
|
673
674
|
symbol: string;
|
|
674
|
-
conflictType:
|
|
675
|
+
conflictType: "long" | "short";
|
|
675
676
|
conflictMessage: string;
|
|
676
677
|
}
|
|
677
678
|
export interface AssetMarketData {
|
|
@@ -733,7 +734,7 @@ export interface ActiveAssetsAllResponse {
|
|
|
733
734
|
/**
|
|
734
735
|
* Candle interval options
|
|
735
736
|
*/
|
|
736
|
-
export type CandleInterval =
|
|
737
|
+
export type CandleInterval = "1m" | "3m" | "5m" | "15m" | "30m" | "1h" | "2h" | "4h" | "8h" | "12h" | "1d" | "3d" | "1w" | "1M";
|
|
737
738
|
/**
|
|
738
739
|
* Candle data structure from WebSocket
|
|
739
740
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AccountSummaryResponseDto, ClearinghouseState, ExtraAgent, PlatformAccountSummaryResponseDto } from
|
|
1
|
+
import type { AccountSummaryResponseDto, ClearinghouseState, ExtraAgent, PlatformAccountSummaryResponseDto } from "../types";
|
|
2
2
|
/**
|
|
3
3
|
* Account summary calculation utility class
|
|
4
4
|
*/
|