@syldel/hl-shared-types 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +15 -0
  2. package/dist/index.d.ts +1 -6
  3. package/dist/index.js +1 -6
  4. package/dist/interfaces/actions/cancel.interfaces.d.ts +14 -0
  5. package/dist/interfaces/actions/index.d.ts +4 -0
  6. package/dist/interfaces/actions/index.js +20 -0
  7. package/dist/interfaces/actions/modify.interfaces.d.ts +25 -0
  8. package/dist/interfaces/actions/order.interfaces.d.ts +12 -0
  9. package/dist/interfaces/actions/transfer.interfaces.d.ts +94 -0
  10. package/dist/interfaces/actions/transfer.interfaces.js +10 -0
  11. package/dist/interfaces/index.d.ts +7 -0
  12. package/dist/interfaces/index.js +23 -0
  13. package/dist/interfaces/orders/index.d.ts +4 -0
  14. package/dist/interfaces/orders/index.js +20 -0
  15. package/dist/interfaces/orders/open-order.interfaces.d.ts +21 -0
  16. package/dist/interfaces/orders/order-details.interfaces.d.ts +69 -0
  17. package/dist/interfaces/orders/order-status.interfaces.d.ts +35 -0
  18. package/dist/interfaces/orders/user-fills.interfaces.d.ts +18 -0
  19. package/dist/interfaces/orders/user-fills.interfaces.js +2 -0
  20. package/dist/interfaces/params/index.d.ts +1 -0
  21. package/dist/interfaces/params/index.js +17 -0
  22. package/dist/interfaces/params/signature.interfaces.d.ts +13 -0
  23. package/dist/interfaces/params/signature.interfaces.js +2 -0
  24. package/dist/interfaces/perp/balance.interfaces.d.ts +43 -0
  25. package/dist/interfaces/perp/balance.interfaces.js +2 -0
  26. package/dist/interfaces/perp/index.d.ts +2 -0
  27. package/dist/interfaces/perp/index.js +18 -0
  28. package/dist/interfaces/perp/meta.interfaces.d.ts +50 -0
  29. package/dist/interfaces/perp/meta.interfaces.js +2 -0
  30. package/dist/interfaces/responses/cancel.interfaces.d.ts +9 -0
  31. package/dist/interfaces/responses/cancel.interfaces.js +2 -0
  32. package/dist/interfaces/responses/error.interfaces.d.ts +10 -0
  33. package/dist/interfaces/responses/error.interfaces.js +18 -0
  34. package/dist/interfaces/responses/index.d.ts +4 -0
  35. package/dist/interfaces/responses/index.js +20 -0
  36. package/dist/interfaces/responses/order.interfaces.d.ts +18 -0
  37. package/dist/interfaces/responses/order.interfaces.js +2 -0
  38. package/dist/interfaces/responses/success.interfaces.d.ts +4 -0
  39. package/dist/interfaces/responses/success.interfaces.js +2 -0
  40. package/dist/interfaces/smart/batch-protective-order.interfaces.d.ts +30 -0
  41. package/dist/interfaces/smart/batch-protective-order.interfaces.js +2 -0
  42. package/dist/interfaces/smart/index.d.ts +3 -0
  43. package/dist/interfaces/smart/index.js +19 -0
  44. package/dist/interfaces/smart/protective-order.interfaces.d.ts +11 -0
  45. package/dist/interfaces/smart/protective-order.interfaces.js +2 -0
  46. package/dist/interfaces/smart/smart-order.interfaces.d.ts +26 -0
  47. package/dist/interfaces/smart/smart-order.interfaces.js +2 -0
  48. package/dist/interfaces/spot/balance.interfaces.d.ts +11 -0
  49. package/dist/interfaces/spot/balance.interfaces.js +2 -0
  50. package/dist/interfaces/spot/index.d.ts +2 -0
  51. package/dist/interfaces/spot/index.js +18 -0
  52. package/dist/interfaces/{market.d.ts → spot/meta.interfaces.d.ts} +4 -5
  53. package/dist/interfaces/spot/meta.interfaces.js +2 -0
  54. package/package.json +16 -7
  55. package/dist/interfaces/account.d.ts +0 -23
  56. package/dist/interfaces/common.d.ts +0 -7
  57. package/dist/interfaces/dto.d.ts +0 -32
  58. package/dist/interfaces/orders.d.ts +0 -15
  59. package/dist/interfaces/responses.d.ts +0 -37
  60. /package/dist/interfaces/{account.js → actions/cancel.interfaces.js} +0 -0
  61. /package/dist/interfaces/{common.js → actions/modify.interfaces.js} +0 -0
  62. /package/dist/interfaces/{dto.js → actions/order.interfaces.js} +0 -0
  63. /package/dist/interfaces/{market.js → orders/open-order.interfaces.js} +0 -0
  64. /package/dist/interfaces/{orders.js → orders/order-details.interfaces.js} +0 -0
  65. /package/dist/interfaces/{responses.js → orders/order-status.interfaces.js} +0 -0
