@pear-protocol/hyperliquid-sdk 0.0.60-beta.9 → 0.0.61
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/hooks/useAuth.d.ts +3 -5
- package/dist/index.d.ts +22 -42
- package/dist/index.js +73 -123
- package/dist/store/historicalPriceDataStore.d.ts +1 -12
- package/dist/store/hyperliquidDataStore.d.ts +1 -25
- package/dist/store/marketDataStore.d.ts +1 -10
- package/dist/store/tokenSelectionMetadataStore.d.ts +1 -1
- package/dist/store/userDataStore.d.ts +1 -30
- package/dist/store/userSelection.d.ts +1 -1
- package/dist/types.d.ts +18 -17
- package/dist/utils/account-summary-calculator.d.ts +1 -1
- package/package.json +2 -3
package/dist/hooks/useAuth.d.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import type { GetEIP712MessageResponse } from "../types";
|
|
2
2
|
export declare function useAuth(): {
|
|
3
3
|
readonly isReady: boolean;
|
|
4
|
-
readonly isAuthenticated:
|
|
5
|
-
readonly accessToken:
|
|
6
|
-
readonly refreshToken:
|
|
4
|
+
readonly isAuthenticated: any;
|
|
5
|
+
readonly accessToken: any;
|
|
6
|
+
readonly refreshToken: any;
|
|
7
7
|
readonly getEip712: (address: string) => Promise<GetEIP712MessageResponse>;
|
|
8
8
|
readonly loginWithSignedMessage: (address: string, signature: string, timestamp: number) => Promise<void>;
|
|
9
9
|
readonly loginWithPrivyToken: (address: string, appId: string, privyAccessToken: string) => Promise<void>;
|
|
10
10
|
readonly refreshTokens: () => Promise<import("../types").RefreshTokenResponse>;
|
|
11
11
|
readonly logout: () => Promise<void>;
|
|
12
|
-
readonly setAddress: (address: string | null) => void;
|
|
13
|
-
readonly address: string | null;
|
|
14
12
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
-
import * as zustand from 'zustand';
|
|
3
2
|
|
|
4
3
|
interface PearHyperliquidContextType {
|
|
5
4
|
clientId: string;
|
|
@@ -48,7 +47,7 @@ interface ExternalFillDto {
|
|
|
48
47
|
coin: string;
|
|
49
48
|
px: string;
|
|
50
49
|
sz: string;
|
|
51
|
-
side:
|
|
50
|
+
side: "B" | "A";
|
|
52
51
|
time: number;
|
|
53
52
|
dir: string;
|
|
54
53
|
fee: string;
|
|
@@ -75,16 +74,16 @@ interface TwapSliceFillResponseItem {
|
|
|
75
74
|
/**
|
|
76
75
|
* WebSocket connection states
|
|
77
76
|
*/
|
|
78
|
-
type WebSocketConnectionState =
|
|
77
|
+
type WebSocketConnectionState = "connecting" | "connected" | "disconnected" | "error";
|
|
79
78
|
/**
|
|
80
79
|
* WebSocket channels
|
|
81
80
|
*/
|
|
82
|
-
type WebSocketChannel =
|
|
81
|
+
type WebSocketChannel = "trade-histories" | "open-positions" | "open-orders" | "account-summary" | "twap-details" | "notifications" | "market-data" | "market-data-all" | "webData3" | "allMids" | "activeAssetData";
|
|
83
82
|
/**
|
|
84
83
|
* WebSocket subscription message
|
|
85
84
|
*/
|
|
86
85
|
interface WebSocketSubscribeMessage {
|
|
87
|
-
action?:
|
|
86
|
+
action?: "subscribe" | "unsubscribe";
|
|
88
87
|
address: string;
|
|
89
88
|
}
|
|
90
89
|
/**
|
|
@@ -114,7 +113,7 @@ interface WatchlistItemDto {
|
|
|
114
113
|
interface ToggleWatchlistResponseDto {
|
|
115
114
|
items: WatchlistItemDto[];
|
|
116
115
|
}
|
|
117
|
-
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";
|
|
118
117
|
interface NotificationDto {
|
|
119
118
|
id: string;
|
|
120
119
|
address: string;
|
|
@@ -131,7 +130,7 @@ interface ChunkFillDto {
|
|
|
131
130
|
size: number;
|
|
132
131
|
executedAt: string;
|
|
133
132
|
}
|
|
134
|
-
type TwapChunkStatus =
|
|
133
|
+
type TwapChunkStatus = "PENDING" | "SCHEDULED" | "EXECUTING" | "COMPLETED" | "FAILED" | "CANCELLED";
|
|
135
134
|
interface TwapChunkStatusDto {
|
|
136
135
|
chunkId: string;
|
|
137
136
|
chunkIndex: number;
|
|
@@ -142,7 +141,7 @@ interface TwapChunkStatusDto {
|
|
|
142
141
|
fills: ChunkFillDto[];
|
|
143
142
|
errorMessage?: string;
|
|
144
143
|
}
|
|
145
|
-
type TwapOrderOverallStatus =
|
|
144
|
+
type TwapOrderOverallStatus = "OPEN" | "EXECUTING" | "COMPLETED" | "PARTIALLY_COMPLETED" | "FAILED" | "CANCELLED";
|
|
146
145
|
interface TwapMonitoringDto {
|
|
147
146
|
orderId: string;
|
|
148
147
|
positionId?: string;
|
|
@@ -229,7 +228,7 @@ interface PositionAssetDetailDto {
|
|
|
229
228
|
fundingPaid?: number;
|
|
230
229
|
}
|
|
231
230
|
interface TpSlThreshold {
|
|
232
|
-
type:
|
|
231
|
+
type: "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE";
|
|
233
232
|
value: number;
|
|
234
233
|
}
|
|
235
234
|
/**
|
|
@@ -264,16 +263,16 @@ interface OrderAssetDto {
|
|
|
264
263
|
/**
|
|
265
264
|
* Order status
|
|
266
265
|
*/
|
|
267
|
-
type OrderStatus =
|
|
266
|
+
type OrderStatus = "OPEN" | "PARTIALLY_FILLED" | "PROCESSING";
|
|
268
267
|
/**
|
|
269
268
|
* Order type
|
|
270
269
|
*/
|
|
271
|
-
type OrderType =
|
|
270
|
+
type OrderType = "TP" | "SL" | "LIMIT" | "MARKET" | "LIMIT_BTCDOM" | "TWAP";
|
|
272
271
|
/**
|
|
273
272
|
* TP/SL trigger type
|
|
274
273
|
*/
|
|
275
|
-
type TpSlTriggerType =
|
|
276
|
-
type OrderDirection =
|
|
274
|
+
type TpSlTriggerType = "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE";
|
|
275
|
+
type OrderDirection = "MORE_THAN" | "LESS_THAN" | null;
|
|
277
276
|
/**
|
|
278
277
|
* Open limit order data structure
|
|
279
278
|
*/
|
|
@@ -344,6 +343,7 @@ interface PlatformAccountSummaryResponseDto {
|
|
|
344
343
|
*/
|
|
345
344
|
interface AccountSummaryResponseDto {
|
|
346
345
|
balanceSummary: BalanceSummaryDto;
|
|
346
|
+
platformAccountSummary: PlatformAccountSummaryResponseDto | null;
|
|
347
347
|
agentWallet?: AgentWalletDto;
|
|
348
348
|
}
|
|
349
349
|
interface UseAuthOptions {
|
|
@@ -378,7 +378,7 @@ interface RefreshTokenResponse {
|
|
|
378
378
|
tokenType: string;
|
|
379
379
|
expiresIn: number;
|
|
380
380
|
}
|
|
381
|
-
type AgentWalletStatus =
|
|
381
|
+
type AgentWalletStatus = "ACTIVE" | "EXPIRED" | "NOT_FOUND";
|
|
382
382
|
interface CreateAgentWalletResponseDto {
|
|
383
383
|
agentWalletAddress: string;
|
|
384
384
|
message: string;
|
|
@@ -391,7 +391,7 @@ interface ExtraAgent {
|
|
|
391
391
|
interface AgentWalletState {
|
|
392
392
|
address: string | null;
|
|
393
393
|
name: string | null;
|
|
394
|
-
status: AgentWalletStatus |
|
|
394
|
+
status: AgentWalletStatus | "PENDING" | null;
|
|
395
395
|
isActive: boolean;
|
|
396
396
|
}
|
|
397
397
|
/**
|
|
@@ -411,7 +411,7 @@ interface WebSocketMessage {
|
|
|
411
411
|
/**
|
|
412
412
|
* WebSocket response from HyperLiquid native API
|
|
413
413
|
*/
|
|
414
|
-
type HLChannel =
|
|
414
|
+
type HLChannel = "webData3" | "allMids" | "activeAssetData" | "candle";
|
|
415
415
|
interface HLChannelDataMap {
|
|
416
416
|
webData3: WebData3Response;
|
|
417
417
|
allMids: WsAllMidsData;
|
|
@@ -611,7 +611,7 @@ interface TokenSelection {
|
|
|
611
611
|
*/
|
|
612
612
|
interface TokenConflict {
|
|
613
613
|
symbol: string;
|
|
614
|
-
conflictType:
|
|
614
|
+
conflictType: "long" | "short";
|
|
615
615
|
conflictMessage: string;
|
|
616
616
|
}
|
|
617
617
|
interface AssetMarketData {
|
|
@@ -770,18 +770,7 @@ interface TokenHistoricalPriceData {
|
|
|
770
770
|
oldestTime: number | null;
|
|
771
771
|
latestTime: number | null;
|
|
772
772
|
}
|
|
773
|
-
|
|
774
|
-
historicalPriceData: Record<string, TokenHistoricalPriceData>;
|
|
775
|
-
loadingTokens: Set<string>;
|
|
776
|
-
addHistoricalPriceData: (symbol: string, interval: CandleInterval, candles: CandleData[], range: HistoricalRange) => void;
|
|
777
|
-
hasHistoricalPriceData: (symbol: string, interval: CandleInterval, startTime: number, endTime: number) => boolean;
|
|
778
|
-
getHistoricalPriceData: (symbol: string, interval: CandleInterval, startTime: number, endTime: number) => CandleData[];
|
|
779
|
-
setTokenLoading: (symbol: string, loading: boolean) => void;
|
|
780
|
-
isTokenLoading: (symbol: string) => boolean;
|
|
781
|
-
removeTokenPriceData: (symbol: string, interval: CandleInterval) => void;
|
|
782
|
-
clearData: () => void;
|
|
783
|
-
}
|
|
784
|
-
declare const useHistoricalPriceDataStore: zustand.UseBoundStore<zustand.StoreApi<HistoricalPriceDataState>>;
|
|
773
|
+
declare const useHistoricalPriceDataStore: any;
|
|
785
774
|
|
|
786
775
|
interface UseHistoricalPriceDataReturn {
|
|
787
776
|
fetchHistoricalPriceData: (startTime: number, endTime: number, interval: CandleInterval, callback?: (data: Record<string, CandleData[]>) => void) => Promise<Record<string, CandleData[]>>;
|
|
@@ -1118,16 +1107,14 @@ declare function usePortfolio(): UsePortfolioResult;
|
|
|
1118
1107
|
|
|
1119
1108
|
declare function useAuth(): {
|
|
1120
1109
|
readonly isReady: boolean;
|
|
1121
|
-
readonly isAuthenticated:
|
|
1122
|
-
readonly accessToken:
|
|
1123
|
-
readonly refreshToken:
|
|
1110
|
+
readonly isAuthenticated: any;
|
|
1111
|
+
readonly accessToken: any;
|
|
1112
|
+
readonly refreshToken: any;
|
|
1124
1113
|
readonly getEip712: (address: string) => Promise<GetEIP712MessageResponse>;
|
|
1125
1114
|
readonly loginWithSignedMessage: (address: string, signature: string, timestamp: number) => Promise<void>;
|
|
1126
1115
|
readonly loginWithPrivyToken: (address: string, appId: string, privyAccessToken: string) => Promise<void>;
|
|
1127
1116
|
readonly refreshTokens: () => Promise<RefreshTokenResponse>;
|
|
1128
1117
|
readonly logout: () => Promise<void>;
|
|
1129
|
-
readonly setAddress: (address: string | null) => void;
|
|
1130
|
-
readonly address: string | null;
|
|
1131
1118
|
};
|
|
1132
1119
|
|
|
1133
1120
|
interface UseHyperliquidWebSocketProps {
|
|
@@ -1304,14 +1291,7 @@ declare function validatePositionSize(usdValue: number, longAssets?: PairAssetIn
|
|
|
1304
1291
|
minimumRequired?: number;
|
|
1305
1292
|
};
|
|
1306
1293
|
|
|
1307
|
-
|
|
1308
|
-
marketData: ActiveAssetsResponse | null;
|
|
1309
|
-
marketDataAll: ActiveAssetsAllResponse | null;
|
|
1310
|
-
setMarketData: (value: ActiveAssetsResponse | null) => void;
|
|
1311
|
-
setMarketDataAll: (value: ActiveAssetsAllResponse | null) => void;
|
|
1312
|
-
clean: () => void;
|
|
1313
|
-
}
|
|
1314
|
-
declare const useMarketData: zustand.UseBoundStore<zustand.StoreApi<MarketDataState>>;
|
|
1294
|
+
declare const useMarketData: any;
|
|
1315
1295
|
|
|
1316
1296
|
export { AccountSummaryCalculator, ConflictDetector, MINIMUM_ASSET_USD_VALUE, MinimumPositionSizeError, PearHyperliquidProvider, TokenMetadataExtractor, adjustAdvancePosition, adjustOrder, adjustPosition, calculateMinimumPositionValue, calculateWeightedRatio, cancelOrder, cancelTwap, cancelTwapOrder, closeAllPositions, closePosition, computeBasketCandles, createCandleLookups, createPosition, getCompleteTimestamps, getPortfolio, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, markNotificationReadById, markNotificationsRead, toggleWatchlist, updateRiskParameters, useAccountSummary, useActiveBaskets, useAgentWallet, useAllBaskets, useAuth, useAutoSyncFills, useBasketCandles, useFindBasket, useHighlightedBaskets, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidNativeWebSocket, useHyperliquidWebSocket, useMarketData, useMarketDataAllPayload, useMarketDataPayload, useNotifications, useOpenOrders, useOrders, usePearHyperliquid, usePerformanceOverlays, usePortfolio, usePosition, useTokenSelectionMetadata, useTopGainers, useTopLosers, useTradeHistories, useTwap, useUserSelection, useWatchlist, useWatchlistBaskets, useWebData, validateMinimumAssetSize, validatePositionSize };
|
|
1317
1297
|
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, CreatePositionRequestInput, CreatePositionResponseDto, CrossMarginSummaryDto, CumFundingDto, ExecutionType, ExtraAgent, HLWebSocketResponse, HistoricalRange, LadderConfigInput, MarginSummaryDto, 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 };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
2
|
+
import { useState, useRef, useCallback, useEffect, useMemo, useContext, createContext } from 'react';
|
|
3
|
+
import { create } from 'zustand';
|
|
3
4
|
|
|
4
5
|
// Browser-compatible WebSocket ready state enum (mirrors native values)
|
|
5
6
|
var ReadyState;
|
|
@@ -10,52 +11,10 @@ var ReadyState;
|
|
|
10
11
|
ReadyState[ReadyState["CLOSED"] = 3] = "CLOSED";
|
|
11
12
|
})(ReadyState || (ReadyState = {}));
|
|
12
13
|
|
|
13
|
-
const createStoreImpl = (createState) => {
|
|
14
|
-
let state;
|
|
15
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
16
|
-
const setState = (partial, replace) => {
|
|
17
|
-
const nextState = typeof partial === "function" ? partial(state) : partial;
|
|
18
|
-
if (!Object.is(nextState, state)) {
|
|
19
|
-
const previousState = state;
|
|
20
|
-
state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
|
|
21
|
-
listeners.forEach((listener) => listener(state, previousState));
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
const getState = () => state;
|
|
25
|
-
const getInitialState = () => initialState;
|
|
26
|
-
const subscribe = (listener) => {
|
|
27
|
-
listeners.add(listener);
|
|
28
|
-
return () => listeners.delete(listener);
|
|
29
|
-
};
|
|
30
|
-
const api = { setState, getState, getInitialState, subscribe };
|
|
31
|
-
const initialState = state = createState(setState, getState, api);
|
|
32
|
-
return api;
|
|
33
|
-
};
|
|
34
|
-
const createStore = ((createState) => createState ? createStoreImpl(createState) : createStoreImpl);
|
|
35
|
-
|
|
36
|
-
const identity = (arg) => arg;
|
|
37
|
-
function useStore(api, selector = identity) {
|
|
38
|
-
const slice = React.useSyncExternalStore(
|
|
39
|
-
api.subscribe,
|
|
40
|
-
React.useCallback(() => selector(api.getState()), [api, selector]),
|
|
41
|
-
React.useCallback(() => selector(api.getInitialState()), [api, selector])
|
|
42
|
-
);
|
|
43
|
-
React.useDebugValue(slice);
|
|
44
|
-
return slice;
|
|
45
|
-
}
|
|
46
|
-
const createImpl = (createState) => {
|
|
47
|
-
const api = createStore(createState);
|
|
48
|
-
const useBoundStore = (selector) => useStore(api, selector);
|
|
49
|
-
Object.assign(useBoundStore, api);
|
|
50
|
-
return useBoundStore;
|
|
51
|
-
};
|
|
52
|
-
const create = ((createState) => createState ? createImpl(createState) : createImpl);
|
|
53
|
-
|
|
54
14
|
const useUserData = create((set) => ({
|
|
55
15
|
accessToken: null,
|
|
56
16
|
refreshToken: null,
|
|
57
17
|
isAuthenticated: false,
|
|
58
|
-
isReady: false,
|
|
59
18
|
address: null,
|
|
60
19
|
tradeHistories: null,
|
|
61
20
|
rawOpenPositions: null,
|
|
@@ -67,18 +26,17 @@ const useUserData = create((set) => ({
|
|
|
67
26
|
setAccessToken: (token) => set({ accessToken: token }),
|
|
68
27
|
setRefreshToken: (token) => set({ refreshToken: token }),
|
|
69
28
|
setIsAuthenticated: (value) => set({ isAuthenticated: value }),
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (typeof window !== "undefined") {
|
|
29
|
+
setAddress: (address) => set(() => {
|
|
30
|
+
if (typeof window !== 'undefined') {
|
|
73
31
|
if (address) {
|
|
74
|
-
window.localStorage.setItem(
|
|
32
|
+
window.localStorage.setItem('address', address);
|
|
75
33
|
}
|
|
76
34
|
else {
|
|
77
|
-
window.localStorage.removeItem(
|
|
35
|
+
window.localStorage.removeItem('address');
|
|
78
36
|
}
|
|
79
37
|
}
|
|
80
|
-
|
|
81
|
-
},
|
|
38
|
+
return { address };
|
|
39
|
+
}),
|
|
82
40
|
setTradeHistories: (value) => set({ tradeHistories: value }),
|
|
83
41
|
setRawOpenPositions: (value) => set({ rawOpenPositions: value }),
|
|
84
42
|
setOpenOrders: (value) => set({ openOrders: value }),
|
|
@@ -89,7 +47,6 @@ const useUserData = create((set) => ({
|
|
|
89
47
|
accessToken: null,
|
|
90
48
|
refreshToken: null,
|
|
91
49
|
isAuthenticated: false,
|
|
92
|
-
isReady: false,
|
|
93
50
|
address: null,
|
|
94
51
|
tradeHistories: null,
|
|
95
52
|
rawOpenPositions: null,
|
|
@@ -890,31 +847,40 @@ class AccountSummaryCalculator {
|
|
|
890
847
|
return null;
|
|
891
848
|
}
|
|
892
849
|
const clearinghouseState = this.clearinghouseState;
|
|
893
|
-
const withdrawableAmount = parseFloat(clearinghouseState.withdrawable ||
|
|
894
|
-
const adjustedWithdrawable = Math.max(0, withdrawableAmount -
|
|
850
|
+
const withdrawableAmount = parseFloat(clearinghouseState.withdrawable || "0");
|
|
851
|
+
const adjustedWithdrawable = Math.max(0, withdrawableAmount -
|
|
852
|
+
((_a = platformAccountSummary === null || platformAccountSummary === void 0 ? void 0 : platformAccountSummary.totalTwapChunkUsdValue) !== null && _a !== void 0 ? _a : 0) -
|
|
853
|
+
((_b = platformAccountSummary === null || platformAccountSummary === void 0 ? void 0 : platformAccountSummary.totalLimitOrderUsdValue) !== null && _b !== void 0 ? _b : 0));
|
|
895
854
|
const accountSummary = {
|
|
896
855
|
balanceSummary: {
|
|
897
|
-
crossMaintenanceMarginUsed: clearinghouseState.crossMaintenanceMarginUsed ||
|
|
856
|
+
crossMaintenanceMarginUsed: clearinghouseState.crossMaintenanceMarginUsed || "0",
|
|
898
857
|
crossMarginSummary: {
|
|
899
|
-
accountValue: ((_c = clearinghouseState.crossMarginSummary) === null || _c === void 0 ? void 0 : _c.accountValue) ||
|
|
900
|
-
totalMarginUsed: ((_d = clearinghouseState.crossMarginSummary) === null || _d === void 0 ? void 0 : _d.totalMarginUsed) ||
|
|
901
|
-
totalNtlPos: ((_e = clearinghouseState.crossMarginSummary) === null || _e === void 0 ? void 0 : _e.totalNtlPos) ||
|
|
902
|
-
totalRawUsd: ((_f = clearinghouseState.crossMarginSummary) === null || _f === void 0 ? void 0 : _f.totalRawUsd) ||
|
|
858
|
+
accountValue: ((_c = clearinghouseState.crossMarginSummary) === null || _c === void 0 ? void 0 : _c.accountValue) || "0",
|
|
859
|
+
totalMarginUsed: ((_d = clearinghouseState.crossMarginSummary) === null || _d === void 0 ? void 0 : _d.totalMarginUsed) || "0",
|
|
860
|
+
totalNtlPos: ((_e = clearinghouseState.crossMarginSummary) === null || _e === void 0 ? void 0 : _e.totalNtlPos) || "0",
|
|
861
|
+
totalRawUsd: ((_f = clearinghouseState.crossMarginSummary) === null || _f === void 0 ? void 0 : _f.totalRawUsd) || "0",
|
|
903
862
|
},
|
|
904
863
|
marginSummary: {
|
|
905
|
-
accountValue: ((_g = clearinghouseState.marginSummary) === null || _g === void 0 ? void 0 : _g.accountValue) ||
|
|
906
|
-
totalMarginUsed: ((_h = clearinghouseState.marginSummary) === null || _h === void 0 ? void 0 : _h.totalMarginUsed) ||
|
|
907
|
-
totalNtlPos: ((_j = clearinghouseState.marginSummary) === null || _j === void 0 ? void 0 : _j.totalNtlPos) ||
|
|
908
|
-
totalRawUsd: ((_k = clearinghouseState.marginSummary) === null || _k === void 0 ? void 0 : _k.totalRawUsd) ||
|
|
864
|
+
accountValue: ((_g = clearinghouseState.marginSummary) === null || _g === void 0 ? void 0 : _g.accountValue) || "0",
|
|
865
|
+
totalMarginUsed: ((_h = clearinghouseState.marginSummary) === null || _h === void 0 ? void 0 : _h.totalMarginUsed) || "0",
|
|
866
|
+
totalNtlPos: ((_j = clearinghouseState.marginSummary) === null || _j === void 0 ? void 0 : _j.totalNtlPos) || "0",
|
|
867
|
+
totalRawUsd: ((_k = clearinghouseState.marginSummary) === null || _k === void 0 ? void 0 : _k.totalRawUsd) || "0",
|
|
909
868
|
},
|
|
910
869
|
time: clearinghouseState.time || Date.now(),
|
|
911
|
-
withdrawable: adjustedWithdrawable.toString()
|
|
912
|
-
}
|
|
870
|
+
withdrawable: adjustedWithdrawable.toString(),
|
|
871
|
+
},
|
|
872
|
+
platformAccountSummary,
|
|
913
873
|
};
|
|
914
874
|
if (platformAccountSummary === null || platformAccountSummary === void 0 ? void 0 : platformAccountSummary.agentWalletAddress) {
|
|
915
875
|
accountSummary.agentWallet = {
|
|
916
876
|
address: platformAccountSummary.agentWalletAddress,
|
|
917
|
-
status: registeredAgentWallets.find((agent) => {
|
|
877
|
+
status: registeredAgentWallets.find((agent) => {
|
|
878
|
+
var _a;
|
|
879
|
+
return agent.address.toLowerCase() ===
|
|
880
|
+
((_a = platformAccountSummary.agentWalletAddress) === null || _a === void 0 ? void 0 : _a.toLowerCase());
|
|
881
|
+
})
|
|
882
|
+
? "ACTIVE"
|
|
883
|
+
: "EXPIRED",
|
|
918
884
|
};
|
|
919
885
|
}
|
|
920
886
|
return accountSummary;
|
|
@@ -7032,47 +6998,38 @@ async function logout(baseUrl, refreshTokenVal) {
|
|
|
7032
6998
|
function useAuth() {
|
|
7033
6999
|
const context = useContext(PearHyperliquidContext);
|
|
7034
7000
|
if (!context) {
|
|
7035
|
-
throw new Error("
|
|
7001
|
+
throw new Error("usePortfolio must be used within a PearHyperliquidProvider");
|
|
7036
7002
|
}
|
|
7037
7003
|
const { apiBaseUrl, clientId } = context;
|
|
7004
|
+
const [isReady, setIsReady] = useState(false);
|
|
7038
7005
|
const accessToken = useUserData((s) => s.accessToken);
|
|
7039
7006
|
const refreshToken$1 = useUserData((s) => s.refreshToken);
|
|
7040
|
-
const isReady = useUserData((s) => s.isReady);
|
|
7041
|
-
const isAuthenticated = useUserData((s) => s.isAuthenticated);
|
|
7042
|
-
const address = useUserData((s) => s.address);
|
|
7043
7007
|
const setAccessToken = useUserData((s) => s.setAccessToken);
|
|
7044
7008
|
const setRefreshToken = useUserData((s) => s.setRefreshToken);
|
|
7045
|
-
const
|
|
7009
|
+
const isAuthenticated = useUserData((s) => s.isAuthenticated);
|
|
7046
7010
|
const setIsAuthenticated = useUserData((s) => s.setIsAuthenticated);
|
|
7047
7011
|
const setAddress = useUserData((s) => s.setAddress);
|
|
7048
|
-
console.log("sdk", { sdkAddress: address });
|
|
7049
7012
|
useEffect(() => {
|
|
7050
7013
|
if (typeof window == "undefined") {
|
|
7051
7014
|
return;
|
|
7052
7015
|
}
|
|
7053
|
-
|
|
7054
|
-
|
|
7055
|
-
|
|
7056
|
-
|
|
7057
|
-
|
|
7058
|
-
|
|
7059
|
-
|
|
7060
|
-
|
|
7061
|
-
setAccessToken(storedAccessToken);
|
|
7062
|
-
setRefreshToken(storedRefreshToken);
|
|
7063
|
-
setIsAuthenticated(true);
|
|
7064
|
-
}
|
|
7065
|
-
}
|
|
7016
|
+
const access = localStorage.getItem("accessToken");
|
|
7017
|
+
const refresh = localStorage.getItem("refreshToken");
|
|
7018
|
+
const addr = localStorage.getItem("address");
|
|
7019
|
+
setAccessToken(access);
|
|
7020
|
+
setRefreshToken(refresh);
|
|
7021
|
+
setAddress(addr);
|
|
7022
|
+
const authed = Boolean(access && addr);
|
|
7023
|
+
setIsAuthenticated(authed);
|
|
7066
7024
|
setIsReady(true);
|
|
7067
|
-
}, [
|
|
7025
|
+
}, [setAccessToken, setRefreshToken, setIsAuthenticated, setAddress]);
|
|
7068
7026
|
useEffect(() => {
|
|
7069
7027
|
const cleanup = addAuthInterceptors({
|
|
7070
7028
|
apiBaseUrl,
|
|
7071
7029
|
getAccessToken: () => {
|
|
7072
|
-
|
|
7073
|
-
|
|
7074
|
-
|
|
7075
|
-
return useUserData.getState().accessToken;
|
|
7030
|
+
return typeof window !== "undefined"
|
|
7031
|
+
? window.localStorage.getItem("accessToken")
|
|
7032
|
+
: null;
|
|
7076
7033
|
},
|
|
7077
7034
|
refreshTokens: async () => {
|
|
7078
7035
|
const data = await refreshTokens();
|
|
@@ -7098,13 +7055,12 @@ function useAuth() {
|
|
|
7098
7055
|
clientId,
|
|
7099
7056
|
details: { signature, timestamp },
|
|
7100
7057
|
});
|
|
7101
|
-
|
|
7102
|
-
|
|
7103
|
-
window.localStorage.setItem(
|
|
7104
|
-
window.localStorage.setItem(refreshTokenKey, data.refreshToken);
|
|
7058
|
+
window.localStorage.setItem("accessToken", data.accessToken);
|
|
7059
|
+
window.localStorage.setItem("refreshToken", data.refreshToken);
|
|
7060
|
+
window.localStorage.setItem("address", address);
|
|
7105
7061
|
setAccessToken(data.accessToken);
|
|
7106
7062
|
setRefreshToken(data.refreshToken);
|
|
7107
|
-
|
|
7063
|
+
setAddress(address);
|
|
7108
7064
|
setIsAuthenticated(true);
|
|
7109
7065
|
}
|
|
7110
7066
|
catch (e) {
|
|
@@ -7119,13 +7075,12 @@ function useAuth() {
|
|
|
7119
7075
|
appId,
|
|
7120
7076
|
accessToken: privyAccessToken,
|
|
7121
7077
|
});
|
|
7122
|
-
|
|
7123
|
-
|
|
7124
|
-
window.localStorage.setItem(
|
|
7125
|
-
window.localStorage.setItem(refreshTokenKey, data.refreshToken);
|
|
7078
|
+
window.localStorage.setItem("accessToken", data.accessToken);
|
|
7079
|
+
window.localStorage.setItem("refreshToken", data.refreshToken);
|
|
7080
|
+
window.localStorage.setItem("address", address);
|
|
7126
7081
|
setAccessToken(data.accessToken);
|
|
7127
7082
|
setRefreshToken(data.refreshToken);
|
|
7128
|
-
|
|
7083
|
+
setAddress(address);
|
|
7129
7084
|
setIsAuthenticated(true);
|
|
7130
7085
|
}
|
|
7131
7086
|
catch (e) {
|
|
@@ -7133,41 +7088,33 @@ function useAuth() {
|
|
|
7133
7088
|
}
|
|
7134
7089
|
}
|
|
7135
7090
|
async function refreshTokens() {
|
|
7136
|
-
const
|
|
7137
|
-
|
|
7138
|
-
if (!currentRefresh || !currentAddress)
|
|
7091
|
+
const refresh = window.localStorage.getItem("refreshToken");
|
|
7092
|
+
if (!refresh)
|
|
7139
7093
|
throw new Error("No refresh token");
|
|
7140
|
-
const { data } = await refreshToken(apiBaseUrl,
|
|
7141
|
-
|
|
7142
|
-
|
|
7143
|
-
const refreshTokenKey = `${currentAddress}_refreshToken`;
|
|
7144
|
-
window.localStorage.setItem(accessTokenKey, data.accessToken);
|
|
7145
|
-
window.localStorage.setItem(refreshTokenKey, data.refreshToken);
|
|
7094
|
+
const { data } = await refreshToken(apiBaseUrl, refresh);
|
|
7095
|
+
window.localStorage.setItem("accessToken", data.accessToken);
|
|
7096
|
+
window.localStorage.setItem("refreshToken", data.refreshToken);
|
|
7146
7097
|
setAccessToken(data.accessToken);
|
|
7147
7098
|
setRefreshToken(data.refreshToken);
|
|
7148
7099
|
setIsAuthenticated(true);
|
|
7149
7100
|
return data;
|
|
7150
7101
|
}
|
|
7151
7102
|
async function logout$1() {
|
|
7152
|
-
const
|
|
7153
|
-
|
|
7154
|
-
if (currentRefresh) {
|
|
7103
|
+
const refresh = window.localStorage.getItem("refreshToken");
|
|
7104
|
+
if (refresh) {
|
|
7155
7105
|
try {
|
|
7156
|
-
await logout(apiBaseUrl,
|
|
7106
|
+
await logout(apiBaseUrl, refresh);
|
|
7157
7107
|
}
|
|
7158
7108
|
catch (_a) {
|
|
7159
7109
|
/* ignore */
|
|
7160
7110
|
}
|
|
7161
7111
|
}
|
|
7162
|
-
|
|
7163
|
-
|
|
7164
|
-
|
|
7165
|
-
window.localStorage.removeItem(accessTokenKey);
|
|
7166
|
-
window.localStorage.removeItem(refreshTokenKey);
|
|
7167
|
-
}
|
|
7112
|
+
window.localStorage.removeItem("accessToken");
|
|
7113
|
+
window.localStorage.removeItem("refreshToken");
|
|
7114
|
+
window.localStorage.removeItem("address");
|
|
7168
7115
|
setAccessToken(null);
|
|
7169
7116
|
setRefreshToken(null);
|
|
7170
|
-
|
|
7117
|
+
setAddress(null);
|
|
7171
7118
|
setIsAuthenticated(false);
|
|
7172
7119
|
}
|
|
7173
7120
|
return {
|
|
@@ -7180,8 +7127,6 @@ function useAuth() {
|
|
|
7180
7127
|
loginWithPrivyToken,
|
|
7181
7128
|
refreshTokens,
|
|
7182
7129
|
logout: logout$1,
|
|
7183
|
-
setAddress,
|
|
7184
|
-
address,
|
|
7185
7130
|
};
|
|
7186
7131
|
}
|
|
7187
7132
|
|
|
@@ -7191,7 +7136,7 @@ const PearHyperliquidContext = createContext(undefined);
|
|
|
7191
7136
|
*/
|
|
7192
7137
|
const PearHyperliquidProvider = ({ children, apiBaseUrl = "https://hl-v2.pearprotocol.io", clientId = "PEARPROTOCOLUI", wsUrl = "wss://hl-v2.pearprotocol.io/ws", }) => {
|
|
7193
7138
|
const address = useUserData((s) => s.address);
|
|
7194
|
-
useUserData((s) => s.setAddress);
|
|
7139
|
+
const setAddress = useUserData((s) => s.setAddress);
|
|
7195
7140
|
const perpsMetaAssets = useHyperliquidData((state) => state.perpMetaAssets);
|
|
7196
7141
|
const setPerpMetaAssets = useHyperliquidData((state) => state.setPerpMetaAssets);
|
|
7197
7142
|
const setHip3DisplayToFull = useHyperliquidData((state) => state.setHip3DisplayToFull);
|
|
@@ -7209,7 +7154,10 @@ const PearHyperliquidProvider = ({ children, apiBaseUrl = "https://hl-v2.pearpro
|
|
|
7209
7154
|
if (perpsMetaAssets === null) {
|
|
7210
7155
|
fetchAllPerpMetas()
|
|
7211
7156
|
.then((res) => {
|
|
7212
|
-
|
|
7157
|
+
// Only show HL and XYZ for now as other are using USDH collateral and need more work
|
|
7158
|
+
const aggregatedPerpMetas = res.data
|
|
7159
|
+
.slice(0, 2)
|
|
7160
|
+
.flatMap((item) => item.universe);
|
|
7213
7161
|
const hip3Map = new Map();
|
|
7214
7162
|
const displayToFull = new Map();
|
|
7215
7163
|
const cleanedPerpMetas = aggregatedPerpMetas.map((asset) => {
|
|
@@ -7253,6 +7201,8 @@ const PearHyperliquidProvider = ({ children, apiBaseUrl = "https://hl-v2.pearpro
|
|
|
7253
7201
|
}), [
|
|
7254
7202
|
apiBaseUrl,
|
|
7255
7203
|
wsUrl,
|
|
7204
|
+
address,
|
|
7205
|
+
setAddress,
|
|
7256
7206
|
isConnected,
|
|
7257
7207
|
lastError,
|
|
7258
7208
|
nativeIsConnected,
|
|
@@ -10,16 +10,5 @@ interface TokenHistoricalPriceData {
|
|
|
10
10
|
oldestTime: number | null;
|
|
11
11
|
latestTime: number | null;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
historicalPriceData: Record<string, TokenHistoricalPriceData>;
|
|
15
|
-
loadingTokens: Set<string>;
|
|
16
|
-
addHistoricalPriceData: (symbol: string, interval: CandleInterval, candles: CandleData[], range: HistoricalRange) => void;
|
|
17
|
-
hasHistoricalPriceData: (symbol: string, interval: CandleInterval, startTime: number, endTime: number) => boolean;
|
|
18
|
-
getHistoricalPriceData: (symbol: string, interval: CandleInterval, startTime: number, endTime: number) => CandleData[];
|
|
19
|
-
setTokenLoading: (symbol: string, loading: boolean) => void;
|
|
20
|
-
isTokenLoading: (symbol: string) => boolean;
|
|
21
|
-
removeTokenPriceData: (symbol: string, interval: CandleInterval) => void;
|
|
22
|
-
clearData: () => void;
|
|
23
|
-
}
|
|
24
|
-
export declare const useHistoricalPriceDataStore: import("zustand").UseBoundStore<import("zustand").StoreApi<HistoricalPriceDataState>>;
|
|
13
|
+
export declare const useHistoricalPriceDataStore: any;
|
|
25
14
|
export type { HistoricalRange, TokenHistoricalPriceData };
|
|
@@ -1,25 +1 @@
|
|
|
1
|
-
|
|
2
|
-
interface HyperliquidDataState {
|
|
3
|
-
allMids: WsAllMidsData | null;
|
|
4
|
-
activeAssetData: Record<string, ActiveAssetData> | null;
|
|
5
|
-
candleData: CandleChartData | null;
|
|
6
|
-
finalAssetContexts: WebData3AssetCtx[] | null;
|
|
7
|
-
finalAtOICaps: string[] | null;
|
|
8
|
-
aggregatedClearingHouseState: ClearinghouseState | null;
|
|
9
|
-
perpMetaAssets: UniverseAsset[] | null;
|
|
10
|
-
hip3DisplayToFull: Map<string, string>;
|
|
11
|
-
setAllMids: (value: WsAllMidsData | null) => void;
|
|
12
|
-
setActiveAssetData: (value: Record<string, ActiveAssetData> | null | ((prev: Record<string, ActiveAssetData> | null) => Record<string, ActiveAssetData> | null)) => void;
|
|
13
|
-
deleteActiveAssetData: (key: string) => void;
|
|
14
|
-
addCandleData: (symbol: string, candle: CandleData) => void;
|
|
15
|
-
deleteCandleSymbol: (symbol: string) => void;
|
|
16
|
-
setCandleData: (value: CandleChartData | null) => void;
|
|
17
|
-
upsertActiveAssetData: (key: string, value: ActiveAssetData) => void;
|
|
18
|
-
setFinalAssetContexts: (value: WebData3AssetCtx[] | null) => void;
|
|
19
|
-
setFinalAtOICaps: (value: string[] | null) => void;
|
|
20
|
-
setAggregatedClearingHouseState: (value: ClearinghouseState | null) => void;
|
|
21
|
-
setPerpMetaAssets: (value: UniverseAsset[] | null) => void;
|
|
22
|
-
setHip3DisplayToFull: (value: Map<string, string>) => void;
|
|
23
|
-
}
|
|
24
|
-
export declare const useHyperliquidData: import("zustand").UseBoundStore<import("zustand").StoreApi<HyperliquidDataState>>;
|
|
25
|
-
export {};
|
|
1
|
+
export declare const useHyperliquidData: any;
|
|
@@ -1,10 +1 @@
|
|
|
1
|
-
|
|
2
|
-
interface MarketDataState {
|
|
3
|
-
marketData: ActiveAssetsResponse | null;
|
|
4
|
-
marketDataAll: ActiveAssetsAllResponse | null;
|
|
5
|
-
setMarketData: (value: ActiveAssetsResponse | null) => void;
|
|
6
|
-
setMarketDataAll: (value: ActiveAssetsAllResponse | null) => void;
|
|
7
|
-
clean: () => void;
|
|
8
|
-
}
|
|
9
|
-
export declare const useMarketData: import("zustand").UseBoundStore<import("zustand").StoreApi<MarketDataState>>;
|
|
10
|
-
export {};
|
|
1
|
+
export declare const useMarketData: any;
|
|
@@ -24,4 +24,4 @@ export interface TokenSelectionMetadataState {
|
|
|
24
24
|
shortTokens: TokenSelection[];
|
|
25
25
|
}) => void;
|
|
26
26
|
}
|
|
27
|
-
export declare const useTokenSelectionMetadataStore:
|
|
27
|
+
export declare const useTokenSelectionMetadataStore: any;
|
|
@@ -1,30 +1 @@
|
|
|
1
|
-
|
|
2
|
-
interface UserDataState {
|
|
3
|
-
accessToken: string | null;
|
|
4
|
-
refreshToken: string | null;
|
|
5
|
-
isAuthenticated: boolean;
|
|
6
|
-
isReady: boolean;
|
|
7
|
-
address: string | null;
|
|
8
|
-
tradeHistories: TradeHistoryDataDto[] | null;
|
|
9
|
-
rawOpenPositions: RawPositionDto[] | null;
|
|
10
|
-
openOrders: OpenLimitOrderDto[] | null;
|
|
11
|
-
accountSummary: PlatformAccountSummaryResponseDto | null;
|
|
12
|
-
twapDetails: TwapMonitoringDto[] | null;
|
|
13
|
-
notifications: NotificationDto[] | null;
|
|
14
|
-
userExtraAgents: ExtraAgent[] | null;
|
|
15
|
-
setAccessToken: (token: string | null) => void;
|
|
16
|
-
setRefreshToken: (token: string | null) => void;
|
|
17
|
-
setIsAuthenticated: (value: boolean) => void;
|
|
18
|
-
setIsReady: (value: boolean) => void;
|
|
19
|
-
setAddress: (address: string | null) => void;
|
|
20
|
-
setTradeHistories: (value: TradeHistoryDataDto[] | null) => void;
|
|
21
|
-
setRawOpenPositions: (value: RawPositionDto[] | null) => void;
|
|
22
|
-
setOpenOrders: (value: OpenLimitOrderDto[] | null) => void;
|
|
23
|
-
setAccountSummary: (value: PlatformAccountSummaryResponseDto | null) => void;
|
|
24
|
-
setUserExtraAgents: (value: ExtraAgent[] | null) => void;
|
|
25
|
-
setTwapDetails: (value: TwapMonitoringDto[] | null) => void;
|
|
26
|
-
setNotifications: (value: NotificationDto[] | null) => void;
|
|
27
|
-
clean: () => void;
|
|
28
|
-
}
|
|
29
|
-
export declare const useUserData: import("zustand").UseBoundStore<import("zustand").StoreApi<UserDataState>>;
|
|
30
|
-
export {};
|
|
1
|
+
export declare const useUserData: any;
|
|
@@ -22,5 +22,5 @@ interface UserSelectionState {
|
|
|
22
22
|
setTokenSelections: (longTokens: TokenSelection[], shortTokens: TokenSelection[]) => void;
|
|
23
23
|
resetToDefaults: () => void;
|
|
24
24
|
}
|
|
25
|
-
export declare const useUserSelection:
|
|
25
|
+
export declare const useUserSelection: any;
|
|
26
26
|
export type { UserSelectionState };
|
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;
|
|
@@ -212,7 +212,7 @@ export interface PositionAssetDetailDto {
|
|
|
212
212
|
fundingPaid?: number;
|
|
213
213
|
}
|
|
214
214
|
export interface TpSlThreshold {
|
|
215
|
-
type:
|
|
215
|
+
type: "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE";
|
|
216
216
|
value: number;
|
|
217
217
|
}
|
|
218
218
|
/**
|
|
@@ -247,16 +247,16 @@ export interface OrderAssetDto {
|
|
|
247
247
|
/**
|
|
248
248
|
* Order status
|
|
249
249
|
*/
|
|
250
|
-
export type OrderStatus =
|
|
250
|
+
export type OrderStatus = "OPEN" | "PARTIALLY_FILLED" | "PROCESSING";
|
|
251
251
|
/**
|
|
252
252
|
* Order type
|
|
253
253
|
*/
|
|
254
|
-
export type OrderType =
|
|
254
|
+
export type OrderType = "TP" | "SL" | "LIMIT" | "MARKET" | "LIMIT_BTCDOM" | "TWAP";
|
|
255
255
|
/**
|
|
256
256
|
* TP/SL trigger type
|
|
257
257
|
*/
|
|
258
|
-
export type TpSlTriggerType =
|
|
259
|
-
export type OrderDirection =
|
|
258
|
+
export type TpSlTriggerType = "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE";
|
|
259
|
+
export type OrderDirection = "MORE_THAN" | "LESS_THAN" | null;
|
|
260
260
|
/**
|
|
261
261
|
* Open limit order data structure
|
|
262
262
|
*/
|
|
@@ -327,6 +327,7 @@ export interface PlatformAccountSummaryResponseDto {
|
|
|
327
327
|
*/
|
|
328
328
|
export interface AccountSummaryResponseDto {
|
|
329
329
|
balanceSummary: BalanceSummaryDto;
|
|
330
|
+
platformAccountSummary: PlatformAccountSummaryResponseDto | null;
|
|
330
331
|
agentWallet?: AgentWalletDto;
|
|
331
332
|
}
|
|
332
333
|
/**
|
|
@@ -369,7 +370,7 @@ export interface PrivyAuthDetails {
|
|
|
369
370
|
accessToken: string;
|
|
370
371
|
}
|
|
371
372
|
export interface AuthenticateRequest {
|
|
372
|
-
method:
|
|
373
|
+
method: "eip712" | "api_key" | "privy_access_token";
|
|
373
374
|
address: string;
|
|
374
375
|
clientId: string;
|
|
375
376
|
details: {
|
|
@@ -402,7 +403,7 @@ export interface LogoutRequest {
|
|
|
402
403
|
export interface LogoutResponse {
|
|
403
404
|
message: string;
|
|
404
405
|
}
|
|
405
|
-
export type AgentWalletStatus =
|
|
406
|
+
export type AgentWalletStatus = "ACTIVE" | "EXPIRED" | "NOT_FOUND";
|
|
406
407
|
export interface GetAgentWalletResponseDto {
|
|
407
408
|
agentWalletAddress?: string;
|
|
408
409
|
agentName: string;
|
|
@@ -420,7 +421,7 @@ export interface ExtraAgent {
|
|
|
420
421
|
export interface AgentWalletState {
|
|
421
422
|
address: string | null;
|
|
422
423
|
name: string | null;
|
|
423
|
-
status: AgentWalletStatus |
|
|
424
|
+
status: AgentWalletStatus | "PENDING" | null;
|
|
424
425
|
isActive: boolean;
|
|
425
426
|
}
|
|
426
427
|
/**
|
|
@@ -440,7 +441,7 @@ export interface WebSocketMessage {
|
|
|
440
441
|
/**
|
|
441
442
|
* WebSocket response from HyperLiquid native API
|
|
442
443
|
*/
|
|
443
|
-
export type HLChannel =
|
|
444
|
+
export type HLChannel = "webData3" | "allMids" | "activeAssetData" | "candle";
|
|
444
445
|
export interface HLChannelDataMap {
|
|
445
446
|
webData3: WebData3Response;
|
|
446
447
|
allMids: WsAllMidsData;
|
|
@@ -658,7 +659,7 @@ export interface TokenSelection {
|
|
|
658
659
|
*/
|
|
659
660
|
export interface TokenConflict {
|
|
660
661
|
symbol: string;
|
|
661
|
-
conflictType:
|
|
662
|
+
conflictType: "long" | "short";
|
|
662
663
|
conflictMessage: string;
|
|
663
664
|
}
|
|
664
665
|
export interface AssetMarketData {
|
|
@@ -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
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pear-protocol/hyperliquid-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.61",
|
|
4
4
|
"description": "React SDK for Pear Protocol Hyperliquid API integration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -24,8 +24,7 @@
|
|
|
24
24
|
"clean": "rimraf dist"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"axios": "^1.6.0"
|
|
28
|
-
"zustand": "^5.0.8"
|
|
27
|
+
"axios": "^1.6.0"
|
|
29
28
|
},
|
|
30
29
|
"peerDependencies": {
|
|
31
30
|
"react": "^18.0.0",
|