@pear-protocol/hyperliquid-sdk 0.0.58 → 0.0.60-alpha-1
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 +17 -16
- package/dist/index.js +65 -40
- package/dist/types.d.ts +18 -17
- package/dist/utils/account-summary-calculator.d.ts +1 -1
- package/package.json +1 -2
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;
|
|
@@ -228,7 +228,7 @@ interface PositionAssetDetailDto {
|
|
|
228
228
|
fundingPaid?: number;
|
|
229
229
|
}
|
|
230
230
|
interface TpSlThreshold {
|
|
231
|
-
type:
|
|
231
|
+
type: "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE";
|
|
232
232
|
value: number;
|
|
233
233
|
}
|
|
234
234
|
/**
|
|
@@ -263,16 +263,16 @@ interface OrderAssetDto {
|
|
|
263
263
|
/**
|
|
264
264
|
* Order status
|
|
265
265
|
*/
|
|
266
|
-
type OrderStatus =
|
|
266
|
+
type OrderStatus = "OPEN" | "PARTIALLY_FILLED" | "PROCESSING";
|
|
267
267
|
/**
|
|
268
268
|
* Order type
|
|
269
269
|
*/
|
|
270
|
-
type OrderType =
|
|
270
|
+
type OrderType = "TP" | "SL" | "LIMIT" | "MARKET" | "LIMIT_BTCDOM" | "TWAP";
|
|
271
271
|
/**
|
|
272
272
|
* TP/SL trigger type
|
|
273
273
|
*/
|
|
274
|
-
type TpSlTriggerType =
|
|
275
|
-
type OrderDirection =
|
|
274
|
+
type TpSlTriggerType = "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE";
|
|
275
|
+
type OrderDirection = "MORE_THAN" | "LESS_THAN" | null;
|
|
276
276
|
/**
|
|
277
277
|
* Open limit order data structure
|
|
278
278
|
*/
|
|
@@ -343,6 +343,7 @@ interface PlatformAccountSummaryResponseDto {
|
|
|
343
343
|
*/
|
|
344
344
|
interface AccountSummaryResponseDto {
|
|
345
345
|
balanceSummary: BalanceSummaryDto;
|
|
346
|
+
platformAccountSummary: PlatformAccountSummaryResponseDto | null;
|
|
346
347
|
agentWallet?: AgentWalletDto;
|
|
347
348
|
}
|
|
348
349
|
interface UseAuthOptions {
|
|
@@ -377,7 +378,7 @@ interface RefreshTokenResponse {
|
|
|
377
378
|
tokenType: string;
|
|
378
379
|
expiresIn: number;
|
|
379
380
|
}
|
|
380
|
-
type AgentWalletStatus =
|
|
381
|
+
type AgentWalletStatus = "ACTIVE" | "EXPIRED" | "NOT_FOUND";
|
|
381
382
|
interface CreateAgentWalletResponseDto {
|
|
382
383
|
agentWalletAddress: string;
|
|
383
384
|
message: string;
|
|
@@ -390,7 +391,7 @@ interface ExtraAgent {
|
|
|
390
391
|
interface AgentWalletState {
|
|
391
392
|
address: string | null;
|
|
392
393
|
name: string | null;
|
|
393
|
-
status: AgentWalletStatus |
|
|
394
|
+
status: AgentWalletStatus | "PENDING" | null;
|
|
394
395
|
isActive: boolean;
|
|
395
396
|
}
|
|
396
397
|
/**
|
|
@@ -410,7 +411,7 @@ interface WebSocketMessage {
|
|
|
410
411
|
/**
|
|
411
412
|
* WebSocket response from HyperLiquid native API
|
|
412
413
|
*/
|
|
413
|
-
type HLChannel =
|
|
414
|
+
type HLChannel = "webData3" | "allMids" | "activeAssetData" | "candle";
|
|
414
415
|
interface HLChannelDataMap {
|
|
415
416
|
webData3: WebData3Response;
|
|
416
417
|
allMids: WsAllMidsData;
|
|
@@ -610,7 +611,7 @@ interface TokenSelection {
|
|
|
610
611
|
*/
|
|
611
612
|
interface TokenConflict {
|
|
612
613
|
symbol: string;
|
|
613
|
-
conflictType:
|
|
614
|
+
conflictType: "long" | "short";
|
|
614
615
|
conflictMessage: string;
|
|
615
616
|
}
|
|
616
617
|
interface AssetMarketData {
|
package/dist/index.js
CHANGED
|
@@ -847,31 +847,40 @@ class AccountSummaryCalculator {
|
|
|
847
847
|
return null;
|
|
848
848
|
}
|
|
849
849
|
const clearinghouseState = this.clearinghouseState;
|
|
850
|
-
const withdrawableAmount = parseFloat(clearinghouseState.withdrawable ||
|
|
851
|
-
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));
|
|
852
854
|
const accountSummary = {
|
|
853
855
|
balanceSummary: {
|
|
854
|
-
crossMaintenanceMarginUsed: clearinghouseState.crossMaintenanceMarginUsed ||
|
|
856
|
+
crossMaintenanceMarginUsed: clearinghouseState.crossMaintenanceMarginUsed || "0",
|
|
855
857
|
crossMarginSummary: {
|
|
856
|
-
accountValue: ((_c = clearinghouseState.crossMarginSummary) === null || _c === void 0 ? void 0 : _c.accountValue) ||
|
|
857
|
-
totalMarginUsed: ((_d = clearinghouseState.crossMarginSummary) === null || _d === void 0 ? void 0 : _d.totalMarginUsed) ||
|
|
858
|
-
totalNtlPos: ((_e = clearinghouseState.crossMarginSummary) === null || _e === void 0 ? void 0 : _e.totalNtlPos) ||
|
|
859
|
-
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",
|
|
860
862
|
},
|
|
861
863
|
marginSummary: {
|
|
862
|
-
accountValue: ((_g = clearinghouseState.marginSummary) === null || _g === void 0 ? void 0 : _g.accountValue) ||
|
|
863
|
-
totalMarginUsed: ((_h = clearinghouseState.marginSummary) === null || _h === void 0 ? void 0 : _h.totalMarginUsed) ||
|
|
864
|
-
totalNtlPos: ((_j = clearinghouseState.marginSummary) === null || _j === void 0 ? void 0 : _j.totalNtlPos) ||
|
|
865
|
-
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",
|
|
866
868
|
},
|
|
867
869
|
time: clearinghouseState.time || Date.now(),
|
|
868
|
-
withdrawable: adjustedWithdrawable.toString()
|
|
869
|
-
}
|
|
870
|
+
withdrawable: adjustedWithdrawable.toString(),
|
|
871
|
+
},
|
|
872
|
+
platformAccountSummary,
|
|
870
873
|
};
|
|
871
874
|
if (platformAccountSummary === null || platformAccountSummary === void 0 ? void 0 : platformAccountSummary.agentWalletAddress) {
|
|
872
875
|
accountSummary.agentWallet = {
|
|
873
876
|
address: platformAccountSummary.agentWalletAddress,
|
|
874
|
-
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",
|
|
875
884
|
};
|
|
876
885
|
}
|
|
877
886
|
return accountSummary;
|
|
@@ -6068,6 +6077,7 @@ function useAgentWallet() {
|
|
|
6068
6077
|
const isAuthenticated = useUserData((state) => state.isAuthenticated);
|
|
6069
6078
|
const address = useUserData((state) => state.address);
|
|
6070
6079
|
const setAgentWallets = useUserData((state) => state.setUserExtraAgents);
|
|
6080
|
+
const setAccountSummary = useUserData((state) => state.setAccountSummary);
|
|
6071
6081
|
const refreshAgentWalletStatus = useCallback(async () => {
|
|
6072
6082
|
const hlAgentWallets = await fetchExtraAgents(address);
|
|
6073
6083
|
setAgentWallets((hlAgentWallets === null || hlAgentWallets === void 0 ? void 0 : hlAgentWallets.data) || []);
|
|
@@ -6082,11 +6092,18 @@ function useAgentWallet() {
|
|
|
6082
6092
|
throw new Error('Not authenticated');
|
|
6083
6093
|
}
|
|
6084
6094
|
const response = await createAgentWallet(apiBaseUrl);
|
|
6095
|
+
const accountSummary = useUserData.getState().accountSummary;
|
|
6096
|
+
if (accountSummary) {
|
|
6097
|
+
const updatedSummary = {
|
|
6098
|
+
agentWalletAddress: response.data.agentWalletAddress,
|
|
6099
|
+
};
|
|
6100
|
+
setAccountSummary(updatedSummary);
|
|
6101
|
+
}
|
|
6085
6102
|
return response.data;
|
|
6086
6103
|
}, [apiBaseUrl, isAuthenticated]);
|
|
6087
6104
|
const notifyAgentWalletApproved = useCallback(async () => {
|
|
6088
6105
|
return refreshAgentWalletStatus();
|
|
6089
|
-
}, [refreshAgentWalletStatus]);
|
|
6106
|
+
}, [refreshAgentWalletStatus, setAccountSummary]);
|
|
6090
6107
|
return {
|
|
6091
6108
|
refreshAgentWalletStatus,
|
|
6092
6109
|
createAgentWallet: createAgentWallet$1,
|
|
@@ -6981,7 +6998,7 @@ async function logout(baseUrl, refreshTokenVal) {
|
|
|
6981
6998
|
function useAuth() {
|
|
6982
6999
|
const context = useContext(PearHyperliquidContext);
|
|
6983
7000
|
if (!context) {
|
|
6984
|
-
throw new Error(
|
|
7001
|
+
throw new Error("usePortfolio must be used within a PearHyperliquidProvider");
|
|
6985
7002
|
}
|
|
6986
7003
|
const { apiBaseUrl, clientId } = context;
|
|
6987
7004
|
const [isReady, setIsReady] = useState(false);
|
|
@@ -6993,12 +7010,12 @@ function useAuth() {
|
|
|
6993
7010
|
const setIsAuthenticated = useUserData((s) => s.setIsAuthenticated);
|
|
6994
7011
|
const setAddress = useUserData((s) => s.setAddress);
|
|
6995
7012
|
useEffect(() => {
|
|
6996
|
-
if (typeof window ==
|
|
7013
|
+
if (typeof window == "undefined") {
|
|
6997
7014
|
return;
|
|
6998
7015
|
}
|
|
6999
|
-
const access = localStorage.getItem(
|
|
7000
|
-
const refresh = localStorage.getItem(
|
|
7001
|
-
const addr = localStorage.getItem(
|
|
7016
|
+
const access = localStorage.getItem("accessToken");
|
|
7017
|
+
const refresh = localStorage.getItem("refreshToken");
|
|
7018
|
+
const addr = localStorage.getItem("address");
|
|
7002
7019
|
setAccessToken(access);
|
|
7003
7020
|
setRefreshToken(refresh);
|
|
7004
7021
|
setAddress(addr);
|
|
@@ -7010,7 +7027,9 @@ function useAuth() {
|
|
|
7010
7027
|
const cleanup = addAuthInterceptors({
|
|
7011
7028
|
apiBaseUrl,
|
|
7012
7029
|
getAccessToken: () => {
|
|
7013
|
-
return typeof window !==
|
|
7030
|
+
return typeof window !== "undefined"
|
|
7031
|
+
? window.localStorage.getItem("accessToken")
|
|
7032
|
+
: null;
|
|
7014
7033
|
},
|
|
7015
7034
|
refreshTokens: async () => {
|
|
7016
7035
|
const data = await refreshTokens();
|
|
@@ -7031,14 +7050,14 @@ function useAuth() {
|
|
|
7031
7050
|
async function loginWithSignedMessage(address, signature, timestamp) {
|
|
7032
7051
|
try {
|
|
7033
7052
|
const { data } = await authenticate(apiBaseUrl, {
|
|
7034
|
-
method:
|
|
7053
|
+
method: "eip712",
|
|
7035
7054
|
address,
|
|
7036
7055
|
clientId,
|
|
7037
7056
|
details: { signature, timestamp },
|
|
7038
7057
|
});
|
|
7039
|
-
window.localStorage.setItem(
|
|
7040
|
-
window.localStorage.setItem(
|
|
7041
|
-
window.localStorage.setItem(
|
|
7058
|
+
window.localStorage.setItem("accessToken", data.accessToken);
|
|
7059
|
+
window.localStorage.setItem("refreshToken", data.refreshToken);
|
|
7060
|
+
window.localStorage.setItem("address", address);
|
|
7042
7061
|
setAccessToken(data.accessToken);
|
|
7043
7062
|
setRefreshToken(data.refreshToken);
|
|
7044
7063
|
setAddress(address);
|
|
@@ -7050,10 +7069,15 @@ function useAuth() {
|
|
|
7050
7069
|
}
|
|
7051
7070
|
async function loginWithPrivyToken(address, appId, privyAccessToken) {
|
|
7052
7071
|
try {
|
|
7053
|
-
const { data } = await authenticateWithPrivy(apiBaseUrl, {
|
|
7054
|
-
|
|
7055
|
-
|
|
7056
|
-
|
|
7072
|
+
const { data } = await authenticateWithPrivy(apiBaseUrl, {
|
|
7073
|
+
address,
|
|
7074
|
+
clientId,
|
|
7075
|
+
appId,
|
|
7076
|
+
accessToken: privyAccessToken,
|
|
7077
|
+
});
|
|
7078
|
+
window.localStorage.setItem("accessToken", data.accessToken);
|
|
7079
|
+
window.localStorage.setItem("refreshToken", data.refreshToken);
|
|
7080
|
+
window.localStorage.setItem("address", address);
|
|
7057
7081
|
setAccessToken(data.accessToken);
|
|
7058
7082
|
setRefreshToken(data.refreshToken);
|
|
7059
7083
|
setAddress(address);
|
|
@@ -7064,28 +7088,30 @@ function useAuth() {
|
|
|
7064
7088
|
}
|
|
7065
7089
|
}
|
|
7066
7090
|
async function refreshTokens() {
|
|
7067
|
-
const refresh = window.localStorage.getItem(
|
|
7091
|
+
const refresh = window.localStorage.getItem("refreshToken");
|
|
7068
7092
|
if (!refresh)
|
|
7069
|
-
throw new Error(
|
|
7093
|
+
throw new Error("No refresh token");
|
|
7070
7094
|
const { data } = await refreshToken(apiBaseUrl, refresh);
|
|
7071
|
-
window.localStorage.setItem(
|
|
7072
|
-
window.localStorage.setItem(
|
|
7095
|
+
window.localStorage.setItem("accessToken", data.accessToken);
|
|
7096
|
+
window.localStorage.setItem("refreshToken", data.refreshToken);
|
|
7073
7097
|
setAccessToken(data.accessToken);
|
|
7074
7098
|
setRefreshToken(data.refreshToken);
|
|
7075
7099
|
setIsAuthenticated(true);
|
|
7076
7100
|
return data;
|
|
7077
7101
|
}
|
|
7078
7102
|
async function logout$1() {
|
|
7079
|
-
const refresh = window.localStorage.getItem(
|
|
7103
|
+
const refresh = window.localStorage.getItem("refreshToken");
|
|
7080
7104
|
if (refresh) {
|
|
7081
7105
|
try {
|
|
7082
7106
|
await logout(apiBaseUrl, refresh);
|
|
7083
7107
|
}
|
|
7084
|
-
catch (
|
|
7108
|
+
catch (_a) {
|
|
7109
|
+
/* ignore */
|
|
7110
|
+
}
|
|
7085
7111
|
}
|
|
7086
|
-
window.localStorage.removeItem(
|
|
7087
|
-
window.localStorage.removeItem(
|
|
7088
|
-
window.localStorage.removeItem(
|
|
7112
|
+
window.localStorage.removeItem("accessToken");
|
|
7113
|
+
window.localStorage.removeItem("refreshToken");
|
|
7114
|
+
window.localStorage.removeItem("address");
|
|
7089
7115
|
setAccessToken(null);
|
|
7090
7116
|
setRefreshToken(null);
|
|
7091
7117
|
setAddress(null);
|
|
@@ -7127,8 +7153,7 @@ const PearHyperliquidProvider = ({ children, apiBaseUrl = 'https://hl-v2.pearpro
|
|
|
7127
7153
|
useEffect(() => {
|
|
7128
7154
|
if (perpsMetaAssets === null) {
|
|
7129
7155
|
fetchAllPerpMetas().then(res => {
|
|
7130
|
-
|
|
7131
|
-
const aggregatedPerpMetas = res.data.slice(0, 2).flatMap(item => item.universe);
|
|
7156
|
+
const aggregatedPerpMetas = res.data.flatMap(item => item.universe);
|
|
7132
7157
|
const hip3Map = new Map();
|
|
7133
7158
|
const displayToFull = new Map();
|
|
7134
7159
|
const cleanedPerpMetas = aggregatedPerpMetas.map((asset) => {
|
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.60-alpha-1",
|
|
4
4
|
"description": "React SDK for Pear Protocol Hyperliquid API integration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -38,7 +38,6 @@
|
|
|
38
38
|
"@types/react": "^18.0.0",
|
|
39
39
|
"concurrently": "^9.2.1",
|
|
40
40
|
"esbuild": "^0.25.9",
|
|
41
|
-
|
|
42
41
|
"rimraf": "^5.0.0",
|
|
43
42
|
"rollup": "^3.0.0",
|
|
44
43
|
"rollup-plugin-dts": "^6.0.0",
|