@pear-protocol/hyperliquid-sdk 0.0.57 → 0.0.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/clients/positions.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +41 -36
- package/package.json +1 -1
|
@@ -123,5 +123,5 @@ export interface AdjustAdvanceResponseDto {
|
|
|
123
123
|
status: string;
|
|
124
124
|
executedAt: string;
|
|
125
125
|
}
|
|
126
|
-
export declare function adjustAdvancePosition(baseUrl: string,
|
|
126
|
+
export declare function adjustAdvancePosition(baseUrl: string, positionId: string, payload: AdjustAdvanceItemInput[], displayToFull: Map<string, string>): Promise<ApiResponse<AdjustAdvanceResponseDto>>;
|
|
127
127
|
export declare function cancelTwap(baseUrl: string, orderId: string): Promise<ApiResponse<CancelTwapResponseDto>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -993,7 +993,7 @@ interface AdjustAdvanceResponseDto {
|
|
|
993
993
|
status: string;
|
|
994
994
|
executedAt: string;
|
|
995
995
|
}
|
|
996
|
-
declare function adjustAdvancePosition(baseUrl: string,
|
|
996
|
+
declare function adjustAdvancePosition(baseUrl: string, positionId: string, payload: AdjustAdvanceItemInput[], displayToFull: Map<string, string>): Promise<ApiResponse<AdjustAdvanceResponseDto>>;
|
|
997
997
|
declare function cancelTwap(baseUrl: string, orderId: string): Promise<ApiResponse<CancelTwapResponseDto>>;
|
|
998
998
|
|
|
999
999
|
declare function usePosition(): {
|
package/dist/index.js
CHANGED
|
@@ -5206,49 +5206,49 @@ function createInstance(defaultConfig) {
|
|
|
5206
5206
|
}
|
|
5207
5207
|
|
|
5208
5208
|
// Create the default instance to be exported
|
|
5209
|
-
const axios
|
|
5209
|
+
const axios = createInstance(defaults$1);
|
|
5210
5210
|
|
|
5211
5211
|
// Expose Axios class to allow class inheritance
|
|
5212
|
-
axios
|
|
5212
|
+
axios.Axios = Axios$1;
|
|
5213
5213
|
|
|
5214
5214
|
// Expose Cancel & CancelToken
|
|
5215
|
-
axios
|
|
5216
|
-
axios
|
|
5217
|
-
axios
|
|
5218
|
-
axios
|
|
5219
|
-
axios
|
|
5215
|
+
axios.CanceledError = CanceledError;
|
|
5216
|
+
axios.CancelToken = CancelToken$1;
|
|
5217
|
+
axios.isCancel = isCancel;
|
|
5218
|
+
axios.VERSION = VERSION;
|
|
5219
|
+
axios.toFormData = toFormData;
|
|
5220
5220
|
|
|
5221
5221
|
// Expose AxiosError class
|
|
5222
|
-
axios
|
|
5222
|
+
axios.AxiosError = AxiosError;
|
|
5223
5223
|
|
|
5224
5224
|
// alias for CanceledError for backward compatibility
|
|
5225
|
-
axios
|
|
5225
|
+
axios.Cancel = axios.CanceledError;
|
|
5226
5226
|
|
|
5227
5227
|
// Expose all/spread
|
|
5228
|
-
axios
|
|
5228
|
+
axios.all = function all(promises) {
|
|
5229
5229
|
return Promise.all(promises);
|
|
5230
5230
|
};
|
|
5231
5231
|
|
|
5232
|
-
axios
|
|
5232
|
+
axios.spread = spread;
|
|
5233
5233
|
|
|
5234
5234
|
// Expose isAxiosError
|
|
5235
|
-
axios
|
|
5235
|
+
axios.isAxiosError = isAxiosError;
|
|
5236
5236
|
|
|
5237
5237
|
// Expose mergeConfig
|
|
5238
|
-
axios
|
|
5238
|
+
axios.mergeConfig = mergeConfig;
|
|
5239
5239
|
|
|
5240
|
-
axios
|
|
5240
|
+
axios.AxiosHeaders = AxiosHeaders$1;
|
|
5241
5241
|
|
|
5242
|
-
axios
|
|
5242
|
+
axios.formToJSON = thing => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
|
|
5243
5243
|
|
|
5244
|
-
axios
|
|
5244
|
+
axios.getAdapter = adapters.getAdapter;
|
|
5245
5245
|
|
|
5246
|
-
axios
|
|
5246
|
+
axios.HttpStatusCode = HttpStatusCode$1;
|
|
5247
5247
|
|
|
5248
|
-
axios
|
|
5248
|
+
axios.default = axios;
|
|
5249
5249
|
|
|
5250
5250
|
// this module should only have a default export
|
|
5251
|
-
var axios$
|
|
5251
|
+
var axios$1 = axios;
|
|
5252
5252
|
|
|
5253
5253
|
// NOTE: do not import React hooks into this util. Consumers should pass
|
|
5254
5254
|
// token getters and actions (refresh/logout) via the interceptor helper below.
|
|
@@ -5278,7 +5278,7 @@ function joinUrl(baseUrl, path) {
|
|
|
5278
5278
|
* - Request: inject Authorization headers from buildAuthHeaders when absent
|
|
5279
5279
|
* - Response: on 401, clear tokens and emit a logout event
|
|
5280
5280
|
*/
|
|
5281
|
-
const apiClient = axios$
|
|
5281
|
+
const apiClient = axios$1.create();
|
|
5282
5282
|
/**
|
|
5283
5283
|
* Attach auth-aware Axios interceptors to `apiClient`.
|
|
5284
5284
|
* - Request: adds `Authorization: Bearer <accessToken>` for requests to `apiBaseUrl`.
|
|
@@ -5404,7 +5404,7 @@ const fetchHistoricalCandles = async (coin, startTime, endTime, interval, displa
|
|
|
5404
5404
|
type: 'candleSnapshot',
|
|
5405
5405
|
};
|
|
5406
5406
|
try {
|
|
5407
|
-
const response = await axios$
|
|
5407
|
+
const response = await axios$1.post('https://api.hyperliquid.xyz/info', request, {
|
|
5408
5408
|
headers: { 'Content-Type': 'application/json' },
|
|
5409
5409
|
});
|
|
5410
5410
|
return { data: response.data, status: response.status, headers: response.headers };
|
|
@@ -5419,7 +5419,7 @@ const fetchHistoricalCandles = async (coin, startTime, endTime, interval, displa
|
|
|
5419
5419
|
const fetchUserFillsFromHyperliquid = async (user, startTime, aggregateByTime = true) => {
|
|
5420
5420
|
const request = { type: 'userFillsByTime', user, startTime, aggregateByTime };
|
|
5421
5421
|
try {
|
|
5422
|
-
const response = await axios$
|
|
5422
|
+
const response = await axios$1.post('https://api.hyperliquid.xyz/info', request, {
|
|
5423
5423
|
headers: { 'Content-Type': 'application/json' },
|
|
5424
5424
|
});
|
|
5425
5425
|
return { data: response.data, status: response.status, headers: response.headers };
|
|
@@ -5434,7 +5434,7 @@ const fetchUserFillsFromHyperliquid = async (user, startTime, aggregateByTime =
|
|
|
5434
5434
|
const fetchUserTwapSliceFillsByTime = async (user, startTime, aggregateByTime = true) => {
|
|
5435
5435
|
const request = { type: 'userTwapSliceFillsByTime', user, startTime, aggregateByTime };
|
|
5436
5436
|
try {
|
|
5437
|
-
const response = await axios$
|
|
5437
|
+
const response = await axios$1.post('https://api.hyperliquid.xyz/info', request, {
|
|
5438
5438
|
headers: { 'Content-Type': 'application/json' },
|
|
5439
5439
|
});
|
|
5440
5440
|
return { data: response.data, status: response.status, headers: response.headers };
|
|
@@ -5451,7 +5451,7 @@ const fetchUserTwapSliceFillsByTime = async (user, startTime, aggregateByTime =
|
|
|
5451
5451
|
const fetchAllPerpMetas = async () => {
|
|
5452
5452
|
const request = { type: 'allPerpMetas' };
|
|
5453
5453
|
try {
|
|
5454
|
-
const response = await axios$
|
|
5454
|
+
const response = await axios$1.post('https://api.hyperliquid.xyz/info', request, {
|
|
5455
5455
|
headers: { 'Content-Type': 'application/json' },
|
|
5456
5456
|
});
|
|
5457
5457
|
return { data: response.data, status: response.status, headers: response.headers };
|
|
@@ -5468,7 +5468,7 @@ const fetchAllPerpMetas = async () => {
|
|
|
5468
5468
|
const fetchExtraAgents = async (user) => {
|
|
5469
5469
|
const request = { type: 'extraAgents', user };
|
|
5470
5470
|
try {
|
|
5471
|
-
const response = await axios$
|
|
5471
|
+
const response = await axios$1.post('https://api.hyperliquid.xyz/info', request, {
|
|
5472
5472
|
headers: { 'Content-Type': 'application/json' },
|
|
5473
5473
|
});
|
|
5474
5474
|
return { data: response.data, status: response.status, headers: response.headers };
|
|
@@ -6068,6 +6068,7 @@ function useAgentWallet() {
|
|
|
6068
6068
|
const isAuthenticated = useUserData((state) => state.isAuthenticated);
|
|
6069
6069
|
const address = useUserData((state) => state.address);
|
|
6070
6070
|
const setAgentWallets = useUserData((state) => state.setUserExtraAgents);
|
|
6071
|
+
const setAccountSummary = useUserData((state) => state.setAccountSummary);
|
|
6071
6072
|
const refreshAgentWalletStatus = useCallback(async () => {
|
|
6072
6073
|
const hlAgentWallets = await fetchExtraAgents(address);
|
|
6073
6074
|
setAgentWallets((hlAgentWallets === null || hlAgentWallets === void 0 ? void 0 : hlAgentWallets.data) || []);
|
|
@@ -6082,11 +6083,18 @@ function useAgentWallet() {
|
|
|
6082
6083
|
throw new Error('Not authenticated');
|
|
6083
6084
|
}
|
|
6084
6085
|
const response = await createAgentWallet(apiBaseUrl);
|
|
6086
|
+
const accountSummary = useUserData.getState().accountSummary;
|
|
6087
|
+
if (accountSummary) {
|
|
6088
|
+
const updatedSummary = {
|
|
6089
|
+
agentWalletAddress: response.data.agentWalletAddress,
|
|
6090
|
+
};
|
|
6091
|
+
setAccountSummary(updatedSummary);
|
|
6092
|
+
}
|
|
6085
6093
|
return response.data;
|
|
6086
6094
|
}, [apiBaseUrl, isAuthenticated]);
|
|
6087
6095
|
const notifyAgentWalletApproved = useCallback(async () => {
|
|
6088
6096
|
return refreshAgentWalletStatus();
|
|
6089
|
-
}, [refreshAgentWalletStatus]);
|
|
6097
|
+
}, [refreshAgentWalletStatus, setAccountSummary]);
|
|
6090
6098
|
return {
|
|
6091
6099
|
refreshAgentWalletStatus,
|
|
6092
6100
|
createAgentWallet: createAgentWallet$1,
|
|
@@ -6425,7 +6433,7 @@ async function adjustPosition(baseUrl, positionId, payload) {
|
|
|
6425
6433
|
throw toApiError(error);
|
|
6426
6434
|
}
|
|
6427
6435
|
}
|
|
6428
|
-
async function adjustAdvancePosition(baseUrl,
|
|
6436
|
+
async function adjustAdvancePosition(baseUrl, positionId, payload, displayToFull) {
|
|
6429
6437
|
const url = joinUrl(baseUrl, `/positions/${positionId}/adjust-advance`);
|
|
6430
6438
|
const mapAssets = (arr) => arr === null || arr === void 0 ? void 0 : arr.map((a) => ({ ...a, asset: toBackendSymbol(a.asset, displayToFull) }));
|
|
6431
6439
|
const translatedPayload = (payload || []).map((item) => ({
|
|
@@ -6433,10 +6441,9 @@ async function adjustAdvancePosition(baseUrl, accessToken, positionId, payload,
|
|
|
6433
6441
|
shortAssets: mapAssets(item.shortAssets),
|
|
6434
6442
|
}));
|
|
6435
6443
|
try {
|
|
6436
|
-
const resp = await
|
|
6444
|
+
const resp = await apiClient.post(url, translatedPayload, {
|
|
6437
6445
|
headers: {
|
|
6438
6446
|
"Content-Type": "application/json",
|
|
6439
|
-
Authorization: `Bearer ${accessToken}`,
|
|
6440
6447
|
},
|
|
6441
6448
|
timeout: 60000,
|
|
6442
6449
|
});
|
|
@@ -6582,9 +6589,7 @@ function usePosition() {
|
|
|
6582
6589
|
};
|
|
6583
6590
|
// Adjust to absolute target sizes per asset, optionally adding new assets
|
|
6584
6591
|
const adjustAdvancePosition$1 = async (positionId, payload) => {
|
|
6585
|
-
|
|
6586
|
-
throw new Error('Not authenticated');
|
|
6587
|
-
return adjustAdvancePosition(apiBaseUrl, accessToken, positionId, payload, displayToFull);
|
|
6592
|
+
return adjustAdvancePosition(apiBaseUrl, positionId, payload, displayToFull);
|
|
6588
6593
|
};
|
|
6589
6594
|
// Open positions using WS data, with derived values
|
|
6590
6595
|
const userOpenPositions = useUserData((state) => state.rawOpenPositions);
|
|
@@ -6931,7 +6936,7 @@ function usePortfolio() {
|
|
|
6931
6936
|
async function getEIP712Message(baseUrl, address, clientId) {
|
|
6932
6937
|
const url = joinUrl(baseUrl, '/auth/eip712-message');
|
|
6933
6938
|
try {
|
|
6934
|
-
const resp = await axios$
|
|
6939
|
+
const resp = await axios$1.get(url, { params: { address, clientId }, timeout: 30000 });
|
|
6935
6940
|
return { data: resp.data, status: resp.status, headers: resp.headers };
|
|
6936
6941
|
}
|
|
6937
6942
|
catch (error) {
|
|
@@ -6941,7 +6946,7 @@ async function getEIP712Message(baseUrl, address, clientId) {
|
|
|
6941
6946
|
async function authenticate(baseUrl, body) {
|
|
6942
6947
|
const url = joinUrl(baseUrl, '/auth/login');
|
|
6943
6948
|
try {
|
|
6944
|
-
const resp = await axios$
|
|
6949
|
+
const resp = await axios$1.post(url, body, { headers: { 'Content-Type': 'application/json' }, timeout: 30000 });
|
|
6945
6950
|
return { data: resp.data, status: resp.status, headers: resp.headers };
|
|
6946
6951
|
}
|
|
6947
6952
|
catch (error) {
|
|
@@ -6963,7 +6968,7 @@ async function authenticateWithPrivy(baseUrl, params) {
|
|
|
6963
6968
|
async function refreshToken(baseUrl, refreshTokenVal) {
|
|
6964
6969
|
const url = joinUrl(baseUrl, '/auth/refresh');
|
|
6965
6970
|
try {
|
|
6966
|
-
const resp = await axios$
|
|
6971
|
+
const resp = await axios$1.post(url, { refreshToken: refreshTokenVal }, { headers: { 'Content-Type': 'application/json' }, timeout: 30000 });
|
|
6967
6972
|
return { data: resp.data, status: resp.status, headers: resp.headers };
|
|
6968
6973
|
}
|
|
6969
6974
|
catch (error) {
|
|
@@ -6973,7 +6978,7 @@ async function refreshToken(baseUrl, refreshTokenVal) {
|
|
|
6973
6978
|
async function logout(baseUrl, refreshTokenVal) {
|
|
6974
6979
|
const url = joinUrl(baseUrl, '/auth/logout');
|
|
6975
6980
|
try {
|
|
6976
|
-
const resp = await axios$
|
|
6981
|
+
const resp = await axios$1.post(url, { refreshToken: refreshTokenVal }, { headers: { 'Content-Type': 'application/json' }, timeout: 30000 });
|
|
6977
6982
|
return { data: resp.data, status: resp.status, headers: resp.headers };
|
|
6978
6983
|
}
|
|
6979
6984
|
catch (error) {
|