@pear-protocol/hyperliquid-sdk 0.0.24 → 0.0.28
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/README.md +324 -127
- package/dist/clients/agentWallet.d.ts +3 -0
- package/dist/clients/auth.d.ts +14 -0
- package/dist/clients/hyperliquid.d.ts +9 -0
- package/dist/clients/orders.d.ts +24 -0
- package/dist/clients/positions.d.ts +89 -0
- package/dist/clients/sync.d.ts +9 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/useAgentWallet.d.ts +10 -0
- package/dist/hooks/useAuth.d.ts +12 -0
- package/dist/hooks/useAutoSyncFills.d.ts +21 -0
- package/dist/hooks/useHistoricalPriceData.d.ts +0 -1
- package/dist/hooks/useOrders.d.ts +10 -0
- package/dist/hooks/usePosition.d.ts +10 -0
- package/dist/hooks/useTrading.d.ts +0 -11
- package/dist/index.d.ts +289 -336
- package/dist/index.js +6689 -6296
- package/dist/provider.d.ts +53 -19
- package/dist/store/userSelection.d.ts +2 -2
- package/dist/types.d.ts +132 -199
- package/dist/utils/http.d.ts +3 -0
- package/package.json +1 -1
- package/dist/client.d.ts +0 -52
- package/dist/migration-sdk.d.ts +0 -59
package/dist/provider.d.ts
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
2
|
import { ReadyState } from 'react-use-websocket';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
export interface TokenSelectorConfig {
|
|
7
|
-
isLong: boolean;
|
|
8
|
-
index: number;
|
|
9
|
-
}
|
|
3
|
+
import type { UserProfile } from './types';
|
|
4
|
+
import { AuthStatus } from './types';
|
|
5
|
+
import type { AgentWalletState } from './types';
|
|
10
6
|
export interface PearHyperliquidContextType {
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
apiBaseUrl: string;
|
|
8
|
+
wsUrl: string;
|
|
13
9
|
address: string | null;
|
|
14
10
|
setAddress: (address: string | null) => void;
|
|
15
11
|
connectionStatus: ReadyState;
|
|
@@ -18,27 +14,65 @@ export interface PearHyperliquidContextType {
|
|
|
18
14
|
nativeConnectionStatus: ReadyState;
|
|
19
15
|
nativeIsConnected: boolean;
|
|
20
16
|
nativeLastError: string | null;
|
|
17
|
+
authStatus: AuthStatus;
|
|
18
|
+
isAuthenticated: boolean;
|
|
19
|
+
accessToken: string | null;
|
|
20
|
+
user: UserProfile | null;
|
|
21
|
+
authError: string | null;
|
|
22
|
+
getEip712: (address: string) => Promise<any>;
|
|
23
|
+
loginWithSignedMessage: (address: string, signature: string, timestamp: number) => Promise<void>;
|
|
24
|
+
loginWithPrivyToken: (address: string, appId: string, accessToken: string) => Promise<void>;
|
|
25
|
+
refreshTokens: () => Promise<any>;
|
|
26
|
+
logout: () => Promise<void>;
|
|
27
|
+
agentWallet: AgentWalletState;
|
|
28
|
+
isAgentWalletReady: boolean;
|
|
29
|
+
agentWalletError: string | null;
|
|
30
|
+
agentWalletLoading: boolean;
|
|
31
|
+
refreshAgentWalletStatus: () => Promise<any>;
|
|
32
|
+
createAgentWallet: () => Promise<any>;
|
|
33
|
+
notifyAgentWalletApproved: () => Promise<any>;
|
|
21
34
|
}
|
|
22
35
|
export declare const PearHyperliquidContext: React.Context<PearHyperliquidContextType | undefined>;
|
|
23
36
|
interface PearHyperliquidProviderProps {
|
|
24
|
-
config: PearHyperliquidConfig;
|
|
25
|
-
/**
|
|
26
|
-
* WebSocket server URL
|
|
27
|
-
* @default 'wss://hl-v2.pearprotocol.io/ws'
|
|
28
|
-
*/
|
|
29
|
-
wsUrl?: string;
|
|
30
37
|
children: ReactNode;
|
|
38
|
+
apiBaseUrl?: string;
|
|
39
|
+
clientId?: string;
|
|
40
|
+
wsUrl?: string;
|
|
31
41
|
}
|
|
32
42
|
/**
|
|
33
43
|
* React Provider for PearHyperliquidClient
|
|
34
44
|
*/
|
|
35
45
|
export declare const PearHyperliquidProvider: React.FC<PearHyperliquidProviderProps>;
|
|
36
46
|
/**
|
|
37
|
-
* Hook to
|
|
47
|
+
* Hook to access the entire Pear Hyperliquid context.
|
|
48
|
+
* Prefer using the more specific hooks below when possible.
|
|
49
|
+
*/
|
|
50
|
+
export declare function usePearHyperliquid(): PearHyperliquidContextType;
|
|
51
|
+
/**
|
|
52
|
+
* Provider-aware Auth hook. Uses auth state/actions provided by PearHyperliquidProvider.
|
|
53
|
+
* Callers do not need to pass baseUrl/clientId.
|
|
38
54
|
*/
|
|
39
|
-
export declare
|
|
55
|
+
export declare function usePearAuth(): {
|
|
56
|
+
readonly status: AuthStatus;
|
|
57
|
+
readonly isAuthenticated: boolean;
|
|
58
|
+
readonly user: UserProfile | null;
|
|
59
|
+
readonly error: string | null;
|
|
60
|
+
readonly getEip712: (address: string) => Promise<any>;
|
|
61
|
+
readonly loginWithSignedMessage: (address: string, signature: string, timestamp: number) => Promise<void>;
|
|
62
|
+
readonly loginWithPrivyToken: (address: string, appId: string, accessToken: string) => Promise<void>;
|
|
63
|
+
readonly refreshTokens: () => Promise<any>;
|
|
64
|
+
readonly logout: () => Promise<void>;
|
|
65
|
+
};
|
|
40
66
|
/**
|
|
41
|
-
*
|
|
67
|
+
* Provider-aware Agent Wallet hook. Uses agent wallet state/actions provided by PearHyperliquidProvider.
|
|
42
68
|
*/
|
|
43
|
-
export declare
|
|
69
|
+
export declare function usePearAgentWallet(): {
|
|
70
|
+
readonly agentWallet: AgentWalletState;
|
|
71
|
+
readonly isReady: boolean;
|
|
72
|
+
readonly loading: boolean;
|
|
73
|
+
readonly error: string | null;
|
|
74
|
+
readonly refreshAgentWalletStatus: () => Promise<any>;
|
|
75
|
+
readonly createAgentWallet: () => Promise<any>;
|
|
76
|
+
readonly notifyAgentWalletApproved: () => Promise<any>;
|
|
77
|
+
};
|
|
44
78
|
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { CandleInterval, TokenConflict, TokenSelection } from "../types";
|
|
2
|
-
import type { TokenSelectorConfig } from "../provider";
|
|
1
|
+
import type { CandleInterval, TokenConflict, TokenSelection, TokenSelectorConfig } from "../types";
|
|
3
2
|
interface UserSelectionState {
|
|
4
3
|
longTokens: TokenSelection[];
|
|
5
4
|
shortTokens: TokenSelection[];
|
|
@@ -20,6 +19,7 @@ interface UserSelectionState {
|
|
|
20
19
|
addToken: (isLong: boolean) => void;
|
|
21
20
|
removeToken: (isLong: boolean, index: number) => void;
|
|
22
21
|
handleTokenSelect: (selectedToken: string) => void;
|
|
22
|
+
setTokenSelections: (longTokens: TokenSelection[], shortTokens: TokenSelection[]) => void;
|
|
23
23
|
resetToDefaults: () => void;
|
|
24
24
|
}
|
|
25
25
|
export declare const useUserSelection: any;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,71 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Raw value data for trade history positions
|
|
3
|
-
*/
|
|
4
|
-
export interface RawValueDto {
|
|
5
|
-
coin: string;
|
|
6
|
-
size: string;
|
|
7
|
-
leverage: number;
|
|
8
|
-
openPx: string;
|
|
9
|
-
closePx: string;
|
|
10
|
-
marginUsed: string;
|
|
11
|
-
positionValue: string;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Trade history data structure from V1 API
|
|
15
|
-
*/
|
|
16
|
-
export interface TradeHistoryV1Dto {
|
|
17
|
-
pearId: string;
|
|
18
|
-
openedDate: string;
|
|
19
|
-
closedDate: string;
|
|
20
|
-
time: string;
|
|
21
|
-
pair: string;
|
|
22
|
-
direction: Record<string, string>;
|
|
23
|
-
closedPrice: number;
|
|
24
|
-
openedPrice: number;
|
|
25
|
-
size: string;
|
|
26
|
-
longPositionValue: number;
|
|
27
|
-
shortPositionValue: number;
|
|
28
|
-
positionValue: number;
|
|
29
|
-
fee: number;
|
|
30
|
-
builderFee: number;
|
|
31
|
-
closedPNL: number;
|
|
32
|
-
closedPnlPercentage: number;
|
|
33
|
-
leverage: number;
|
|
34
|
-
rawLongValue: RawValueDto;
|
|
35
|
-
rawShortValue: RawValueDto;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Request payload for syncing trade history
|
|
39
|
-
*/
|
|
40
|
-
export interface SyncTradeHistoryDto {
|
|
41
|
-
address: string;
|
|
42
|
-
data: TradeHistoryV1Dto[];
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Response from sync trade history endpoint
|
|
46
|
-
*/
|
|
47
|
-
export interface SyncTradeHistoryResponseDto {
|
|
48
|
-
success: boolean;
|
|
49
|
-
positionId: string;
|
|
50
|
-
tradeHistoryId: string;
|
|
51
|
-
message: string;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Base API error response
|
|
55
|
-
*/
|
|
56
1
|
export interface ApiErrorResponse {
|
|
57
2
|
statusCode: number;
|
|
58
3
|
message: string;
|
|
59
4
|
error?: string;
|
|
60
5
|
}
|
|
61
|
-
/**
|
|
62
|
-
* Configuration options for the SDK
|
|
63
|
-
*/
|
|
64
|
-
export interface PearHyperliquidConfig {
|
|
65
|
-
baseUrl: string;
|
|
66
|
-
timeout?: number;
|
|
67
|
-
headers?: Record<string, string>;
|
|
68
|
-
}
|
|
69
6
|
/**
|
|
70
7
|
* HTTP client response wrapper
|
|
71
8
|
*/
|
|
@@ -74,136 +11,38 @@ export interface ApiResponse<T> {
|
|
|
74
11
|
status: number;
|
|
75
12
|
headers: Record<string, string>;
|
|
76
13
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
loading: boolean;
|
|
82
|
-
error: ApiErrorResponse | null;
|
|
83
|
-
data: T | null;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* PnL data structure for open positions
|
|
87
|
-
*/
|
|
88
|
-
export interface PnlDto {
|
|
89
|
-
value: number;
|
|
90
|
-
percentage: number;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Take profit and stop loss data structure
|
|
94
|
-
*/
|
|
95
|
-
export interface TpSlDto {
|
|
96
|
-
takeProfit?: number;
|
|
97
|
-
stopLoss?: number;
|
|
14
|
+
export interface ExternalLiquidationDto {
|
|
15
|
+
liquidatedUser: string;
|
|
16
|
+
markPx: string;
|
|
17
|
+
method: string;
|
|
98
18
|
}
|
|
99
|
-
|
|
100
|
-
* Position side data structure for open positions
|
|
101
|
-
*/
|
|
102
|
-
export interface PositionSideDto {
|
|
19
|
+
export interface ExternalFillDto {
|
|
103
20
|
coin: string;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
longPositionValue?: number;
|
|
122
|
-
shortPositionValue?: number;
|
|
123
|
-
positionValue: number;
|
|
124
|
-
entryPrice: number;
|
|
125
|
-
markPrice: number;
|
|
126
|
-
pnl: PnlDto;
|
|
127
|
-
liqPrice: string | number;
|
|
128
|
-
margin: number;
|
|
129
|
-
funding: number;
|
|
130
|
-
pearId: string;
|
|
131
|
-
openedDate: string;
|
|
132
|
-
tpsl: TpSlDto;
|
|
133
|
-
long: PositionSideDto;
|
|
134
|
-
short: PositionSideDto;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Request payload for syncing open positions
|
|
138
|
-
*/
|
|
139
|
-
export interface SyncOpenPositionDto {
|
|
140
|
-
address: string;
|
|
141
|
-
data: OpenPositionV1Dto[];
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Response from sync open positions endpoint
|
|
145
|
-
*/
|
|
146
|
-
export interface SyncOpenPositionResponseDto {
|
|
147
|
-
success: boolean;
|
|
148
|
-
positionIds: string[];
|
|
149
|
-
count: number;
|
|
150
|
-
message: string;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Open order data structure from V1 API
|
|
154
|
-
*/
|
|
155
|
-
export interface OpenOrderV1Dto {
|
|
156
|
-
id: string;
|
|
157
|
-
time: string;
|
|
158
|
-
pair: string;
|
|
159
|
-
type: string;
|
|
160
|
-
orderValue: number;
|
|
161
|
-
price: number;
|
|
162
|
-
triggerConditions: string;
|
|
163
|
-
status: string;
|
|
164
|
-
leverage?: string;
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Request payload for syncing open orders
|
|
168
|
-
*/
|
|
169
|
-
export interface SyncOpenOrderDto {
|
|
170
|
-
address: string;
|
|
171
|
-
data: OpenOrderV1Dto[];
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Response from sync open orders endpoint
|
|
175
|
-
*/
|
|
176
|
-
export interface SyncOpenOrderResponseDto {
|
|
177
|
-
success: boolean;
|
|
178
|
-
orderIds: string[];
|
|
179
|
-
count: number;
|
|
180
|
-
message: string;
|
|
21
|
+
px: string;
|
|
22
|
+
sz: string;
|
|
23
|
+
side: 'B' | 'A';
|
|
24
|
+
time: number;
|
|
25
|
+
dir: string;
|
|
26
|
+
fee: string;
|
|
27
|
+
builderFee?: string;
|
|
28
|
+
oid?: string | number;
|
|
29
|
+
tid?: string | number;
|
|
30
|
+
cloid?: string | null;
|
|
31
|
+
hash?: string | null;
|
|
32
|
+
feeToken?: string | null;
|
|
33
|
+
liquidation?: ExternalLiquidationDto | null;
|
|
34
|
+
}
|
|
35
|
+
export interface SyncFillsRequestDto {
|
|
36
|
+
user: string;
|
|
37
|
+
fills: ExternalFillDto[];
|
|
181
38
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
error: ApiErrorResponse | null;
|
|
190
|
-
data: SyncTradeHistoryResponseDto | null;
|
|
191
|
-
reset: () => void;
|
|
192
|
-
};
|
|
193
|
-
openPositions: {
|
|
194
|
-
sync: (payload: SyncOpenPositionDto) => Promise<ApiResponse<SyncOpenPositionResponseDto>>;
|
|
195
|
-
loading: boolean;
|
|
196
|
-
error: ApiErrorResponse | null;
|
|
197
|
-
data: SyncOpenPositionResponseDto | null;
|
|
198
|
-
reset: () => void;
|
|
199
|
-
};
|
|
200
|
-
openOrders: {
|
|
201
|
-
sync: (payload: SyncOpenOrderDto) => Promise<ApiResponse<SyncOpenOrderResponseDto>>;
|
|
202
|
-
loading: boolean;
|
|
203
|
-
error: ApiErrorResponse | null;
|
|
204
|
-
data: SyncOpenOrderResponseDto | null;
|
|
205
|
-
reset: () => void;
|
|
206
|
-
};
|
|
39
|
+
export interface SyncFillsResponseDto {
|
|
40
|
+
insertedFills: number;
|
|
41
|
+
skippedDuplicates: number;
|
|
42
|
+
createdOrders: number;
|
|
43
|
+
updatedPositions: number;
|
|
44
|
+
createdPositions: number;
|
|
45
|
+
closedPositions: number;
|
|
207
46
|
}
|
|
208
47
|
/**
|
|
209
48
|
* WebSocket connection states
|
|
@@ -240,6 +79,7 @@ export interface WebSocketDataMessage<T = unknown> {
|
|
|
240
79
|
*/
|
|
241
80
|
export interface TradeHistoryAssetDataDto {
|
|
242
81
|
coin: string;
|
|
82
|
+
entryWeight: number;
|
|
243
83
|
entryPrice: number;
|
|
244
84
|
limitPrice: number;
|
|
245
85
|
size: number;
|
|
@@ -257,6 +97,7 @@ export interface TradeHistoryDataDto {
|
|
|
257
97
|
externalFeePaid: number;
|
|
258
98
|
builderFeePaid: number;
|
|
259
99
|
realizedPnl: number;
|
|
100
|
+
totalEntryValue: number;
|
|
260
101
|
totalValue: number;
|
|
261
102
|
entryRatio: number;
|
|
262
103
|
exitRatio: number;
|
|
@@ -283,16 +124,16 @@ export interface PositionAssetDetailDto {
|
|
|
283
124
|
actualSize: number;
|
|
284
125
|
cumFunding: CumFundingDto;
|
|
285
126
|
marginUsed: number;
|
|
127
|
+
entryPositionValue: number;
|
|
286
128
|
positionValue: number;
|
|
287
129
|
unrealizedPnl: number;
|
|
288
130
|
liquidationPrice: number;
|
|
289
|
-
isExternallyModified: boolean;
|
|
290
131
|
initialWeight: number;
|
|
291
132
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
133
|
+
export interface TpSlThreshold {
|
|
134
|
+
type: 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE';
|
|
135
|
+
value: number;
|
|
136
|
+
}
|
|
296
137
|
/**
|
|
297
138
|
* Open position data structure
|
|
298
139
|
*/
|
|
@@ -300,18 +141,17 @@ export interface OpenPositionDto {
|
|
|
300
141
|
positionId: string;
|
|
301
142
|
address: string;
|
|
302
143
|
leverage: number;
|
|
303
|
-
stopLoss:
|
|
304
|
-
takeProfit:
|
|
144
|
+
stopLoss: TpSlThreshold | null;
|
|
145
|
+
takeProfit: TpSlThreshold | null;
|
|
305
146
|
entryRatio: number;
|
|
306
147
|
markRatio: number;
|
|
307
148
|
netFunding: number;
|
|
149
|
+
entryPositionValue: number;
|
|
308
150
|
positionValue: number;
|
|
309
151
|
marginUsed: number;
|
|
310
152
|
unrealizedPnl: number;
|
|
311
153
|
longAssets: PositionAssetDetailDto[];
|
|
312
154
|
shortAssets: PositionAssetDetailDto[];
|
|
313
|
-
syncStatus: PositionSyncStatus;
|
|
314
|
-
lastSyncAt: string;
|
|
315
155
|
createdAt: string;
|
|
316
156
|
updatedAt: string;
|
|
317
157
|
}
|
|
@@ -407,6 +247,95 @@ export interface AddressState {
|
|
|
407
247
|
autoConnect: boolean;
|
|
408
248
|
previousAddresses: string[];
|
|
409
249
|
}
|
|
250
|
+
export declare enum AuthStatus {
|
|
251
|
+
Idle = "idle",
|
|
252
|
+
Authenticating = "authenticating",
|
|
253
|
+
Authenticated = "authenticated",
|
|
254
|
+
Error = "error"
|
|
255
|
+
}
|
|
256
|
+
export interface UseAuthOptions {
|
|
257
|
+
baseUrl: string;
|
|
258
|
+
clientId: string;
|
|
259
|
+
}
|
|
260
|
+
export interface UserProfile {
|
|
261
|
+
userId: string;
|
|
262
|
+
address: string;
|
|
263
|
+
appId: string;
|
|
264
|
+
}
|
|
265
|
+
export interface EIP712AuthDetails {
|
|
266
|
+
primaryType: string;
|
|
267
|
+
domain: {
|
|
268
|
+
name: string;
|
|
269
|
+
version: string;
|
|
270
|
+
chainId: number;
|
|
271
|
+
verifyingContract: string;
|
|
272
|
+
};
|
|
273
|
+
types: Record<string, Array<{
|
|
274
|
+
name: string;
|
|
275
|
+
type: string;
|
|
276
|
+
}>>;
|
|
277
|
+
message: Record<string, unknown>;
|
|
278
|
+
timestamp: number;
|
|
279
|
+
}
|
|
280
|
+
export interface GetEIP712MessageResponse extends EIP712AuthDetails {
|
|
281
|
+
}
|
|
282
|
+
export interface PrivyAuthDetails {
|
|
283
|
+
appId: string;
|
|
284
|
+
accessToken: string;
|
|
285
|
+
}
|
|
286
|
+
export interface AuthenticateRequest {
|
|
287
|
+
method: 'eip712' | 'api_key' | 'privy_access_token';
|
|
288
|
+
address: string;
|
|
289
|
+
clientId: string;
|
|
290
|
+
details: {
|
|
291
|
+
signature: string;
|
|
292
|
+
timestamp: number;
|
|
293
|
+
} | {
|
|
294
|
+
apiKey: string;
|
|
295
|
+
} | PrivyAuthDetails;
|
|
296
|
+
}
|
|
297
|
+
export interface AuthenticateResponse {
|
|
298
|
+
accessToken: string;
|
|
299
|
+
refreshToken: string;
|
|
300
|
+
tokenType: string;
|
|
301
|
+
expiresIn: number;
|
|
302
|
+
address: string;
|
|
303
|
+
clientId: string;
|
|
304
|
+
}
|
|
305
|
+
export interface RefreshTokenRequest {
|
|
306
|
+
refreshToken: string;
|
|
307
|
+
}
|
|
308
|
+
export interface RefreshTokenResponse {
|
|
309
|
+
accessToken: string;
|
|
310
|
+
refreshToken: string;
|
|
311
|
+
tokenType: string;
|
|
312
|
+
expiresIn: number;
|
|
313
|
+
}
|
|
314
|
+
export interface LogoutRequest {
|
|
315
|
+
refreshToken: string;
|
|
316
|
+
}
|
|
317
|
+
export interface LogoutResponse {
|
|
318
|
+
message: string;
|
|
319
|
+
}
|
|
320
|
+
export type AgentWalletStatus = 'ACTIVE' | 'EXPIRED' | 'NOT_FOUND';
|
|
321
|
+
export interface GetAgentWalletResponseDto {
|
|
322
|
+
agentWalletAddress?: string;
|
|
323
|
+
agentName: string;
|
|
324
|
+
status: AgentWalletStatus;
|
|
325
|
+
}
|
|
326
|
+
export interface CreateAgentWalletResponseDto {
|
|
327
|
+
agentWalletAddress: string;
|
|
328
|
+
message: string;
|
|
329
|
+
}
|
|
330
|
+
export interface UseAgentWalletOptions {
|
|
331
|
+
baseUrl: string;
|
|
332
|
+
}
|
|
333
|
+
export interface AgentWalletState {
|
|
334
|
+
address: string | null;
|
|
335
|
+
name: string | null;
|
|
336
|
+
status: AgentWalletStatus | 'PENDING' | null;
|
|
337
|
+
isActive: boolean;
|
|
338
|
+
}
|
|
410
339
|
/**
|
|
411
340
|
* WebSocket message from HyperLiquid native API
|
|
412
341
|
*/
|
|
@@ -646,3 +575,7 @@ export interface CandleSnapshotRequest {
|
|
|
646
575
|
};
|
|
647
576
|
type: "candleSnapshot";
|
|
648
577
|
}
|
|
578
|
+
export interface TokenSelectorConfig {
|
|
579
|
+
isLong: boolean;
|
|
580
|
+
index: number;
|
|
581
|
+
}
|
package/package.json
CHANGED
package/dist/client.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { PearHyperliquidConfig, ApiResponse, SyncTradeHistoryDto, SyncTradeHistoryResponseDto, SyncOpenPositionDto, SyncOpenPositionResponseDto, SyncOpenOrderDto, SyncOpenOrderResponseDto, CandleData, CandleInterval } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Main SDK client for Pear Protocol Hyperliquid API integration
|
|
4
|
-
*/
|
|
5
|
-
export declare class PearHyperliquidClient {
|
|
6
|
-
private httpClient;
|
|
7
|
-
private baseUrl;
|
|
8
|
-
constructor(config: PearHyperliquidConfig);
|
|
9
|
-
/**
|
|
10
|
-
* Get the configured base URL
|
|
11
|
-
*/
|
|
12
|
-
getBaseUrl(): string;
|
|
13
|
-
/**
|
|
14
|
-
* Update request headers
|
|
15
|
-
*/
|
|
16
|
-
setHeaders(headers: Record<string, string>): void;
|
|
17
|
-
/**
|
|
18
|
-
* Set authorization header
|
|
19
|
-
*/
|
|
20
|
-
setAuthToken(token: string): void;
|
|
21
|
-
/**
|
|
22
|
-
* Make a generic HTTP request
|
|
23
|
-
*/
|
|
24
|
-
private makeRequest;
|
|
25
|
-
/**
|
|
26
|
-
* Sync trade history data from old database structure to new database format
|
|
27
|
-
* @param payload - Trade history data with user address
|
|
28
|
-
* @returns Promise with sync result
|
|
29
|
-
*/
|
|
30
|
-
syncTradeHistory(payload: SyncTradeHistoryDto): Promise<ApiResponse<SyncTradeHistoryResponseDto>>;
|
|
31
|
-
/**
|
|
32
|
-
* Sync open positions data from old database structure to new database format
|
|
33
|
-
* @param payload - Open positions data with user address
|
|
34
|
-
* @returns Promise with sync result
|
|
35
|
-
*/
|
|
36
|
-
syncOpenPositions(payload: SyncOpenPositionDto): Promise<ApiResponse<SyncOpenPositionResponseDto>>;
|
|
37
|
-
/**
|
|
38
|
-
* Sync open orders data from old database structure to new database format
|
|
39
|
-
* @param payload - Open orders data with user address
|
|
40
|
-
* @returns Promise with sync result
|
|
41
|
-
*/
|
|
42
|
-
syncOpenOrders(payload: SyncOpenOrderDto): Promise<ApiResponse<SyncOpenOrderResponseDto>>;
|
|
43
|
-
/**
|
|
44
|
-
* Fetch historical candle data from HyperLiquid API
|
|
45
|
-
* @param coin - Token symbol (e.g., 'BTC', 'ETH')
|
|
46
|
-
* @param startTime - Start time in milliseconds
|
|
47
|
-
* @param endTime - End time in milliseconds
|
|
48
|
-
* @param interval - Candle interval
|
|
49
|
-
* @returns Promise with historical candle data
|
|
50
|
-
*/
|
|
51
|
-
fetchHistoricalCandles(coin: string, startTime: number, endTime: number, interval: CandleInterval): Promise<ApiResponse<CandleData[]>>;
|
|
52
|
-
}
|
package/dist/migration-sdk.d.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { PearHyperliquidClient } from './client';
|
|
2
|
-
import { SyncTradeHistoryDto, SyncTradeHistoryResponseDto, SyncOpenPositionDto, SyncOpenPositionResponseDto, SyncOpenOrderDto, SyncOpenOrderResponseDto, ApiResponse } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Main Migration SDK Class - Simple request/response pattern
|
|
5
|
-
*/
|
|
6
|
-
export declare class PearMigrationSDK {
|
|
7
|
-
private client;
|
|
8
|
-
private isTradeHistorySyncRunning;
|
|
9
|
-
private isOpenPositionsSyncRunning;
|
|
10
|
-
private isOpenOrdersSyncRunning;
|
|
11
|
-
constructor(client: PearHyperliquidClient);
|
|
12
|
-
/**
|
|
13
|
-
* Sync trade history data - can only run one at a time
|
|
14
|
-
* If called while already running, returns immediately without making request
|
|
15
|
-
*/
|
|
16
|
-
syncTradeHistory(payload: SyncTradeHistoryDto): Promise<ApiResponse<SyncTradeHistoryResponseDto> | null>;
|
|
17
|
-
/**
|
|
18
|
-
* Sync open positions data - can only run one at a time
|
|
19
|
-
* If called while already running, returns immediately without making request
|
|
20
|
-
*/
|
|
21
|
-
syncOpenPositions(payload: SyncOpenPositionDto): Promise<ApiResponse<SyncOpenPositionResponseDto> | null>;
|
|
22
|
-
/**
|
|
23
|
-
* Sync open orders data - can only run one at a time
|
|
24
|
-
* If called while already running, returns immediately without making request
|
|
25
|
-
*/
|
|
26
|
-
syncOpenOrders(payload: SyncOpenOrderDto): Promise<ApiResponse<SyncOpenOrderResponseDto> | null>;
|
|
27
|
-
/**
|
|
28
|
-
* Check if any sync is currently running
|
|
29
|
-
*/
|
|
30
|
-
isSyncInProgress(): boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Check if trade history sync is currently running
|
|
33
|
-
*/
|
|
34
|
-
isTradeHistorySyncInProgress(): boolean;
|
|
35
|
-
/**
|
|
36
|
-
* Check if open positions sync is currently running
|
|
37
|
-
*/
|
|
38
|
-
isOpenPositionsSyncInProgress(): boolean;
|
|
39
|
-
/**
|
|
40
|
-
* Check if open orders sync is currently running
|
|
41
|
-
*/
|
|
42
|
-
isOpenOrdersSyncInProgress(): boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Get the underlying client instance
|
|
45
|
-
*/
|
|
46
|
-
getClient(): PearHyperliquidClient;
|
|
47
|
-
/**
|
|
48
|
-
* Set authorization token on the client
|
|
49
|
-
*/
|
|
50
|
-
setAuthToken(token: string): void;
|
|
51
|
-
/**
|
|
52
|
-
* Set custom headers on the client
|
|
53
|
-
*/
|
|
54
|
-
setHeaders(headers: Record<string, string>): void;
|
|
55
|
-
/**
|
|
56
|
-
* Get base URL from client
|
|
57
|
-
*/
|
|
58
|
-
getBaseUrl(): string;
|
|
59
|
-
}
|