@syldel/hl-shared-types 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.MD ADDED
@@ -0,0 +1,5 @@
1
+ Copyright (c) 2026, Syl-Studio Inc. c/o Syl. D.
2
+
3
+ Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
4
+
5
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,95 @@
1
+ # @syldel/hl-types 🚀
2
+
3
+ Ce package centralise les définitions TypeScript pour l'écosystème **Hyperliquid**. Il sert de source de vérité unique pour les interfaces d'API, les types de la blockchain (L1) et les DTOs de communication entre le Gateway, le Bot de trading et l'application mobile.
4
+
5
+ Inspiré par les standards de `nktkas/hyperliquid` et `nomeida/hyperliquid`.
6
+
7
+ ---
8
+
9
+ ## 🛠 Structure du projet
10
+
11
+ * **Common** : Types de base (Hex, DecimalStrings, ID d'ordres).
12
+ * **Account** : États du compte, positions Perp et soldes Spot.
13
+ * **Market** : Métadonnées des actifs et résumés de marché.
14
+ * **Orders** : Définitions des ordres ouverts et historiques.
15
+ * **DTO** : Objets de transfert de données pour les requêtes API (NestJS).
16
+
17
+ ---
18
+
19
+ ## 👨‍💻 Développement
20
+
21
+ ### Installation des dépendances
22
+ ```bash
23
+ npm install
24
+ ```
25
+
26
+ ### Compilation
27
+ Génère le dossier `dist/` contenant les fichiers JavaScript et les déclarations de types (`.d.ts`).
28
+ ```bash
29
+ npm run build
30
+ ```
31
+
32
+ ### Qualité du code
33
+ Le projet utilise **ESLint** pour la logique et **Prettier** pour le formatage.
34
+ ```bash
35
+ # Vérifier les erreurs
36
+ npx eslint .
37
+
38
+ # Formater automatiquement
39
+ npx prettier --write .
40
+ ```
41
+
42
+ ---
43
+
44
+ ## 🔗 Utilisation en local (Development Workflow)
45
+
46
+ Pour utiliser ce package dans tes autres projets (`bot`, `gateway` ou `mobile`) sans le publier sur NPM :
47
+
48
+ 1. Dans le dossier `hl-types` :
49
+ ```bash
50
+ npm link
51
+ ```
52
+ 2. Dans ton projet (ex: `my-trading-bot`) :
53
+ ```bash
54
+ npm link @syldel/hl-types
55
+ ```
56
+
57
+ ---
58
+
59
+ ## 📦 Publication
60
+
61
+ ### 1. Préparer la version
62
+ Mets à jour la version dans le `package.json` (ex: `1.0.0`), puis :
63
+ ```bash
64
+ npm run build
65
+ ```
66
+
67
+ ### 2. Publier sur NPM (Public)
68
+ ```bash
69
+ npm publish --access public
70
+ ```
71
+
72
+ Le projet utilise des **Granular Access Tokens** pour la publication afin de contourner la double authentification (2FA) manuelle tout en maintenant une sécurité maximale.
73
+
74
+ ### Configuration du Token
75
+ 1. Générer un token sur NPM avec les permissions `Read and Write`.
76
+ 2. Restreindre l'accès au package `@syldel/hl-shared-types` uniquement.
77
+
78
+ ### Commande de publication rapide
79
+ Si tu n'utilises pas de fichier `.npmrc`, tu peux publier en passant le token directement :
80
+ ```bash
81
+ npm publish --access public --//registry.npmjs.org/:_authToken=TON_TOKEN_ICI
82
+ ```
83
+
84
+ ---
85
+
86
+ ## 📝 Conventions de code
87
+
88
+ * **Sauts de ligne** : Une ligne vide est automatiquement insérée entre chaque `interface` pour une meilleure lisibilité.
89
+ * **Naming** : Toutes les interfaces commencent par `HL`.
90
+ * **Types stricts** : Usage de `DecimalString` pour la précision financière.
91
+
92
+ ---
93
+
94
+ ## ⚖️ Licence
95
+ ISC
@@ -0,0 +1,6 @@
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';
package/dist/index.js ADDED
@@ -0,0 +1,22 @@
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("./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);
@@ -0,0 +1,23 @@
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
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
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
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,32 @@
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
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,24 @@
1
+ import { DecimalString, HexString } from './common';
2
+ export interface HLSpotTokenMeta {
3
+ name: string;
4
+ szDecimals: number;
5
+ weiDecimals: number;
6
+ index: number;
7
+ tokenId: HexString;
8
+ isCanonical: boolean;
9
+ }
10
+ export interface HLSpotMarketMeta {
11
+ name: string;
12
+ tokens: [number, number];
13
+ index: number;
14
+ isCanonical: boolean;
15
+ }
16
+ export interface HLSpotMeta {
17
+ tokens: HLSpotTokenMeta[];
18
+ universe: HLSpotMarketMeta[];
19
+ }
20
+ export interface HLSpotAssetSummary extends HLSpotMarketMeta {
21
+ szDecimals: number;
22
+ markPrice: DecimalString;
23
+ midPrice: DecimalString;
24
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,15 @@
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
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,37 @@
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
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@syldel/hl-shared-types",
3
+ "version": "0.0.1",
4
+ "description": "Shared Hyperliquid types",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "prepublishOnly": "npm run build"
13
+ },
14
+ "keywords": ["hyperliquid", "trading", "types", "crypto", "exchange", "defi"],
15
+ "author": "Syl. D.",
16
+ "license": "ISC",
17
+ "devDependencies": {
18
+ "eslint": "^9.39.2",
19
+ "eslint-config-prettier": "^10.1.8",
20
+ "eslint-plugin-prettier": "^5.5.5",
21
+ "prettier": "^3.8.0",
22
+ "typescript": "^5.3.3",
23
+ "typescript-eslint": "^8.53.0"
24
+ }
25
+ }