@pear-protocol/hyperliquid-sdk 0.0.60-beta-usdh-2 → 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/hooks/useAuth.d.ts +1 -1
- package/dist/index.d.ts +18 -17
- package/dist/index.js +59 -41
- 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/hooks/useAuth.d.ts
CHANGED
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
|
*/
|
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;
|
|
@@ -7560,7 +7569,7 @@ async function logout(baseUrl, refreshTokenVal) {
|
|
|
7560
7569
|
function useAuth() {
|
|
7561
7570
|
const context = useContext(PearHyperliquidContext);
|
|
7562
7571
|
if (!context) {
|
|
7563
|
-
throw new Error(
|
|
7572
|
+
throw new Error("usePortfolio must be used within a PearHyperliquidProvider");
|
|
7564
7573
|
}
|
|
7565
7574
|
const { apiBaseUrl, clientId } = context;
|
|
7566
7575
|
const [isReady, setIsReady] = useState(false);
|
|
@@ -7572,12 +7581,12 @@ function useAuth() {
|
|
|
7572
7581
|
const setIsAuthenticated = useUserData((s) => s.setIsAuthenticated);
|
|
7573
7582
|
const setAddress = useUserData((s) => s.setAddress);
|
|
7574
7583
|
useEffect(() => {
|
|
7575
|
-
if (typeof window ==
|
|
7584
|
+
if (typeof window == "undefined") {
|
|
7576
7585
|
return;
|
|
7577
7586
|
}
|
|
7578
|
-
const access = localStorage.getItem(
|
|
7579
|
-
const refresh = localStorage.getItem(
|
|
7580
|
-
const addr = localStorage.getItem(
|
|
7587
|
+
const access = localStorage.getItem("accessToken");
|
|
7588
|
+
const refresh = localStorage.getItem("refreshToken");
|
|
7589
|
+
const addr = localStorage.getItem("address");
|
|
7581
7590
|
setAccessToken(access);
|
|
7582
7591
|
setRefreshToken(refresh);
|
|
7583
7592
|
setAddress(addr);
|
|
@@ -7589,7 +7598,9 @@ function useAuth() {
|
|
|
7589
7598
|
const cleanup = addAuthInterceptors({
|
|
7590
7599
|
apiBaseUrl,
|
|
7591
7600
|
getAccessToken: () => {
|
|
7592
|
-
return typeof window !==
|
|
7601
|
+
return typeof window !== "undefined"
|
|
7602
|
+
? window.localStorage.getItem("accessToken")
|
|
7603
|
+
: null;
|
|
7593
7604
|
},
|
|
7594
7605
|
refreshTokens: async () => {
|
|
7595
7606
|
const data = await refreshTokens();
|
|
@@ -7610,14 +7621,14 @@ function useAuth() {
|
|
|
7610
7621
|
async function loginWithSignedMessage(address, signature, timestamp) {
|
|
7611
7622
|
try {
|
|
7612
7623
|
const { data } = await authenticate(apiBaseUrl, {
|
|
7613
|
-
method:
|
|
7624
|
+
method: "eip712",
|
|
7614
7625
|
address,
|
|
7615
7626
|
clientId,
|
|
7616
7627
|
details: { signature, timestamp },
|
|
7617
7628
|
});
|
|
7618
|
-
window.localStorage.setItem(
|
|
7619
|
-
window.localStorage.setItem(
|
|
7620
|
-
window.localStorage.setItem(
|
|
7629
|
+
window.localStorage.setItem("accessToken", data.accessToken);
|
|
7630
|
+
window.localStorage.setItem("refreshToken", data.refreshToken);
|
|
7631
|
+
window.localStorage.setItem("address", address);
|
|
7621
7632
|
setAccessToken(data.accessToken);
|
|
7622
7633
|
setRefreshToken(data.refreshToken);
|
|
7623
7634
|
setAddress(address);
|
|
@@ -7629,10 +7640,15 @@ function useAuth() {
|
|
|
7629
7640
|
}
|
|
7630
7641
|
async function loginWithPrivyToken(address, appId, privyAccessToken) {
|
|
7631
7642
|
try {
|
|
7632
|
-
const { data } = await authenticateWithPrivy(apiBaseUrl, {
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
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);
|
|
7636
7652
|
setAccessToken(data.accessToken);
|
|
7637
7653
|
setRefreshToken(data.refreshToken);
|
|
7638
7654
|
setAddress(address);
|
|
@@ -7643,28 +7659,30 @@ function useAuth() {
|
|
|
7643
7659
|
}
|
|
7644
7660
|
}
|
|
7645
7661
|
async function refreshTokens() {
|
|
7646
|
-
const refresh = window.localStorage.getItem(
|
|
7662
|
+
const refresh = window.localStorage.getItem("refreshToken");
|
|
7647
7663
|
if (!refresh)
|
|
7648
|
-
throw new Error(
|
|
7664
|
+
throw new Error("No refresh token");
|
|
7649
7665
|
const { data } = await refreshToken(apiBaseUrl, refresh);
|
|
7650
|
-
window.localStorage.setItem(
|
|
7651
|
-
window.localStorage.setItem(
|
|
7666
|
+
window.localStorage.setItem("accessToken", data.accessToken);
|
|
7667
|
+
window.localStorage.setItem("refreshToken", data.refreshToken);
|
|
7652
7668
|
setAccessToken(data.accessToken);
|
|
7653
7669
|
setRefreshToken(data.refreshToken);
|
|
7654
7670
|
setIsAuthenticated(true);
|
|
7655
7671
|
return data;
|
|
7656
7672
|
}
|
|
7657
7673
|
async function logout$1() {
|
|
7658
|
-
const refresh = window.localStorage.getItem(
|
|
7674
|
+
const refresh = window.localStorage.getItem("refreshToken");
|
|
7659
7675
|
if (refresh) {
|
|
7660
7676
|
try {
|
|
7661
7677
|
await logout(apiBaseUrl, refresh);
|
|
7662
7678
|
}
|
|
7663
|
-
catch (
|
|
7679
|
+
catch (_a) {
|
|
7680
|
+
/* ignore */
|
|
7681
|
+
}
|
|
7664
7682
|
}
|
|
7665
|
-
window.localStorage.removeItem(
|
|
7666
|
-
window.localStorage.removeItem(
|
|
7667
|
-
window.localStorage.removeItem(
|
|
7683
|
+
window.localStorage.removeItem("accessToken");
|
|
7684
|
+
window.localStorage.removeItem("refreshToken");
|
|
7685
|
+
window.localStorage.removeItem("address");
|
|
7668
7686
|
setAccessToken(null);
|
|
7669
7687
|
setRefreshToken(null);
|
|
7670
7688
|
setAddress(null);
|
|
@@ -7687,7 +7705,7 @@ const PearHyperliquidContext = createContext(undefined);
|
|
|
7687
7705
|
/**
|
|
7688
7706
|
* React Provider for PearHyperliquidClient
|
|
7689
7707
|
*/
|
|
7690
|
-
const PearHyperliquidProvider = ({ children, apiBaseUrl =
|
|
7708
|
+
const PearHyperliquidProvider = ({ children, apiBaseUrl = "https://hl-v2.pearprotocol.io", clientId = "PEARPROTOCOLUI", wsUrl = "wss://hl-v2.pearprotocol.io/ws", }) => {
|
|
7691
7709
|
const address = useUserData((s) => s.address);
|
|
7692
7710
|
const setAddress = useUserData((s) => s.setAddress);
|
|
7693
7711
|
const perpsMetaAssets = useHyperliquidData((state) => state.perpMetaAssets);
|
|
@@ -7715,10 +7733,10 @@ const PearHyperliquidProvider = ({ children, apiBaseUrl = 'https://hl-v2.pearpro
|
|
|
7715
7733
|
// Process each market group (different collateral tokens)
|
|
7716
7734
|
res.data.forEach((item) => {
|
|
7717
7735
|
// Convert numeric collateral token to human-readable name
|
|
7718
|
-
const collateralToken = item.collateralToken === 360 ?
|
|
7736
|
+
const collateralToken = item.collateralToken === 360 ? "USDH" : "USDC";
|
|
7719
7737
|
item.universe.forEach((asset) => {
|
|
7720
7738
|
var _a;
|
|
7721
|
-
const [maybePrefix, maybeMarket] = asset.name.split(
|
|
7739
|
+
const [maybePrefix, maybeMarket] = asset.name.split(":");
|
|
7722
7740
|
if (maybeMarket) {
|
|
7723
7741
|
// HIP-3 market with prefix (e.g., "xyz:TSLA")
|
|
7724
7742
|
const prefix = maybePrefix.toLowerCase();
|
|
@@ -7802,7 +7820,7 @@ const PearHyperliquidProvider = ({ children, apiBaseUrl = 'https://hl-v2.pearpro
|
|
|
7802
7820
|
function usePearHyperliquid() {
|
|
7803
7821
|
const ctx = useContext(PearHyperliquidContext);
|
|
7804
7822
|
if (!ctx)
|
|
7805
|
-
throw new Error(
|
|
7823
|
+
throw new Error("usePearHyperliquid must be used within a PearHyperliquidProvider");
|
|
7806
7824
|
return ctx;
|
|
7807
7825
|
}
|
|
7808
7826
|
|
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
|
*/
|