@yuants/vendor-hyperliquid 0.9.10 → 0.10.0
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/api/client.js +36 -2
- package/dist/api/client.js.map +1 -1
- package/dist/api/private-api.js +52 -41
- package/dist/api/private-api.js.map +1 -1
- package/dist/api/public-api.js +22 -11
- package/dist/api/public-api.js.map +1 -1
- package/dist/api/rate-limit.js +205 -0
- package/dist/api/rate-limit.js.map +1 -0
- package/dist/api/rate-limit.test.js +129 -0
- package/dist/api/rate-limit.test.js.map +1 -0
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/lib/api/client.d.ts.map +1 -1
- package/lib/api/client.js +35 -1
- package/lib/api/client.js.map +1 -1
- package/lib/api/private-api.d.ts +65 -1
- package/lib/api/private-api.d.ts.map +1 -1
- package/lib/api/private-api.js +59 -43
- package/lib/api/private-api.js.map +1 -1
- package/lib/api/public-api.d.ts +54 -1
- package/lib/api/public-api.d.ts.map +1 -1
- package/lib/api/public-api.js +33 -12
- package/lib/api/public-api.js.map +1 -1
- package/lib/api/rate-limit.d.ts +21 -0
- package/lib/api/rate-limit.d.ts.map +1 -0
- package/lib/api/rate-limit.js +214 -0
- package/lib/api/rate-limit.js.map +1 -0
- package/lib/api/rate-limit.test.d.ts +2 -0
- package/lib/api/rate-limit.test.d.ts.map +1 -0
- package/lib/api/rate-limit.test.js +131 -0
- package/lib/api/rate-limit.test.js.map +1 -0
- package/lib/index.d.ts +0 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +0 -2
- package/lib/index.js.map +1 -1
- package/package.json +5 -5
- package/temp/build/typescript/ts_HOjXkPSo.json +1 -1
- package/temp/package-deps.json +10 -10
- package/temp/test/jest/haste-map-1a3370ad4952cc1cbecf8fc42c6e9732-7b2990dcc44090c4eba2c52e971c544c-6a2a6e27ca3579da37751287ea19ab4c +0 -0
- package/temp/test/jest/perf-cache-1a3370ad4952cc1cbecf8fc42c6e9732-da39a3ee5e6b4b0d3255bfef95601890 +1 -0
- package/dist/services/markets/interest-rate.js +0 -61
- package/dist/services/markets/interest-rate.js.map +0 -1
- package/dist/services/markets/ohlc.js +0 -111
- package/dist/services/markets/ohlc.js.map +0 -1
- package/lib/services/markets/interest-rate.d.ts +0 -2
- package/lib/services/markets/interest-rate.d.ts.map +0 -1
- package/lib/services/markets/interest-rate.js +0 -63
- package/lib/services/markets/interest-rate.js.map +0 -1
- package/lib/services/markets/ohlc.d.ts +0 -2
- package/lib/services/markets/ohlc.d.ts.map +0 -1
- package/lib/services/markets/ohlc.js +0 -113
- package/lib/services/markets/ohlc.js.map +0 -1
package/lib/api/private-api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getUserFills = exports.modifyOrder = exports.cancelOrder = exports.placeOrder = void 0;
|
|
3
|
+
exports.getUserFills = exports.buildUserFillsRequestBody = exports.modifyOrder = exports.cancelOrder = exports.placeOrder = exports.createSignedExchangeRequestBody = exports.buildModifyOrderAction = exports.buildCancelOrderAction = exports.buildPlaceOrderAction = void 0;
|
|
4
4
|
const ethers_1 = require("ethers");
|
|
5
5
|
const sign_1 = require("./sign");
|
|
6
6
|
const client_1 = require("./client");
|
|
@@ -11,6 +11,31 @@ const getWallet = (credential) => {
|
|
|
11
11
|
}
|
|
12
12
|
return walletCache.get(credential.private_key);
|
|
13
13
|
};
|
|
14
|
+
const buildPlaceOrderAction = (params) => {
|
|
15
|
+
const action = { type: 'order', orders: params.orders, grouping: 'na' };
|
|
16
|
+
if (!params.builder)
|
|
17
|
+
return action;
|
|
18
|
+
return Object.assign(Object.assign({}, action), { builder: params.builder });
|
|
19
|
+
};
|
|
20
|
+
exports.buildPlaceOrderAction = buildPlaceOrderAction;
|
|
21
|
+
const buildCancelOrderAction = (params) => ({
|
|
22
|
+
type: 'cancel',
|
|
23
|
+
cancels: params.cancels,
|
|
24
|
+
});
|
|
25
|
+
exports.buildCancelOrderAction = buildCancelOrderAction;
|
|
26
|
+
const buildModifyOrderAction = (params) => ({
|
|
27
|
+
type: 'modify',
|
|
28
|
+
oid: params.oid,
|
|
29
|
+
order: params.order,
|
|
30
|
+
});
|
|
31
|
+
exports.buildModifyOrderAction = buildModifyOrderAction;
|
|
32
|
+
const createSignedExchangeRequestBody = async (credential, action, options) => {
|
|
33
|
+
var _a, _b, _c, _d;
|
|
34
|
+
const nonce = (_a = options === null || options === void 0 ? void 0 : options.nonce) !== null && _a !== void 0 ? _a : Date.now();
|
|
35
|
+
const signature = await (0, sign_1.signL1Action)(getWallet(credential), action, (_b = options === null || options === void 0 ? void 0 : options.vaultAddress) !== null && _b !== void 0 ? _b : null, nonce, (_c = options === null || options === void 0 ? void 0 : options.expiresAfter) !== null && _c !== void 0 ? _c : null, (_d = options === null || options === void 0 ? void 0 : options.isMainnet) !== null && _d !== void 0 ? _d : true);
|
|
36
|
+
return { action, nonce, signature };
|
|
37
|
+
};
|
|
38
|
+
exports.createSignedExchangeRequestBody = createSignedExchangeRequestBody;
|
|
14
39
|
/**
|
|
15
40
|
* Place orders on Hyperliquid exchange
|
|
16
41
|
* API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#place-an-order
|
|
@@ -20,18 +45,12 @@ const getWallet = (credential) => {
|
|
|
20
45
|
* @returns Promise resolving to exchange response
|
|
21
46
|
*/
|
|
22
47
|
const placeOrder = async (credential, params) => {
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (params.builder) {
|
|
30
|
-
action['builder'] = params.builder;
|
|
31
|
-
}
|
|
32
|
-
const nonce = Date.now();
|
|
33
|
-
const signature = await (0, sign_1.signL1Action)(getWallet(credential), action, (_a = params.vaultAddress) !== null && _a !== void 0 ? _a : null, nonce, (_b = params.expiresAfter) !== null && _b !== void 0 ? _b : null, true);
|
|
34
|
-
return (0, client_1.request)('POST', 'exchange', { action, nonce, signature });
|
|
48
|
+
const action = (0, exports.buildPlaceOrderAction)(params);
|
|
49
|
+
const requestBody = await (0, exports.createSignedExchangeRequestBody)(credential, action, {
|
|
50
|
+
vaultAddress: params.vaultAddress,
|
|
51
|
+
expiresAfter: params.expiresAfter,
|
|
52
|
+
});
|
|
53
|
+
return (0, client_1.request)('POST', 'exchange', requestBody);
|
|
35
54
|
};
|
|
36
55
|
exports.placeOrder = placeOrder;
|
|
37
56
|
/**
|
|
@@ -43,14 +62,12 @@ exports.placeOrder = placeOrder;
|
|
|
43
62
|
* @returns Promise resolving to exchange response
|
|
44
63
|
*/
|
|
45
64
|
const cancelOrder = async (credential, params) => {
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const signature = await (0, sign_1.signL1Action)(getWallet(credential), action, (_a = params.vaultAddress) !== null && _a !== void 0 ? _a : null, nonce, (_b = params.expiresAfter) !== null && _b !== void 0 ? _b : null, true);
|
|
53
|
-
return (0, client_1.request)('POST', 'exchange', { action, nonce, signature });
|
|
65
|
+
const action = (0, exports.buildCancelOrderAction)(params);
|
|
66
|
+
const requestBody = await (0, exports.createSignedExchangeRequestBody)(credential, action, {
|
|
67
|
+
vaultAddress: params.vaultAddress,
|
|
68
|
+
expiresAfter: params.expiresAfter,
|
|
69
|
+
});
|
|
70
|
+
return (0, client_1.request)('POST', 'exchange', requestBody);
|
|
54
71
|
};
|
|
55
72
|
exports.cancelOrder = cancelOrder;
|
|
56
73
|
/**
|
|
@@ -61,17 +78,28 @@ exports.cancelOrder = cancelOrder;
|
|
|
61
78
|
* @returns Promise resolving to exchange response
|
|
62
79
|
*/
|
|
63
80
|
const modifyOrder = async (credential, params) => {
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const nonce = Date.now();
|
|
71
|
-
const signature = await (0, sign_1.signL1Action)(getWallet(credential), action, (_a = params.vaultAddress) !== null && _a !== void 0 ? _a : null, nonce, (_b = params.expiresAfter) !== null && _b !== void 0 ? _b : null, true);
|
|
72
|
-
return (0, client_1.request)('POST', 'exchange', { action, nonce, signature });
|
|
81
|
+
const action = (0, exports.buildModifyOrderAction)(params);
|
|
82
|
+
const requestBody = await (0, exports.createSignedExchangeRequestBody)(credential, action, {
|
|
83
|
+
vaultAddress: params.vaultAddress,
|
|
84
|
+
expiresAfter: params.expiresAfter,
|
|
85
|
+
});
|
|
86
|
+
return (0, client_1.request)('POST', 'exchange', requestBody);
|
|
73
87
|
};
|
|
74
88
|
exports.modifyOrder = modifyOrder;
|
|
89
|
+
const buildUserFillsRequestBody = (credential, params) => {
|
|
90
|
+
const requestBody = {
|
|
91
|
+
type: 'userFills',
|
|
92
|
+
user: credential.address,
|
|
93
|
+
};
|
|
94
|
+
if ((params === null || params === void 0 ? void 0 : params.startTime) != null) {
|
|
95
|
+
requestBody.startTime = params.startTime;
|
|
96
|
+
}
|
|
97
|
+
if ((params === null || params === void 0 ? void 0 : params.endTime) != null) {
|
|
98
|
+
requestBody.endTime = params.endTime;
|
|
99
|
+
}
|
|
100
|
+
return requestBody;
|
|
101
|
+
};
|
|
102
|
+
exports.buildUserFillsRequestBody = buildUserFillsRequestBody;
|
|
75
103
|
/**
|
|
76
104
|
* Get user's fill history (trade history) from Hyperliquid
|
|
77
105
|
* API Endpoint: POST /info (type: userFills)
|
|
@@ -80,19 +108,7 @@ exports.modifyOrder = modifyOrder;
|
|
|
80
108
|
* @returns Promise resolving to user fill history with detailed trade information
|
|
81
109
|
*/
|
|
82
110
|
const getUserFills = async (credential, params) => {
|
|
83
|
-
|
|
84
|
-
const address = wallet.address;
|
|
85
|
-
const requestBody = {
|
|
86
|
-
type: 'userFills',
|
|
87
|
-
user: address,
|
|
88
|
-
};
|
|
89
|
-
if (params === null || params === void 0 ? void 0 : params.startTime) {
|
|
90
|
-
requestBody.startTime = params.startTime;
|
|
91
|
-
}
|
|
92
|
-
if (params === null || params === void 0 ? void 0 : params.endTime) {
|
|
93
|
-
requestBody.endTime = params.endTime;
|
|
94
|
-
}
|
|
95
|
-
return (0, client_1.request)('POST', 'info', requestBody);
|
|
111
|
+
return (0, client_1.request)('POST', 'info', (0, exports.buildUserFillsRequestBody)(credential, params));
|
|
96
112
|
};
|
|
97
113
|
exports.getUserFills = getUserFills;
|
|
98
114
|
//# sourceMappingURL=private-api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"private-api.js","sourceRoot":"","sources":["../../src/api/private-api.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAChC,iCAAsC;AACtC,qCAAmC;AAuDnC,MAAM,WAAW,GAAG,IAAI,GAAG,EAAkB,CAAC;AAE9C,MAAM,SAAS,GAAG,CAAC,UAAuB,EAAE,EAAE;IAC5C,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QAC7C,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,EAAE,IAAI,eAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,CAAE,CAAC;AAClD,CAAC,CAAC;AAEF;;;;;;;GAOG;AACI,MAAM,UAAU,GAAG,KAAK,EAC7B,UAAuB,EACvB,MAKC,EACD,EAAE;;IACF,MAAM,MAAM,GAAwB;QAClC,IAAI,EAAE,OAAO;QACb,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,QAAQ,EAAE,IAAI;KACf,CAAC;IACF,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,MAAM,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC;IACrC,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACzB,MAAM,SAAS,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AG,MAAM,IAAA,mBAAY,EAClC,SAAS,CAAC,UAAU,CAAC,EACrB,MAAM,EACN,MAAA,MAAM,CAAC,YAAY,mCAAI,IAAI,EAC3B,KAAK,EACL,MAAA,MAAM,CAAC,YAAY,mCAAI,IAAI,EAC3B,IAAI,CACL,CAAC;IACF,OAAO,IAAA,gBAAO,EAAC,MAAM,EAAE,UAAU,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;AACnE,CAAC,CAAC;AAxBW,QAAA,WAAW,eAwBtB;AAEF;;;;;;GAMG;AACI,MAAM,YAAY,GAAG,KAAK,EAC/B,UAAuB,EACvB,MAAiD,EACjD,EAAE;IACF,MAAM,MAAM,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;IACrC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAE/B,MAAM,WAAW,GAAQ;QACvB,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,OAAO;KACd,CAAC;IAEF,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,EAAE,CAAC;QACtB,WAAW,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;IAC3C,CAAC;IAED,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,EAAE,CAAC;QACpB,WAAW,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IACvC,CAAC;IAED,OAAO,IAAA,gBAAO,EAuBX,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;AAClC,CAAC,CAAC;AA5CW,QAAA,YAAY,gBA4CvB","sourcesContent":["import { Wallet } from 'ethers';\nimport { signL1Action } from './sign';\nimport { request } from './client';\nimport { ICredential } from './types';\n\n/**\n * Order payload for placing orders on Hyperliquid\n */\ntype OrderPayload = {\n /** Asset index (absolute) */\n a: number;\n /** Buy flag (true for buy, false for sell) */\n b: boolean;\n /** Limit price string */\n p: string;\n /** Size string */\n s: string;\n /** Reduce only flag */\n r: boolean;\n /** Order type configuration */\n t: {\n /** Time in force for limit orders: \"Alo\" (Post-Only), \"Ioc\" (Immediate or Cancel), \"Gtc\" (Good til Cancel) */\n limit?: { tif: string };\n /** Trigger order configuration */\n trigger?: {\n /** Is market trigger price */\n isMarket: boolean;\n /** Trigger price string */\n triggerPx: string;\n /** Take profit/stop loss indicator */\n tpsl: string;\n };\n };\n /** Order fee coefficient */\n c?: number;\n};\n\n/**\n * Cancel order payload\n */\ntype CancelPayload = {\n /** Asset index (absolute) */\n a: number;\n /** Order ID */\n o: number;\n};\n\n/**\n * Modify order payload\n */\ntype ModifyOrderPayload = {\n /** Order ID to modify */\n oid: number | string;\n /** New order parameters */\n order: OrderPayload;\n};\n\nconst walletCache = new Map<string, Wallet>();\n\nconst getWallet = (credential: ICredential) => {\n if (!walletCache.has(credential.private_key)) {\n walletCache.set(credential.private_key, new Wallet(credential.private_key));\n }\n return walletCache.get(credential.private_key)!;\n};\n\n/**\n * Place orders on Hyperliquid exchange\n * API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#place-an-order\n * API Endpoint: POST /exchange\n * @param credential - User credential containing private key for signing\n * @param params - Order placement parameters\n * @returns Promise resolving to exchange response\n */\nexport const placeOrder = async (\n credential: ICredential,\n params: {\n orders: OrderPayload[];\n builder?: { b: string; f: number };\n vaultAddress?: string;\n expiresAfter?: number;\n },\n) => {\n const action: Record<string, any> = {\n type: 'order',\n orders: params.orders,\n grouping: 'na',\n };\n if (params.builder) {\n action['builder'] = params.builder;\n }\n const nonce = Date.now();\n const signature = await signL1Action(\n getWallet(credential),\n action,\n params.vaultAddress ?? null,\n nonce,\n params.expiresAfter ?? null,\n true,\n );\n return request('POST', 'exchange', { action, nonce, signature });\n};\n\n/**\n * Cancel orders on Hyperliquid exchange\n * API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#cancel-order-s\n * API Endpoint: POST /exchange\n * @param credential - User credential containing private key for signing\n * @param params - Order cancellation parameters\n * @returns Promise resolving to exchange response\n */\nexport const cancelOrder = async (\n credential: ICredential,\n params: { cancels: CancelPayload[]; vaultAddress?: string; expiresAfter?: number },\n) => {\n const action: Record<string, any> = {\n type: 'cancel',\n cancels: params.cancels,\n };\n const nonce = Date.now();\n const signature = await signL1Action(\n getWallet(credential),\n action,\n params.vaultAddress ?? null,\n nonce,\n params.expiresAfter ?? null,\n true,\n );\n return request('POST', 'exchange', { action, nonce, signature });\n};\n\n/**\n * Modify an existing order on Hyperliquid exchange\n * API Endpoint: POST /exchange\n * @param credential - User credential containing private key for signing\n * @param params - Order modification parameters\n * @returns Promise resolving to exchange response\n */\nexport const modifyOrder = async (\n credential: ICredential,\n params: {\n oid: number | string;\n order: OrderPayload;\n vaultAddress?: string;\n expiresAfter?: number;\n },\n) => {\n const action: Record<string, any> = {\n type: 'modify',\n oid: params.oid,\n order: params.order,\n };\n const nonce = Date.now();\n const signature = await signL1Action(\n getWallet(credential),\n action,\n params.vaultAddress ?? null,\n nonce,\n params.expiresAfter ?? null,\n true,\n );\n return request('POST', 'exchange', { action, nonce, signature });\n};\n\n/**\n * Get user's fill history (trade history) from Hyperliquid\n * API Endpoint: POST /info (type: userFills)\n * @param credential - User credential containing private key for authentication\n * @param params - Optional time range parameters\n * @returns Promise resolving to user fill history with detailed trade information\n */\nexport const getUserFills = async (\n credential: ICredential,\n params?: { startTime?: number; endTime?: number },\n) => {\n const wallet = getWallet(credential);\n const address = wallet.address;\n\n const requestBody: any = {\n type: 'userFills',\n user: address,\n };\n\n if (params?.startTime) {\n requestBody.startTime = params.startTime;\n }\n\n if (params?.endTime) {\n requestBody.endTime = params.endTime;\n }\n\n return request<{\n fills: {\n time: number;\n feedId: string;\n hash: string;\n coin: string;\n side: string;\n px: string;\n sz: string;\n oid: number;\n startPos: string;\n fee: string;\n feeToken: string;\n closedSize: string;\n closedPnl: string;\n dir: string;\n source: string;\n type: string;\n positionAction: string;\n asset: number;\n tid: string;\n crossChain: any;\n }[];\n }>('POST', 'info', requestBody);\n};\n"]}
|
|
1
|
+
{"version":3,"file":"private-api.js","sourceRoot":"","sources":["../../src/api/private-api.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAChC,iCAAsC;AACtC,qCAAmC;AA6EnC,MAAM,WAAW,GAAG,IAAI,GAAG,EAAkB,CAAC;AAE9C,MAAM,SAAS,GAAG,CAAC,UAAuB,EAAE,EAAE;IAC5C,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QAC7C,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,EAAE,IAAI,eAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,CAAE,CAAC;AAClD,CAAC,CAAC;AAEK,MAAM,qBAAqB,GAAG,CAAC,MAGrC,EAAE,EAAE;IACH,MAAM,MAAM,GAAgB,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACrF,IAAI,CAAC,MAAM,CAAC,OAAO;QAAE,OAAO,MAAM,CAAC;IACnC,uCAAY,MAAM,KAAE,OAAO,EAAE,MAAM,CAAC,OAAO,IAAG;AAChD,CAAC,CAAC;AAPW,QAAA,qBAAqB,yBAOhC;AAEK,MAAM,sBAAsB,GAAG,CAAC,MAAoC,EAAE,EAAE,CAC7E,CAAC;IACC,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,MAAM,CAAC,OAAO;CACA,CAAA,CAAC;AAJf,QAAA,sBAAsB,0BAIP;AAErB,MAAM,sBAAsB,GAAG,CAAC,MAAqD,EAAE,EAAE,CAC9F,CAAC;IACC,IAAI,EAAE,QAAQ;IACd,GAAG,EAAE,MAAM,CAAC,GAAG;IACf,KAAK,EAAE,MAAM,CAAC,KAAK;CACI,CAAA,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yBAAyB,6BAkBpC;AAEF;;;;;;GAMG;AACI,MAAM,YAAY,GAAG,KAAK,EAC/B,UAAuB,EACvB,MAAiD,EACjD,EAAE;IACF,OAAO,IAAA,gBAAO,EAuBX,MAAM,EAAE,MAAM,EAAE,IAAA,iCAAyB,EAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;AACpE,CAAC,CAAC;AA5BW,QAAA,YAAY,gBA4BvB","sourcesContent":["import { Wallet } from 'ethers';\nimport { signL1Action } from './sign';\nimport { request } from './client';\nimport { ICredential } from './types';\n\n/**\n * Order payload for placing orders on Hyperliquid\n */\ntype OrderPayload = {\n /** Asset index (absolute) */\n a: number;\n /** Buy flag (true for buy, false for sell) */\n b: boolean;\n /** Limit price string */\n p: string;\n /** Size string */\n s: string;\n /** Reduce only flag */\n r: boolean;\n /** Order type configuration */\n t: {\n /** Time in force for limit orders: \"Alo\" (Post-Only), \"Ioc\" (Immediate or Cancel), \"Gtc\" (Good til Cancel) */\n limit?: { tif: string };\n /** Trigger order configuration */\n trigger?: {\n /** Is market trigger price */\n isMarket: boolean;\n /** Trigger price string */\n triggerPx: string;\n /** Take profit/stop loss indicator */\n tpsl: string;\n };\n };\n /** Order fee coefficient */\n c?: number;\n};\n\n/**\n * Cancel order payload\n */\ntype CancelPayload = {\n /** Asset index (absolute) */\n a: number;\n /** Order ID */\n o: number;\n};\n\n/**\n * Modify order payload\n */\ntype ModifyOrderPayload = {\n /** Order ID to modify */\n oid: number | string;\n /** New order parameters */\n order: OrderPayload;\n};\n\ntype OrderAction = {\n type: 'order';\n orders: OrderPayload[];\n grouping: 'na';\n builder?: { b: string; f: number };\n};\n\ntype CancelAction = {\n type: 'cancel';\n cancels: CancelPayload[];\n};\n\ntype ModifyAction = {\n type: 'modify';\n oid: number | string;\n order: OrderPayload;\n};\n\ntype ExchangeAction = OrderAction | CancelAction | ModifyAction;\n\ntype L1Signature = { r: string; s: string; v: number };\n\nconst walletCache = new Map<string, Wallet>();\n\nconst getWallet = (credential: ICredential) => {\n if (!walletCache.has(credential.private_key)) {\n walletCache.set(credential.private_key, new Wallet(credential.private_key));\n }\n return walletCache.get(credential.private_key)!;\n};\n\nexport const buildPlaceOrderAction = (params: {\n orders: OrderPayload[];\n builder?: { b: string; f: number };\n}) => {\n const action: OrderAction = { type: 'order', orders: params.orders, grouping: 'na' };\n if (!params.builder) return action;\n return { ...action, builder: params.builder };\n};\n\nexport const buildCancelOrderAction = (params: { cancels: CancelPayload[] }) =>\n ({\n type: 'cancel',\n cancels: params.cancels,\n } satisfies CancelAction);\n\nexport const buildModifyOrderAction = (params: { oid: number | string; order: OrderPayload }) =>\n ({\n type: 'modify',\n oid: params.oid,\n order: params.order,\n } satisfies ModifyAction);\n\nexport const createSignedExchangeRequestBody = async (\n credential: ICredential,\n action: ExchangeAction,\n options?: { nonce?: number; vaultAddress?: string; expiresAfter?: number; isMainnet?: boolean },\n) => {\n const nonce = options?.nonce ?? Date.now();\n const signature: L1Signature = await signL1Action(\n getWallet(credential),\n action,\n options?.vaultAddress ?? null,\n nonce,\n options?.expiresAfter ?? null,\n options?.isMainnet ?? true,\n );\n return { action, nonce, signature };\n};\n\n/**\n * Place orders on Hyperliquid exchange\n * API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#place-an-order\n * API Endpoint: POST /exchange\n * @param credential - User credential containing private key for signing\n * @param params - Order placement parameters\n * @returns Promise resolving to exchange response\n */\nexport const placeOrder = async (\n credential: ICredential,\n params: {\n orders: OrderPayload[];\n builder?: { b: string; f: number };\n vaultAddress?: string;\n expiresAfter?: number;\n },\n) => {\n const action = buildPlaceOrderAction(params);\n const requestBody = await createSignedExchangeRequestBody(credential, action, {\n vaultAddress: params.vaultAddress,\n expiresAfter: params.expiresAfter,\n });\n return request('POST', 'exchange', requestBody);\n};\n\n/**\n * Cancel orders on Hyperliquid exchange\n * API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#cancel-order-s\n * API Endpoint: POST /exchange\n * @param credential - User credential containing private key for signing\n * @param params - Order cancellation parameters\n * @returns Promise resolving to exchange response\n */\nexport const cancelOrder = async (\n credential: ICredential,\n params: { cancels: CancelPayload[]; vaultAddress?: string; expiresAfter?: number },\n) => {\n const action = buildCancelOrderAction(params);\n const requestBody = await createSignedExchangeRequestBody(credential, action, {\n vaultAddress: params.vaultAddress,\n expiresAfter: params.expiresAfter,\n });\n return request('POST', 'exchange', requestBody);\n};\n\n/**\n * Modify an existing order on Hyperliquid exchange\n * API Endpoint: POST /exchange\n * @param credential - User credential containing private key for signing\n * @param params - Order modification parameters\n * @returns Promise resolving to exchange response\n */\nexport const modifyOrder = async (\n credential: ICredential,\n params: {\n oid: number | string;\n order: OrderPayload;\n vaultAddress?: string;\n expiresAfter?: number;\n },\n) => {\n const action = buildModifyOrderAction(params);\n const requestBody = await createSignedExchangeRequestBody(credential, action, {\n vaultAddress: params.vaultAddress,\n expiresAfter: params.expiresAfter,\n });\n return request('POST', 'exchange', requestBody);\n};\n\nexport const buildUserFillsRequestBody = (\n credential: ICredential,\n params?: { startTime?: number; endTime?: number },\n) => {\n const requestBody: { type: 'userFills'; user: string; startTime?: number; endTime?: number } = {\n type: 'userFills',\n user: credential.address,\n };\n\n if (params?.startTime != null) {\n requestBody.startTime = params.startTime;\n }\n\n if (params?.endTime != null) {\n requestBody.endTime = params.endTime;\n }\n\n return requestBody;\n};\n\n/**\n * Get user's fill history (trade history) from Hyperliquid\n * API Endpoint: POST /info (type: userFills)\n * @param credential - User credential containing private key for authentication\n * @param params - Optional time range parameters\n * @returns Promise resolving to user fill history with detailed trade information\n */\nexport const getUserFills = async (\n credential: ICredential,\n params?: { startTime?: number; endTime?: number },\n) => {\n return request<{\n fills: {\n time: number;\n feedId: string;\n hash: string;\n coin: string;\n side: string;\n px: string;\n sz: string;\n oid: number;\n startPos: string;\n fee: string;\n feeToken: string;\n closedSize: string;\n closedPnl: string;\n dir: string;\n source: string;\n type: string;\n positionAction: string;\n asset: number;\n tid: string;\n crossChain: unknown;\n }[];\n }>('POST', 'info', buildUserFillsRequestBody(credential, params));\n};\n"]}
|
package/lib/api/public-api.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
export declare const buildUserPerpetualsAccountSummaryRequestBody: (params: {
|
|
2
|
+
user: string;
|
|
3
|
+
}) => {
|
|
4
|
+
type: string;
|
|
5
|
+
};
|
|
1
6
|
/**
|
|
2
7
|
* Get user's perpetual account summary including positions, margin, and portfolio information
|
|
3
8
|
* API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-users-perpetuals-account-summary
|
|
@@ -48,6 +53,11 @@ export declare const getUserPerpetualsAccountSummary: (params: {
|
|
|
48
53
|
}[];
|
|
49
54
|
time: number;
|
|
50
55
|
}>;
|
|
56
|
+
export declare const buildPerpetualsMetaDataRequestBody: (params?: {
|
|
57
|
+
dex?: string;
|
|
58
|
+
}) => {
|
|
59
|
+
type: string;
|
|
60
|
+
};
|
|
51
61
|
/**
|
|
52
62
|
* Get perpetual market metadata including available assets, their specifications, and margin tiers
|
|
53
63
|
* API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-metadata
|
|
@@ -74,6 +84,9 @@ export declare const getPerpetualsMetaData: (params?: {
|
|
|
74
84
|
}[];
|
|
75
85
|
}][];
|
|
76
86
|
}>;
|
|
87
|
+
export declare const buildSpotMetaDataRequestBody: () => {
|
|
88
|
+
type: string;
|
|
89
|
+
};
|
|
77
90
|
/**
|
|
78
91
|
* Get spot market metadata including available tokens and trading pairs
|
|
79
92
|
* API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-spot-metadata
|
|
@@ -98,6 +111,13 @@ export declare const getSpotMetaData: () => Promise<{
|
|
|
98
111
|
isCanonical: boolean;
|
|
99
112
|
}[];
|
|
100
113
|
}>;
|
|
114
|
+
export declare const buildUserFundingHistoryRequestBody: (params: {
|
|
115
|
+
user: string;
|
|
116
|
+
startTime?: number;
|
|
117
|
+
endTime?: number;
|
|
118
|
+
}) => {
|
|
119
|
+
type: string;
|
|
120
|
+
};
|
|
101
121
|
/**
|
|
102
122
|
* Get user's funding rate payment history for perpetual positions
|
|
103
123
|
* API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-a-users-funding-history-or-non-funding-ledger-updates
|
|
@@ -123,10 +143,15 @@ export declare const getUserFundingHistory: (params: {
|
|
|
123
143
|
fundingRate: string;
|
|
124
144
|
};
|
|
125
145
|
}[]>;
|
|
146
|
+
export declare const buildUserTokenBalancesRequestBody: (params: {
|
|
147
|
+
user: string;
|
|
148
|
+
}) => {
|
|
149
|
+
type: string;
|
|
150
|
+
};
|
|
126
151
|
/**
|
|
127
152
|
* Get user's token balances for both spot and perpetual accounts
|
|
128
153
|
* API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-a-users-token-balances
|
|
129
|
-
* API Endpoint: POST /info (type:
|
|
154
|
+
* API Endpoint: POST /info (type: spotClearinghouseState)
|
|
130
155
|
* @param params - Query parameters
|
|
131
156
|
* @param params.user - User's wallet address
|
|
132
157
|
* @returns Promise resolving to array of token balances with held and total amounts
|
|
@@ -142,6 +167,11 @@ export declare const getUserTokenBalances: (params: {
|
|
|
142
167
|
entryNtl: string;
|
|
143
168
|
}[];
|
|
144
169
|
}>;
|
|
170
|
+
export declare const buildUserOpenOrdersRequestBody: (params: {
|
|
171
|
+
user: string;
|
|
172
|
+
}) => {
|
|
173
|
+
type: string;
|
|
174
|
+
};
|
|
145
175
|
/**
|
|
146
176
|
* Get user's currently open orders across all markets
|
|
147
177
|
* API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#open-orders
|
|
@@ -160,6 +190,13 @@ export declare const getUserOpenOrders: (params: {
|
|
|
160
190
|
sz: string;
|
|
161
191
|
timestamp: number;
|
|
162
192
|
}[]>;
|
|
193
|
+
export declare const buildHistoricalFundingRatesRequestBody: (params: {
|
|
194
|
+
coin: string;
|
|
195
|
+
startTime: number;
|
|
196
|
+
endTime?: number;
|
|
197
|
+
}) => {
|
|
198
|
+
type: string;
|
|
199
|
+
};
|
|
163
200
|
/**
|
|
164
201
|
* Get historical funding rates for a specific perpetual asset
|
|
165
202
|
* API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-historical-funding-rates
|
|
@@ -180,6 +217,9 @@ export declare const getHistoricalFundingRates: (params: {
|
|
|
180
217
|
premium: string;
|
|
181
218
|
time: number;
|
|
182
219
|
}[]>;
|
|
220
|
+
export declare const buildAllMidsRequestBody: () => {
|
|
221
|
+
type: string;
|
|
222
|
+
};
|
|
183
223
|
/**
|
|
184
224
|
* Get current mid prices for all tradable assets
|
|
185
225
|
* API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-mids-for-all-coins
|
|
@@ -187,6 +227,9 @@ export declare const getHistoricalFundingRates: (params: {
|
|
|
187
227
|
* @returns Promise resolving to record of asset symbols mapped to their mid prices
|
|
188
228
|
*/
|
|
189
229
|
export declare const getAllMids: () => Promise<Record<string, string>>;
|
|
230
|
+
export declare const buildMetaAndAssetCtxsRequestBody: () => {
|
|
231
|
+
type: string;
|
|
232
|
+
};
|
|
190
233
|
/**
|
|
191
234
|
* Get metadata and asset contexts (prices, funding, OI) for all perpetuals
|
|
192
235
|
* API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-asset-contexts-includes-mark-price-current-funding-open-interest-etc.
|
|
@@ -212,6 +255,16 @@ export declare const getMetaAndAssetCtxs: () => Promise<[{
|
|
|
212
255
|
premium: string;
|
|
213
256
|
prevDayPx: string;
|
|
214
257
|
}[]]>;
|
|
258
|
+
export declare const buildCandleSnapshotRequestBody: (params: {
|
|
259
|
+
req: {
|
|
260
|
+
coin: string;
|
|
261
|
+
interval: string;
|
|
262
|
+
startTime: number;
|
|
263
|
+
endTime: number;
|
|
264
|
+
};
|
|
265
|
+
}) => {
|
|
266
|
+
type: string;
|
|
267
|
+
};
|
|
215
268
|
/**
|
|
216
269
|
* Get candle/K-line data for a specific asset and time range
|
|
217
270
|
* API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#candle-snapshot
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../../src/api/public-api.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../../src/api/public-api.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,4CAA4C,GAAI,QAAQ;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE;;CACjC,CAAC;AAErD;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,GAAI,QAAQ;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE;mBAErD;QACb,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC;QACpB,eAAe,EAAE,MAAM,CAAC;KACzB;wBACmB;QAClB,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC;QACpB,eAAe,EAAE,MAAM,CAAC;KACzB;gCAC2B,MAAM;kBACpB,MAAM;oBACJ;QACd,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE;YACR,IAAI,EAAE,MAAM,CAAC;YACb,GAAG,EAAE,MAAM,CAAC;YACZ,QAAQ,EAAE;gBAAE,IAAI,EAAE,MAAM,CAAC;gBAAC,KAAK,EAAE,MAAM,CAAA;aAAE,CAAC;YAC1C,OAAO,EAAE,MAAM,CAAC;YAChB,aAAa,EAAE,MAAM,CAAC;YACtB,aAAa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QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7E;OAGQ,MAAM;OACN,MAAM;OACN,MAAM;OACN,MAAM;OACN,MAAM;OACN,MAAM;OACN,MAAM;OACN,MAAM;OACN,MAAM;OACN,MAAM;IAE4C,CAAC"}
|
package/lib/api/public-api.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCandleSnapshot = exports.getMetaAndAssetCtxs = exports.getAllMids = exports.getHistoricalFundingRates = exports.getUserOpenOrders = exports.getUserTokenBalances = exports.getUserFundingHistory = exports.getSpotMetaData = exports.getPerpetualsMetaData = exports.getUserPerpetualsAccountSummary = void 0;
|
|
3
|
+
exports.getCandleSnapshot = exports.buildCandleSnapshotRequestBody = exports.getMetaAndAssetCtxs = exports.buildMetaAndAssetCtxsRequestBody = exports.getAllMids = exports.buildAllMidsRequestBody = exports.getHistoricalFundingRates = exports.buildHistoricalFundingRatesRequestBody = exports.getUserOpenOrders = exports.buildUserOpenOrdersRequestBody = exports.getUserTokenBalances = exports.buildUserTokenBalancesRequestBody = exports.getUserFundingHistory = exports.buildUserFundingHistoryRequestBody = exports.getSpotMetaData = exports.buildSpotMetaDataRequestBody = exports.getPerpetualsMetaData = exports.buildPerpetualsMetaDataRequestBody = exports.getUserPerpetualsAccountSummary = exports.buildUserPerpetualsAccountSummaryRequestBody = void 0;
|
|
4
4
|
const client_1 = require("./client");
|
|
5
|
+
const buildInfoRequestBody = (type, params) => (Object.assign(Object.assign({}, (params !== null && params !== void 0 ? params : {})), { type }));
|
|
6
|
+
const buildUserPerpetualsAccountSummaryRequestBody = (params) => buildInfoRequestBody('clearinghouseState', params);
|
|
7
|
+
exports.buildUserPerpetualsAccountSummaryRequestBody = buildUserPerpetualsAccountSummaryRequestBody;
|
|
5
8
|
/**
|
|
6
9
|
* Get user's perpetual account summary including positions, margin, and portfolio information
|
|
7
10
|
* API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-users-perpetuals-account-summary
|
|
@@ -10,8 +13,10 @@ const client_1 = require("./client");
|
|
|
10
13
|
* @param params.user - User's wallet address
|
|
11
14
|
* @returns Promise resolving to account summary with margin information, positions, and portfolio details
|
|
12
15
|
*/
|
|
13
|
-
const getUserPerpetualsAccountSummary = (params) => (0, client_1.request)('POST', 'info',
|
|
16
|
+
const getUserPerpetualsAccountSummary = (params) => (0, client_1.request)('POST', 'info', (0, exports.buildUserPerpetualsAccountSummaryRequestBody)(params));
|
|
14
17
|
exports.getUserPerpetualsAccountSummary = getUserPerpetualsAccountSummary;
|
|
18
|
+
const buildPerpetualsMetaDataRequestBody = (params) => buildInfoRequestBody('meta', params !== null && params !== void 0 ? params : {});
|
|
19
|
+
exports.buildPerpetualsMetaDataRequestBody = buildPerpetualsMetaDataRequestBody;
|
|
15
20
|
/**
|
|
16
21
|
* Get perpetual market metadata including available assets, their specifications, and margin tiers
|
|
17
22
|
* API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-metadata
|
|
@@ -20,16 +25,20 @@ exports.getUserPerpetualsAccountSummary = getUserPerpetualsAccountSummary;
|
|
|
20
25
|
* @param params.dex - Optional DEX identifier
|
|
21
26
|
* @returns Promise resolving to universe of perpetual assets and margin configuration
|
|
22
27
|
*/
|
|
23
|
-
const getPerpetualsMetaData = (params) => (0, client_1.request)('POST', 'info',
|
|
28
|
+
const getPerpetualsMetaData = (params) => (0, client_1.request)('POST', 'info', (0, exports.buildPerpetualsMetaDataRequestBody)(params));
|
|
24
29
|
exports.getPerpetualsMetaData = getPerpetualsMetaData;
|
|
30
|
+
const buildSpotMetaDataRequestBody = () => buildInfoRequestBody('spotMeta');
|
|
31
|
+
exports.buildSpotMetaDataRequestBody = buildSpotMetaDataRequestBody;
|
|
25
32
|
/**
|
|
26
33
|
* Get spot market metadata including available tokens and trading pairs
|
|
27
34
|
* API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-spot-metadata
|
|
28
35
|
* API Endpoint: POST /info (type: spotMeta)
|
|
29
36
|
* @returns Promise resolving to spot universe with token information and pair configurations
|
|
30
37
|
*/
|
|
31
|
-
const getSpotMetaData = () => (0, client_1.request)('POST', 'info',
|
|
38
|
+
const getSpotMetaData = () => (0, client_1.request)('POST', 'info', (0, exports.buildSpotMetaDataRequestBody)());
|
|
32
39
|
exports.getSpotMetaData = getSpotMetaData;
|
|
40
|
+
const buildUserFundingHistoryRequestBody = (params) => buildInfoRequestBody('fundingHistory', params);
|
|
41
|
+
exports.buildUserFundingHistoryRequestBody = buildUserFundingHistoryRequestBody;
|
|
33
42
|
/**
|
|
34
43
|
* Get user's funding rate payment history for perpetual positions
|
|
35
44
|
* API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-a-users-funding-history-or-non-funding-ledger-updates
|
|
@@ -40,18 +49,22 @@ exports.getSpotMetaData = getSpotMetaData;
|
|
|
40
49
|
* @param params.endTime - Optional end timestamp in milliseconds
|
|
41
50
|
* @returns Promise resolving to array of funding payment records with amounts and rates
|
|
42
51
|
*/
|
|
43
|
-
const getUserFundingHistory = (params) => (0, client_1.request)('POST', 'info',
|
|
52
|
+
const getUserFundingHistory = (params) => (0, client_1.request)('POST', 'info', (0, exports.buildUserFundingHistoryRequestBody)(params));
|
|
44
53
|
exports.getUserFundingHistory = getUserFundingHistory;
|
|
54
|
+
const buildUserTokenBalancesRequestBody = (params) => buildInfoRequestBody('spotClearinghouseState', params);
|
|
55
|
+
exports.buildUserTokenBalancesRequestBody = buildUserTokenBalancesRequestBody;
|
|
45
56
|
/**
|
|
46
57
|
* Get user's token balances for both spot and perpetual accounts
|
|
47
58
|
* API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-a-users-token-balances
|
|
48
|
-
* API Endpoint: POST /info (type:
|
|
59
|
+
* API Endpoint: POST /info (type: spotClearinghouseState)
|
|
49
60
|
* @param params - Query parameters
|
|
50
61
|
* @param params.user - User's wallet address
|
|
51
62
|
* @returns Promise resolving to array of token balances with held and total amounts
|
|
52
63
|
*/
|
|
53
|
-
const getUserTokenBalances = (params) => (0, client_1.request)('POST', 'info',
|
|
64
|
+
const getUserTokenBalances = (params) => (0, client_1.request)('POST', 'info', (0, exports.buildUserTokenBalancesRequestBody)(params));
|
|
54
65
|
exports.getUserTokenBalances = getUserTokenBalances;
|
|
66
|
+
const buildUserOpenOrdersRequestBody = (params) => buildInfoRequestBody('openOrders', params);
|
|
67
|
+
exports.buildUserOpenOrdersRequestBody = buildUserOpenOrdersRequestBody;
|
|
55
68
|
/**
|
|
56
69
|
* Get user's currently open orders across all markets
|
|
57
70
|
* API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#open-orders
|
|
@@ -60,8 +73,10 @@ exports.getUserTokenBalances = getUserTokenBalances;
|
|
|
60
73
|
* @param params.user - User's wallet address
|
|
61
74
|
* @returns Promise resolving to array of open order details with prices, sizes, and timestamps
|
|
62
75
|
*/
|
|
63
|
-
const getUserOpenOrders = (params) => (0, client_1.request)('POST', 'info',
|
|
76
|
+
const getUserOpenOrders = (params) => (0, client_1.request)('POST', 'info', (0, exports.buildUserOpenOrdersRequestBody)(params));
|
|
64
77
|
exports.getUserOpenOrders = getUserOpenOrders;
|
|
78
|
+
const buildHistoricalFundingRatesRequestBody = (params) => buildInfoRequestBody('fundingHistory', params);
|
|
79
|
+
exports.buildHistoricalFundingRatesRequestBody = buildHistoricalFundingRatesRequestBody;
|
|
65
80
|
/**
|
|
66
81
|
* Get historical funding rates for a specific perpetual asset
|
|
67
82
|
* API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-historical-funding-rates
|
|
@@ -72,24 +87,30 @@ exports.getUserOpenOrders = getUserOpenOrders;
|
|
|
72
87
|
* @param params.endTime - Optional end timestamp in milliseconds
|
|
73
88
|
* @returns Promise resolving to array of historical funding rate records
|
|
74
89
|
*/
|
|
75
|
-
const getHistoricalFundingRates = (params) => (0, client_1.request)('POST', 'info',
|
|
90
|
+
const getHistoricalFundingRates = (params) => (0, client_1.request)('POST', 'info', (0, exports.buildHistoricalFundingRatesRequestBody)(params));
|
|
76
91
|
exports.getHistoricalFundingRates = getHistoricalFundingRates;
|
|
92
|
+
const buildAllMidsRequestBody = () => buildInfoRequestBody('allMids');
|
|
93
|
+
exports.buildAllMidsRequestBody = buildAllMidsRequestBody;
|
|
77
94
|
/**
|
|
78
95
|
* Get current mid prices for all tradable assets
|
|
79
96
|
* API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-mids-for-all-coins
|
|
80
97
|
* API Endpoint: POST /info (type: allMids)
|
|
81
98
|
* @returns Promise resolving to record of asset symbols mapped to their mid prices
|
|
82
99
|
*/
|
|
83
|
-
const getAllMids = () => (0, client_1.request)('POST', 'info',
|
|
100
|
+
const getAllMids = () => (0, client_1.request)('POST', 'info', (0, exports.buildAllMidsRequestBody)());
|
|
84
101
|
exports.getAllMids = getAllMids;
|
|
102
|
+
const buildMetaAndAssetCtxsRequestBody = () => buildInfoRequestBody('metaAndAssetCtxs');
|
|
103
|
+
exports.buildMetaAndAssetCtxsRequestBody = buildMetaAndAssetCtxsRequestBody;
|
|
85
104
|
/**
|
|
86
105
|
* Get metadata and asset contexts (prices, funding, OI) for all perpetuals
|
|
87
106
|
* API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-asset-contexts-includes-mark-price-current-funding-open-interest-etc.
|
|
88
107
|
* API Endpoint: POST /info (type: metaAndAssetCtxs)
|
|
89
108
|
* @returns Promise resolving to metadata and current asset contexts
|
|
90
109
|
*/
|
|
91
|
-
const getMetaAndAssetCtxs = () => (0, client_1.request)('POST', 'info',
|
|
110
|
+
const getMetaAndAssetCtxs = () => (0, client_1.request)('POST', 'info', (0, exports.buildMetaAndAssetCtxsRequestBody)());
|
|
92
111
|
exports.getMetaAndAssetCtxs = getMetaAndAssetCtxs;
|
|
112
|
+
const buildCandleSnapshotRequestBody = (params) => buildInfoRequestBody('candleSnapshot', params);
|
|
113
|
+
exports.buildCandleSnapshotRequestBody = buildCandleSnapshotRequestBody;
|
|
93
114
|
/**
|
|
94
115
|
* Get candle/K-line data for a specific asset and time range
|
|
95
116
|
* API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#candle-snapshot
|
|
@@ -102,6 +123,6 @@ exports.getMetaAndAssetCtxs = getMetaAndAssetCtxs;
|
|
|
102
123
|
* @param params.req.endTime - End timestamp in milliseconds
|
|
103
124
|
* @returns Promise resolving to candle data with OHLCV information
|
|
104
125
|
*/
|
|
105
|
-
const getCandleSnapshot = (params) => (0, client_1.request)('POST', 'info',
|
|
126
|
+
const getCandleSnapshot = (params) => (0, client_1.request)('POST', 'info', (0, exports.buildCandleSnapshotRequestBody)(params));
|
|
106
127
|
exports.getCandleSnapshot = getCandleSnapshot;
|
|
107
128
|
//# sourceMappingURL=public-api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public-api.js","sourceRoot":"","sources":["../../src/api/public-api.ts"],"names":[],"mappings":";;;AAAA,qCAAmC;AAEnC;;;;;;;GAOG;AACI,MAAM,+BAA+B,GAAG,CAAC,MAAwB,EAAE,EAAE,CAC1E,IAAA,gBAAO,EAoCJ,MAAM,EAAE,MAAM,kCAAO,MAAM,KAAE,IAAI,EAAE,oBAAoB,IAAG,CAAC;AArCnD,QAAA,+BAA+B,mCAqCoB;AAEhE;;;;;;;GAOG;AACI,MAAM,qBAAqB,GAAG,CAAC,MAAyB,EAA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AAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;AAAxF,QAAA,UAAU,cAA8E;AAErG;;;;;GAKG;AACI,MAAM,mBAAmB,GAAG,GAAG,EAAE,CACtC,IAAA,gBAAO,EAuBL,MAAM,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC,CAAC;AAxBrC,QAAA,mBAAmB,uBAwBkB;AAElD;;;;;;;;;;;GAWG;AACI,MAAM,iBAAiB,GAAG,CAAC,MAEjC,EAAE,EAAE,CACH,IAAA,gBAAO,EAaL,MAAM,EAAE,MAAM,kBAAI,IAAI,EAAE,gBAAgB,IAAK,MAAM,EAAG,CAAC;AAhB9C,QAAA,iBAAiB,qBAgB6B","sourcesContent":["import { request } from './client';\n\n/**\n * Get user's perpetual account summary including positions, margin, and portfolio information\n * API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-users-perpetuals-account-summary\n * API Endpoint: POST /info (type: clearinghouseState)\n * @param params - Query parameters\n * @param params.user - User's wallet address\n * @returns Promise resolving to account summary with margin information, positions, and portfolio details\n */\nexport const getUserPerpetualsAccountSummary = (params: { user: string }) =>\n request<{\n marginSummary: {\n accountValue: string;\n totalNtlPos: string;\n totalRawUsd: string;\n totalMarginUsed: string;\n };\n crossMarginSummary: {\n accountValue: string;\n totalNtlPos: string;\n totalRawUsd: string;\n totalMarginUsed: string;\n };\n crossMaintenanceMarginUsed: string;\n withdrawable: string;\n assetPositions: {\n type: string;\n position: {\n coin: string;\n szi: string;\n leverage: { type: string; value: number };\n entryPx: string;\n positionValue: string;\n unrealizedPnl: string;\n returnOnEquity: string;\n liquidationPx: string;\n marginUsed: string;\n maxLeverage: number;\n cumFunding: {\n allTime: string;\n sinceOpen: string;\n sinceChange: string;\n };\n };\n }[];\n time: number;\n }>('POST', 'info', { ...params, type: 'clearinghouseState' });\n\n/**\n * Get perpetual market metadata including available assets, their specifications, and margin tiers\n * API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-metadata\n * API Endpoint: POST /info (type: meta)\n * @param params - Optional query parameters\n * @param params.dex - Optional DEX identifier\n * @returns Promise resolving to universe of perpetual assets and margin configuration\n */\nexport const getPerpetualsMetaData = (params?: { dex?: string }) =>\n request<{\n universe: {\n name: string;\n szDecimals: number;\n maxLeverage: number;\n onlyIsolated?: boolean;\n isDelisted?: boolean;\n }[];\n marginTables: [\n number,\n {\n description: string;\n marginTiers: {\n lowerBound: string;\n maxLeverage: number;\n }[];\n },\n ][];\n }>('POST', 'info', { ...(params ?? {}), type: 'meta' });\n\n/**\n * Get spot market metadata including available tokens and trading pairs\n * API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-spot-metadata\n * API Endpoint: POST /info (type: spotMeta)\n * @returns Promise resolving to spot universe with token information and pair configurations\n */\nexport const getSpotMetaData = () =>\n request<{\n tokens: {\n name: string;\n szDecimals: number;\n weiDecimals: number;\n index: number;\n tokenId: string;\n isCanonical: boolean;\n evmContract: null;\n fullName: null;\n }[];\n universe: {\n name: string;\n tokens: number[];\n index: number;\n isCanonical: boolean;\n }[];\n }>('POST', 'info', { type: 'spotMeta' });\n\n/**\n * Get user's funding rate payment history for perpetual positions\n * API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-a-users-funding-history-or-non-funding-ledger-updates\n * API Endpoint: POST /info (type: fundingHistory)\n * @param params - Query parameters\n * @param params.user - User's wallet address\n * @param params.startTime - Optional start timestamp in milliseconds\n * @param params.endTime - Optional end timestamp in milliseconds\n * @returns Promise resolving to array of funding payment records with amounts and rates\n */\nexport const getUserFundingHistory = (params: { user: string; startTime?: number; endTime?: number }) =>\n request<\n {\n time: number;\n hash: string;\n delta: { type: string; coin: string; usdc: string; szi: string; fundingRate: string };\n }[]\n >('POST', 'info', { ...params, type: 'fundingHistory' });\n\n/**\n * Get user's token balances for both spot and perpetual accounts\n * API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-a-users-token-balances\n * API Endpoint: POST /info (type: tokenBalances)\n * @param params - Query parameters\n * @param params.user - User's wallet address\n * @returns Promise resolving to array of token balances with held and total amounts\n */\nexport const getUserTokenBalances = (params: { user: string }) =>\n request<{ balances: { coin: string; token: number; hold: string; total: string; entryNtl: string }[] }>(\n 'POST',\n 'info',\n {\n ...params,\n type: 'spotClearinghouseState',\n },\n );\n\n/**\n * Get user's currently open orders across all markets\n * API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#open-orders\n * API Endpoint: POST /info (type: openOrders)\n * @param params - Query parameters\n * @param params.user - User's wallet address\n * @returns Promise resolving to array of open order details with prices, sizes, and timestamps\n */\nexport const getUserOpenOrders = (params: { user: string }) =>\n request<{ coin: string; limitPx: string; oid: number; side: string; sz: string; timestamp: number }[]>(\n 'POST',\n 'info',\n {\n ...params,\n type: 'openOrders',\n },\n );\n\n/**\n * Get historical funding rates for a specific perpetual asset\n * API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-historical-funding-rates\n * API Endpoint: POST /info (type: fundingHistory)\n * @param params - Query parameters\n * @param params.coin - Asset symbol (e.g., \"BTC\", \"ETH\")\n * @param params.startTime - Start timestamp in milliseconds\n * @param params.endTime - Optional end timestamp in milliseconds\n * @returns Promise resolving to array of historical funding rate records\n */\nexport const getHistoricalFundingRates = (params: { coin: string; startTime: number; endTime?: number }) =>\n request<{ coin: string; fundingRate: string; premium: string; time: number }[]>('POST', 'info', {\n ...params,\n type: 'fundingHistory',\n });\n\n/**\n * Get current mid prices for all tradable assets\n * API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-mids-for-all-coins\n * API Endpoint: POST /info (type: allMids)\n * @returns Promise resolving to record of asset symbols mapped to their mid prices\n */\nexport const getAllMids = () => request<Record<string, string>>('POST', 'info', { type: 'allMids' });\n\n/**\n * Get metadata and asset contexts (prices, funding, OI) for all perpetuals\n * API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-asset-contexts-includes-mark-price-current-funding-open-interest-etc.\n * API Endpoint: POST /info (type: metaAndAssetCtxs)\n * @returns Promise resolving to metadata and current asset contexts\n */\nexport const getMetaAndAssetCtxs = () =>\n request<\n [\n {\n universe: {\n name: string;\n szDecimals: number;\n maxLeverage: number;\n onlyIsolated?: boolean;\n isDelisted?: boolean;\n }[];\n },\n {\n dayNtlVlm: string;\n funding: string;\n impactPxs: [string, string];\n markPx: string;\n midPx: string;\n openInterest: string;\n oraclePx: string;\n premium: string;\n prevDayPx: string;\n }[],\n ]\n >('POST', 'info', { type: 'metaAndAssetCtxs' });\n\n/**\n * Get candle/K-line data for a specific asset and time range\n * API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#candle-snapshot\n * API Endpoint: POST /info (type: candleSnapshot)\n * @param params - Query parameters\n * @param params.req - Request object with candle parameters\n * @param params.req.coin - Asset symbol\n * @param params.req.interval - Time interval (e.g., \"1m\", \"5m\", \"1h\", \"1d\")\n * @param params.req.startTime - Start timestamp in milliseconds\n * @param params.req.endTime - End timestamp in milliseconds\n * @returns Promise resolving to candle data with OHLCV information\n */\nexport const getCandleSnapshot = (params: {\n req: { coin: string; interval: string; startTime: number; endTime: number };\n}) =>\n request<\n {\n T: number;\n c: string;\n h: string;\n i: string;\n l: string;\n o: string;\n n: number;\n s: string;\n t: number;\n v: string;\n }[]\n >('POST', 'info', { type: 'candleSnapshot', ...params });\n"]}
|
|
1
|
+
{"version":3,"file":"public-api.js","sourceRoot":"","sources":["../../src/api/public-api.ts"],"names":[],"mappings":";;;AAAA,qCAAmC;AAEnC,MAAM,oBAAoB,GAAG,CAAoC,IAAY,EAAE,MAAU,EAAE,EAAE,CAAC,iC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;;;;;GAKG;AACI,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,IAAA,gBAAO,EAAyB,MAAM,EAAE,MAAM,EAAE,IAAA,+BAAuB,GAAE,CAAC,CAAC;AAA9F,QAAA,UAAU,cAAoF;AAEpG,MAAM,gCAAgC,GAAG,GAAG,EAAE,CAAC,oBAAoB,CAAC,kBAAkB,CAAC,CAAC;AAAlF,QAAA,gCAAgC,oCAAkD;AAE/F;;;;;GAKG;AACI,MAAM,mBAAmB,GAAG,GAAG,EAAE,CACtC,IAAA,gBAAO,EAuBL,MAAM,EAAE,MAAM,EAAE,IAAA,wCAAgC,GAAE,CAAC,CAAC;AAxB3C,QAAA,mBAAmB,uBAwBwB;AAEjD,MAAM,8BAA8B,GAAG,CAAC,MAE9C,EAAE,EAAE,CAAC,oBAAoB,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;AAFxC,QAAA,8BAA8B,kCAEU;AAErD;;;;;;;;;;;GAWG;AACI,MAAM,iBAAiB,GAAG,CAAC,MAEjC,EAAE,EAAE,CACH,IAAA,gBAAO,EAaL,MAAM,EAAE,MAAM,EAAE,IAAA,sCAA8B,EAAC,MAAM,CAAC,CAAC,CAAC;AAhB/C,QAAA,iBAAiB,qBAgB8B","sourcesContent":["import { request } from './client';\n\nconst buildInfoRequestBody = <P extends Record<string, unknown>>(type: string, params?: P) => ({\n ...(params ?? {}),\n type,\n});\n\nexport const buildUserPerpetualsAccountSummaryRequestBody = (params: { user: string }) =>\n buildInfoRequestBody('clearinghouseState', params);\n\n/**\n * Get user's perpetual account summary including positions, margin, and portfolio information\n * API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-users-perpetuals-account-summary\n * API Endpoint: POST /info (type: clearinghouseState)\n * @param params - Query parameters\n * @param params.user - User's wallet address\n * @returns Promise resolving to account summary with margin information, positions, and portfolio details\n */\nexport const getUserPerpetualsAccountSummary = (params: { user: string }) =>\n request<{\n marginSummary: {\n accountValue: string;\n totalNtlPos: string;\n totalRawUsd: string;\n totalMarginUsed: string;\n };\n crossMarginSummary: {\n accountValue: string;\n totalNtlPos: string;\n totalRawUsd: string;\n totalMarginUsed: string;\n };\n crossMaintenanceMarginUsed: string;\n withdrawable: string;\n assetPositions: {\n type: string;\n position: {\n coin: string;\n szi: string;\n leverage: { type: string; value: number };\n entryPx: string;\n positionValue: string;\n unrealizedPnl: string;\n returnOnEquity: string;\n liquidationPx: string;\n marginUsed: string;\n maxLeverage: number;\n cumFunding: {\n allTime: string;\n sinceOpen: string;\n sinceChange: string;\n };\n };\n }[];\n time: number;\n }>('POST', 'info', buildUserPerpetualsAccountSummaryRequestBody(params));\n\nexport const buildPerpetualsMetaDataRequestBody = (params?: { dex?: string }) =>\n buildInfoRequestBody('meta', params ?? {});\n\n/**\n * Get perpetual market metadata including available assets, their specifications, and margin tiers\n * API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-metadata\n * API Endpoint: POST /info (type: meta)\n * @param params - Optional query parameters\n * @param params.dex - Optional DEX identifier\n * @returns Promise resolving to universe of perpetual assets and margin configuration\n */\nexport const getPerpetualsMetaData = (params?: { dex?: string }) =>\n request<{\n universe: {\n name: string;\n szDecimals: number;\n maxLeverage: number;\n onlyIsolated?: boolean;\n isDelisted?: boolean;\n }[];\n marginTables: [\n number,\n {\n description: string;\n marginTiers: {\n lowerBound: string;\n maxLeverage: number;\n }[];\n },\n ][];\n }>('POST', 'info', buildPerpetualsMetaDataRequestBody(params));\n\nexport const buildSpotMetaDataRequestBody = () => buildInfoRequestBody('spotMeta');\n\n/**\n * Get spot market metadata including available tokens and trading pairs\n * API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-spot-metadata\n * API Endpoint: POST /info (type: spotMeta)\n * @returns Promise resolving to spot universe with token information and pair configurations\n */\nexport const getSpotMetaData = () =>\n request<{\n tokens: {\n name: string;\n szDecimals: number;\n weiDecimals: number;\n index: number;\n tokenId: string;\n isCanonical: boolean;\n evmContract: null;\n fullName: null;\n }[];\n universe: {\n name: string;\n tokens: number[];\n index: number;\n isCanonical: boolean;\n }[];\n }>('POST', 'info', buildSpotMetaDataRequestBody());\n\nexport const buildUserFundingHistoryRequestBody = (params: {\n user: string;\n startTime?: number;\n endTime?: number;\n}) => buildInfoRequestBody('fundingHistory', params);\n\n/**\n * Get user's funding rate payment history for perpetual positions\n * API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-a-users-funding-history-or-non-funding-ledger-updates\n * API Endpoint: POST /info (type: fundingHistory)\n * @param params - Query parameters\n * @param params.user - User's wallet address\n * @param params.startTime - Optional start timestamp in milliseconds\n * @param params.endTime - Optional end timestamp in milliseconds\n * @returns Promise resolving to array of funding payment records with amounts and rates\n */\nexport const getUserFundingHistory = (params: { user: string; startTime?: number; endTime?: number }) =>\n request<\n {\n time: number;\n hash: string;\n delta: { type: string; coin: string; usdc: string; szi: string; fundingRate: string };\n }[]\n >('POST', 'info', buildUserFundingHistoryRequestBody(params));\n\nexport const buildUserTokenBalancesRequestBody = (params: { user: string }) =>\n buildInfoRequestBody('spotClearinghouseState', params);\n\n/**\n * Get user's token balances for both spot and perpetual accounts\n * API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-a-users-token-balances\n * API Endpoint: POST /info (type: spotClearinghouseState)\n * @param params - Query parameters\n * @param params.user - User's wallet address\n * @returns Promise resolving to array of token balances with held and total amounts\n */\nexport const getUserTokenBalances = (params: { user: string }) =>\n request<{ balances: { coin: string; token: number; hold: string; total: string; entryNtl: string }[] }>(\n 'POST',\n 'info',\n buildUserTokenBalancesRequestBody(params),\n );\n\nexport const buildUserOpenOrdersRequestBody = (params: { user: string }) =>\n buildInfoRequestBody('openOrders', params);\n\n/**\n * Get user's currently open orders across all markets\n * API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#open-orders\n * API Endpoint: POST /info (type: openOrders)\n * @param params - Query parameters\n * @param params.user - User's wallet address\n * @returns Promise resolving to array of open order details with prices, sizes, and timestamps\n */\nexport const getUserOpenOrders = (params: { user: string }) =>\n request<{ coin: string; limitPx: string; oid: number; side: string; sz: string; timestamp: number }[]>(\n 'POST',\n 'info',\n buildUserOpenOrdersRequestBody(params),\n );\n\nexport const buildHistoricalFundingRatesRequestBody = (params: {\n coin: string;\n startTime: number;\n endTime?: number;\n}) => buildInfoRequestBody('fundingHistory', params);\n\n/**\n * Get historical funding rates for a specific perpetual asset\n * API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-historical-funding-rates\n * API Endpoint: POST /info (type: fundingHistory)\n * @param params - Query parameters\n * @param params.coin - Asset symbol (e.g., \"BTC\", \"ETH\")\n * @param params.startTime - Start timestamp in milliseconds\n * @param params.endTime - Optional end timestamp in milliseconds\n * @returns Promise resolving to array of historical funding rate records\n */\nexport const getHistoricalFundingRates = (params: { coin: string; startTime: number; endTime?: number }) =>\n request<{ coin: string; fundingRate: string; premium: string; time: number }[]>(\n 'POST',\n 'info',\n buildHistoricalFundingRatesRequestBody(params),\n );\n\nexport const buildAllMidsRequestBody = () => buildInfoRequestBody('allMids');\n\n/**\n * Get current mid prices for all tradable assets\n * API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-mids-for-all-coins\n * API Endpoint: POST /info (type: allMids)\n * @returns Promise resolving to record of asset symbols mapped to their mid prices\n */\nexport const getAllMids = () => request<Record<string, string>>('POST', 'info', buildAllMidsRequestBody());\n\nexport const buildMetaAndAssetCtxsRequestBody = () => buildInfoRequestBody('metaAndAssetCtxs');\n\n/**\n * Get metadata and asset contexts (prices, funding, OI) for all perpetuals\n * API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-asset-contexts-includes-mark-price-current-funding-open-interest-etc.\n * API Endpoint: POST /info (type: metaAndAssetCtxs)\n * @returns Promise resolving to metadata and current asset contexts\n */\nexport const getMetaAndAssetCtxs = () =>\n request<\n [\n {\n universe: {\n name: string;\n szDecimals: number;\n maxLeverage: number;\n onlyIsolated?: boolean;\n isDelisted?: boolean;\n }[];\n },\n {\n dayNtlVlm: string;\n funding: string;\n impactPxs: [string, string];\n markPx: string;\n midPx: string;\n openInterest: string;\n oraclePx: string;\n premium: string;\n prevDayPx: string;\n }[],\n ]\n >('POST', 'info', buildMetaAndAssetCtxsRequestBody());\n\nexport const buildCandleSnapshotRequestBody = (params: {\n req: { coin: string; interval: string; startTime: number; endTime: number };\n}) => buildInfoRequestBody('candleSnapshot', params);\n\n/**\n * Get candle/K-line data for a specific asset and time range\n * API Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#candle-snapshot\n * API Endpoint: POST /info (type: candleSnapshot)\n * @param params - Query parameters\n * @param params.req - Request object with candle parameters\n * @param params.req.coin - Asset symbol\n * @param params.req.interval - Time interval (e.g., \"1m\", \"5m\", \"1h\", \"1d\")\n * @param params.req.startTime - Start timestamp in milliseconds\n * @param params.req.endTime - End timestamp in milliseconds\n * @returns Promise resolving to candle data with OHLCV information\n */\nexport const getCandleSnapshot = (params: {\n req: { coin: string; interval: string; startTime: number; endTime: number };\n}) =>\n request<\n {\n T: number;\n c: string;\n h: string;\n i: string;\n l: string;\n o: string;\n n: number;\n s: string;\n t: number;\n v: string;\n }[]\n >('POST', 'info', buildCandleSnapshotRequestBody(params));\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
type HttpMethod = 'GET' | 'POST';
|
|
2
|
+
type RestRequestContext = Readonly<{
|
|
3
|
+
method: HttpMethod;
|
|
4
|
+
path: string;
|
|
5
|
+
body?: unknown;
|
|
6
|
+
kind: 'info' | 'exchange' | 'explorer' | 'other';
|
|
7
|
+
infoType?: string;
|
|
8
|
+
exchangeActionType?: string;
|
|
9
|
+
exchangeBatchLength?: number;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const getRestRequestContext: (method: HttpMethod, path: string, body?: unknown) => RestRequestContext;
|
|
12
|
+
export declare const getRestBaseWeight: (ctx: RestRequestContext) => number;
|
|
13
|
+
export declare const getRestEstimatedExtraWeight: (ctx: RestRequestContext) => number;
|
|
14
|
+
export declare const acquireRestIpWeightSync: (meta: Record<string, unknown>, weight: number) => void;
|
|
15
|
+
export declare const beforeRestRequest: (meta: Record<string, unknown>, ctx: RestRequestContext) => Readonly<{
|
|
16
|
+
baseWeight: number;
|
|
17
|
+
estimatedExtraWeight: number;
|
|
18
|
+
}>;
|
|
19
|
+
export declare const afterRestResponse: (meta: Record<string, unknown>, ctx: RestRequestContext, response: unknown, estimatedExtraWeight: number) => Promise<void>;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=rate-limit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rate-limit.d.ts","sourceRoot":"","sources":["../../src/api/rate-limit.ts"],"names":[],"mappings":"AAEA,KAAK,UAAU,GAAG,KAAK,GAAG,MAAM,CAAC;AAEjC,KAAK,kBAAkB,GAAG,QAAQ,CAAC;IACjC,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC;IACjD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC,CAAC;AAkEH,eAAO,MAAM,qBAAqB,GAChC,QAAQ,UAAU,EAClB,MAAM,MAAM,EACZ,OAAO,OAAO,KACb,kBAmBF,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,KAAK,kBAAkB,KAAG,MAY3D,CAAC;AA0D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