@pear-protocol/hyperliquid-sdk 0.0.57 → 0.0.58
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 +32 -35
- 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 };
|
|
@@ -6425,7 +6425,7 @@ async function adjustPosition(baseUrl, positionId, payload) {
|
|
|
6425
6425
|
throw toApiError(error);
|
|
6426
6426
|
}
|
|
6427
6427
|
}
|
|
6428
|
-
async function adjustAdvancePosition(baseUrl,
|
|
6428
|
+
async function adjustAdvancePosition(baseUrl, positionId, payload, displayToFull) {
|
|
6429
6429
|
const url = joinUrl(baseUrl, `/positions/${positionId}/adjust-advance`);
|
|
6430
6430
|
const mapAssets = (arr) => arr === null || arr === void 0 ? void 0 : arr.map((a) => ({ ...a, asset: toBackendSymbol(a.asset, displayToFull) }));
|
|
6431
6431
|
const translatedPayload = (payload || []).map((item) => ({
|
|
@@ -6433,10 +6433,9 @@ async function adjustAdvancePosition(baseUrl, accessToken, positionId, payload,
|
|
|
6433
6433
|
shortAssets: mapAssets(item.shortAssets),
|
|
6434
6434
|
}));
|
|
6435
6435
|
try {
|
|
6436
|
-
const resp = await
|
|
6436
|
+
const resp = await apiClient.post(url, translatedPayload, {
|
|
6437
6437
|
headers: {
|
|
6438
6438
|
"Content-Type": "application/json",
|
|
6439
|
-
Authorization: `Bearer ${accessToken}`,
|
|
6440
6439
|
},
|
|
6441
6440
|
timeout: 60000,
|
|
6442
6441
|
});
|
|
@@ -6582,9 +6581,7 @@ function usePosition() {
|
|
|
6582
6581
|
};
|
|
6583
6582
|
// Adjust to absolute target sizes per asset, optionally adding new assets
|
|
6584
6583
|
const adjustAdvancePosition$1 = async (positionId, payload) => {
|
|
6585
|
-
|
|
6586
|
-
throw new Error('Not authenticated');
|
|
6587
|
-
return adjustAdvancePosition(apiBaseUrl, accessToken, positionId, payload, displayToFull);
|
|
6584
|
+
return adjustAdvancePosition(apiBaseUrl, positionId, payload, displayToFull);
|
|
6588
6585
|
};
|
|
6589
6586
|
// Open positions using WS data, with derived values
|
|
6590
6587
|
const userOpenPositions = useUserData((state) => state.rawOpenPositions);
|
|
@@ -6931,7 +6928,7 @@ function usePortfolio() {
|
|
|
6931
6928
|
async function getEIP712Message(baseUrl, address, clientId) {
|
|
6932
6929
|
const url = joinUrl(baseUrl, '/auth/eip712-message');
|
|
6933
6930
|
try {
|
|
6934
|
-
const resp = await axios$
|
|
6931
|
+
const resp = await axios$1.get(url, { params: { address, clientId }, timeout: 30000 });
|
|
6935
6932
|
return { data: resp.data, status: resp.status, headers: resp.headers };
|
|
6936
6933
|
}
|
|
6937
6934
|
catch (error) {
|
|
@@ -6941,7 +6938,7 @@ async function getEIP712Message(baseUrl, address, clientId) {
|
|
|
6941
6938
|
async function authenticate(baseUrl, body) {
|
|
6942
6939
|
const url = joinUrl(baseUrl, '/auth/login');
|
|
6943
6940
|
try {
|
|
6944
|
-
const resp = await axios$
|
|
6941
|
+
const resp = await axios$1.post(url, body, { headers: { 'Content-Type': 'application/json' }, timeout: 30000 });
|
|
6945
6942
|
return { data: resp.data, status: resp.status, headers: resp.headers };
|
|
6946
6943
|
}
|
|
6947
6944
|
catch (error) {
|
|
@@ -6963,7 +6960,7 @@ async function authenticateWithPrivy(baseUrl, params) {
|
|
|
6963
6960
|
async function refreshToken(baseUrl, refreshTokenVal) {
|
|
6964
6961
|
const url = joinUrl(baseUrl, '/auth/refresh');
|
|
6965
6962
|
try {
|
|
6966
|
-
const resp = await axios$
|
|
6963
|
+
const resp = await axios$1.post(url, { refreshToken: refreshTokenVal }, { headers: { 'Content-Type': 'application/json' }, timeout: 30000 });
|
|
6967
6964
|
return { data: resp.data, status: resp.status, headers: resp.headers };
|
|
6968
6965
|
}
|
|
6969
6966
|
catch (error) {
|
|
@@ -6973,7 +6970,7 @@ async function refreshToken(baseUrl, refreshTokenVal) {
|
|
|
6973
6970
|
async function logout(baseUrl, refreshTokenVal) {
|
|
6974
6971
|
const url = joinUrl(baseUrl, '/auth/logout');
|
|
6975
6972
|
try {
|
|
6976
|
-
const resp = await axios$
|
|
6973
|
+
const resp = await axios$1.post(url, { refreshToken: refreshTokenVal }, { headers: { 'Content-Type': 'application/json' }, timeout: 30000 });
|
|
6977
6974
|
return { data: resp.data, status: resp.status, headers: resp.headers };
|
|
6978
6975
|
}
|
|
6979
6976
|
catch (error) {
|