package/README.md CHANGED
@@ -74,6 +74,7 @@ Le projet utilise des **Granular Access Tokens** pour la publication afin de con
74
74
  ### Configuration du Token
75
75
  1. Générer un token sur NPM avec les permissions `Read and Write`.
76
76
  2. Restreindre l'accès au package `@syldel/hl-shared-types` uniquement.
77
+ 3. Utiliser l'option `Bypass 2FA` pour permettre l'automatisation.
77
78
 
78
79
  ### Commande de publication rapide
79
80
  Si tu n'utilises pas de fichier `.npmrc`, tu peux publier en passant le token directement :
@@ -81,6 +82,20 @@ Si tu n'utilises pas de fichier `.npmrc`, tu peux publier en passant le token di
81
82
  npm publish --access public --//registry.npmjs.org/:_authToken=TON_TOKEN_ICI
82
83
  ```
83
84
 
85
+ ### Configuration de la publication
86
+ Créez un fichier .npmrc à la racine (ignoré par Git) pour l'authentification :
87
+
88
+ ```
89
+ //registry.npmjs.org/:_authToken=npm_votre_token_ici
90
+ ```
91
+
92
+ ### Publier une nouvelle version
93
+ La commande suivante automatise le build, l'incrémentation de version et l'envoi vers NPM :
94
+
95
+ ```bash
96
+ npm run release
97
+ ```
98
+
84
99
  ---
85
100
 
86
101
  ## 📝 Conventions de code
package/dist/index.d.ts CHANGED
@@ -1,6 +1 @@
1
- export * from './interfaces/common';
2
- export * from './interfaces/account';
3
- export * from './interfaces/market';
4
- export * from './interfaces/orders';
5
- export * from './interfaces/responses';
6
- export * from './interfaces/dto';
1
+ export * from './interfaces';
package/dist/index.js CHANGED
@@ -14,9 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./interfaces/common"), exports);
18
- __exportStar(require("./interfaces/account"), exports);
19
- __exportStar(require("./interfaces/market"), exports);
20
- __exportStar(require("./interfaces/orders"), exports);
21
- __exportStar(require("./interfaces/responses"), exports);
22
- __exportStar(require("./interfaces/dto"), exports);
17
+ __exportStar(require("./interfaces"), exports);
@@ -0,0 +1,14 @@
1
+ export interface HLCancelAction {
2
+ type: 'cancel';
3
+ cancels: Array<{
4
+ a: number;
5
+ o: number;
6
+ }>;
7
+ }
8
+ export interface HLCancelByCloidAction {
9
+ type: 'cancelByCloid';
10
+ cancels: Array<{
11
+ asset: number;
12
+ cloid: string;
13
+ }>;
14
+ }
@@ -0,0 +1,4 @@
1
+ export * from './order.interfaces';
2
+ export * from './cancel.interfaces';
3
+ export * from './modify.interfaces';
4
+ export * from './transfer.interfaces';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./order.interfaces"), exports);
18
+ __exportStar(require("./cancel.interfaces"), exports);
19
+ __exportStar(require("./modify.interfaces"), exports);
20
+ __exportStar(require("./transfer.interfaces"), exports);
@@ -0,0 +1,25 @@
1
+ import { HLApiOrder, HLOid } from '../orders';
2
+ export interface HLModifyAction {
3
+ type: 'modify';
4
+ oid: HLOid;
5
+ order: HLApiOrder;
6
+ }
7
+ export interface HLBatchModifyAction {
8
+ type: 'batchModify';
9
+ modifies: Array<{
10
+ oid: HLOid;
11
+ order: HLApiOrder;
12
+ }>;
13
+ }
14
+ export interface HLUpdateLeverageAction {
15
+ type: 'updateLeverage';
16
+ asset: number;
17
+ isCross: boolean;
18
+ leverage: number;
19
+ }
20
+ export interface HLUpdateIsolatedMarginAction {
21
+ type: 'updateIsolatedMargin';
22
+ asset: number;
23
+ isBuy: boolean;
24
+ ntli: number;
25
+ }
@@ -0,0 +1,12 @@
1
+ import { HLApiOrder } from '../orders/order-details.interfaces';
2
+ export type HLOrderGrouping = 'na' | 'normalTpsl' | 'positionTpsl';
3
+ export type HLOrderBuilder = {
4
+ b: string;
5
+ f: number;
6
+ };
7
+ export interface HLOrderAction {
8
+ type: 'order';
9
+ orders: HLApiOrder[];
10
+ grouping: HLOrderGrouping;
11
+ builder?: HLOrderBuilder;
12
+ }
@@ -0,0 +1,94 @@
1
+ export interface HLUsdClassTransferAction {
2
+ type: 'usdClassTransfer';
3
+ hyperliquidChain: 'Mainnet' | 'Testnet';
4
+ signatureChainId: string;
5
+ amount: string;
6
+ toPerp: boolean;
7
+ nonce: number;
8
+ }
9
+ export interface HLSpotSendAction {
10
+ type: 'spotSend';
11
+ hyperliquidChain: 'Mainnet' | 'Testnet';
12
+ signatureChainId: string;
13
+ destination: string;
14
+ token: string;
15
+ amount: string;
16
+ time: number;
17
+ }
18
+ export interface HLSendAssetAction {
19
+ type: 'sendAsset';
20
+ hyperliquidChain: 'Mainnet' | 'Testnet';
21
+ signatureChainId: string;
22
+ destination: string;
23
+ sourceDex: string;
24
+ destinationDex: string;
25
+ token: string;
26
+ amount: string;
27
+ fromSubAccount: string;
28
+ nonce: number;
29
+ }
30
+ export interface HLCDepositAction {
31
+ type: 'cDeposit';
32
+ hyperliquidChain: 'Mainnet' | 'Testnet';
33
+ signatureChainId: string;
34
+ wei: number;
35
+ nonce: number;
36
+ }
37
+ export interface HLCWithdrawAction {
38
+ type: 'cWithdraw';
39
+ hyperliquidChain: 'Mainnet' | 'Testnet';
40
+ signatureChainId: string;
41
+ wei: number;
42
+ nonce: number;
43
+ }
44
+ export interface HLTokenDelegateAction {
45
+ type: 'tokenDelegate';
46
+ hyperliquidChain: 'Mainnet' | 'Testnet';
47
+ signatureChainId: string;
48
+ validator: string;
49
+ isUndelegate: boolean;
50
+ wei: number;
51
+ nonce: number;
52
+ }
53
+ export interface HLVaultTransferAction {
54
+ type: 'vaultTransfer';
55
+ vaultAddress: string;
56
+ isDeposit: boolean;
57
+ usd: number;
58
+ }
59
+ export interface HLApproveAgentAction {
60
+ type: 'approveAgent';
61
+ hyperliquidChain: 'Mainnet' | 'Testnet';
62
+ signatureChainId: string;
63
+ agentAddress: string;
64
+ agentName?: string;
65
+ nonce: number;
66
+ }
67
+ export interface HLApproveBuilderFeeAction {
68
+ type: 'approveBuilderFee';
69
+ hyperliquidChain: 'Mainnet' | 'Testnet';
70
+ signatureChainId: string;
71
+ maxFeeRate: string;
72
+ builder: string;
73
+ nonce: number;
74
+ }
75
+ export interface HLTwapOrderAction {
76
+ type: 'twapOrder';
77
+ twap: {
78
+ a: number;
79
+ b: boolean;
80
+ s: string;
81
+ r: boolean;
82
+ m: number;
83
+ t: boolean;
84
+ };
85
+ }
86
+ export interface HLTwapCancelAction {
87
+ type: 'twapCancel';
88
+ a: number;
89
+ t: number;
90
+ }
91
+ export interface HLReserveRequestWeightAction {
92
+ type: 'reserveRequestWeight';
93
+ weight: number;
94
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ // export interface HLUsdSendAction {
3
+ // type: 'usdSend';
4
+ // hyperliquidChain: 'Mainnet' | 'Testnet';
5
+ // signatureChainId: string;
6
+ // destination: string;
7
+ // amount: string;
8
+ // time: number;
9
+ // }
10
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ export * from './actions/index';
2
+ export * from './orders/index';
3
+ export * from './params/index';
4
+ export * from './responses/index';
5
+ export * from './spot/index';
6
+ export * from './perp/index';
7
+ export * from './smart/index';
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./actions/index"), exports);
18
+ __exportStar(require("./orders/index"), exports);
19
+ __exportStar(require("./params/index"), exports);
20
+ __exportStar(require("./responses/index"), exports);
21
+ __exportStar(require("./spot/index"), exports);
22
+ __exportStar(require("./perp/index"), exports);
23
+ __exportStar(require("./smart/index"), exports);
@@ -0,0 +1,4 @@
1
+ export * from './order-details.interfaces';
2
+ export * from './order-status.interfaces';
3
+ export * from './open-order.interfaces';
4
+ export * from './user-fills.interfaces';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./order-details.interfaces"), exports);
18
+ __exportStar(require("./order-status.interfaces"), exports);
19
+ __exportStar(require("./open-order.interfaces"), exports);
20
+ __exportStar(require("./user-fills.interfaces"), exports);
@@ -0,0 +1,21 @@
1
+ import { DecimalString } from './order-details.interfaces';
2
+ export type HLOid = number | `0x${string}`;
3
+ export interface HLOpenOrder {
4
+ coin: string;
5
+ limitPx: DecimalString;
6
+ oid: HLOid;
7
+ side: 'A' | 'B';
8
+ sz: DecimalString;
9
+ timestamp: number;
10
+ }
11
+ export type HLOpenOrdersResponse = HLOpenOrder[];
12
+ export interface HLFrontendOpenOrder extends HLOpenOrder {
13
+ isPositionTpsl: boolean;
14
+ isTrigger: boolean;
15
+ orderType: 'Limit' | 'Market';
16
+ origSz: DecimalString;
17
+ reduceOnly: boolean;
18
+ triggerCondition: string;
19
+ triggerPx: DecimalString;
20
+ }
21
+ export type HLFrontendOpenOrdersResponse = HLFrontendOpenOrder[];
@@ -0,0 +1,69 @@
1
+ export type DecimalString = string;
2
+ /**
3
+ * Détails d'un ordre à placer sur Hyperliquid.
4
+ *
5
+ * @interface HLOrderDetails
6
+ *
7
+ * @property {number} asset - Identifiant numérique de l'actif à trader.
8
+ * @property {boolean} isBuy - True pour un ordre d'achat, false pour un ordre de vente.
9
+ * @property {DecimalString} limitPx - Prix limite pour l'ordre (pour limit orders).
10
+ * @property {DecimalString} sz - Taille (quantité) de l'ordre.
11
+ * @property {boolean} reduceOnly - True si l'ordre est uniquement pour réduire une position existante.
12
+ * @property { { limit: { tif: 'Alo' | 'Ioc' | 'Gtc' } } | { trigger: { isMarket: boolean, triggerPx: DecimalString, tpsl: 'tp' | 'sl' } } } orderType
13
+ * - Type d'ordre :
14
+ * - **Limit Order** : { limit: { tif } } où `tif` définit le comportement du temps de vie de l'ordre :
15
+ *
16
+ * | TIF | Comportement |
17
+ * |-----|--------------|
18
+ * | **Alo** | Post-only, annule si risque d’exécution immédiate |
19
+ * | **Ioc** | Immediate or Cancel, exécute ce qui peut être pris, annule le reste |
20
+ * | **Gtc** | Good Till Cancelled, reste sur le carnet jusqu’à annulation manuelle ou exécution |
21
+ *
22
+ * - **Trigger Order** : { trigger: { isMarket, triggerPx, tpsl } } pour TP/SL
23
+ * - `isMarket` : True si l'ordre se déclenche au prix du marché
24
+ * - `triggerPx` : Prix de déclenchement
25
+ * - `tpsl` : "tp" pour Take Profit, "sl" pour Stop Loss
26
+ * @property {string} [cloid] - Client Order ID optionnel (128-bit hex string, ex. "0x1234...").
27
+ */
28
+ export interface HLOrderDetails {
29
+ assetName: string;
30
+ isBuy: boolean;
31
+ limitPx: DecimalString;
32
+ sz: DecimalString;
33
+ reduceOnly: boolean;
34
+ orderType: {
35
+ limit: {
36
+ tif: 'Alo' | 'Ioc' | 'Gtc';
37
+ };
38
+ } | {
39
+ trigger: {
40
+ isMarket: boolean;
41
+ triggerPx: DecimalString;
42
+ tpsl: 'tp' | 'sl';
43
+ };
44
+ };
45
+ cloid?: string;
46
+ }
47
+ /**
48
+ * Représente un ordre formaté pour l'API Hyperliquid.
49
+ * Les clés correspondent exactement à ce que l'API attend.
50
+ */
51
+ export interface HLApiOrder {
52
+ a: number;
53
+ b: boolean;
54
+ p: DecimalString;
55
+ s: DecimalString;
56
+ r: boolean;
57
+ t: {
58
+ limit: {
59
+ tif: 'Alo' | 'Ioc' | 'Gtc';
60
+ };
61
+ } | {
62
+ trigger: {
63
+ isMarket: boolean;
64
+ triggerPx: DecimalString;
65
+ tpsl: 'tp' | 'sl';
66
+ };
67
+ };
68
+ c?: string;
69
+ }
@@ -0,0 +1,35 @@
1
+ import { HLOid } from './open-order.interfaces';
2
+ import { DecimalString } from './order-details.interfaces';
3
+ export type HLOrderStatus = 'open' | 'filled' | 'canceled' | 'triggered' | 'rejected' | 'marginCanceled' | 'vaultWithdrawalCanceled' | 'openInterestCapCanceled' | 'selfTradeCanceled' | 'reduceOnlyCanceled' | 'siblingFilledCanceled' | 'delistedCanceled' | 'liquidatedCanceled' | 'scheduledCancel' | 'tickRejected' | 'minTradeNtlRejected' | 'perpMarginRejected' | 'reduceOnlyRejected' | 'badAloPxRejected' | 'iocCancelRejected' | 'badTriggerPxRejected' | 'marketOrderNoLiquidityRejected' | 'positionIncreaseAtOpenInterestCapRejected' | 'positionFlipAtOpenInterestCapRejected' | 'tooAggressiveAtOpenInterestCapRejected' | 'openInterestIncreaseRejected' | 'insufficientSpotBalanceRejected' | 'oracleRejected' | 'perpMaxPositionRejected';
4
+ export interface HLOrderStatusDetails {
5
+ coin: string;
6
+ side: 'A' | 'B';
7
+ limitPx: DecimalString;
8
+ sz: DecimalString;
9
+ oid: HLOid;
10
+ timestamp: number;
11
+ triggerCondition: string;
12
+ isTrigger: boolean;
13
+ triggerPx: DecimalString;
14
+ children: unknown[];
15
+ isPositionTpsl: boolean;
16
+ reduceOnly: boolean;
17
+ orderType: string;
18
+ origSz: DecimalString;
19
+ tif: string;
20
+ cloid: string | null;
21
+ }
22
+ export interface HLOrderStatusData {
23
+ order: HLOrderStatusDetails;
24
+ status: HLOrderStatus;
25
+ statusTimestamp: number;
26
+ }
27
+ export interface HLOrderStatusResponse {
28
+ status: 'order' | 'unknownOid';
29
+ order: HLOrderStatusData;
30
+ }
31
+ export interface HLOrderStatusRequest {
32
+ type: 'orderStatus';
33
+ user: `0x${string}`;
34
+ oid: HLOid;
35
+ }
@@ -0,0 +1,18 @@
1
+ export interface HLUserFill {
2
+ coin: string;
3
+ px: string;
4
+ sz: string;
5
+ side: 'A' | 'B';
6
+ time: number;
7
+ oid: number;
8
+ tid: number;
9
+ dir: string;
10
+ startPosition: string;
11
+ closedPnl: string;
12
+ crossed: boolean;
13
+ hash: `0x${string}`;
14
+ fee: string;
15
+ feeToken: string;
16
+ builderFee?: string;
17
+ }
18
+ export type HLUserFillsResponse = HLUserFill[];
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export * from './signature.interfaces';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./signature.interfaces"), exports);
@@ -0,0 +1,13 @@
1
+ export interface HLSignature {
2
+ v: number;
3
+ r: string;
4
+ s: string;
5
+ }
6
+ /** ECDSA signature components. */
7
+ export interface HLParams<T> {
8
+ action: T;
9
+ nonce: number;
10
+ signature: HLSignature;
11
+ vaultAddress?: string | null;
12
+ expiresAfter?: number;
13
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,43 @@
1
+ import { DecimalString } from '../orders/order-details.interfaces';
2
+ export type Timestamp = number;
3
+ export interface HLPerpLeverage {
4
+ rawUsd: DecimalString;
5
+ type: 'isolated' | 'cross';
6
+ value: number;
7
+ }
8
+ export interface HLPerpCumFunding {
9
+ allTime: DecimalString;
10
+ sinceChange: DecimalString;
11
+ sinceOpen: DecimalString;
12
+ }
13
+ export interface HLPerpPositionDetail {
14
+ coin: string;
15
+ cumFunding: HLPerpCumFunding;
16
+ entryPx: DecimalString;
17
+ leverage: HLPerpLeverage;
18
+ liquidationPx: DecimalString;
19
+ marginUsed: DecimalString;
20
+ maxLeverage: number;
21
+ positionValue: DecimalString;
22
+ returnOnEquity: DecimalString;
23
+ szi: DecimalString;
24
+ unrealizedPnl: DecimalString;
25
+ }
26
+ export interface HLPerpAssetPosition {
27
+ position: HLPerpPositionDetail | null;
28
+ type: 'oneWay' | 'hedged';
29
+ }
30
+ export interface HLPerpMarginSummary {
31
+ accountValue: DecimalString;
32
+ totalMarginUsed: DecimalString;
33
+ totalNtlPos: DecimalString;
34
+ totalRawUsd: DecimalString;
35
+ }
36
+ export interface HLClearinghouseState {
37
+ assetPositions: HLPerpAssetPosition[];
38
+ crossMaintenanceMarginUsed: DecimalString;
39
+ crossMarginSummary: HLPerpMarginSummary;
40
+ marginSummary: HLPerpMarginSummary;
41
+ time: Timestamp;
42
+ withdrawable: DecimalString;
43
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export * from './balance.interfaces';
2
+ export * from './meta.interfaces';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./balance.interfaces"), exports);
18
+ __exportStar(require("./meta.interfaces"), exports);
@@ -0,0 +1,50 @@
1
+ import { DecimalString } from '../orders';
2
+ export interface HLPerpMarketInfo {
3
+ name: string;
4
+ szDecimals: number;
5
+ maxLeverage: number;
6
+ onlyIsolated?: boolean;
7
+ isDelisted?: boolean;
8
+ marginMode?: 'strictIsolated' | 'noCross';
9
+ }
10
+ export interface HLPerpMarginTier {
11
+ lowerBound: string;
12
+ maxLeverage: number;
13
+ }
14
+ export interface HLPerpMarginTable {
15
+ description: string;
16
+ marginTiers: HLPerpMarginTier[];
17
+ }
18
+ export type HLPerpMarginTableEntry = [number, HLPerpMarginTable];
19
+ export interface HLPerpMeta {
20
+ universe: HLPerpMarketInfo[];
21
+ marginTables: HLPerpMarginTableEntry[];
22
+ }
23
+ export interface HLPerpMarketUniverse extends HLPerpMarketInfo {
24
+ index: number;
25
+ }
26
+ export interface HLPerpAssetCtx {
27
+ dayNtlVlm: string;
28
+ funding: string;
29
+ impactPxs: string[];
30
+ markPx: string;
31
+ midPx: string;
32
+ openInterest: string;
33
+ oraclePx: string;
34
+ premium: string;
35
+ prevDayPx: string;
36
+ }
37
+ export type HLPerpMetaAndCtx = [{
38
+ universe: HLPerpMarketInfo[];
39
+ }, HLPerpAssetCtx[]];
40
+ export interface HLPerpMarket {
41
+ index: number;
42
+ name: string;
43
+ szDecimals: number;
44
+ maxLeverage: number;
45
+ marginTableId?: number;
46
+ markPrice?: DecimalString;
47
+ midPrice?: DecimalString;
48
+ funding?: DecimalString;
49
+ openInterest?: DecimalString;
50
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ export type HLCancelStatus = 'success' | {
2
+ error: string;
3
+ };
4
+ export interface HLCancelOrderResponse {
5
+ type: 'cancel';
6
+ data: {
7
+ statuses: HLCancelStatus[];
8
+ };
9
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,10 @@
1
+ export interface HLErrorResponse {
2
+ status: 'error';
3
+ message: string;
4
+ }
5
+ /**
6
+ * Type guard pour vérifier si un objet est une HLErrorResponse.
7
+ * @param obj Objet à vérifier.
8
+ * @returns True si l'objet correspond à HLErrorResponse.
9
+ */
10
+ export declare function isHLErrorResponse(obj: unknown): obj is HLErrorResponse;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isHLErrorResponse = isHLErrorResponse;
4
+ /**
5
+ * Type guard pour vérifier si un objet est une HLErrorResponse.
6
+ * @param obj Objet à vérifier.
7
+ * @returns True si l'objet correspond à HLErrorResponse.
8
+ */
9
+ function isHLErrorResponse(obj) {
10
+ if (typeof obj !== 'object' || obj === null) {
11
+ return false;
12
+ }
13
+ const errorObj = obj;
14
+ return ('status' in errorObj &&
15
+ errorObj.status === 'error' &&
16
+ 'message' in errorObj &&
17
+ typeof errorObj.message === 'string');
18
+ }
@@ -0,0 +1,4 @@
1
+ export * from './error.interfaces';
2
+ export * from './success.interfaces';
3
+ export * from './order.interfaces';
4
+ export * from './cancel.interfaces';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./error.interfaces"), exports);
18
+ __exportStar(require("./success.interfaces"), exports);
19
+ __exportStar(require("./order.interfaces"), exports);
20
+ __exportStar(require("./cancel.interfaces"), exports);
@@ -0,0 +1,18 @@
1
+ import { HLOid } from '../orders';
2
+ export interface HLPlaceOrderStatus {
3
+ resting?: {
4
+ oid: HLOid;
5
+ };
6
+ filled?: {
7
+ oid: HLOid;
8
+ totalSz: string;
9
+ avgPx: string;
10
+ };
11
+ error?: string;
12
+ }
13
+ export interface HLPlaceOrderResponse {
14
+ type: 'order';
15
+ data: {
16
+ statuses: HLPlaceOrderStatus[];
17
+ };
18
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ export interface HLSuccessResponse<T = any> {
2
+ status: 'ok';
3
+ response: T;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,30 @@
1
+ import { DecimalString, HLOid, HLOrderDetails } from '../orders';
2
+ import { HLProtectiveKind } from './protective-order.interfaces';
3
+ export interface BatchProtectiveOrderItem {
4
+ sz: string;
5
+ price: string;
6
+ isMarket?: boolean;
7
+ }
8
+ export interface BatchProtectiveOrders {
9
+ assetName: string;
10
+ isBuy: boolean;
11
+ tp?: BatchProtectiveOrderItem[];
12
+ sl?: BatchProtectiveOrderItem[];
13
+ }
14
+ export interface ExistingProtectiveOrder {
15
+ oid: HLOid;
16
+ kind: HLProtectiveKind;
17
+ price: DecimalString;
18
+ sz: DecimalString;
19
+ isMarket: boolean;
20
+ }
21
+ export interface NormalizedProtectiveOrder {
22
+ kind: HLProtectiveKind;
23
+ price: DecimalString;
24
+ sz: DecimalString;
25
+ isMarket?: boolean;
26
+ }
27
+ export interface HLModifyInput {
28
+ oid: HLOid;
29
+ order: HLOrderDetails;
30
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ export * from './smart-order.interfaces';
2
+ export * from './protective-order.interfaces';
3
+ export * from './batch-protective-order.interfaces';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./smart-order.interfaces"), exports);
18
+ __exportStar(require("./protective-order.interfaces"), exports);
19
+ __exportStar(require("./batch-protective-order.interfaces"), exports);
@@ -0,0 +1,11 @@
1
+ import { DecimalString } from '../orders';
2
+ export type HLProtectiveKind = 'tp' | 'sl';
3
+ export interface ProtectiveOrderParams {
4
+ assetName: string;
5
+ kind: HLProtectiveKind;
6
+ isBuy: boolean;
7
+ sz: DecimalString;
8
+ price: DecimalString;
9
+ isMarket?: boolean;
10
+ isTestnet?: boolean;
11
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,26 @@
1
+ import { DecimalString, HLOid } from '../orders';
2
+ export type HLOrderSize = {
3
+ type: 'base';
4
+ sz: DecimalString;
5
+ } | {
6
+ type: 'quote';
7
+ usdc: DecimalString;
8
+ } | {
9
+ type: 'percent';
10
+ percent: DecimalString;
11
+ };
12
+ export interface InstantOrderParams {
13
+ assetName: string;
14
+ isBuy: boolean;
15
+ size: HLOrderSize;
16
+ reduceOnly?: boolean;
17
+ isTestnet?: boolean;
18
+ maxRetries?: number;
19
+ delayMs?: number;
20
+ }
21
+ export interface WaitOrderStatusOptions {
22
+ oid: HLOid;
23
+ timeoutMs?: number;
24
+ pollIntervalMs?: number;
25
+ isTestnet?: boolean;
26
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ import { DecimalString } from '../orders/order-details.interfaces';
2
+ export interface HLSpotBalance {
3
+ coin: string;
4
+ token: number;
5
+ hold: DecimalString;
6
+ total: DecimalString;
7
+ entryNtl: DecimalString;
8
+ }
9
+ export interface HLSpotClearinghouseState {
10
+ balances: HLSpotBalance[];
11
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export * from './balance.interfaces';
2
+ export * from './meta.interfaces';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./balance.interfaces"), exports);
18
+ __exportStar(require("./meta.interfaces"), exports);
@@ -1,11 +1,12 @@
1
- import { DecimalString, HexString } from './common';
2
1
  export interface HLSpotTokenMeta {
3
2
  name: string;
4
3
  szDecimals: number;
5
4
  weiDecimals: number;
6
5
  index: number;
7
- tokenId: HexString;
6
+ tokenId: string;
8
7
  isCanonical: boolean;
8
+ evmContract: string | null;
9
+ fullName: string | null;
9
10
  }
10
11
  export interface HLSpotMarketMeta {
11
12
  name: string;
@@ -18,7 +19,5 @@ export interface HLSpotMeta {
18
19
  universe: HLSpotMarketMeta[];
19
20
  }
20
21
  export interface HLSpotAssetSummary extends HLSpotMarketMeta {
21
- szDecimals: number;
22
- markPrice: DecimalString;
23
- midPrice: DecimalString;
22
+ szDecimals?: number;
24
23
  }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,23 +1,32 @@
1
1
  {
2
2
  "name": "@syldel/hl-shared-types",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Shared Hyperliquid types",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
- "files": [
8
- "dist"
9
- ],
7
+ "files": ["dist"],
10
8
  "scripts": {
11
- "build": "tsc",
12
- "prepublishOnly": "npm run build"
9
+ "lint": "eslint .",
10
+ "lint:fix": "eslint . --fix",
11
+ "format:pkg": "eslint package.json --fix",
12
+ "clean": "rm -rf dist",
13
+ "build": "npm run lint && npm run clean && tsc",
14
+ "postversion": "npm run format:pkg",
15
+ "prepublishOnly": "npm run build",
16
+ "release": "npm version patch && npm run build && npm publish"
13
17
  },
14
- "keywords": ["hyperliquid", "trading", "types", "crypto", "exchange", "defi"],
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "keywords": ["hyperliquid", "trading", "types", "interfaces", "crypto", "exchange", "defi"],
15
22
  "author": "Syl. D.",
16
23
  "license": "ISC",
17
24
  "devDependencies": {
18
25
  "eslint": "^9.39.2",
19
26
  "eslint-config-prettier": "^10.1.8",
27
+ "eslint-plugin-jsonc": "^2.21.0",
20
28
  "eslint-plugin-prettier": "^5.5.5",
29
+ "jsonc-eslint-parser": "^2.4.2",
21
30
  "prettier": "^3.8.0",
22
31
  "typescript": "^5.3.3",
23
32
  "typescript-eslint": "^8.53.0"
@@ -1,23 +0,0 @@
1
- import { DecimalString } from './common';
2
- export interface HLPerpPosition {
3
- coin: string;
4
- szi: DecimalString;
5
- entryPx: DecimalString;
6
- leverage: {
7
- type: 'cross' | 'isolated';
8
- value: number;
9
- };
10
- unrealizedPnl: DecimalString;
11
- liquidationPx: DecimalString | null;
12
- marginUsed: DecimalString;
13
- }
14
- export interface HLClearinghouseState {
15
- marginSummary: {
16
- accountValue: DecimalString;
17
- totalMarginUsed: DecimalString;
18
- withdrawable: DecimalString;
19
- };
20
- assetPositions: {
21
- position: HLPerpPosition | null;
22
- }[];
23
- }
@@ -1,7 +0,0 @@
1
- export type DecimalString = string;
2
- export type HLOid = number;
3
- export type HexString = `0x${string}`;
4
- export interface HLSuccessResponse<T> {
5
- status: 'ok';
6
- response: T;
7
- }
@@ -1,32 +0,0 @@
1
- import { HLOrderDetailsDto } from './orders';
2
- export interface InstantOrderDto {
3
- assetName: string;
4
- isBuy: boolean;
5
- size: {
6
- type: 'base' | 'quote' | 'percent';
7
- sz?: string;
8
- usdc?: string;
9
- percent?: string;
10
- };
11
- isTestnet?: boolean;
12
- }
13
- export interface ProtectiveOrderDto {
14
- assetName: string;
15
- kind: 'tp' | 'sl';
16
- isBuy: boolean;
17
- sz: string;
18
- price: string;
19
- isTestnet?: boolean;
20
- }
21
- export interface CancelOrderParams {
22
- cancels: Array<{
23
- asset: number;
24
- oid: number;
25
- }>;
26
- isTestnet?: boolean;
27
- }
28
- export interface ModifyOrderDto {
29
- oid: number;
30
- order: HLOrderDetailsDto;
31
- isTestnet?: boolean;
32
- }
@@ -1,15 +0,0 @@
1
- import { DecimalString, HLOid } from './common';
2
- export interface HLOrderDetailsDto {
3
- assetName: string;
4
- isBuy: boolean;
5
- limitPx: DecimalString;
6
- sz: DecimalString;
7
- reduceOnly: boolean;
8
- }
9
- export interface HLOpenOrder {
10
- coin: string;
11
- limitPx: DecimalString;
12
- oid: HLOid;
13
- sz: DecimalString;
14
- timestamp: number;
15
- }
@@ -1,37 +0,0 @@
1
- import { HLOid, DecimalString } from './common';
2
- export interface HLPlaceOrderResponse {
3
- type: 'order';
4
- data: {
5
- statuses: Array<{
6
- resting?: {
7
- oid: HLOid;
8
- };
9
- filled?: {
10
- oid: HLOid;
11
- totalSz: DecimalString;
12
- avgPx: DecimalString;
13
- };
14
- error?: string;
15
- }>;
16
- };
17
- }
18
- export interface HLSmartOrderResponse {
19
- tp: {
20
- cancelled: HLOid[];
21
- created: HLOid[];
22
- updated: HLOid[];
23
- };
24
- sl: {
25
- cancelled: HLOid[];
26
- created: HLOid[];
27
- updated: HLOid[];
28
- };
29
- }
30
- export interface HLCancelOrderResponse {
31
- type: 'cancel';
32
- data: {
33
- statuses: ('success' | {
34
- error: string;
35
- })[];
36
- };
37
- }