@syldel/hl-shared-types 0.0.22 → 0.0.23
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 +4 -4
- package/dist/interfaces/perp/balance.interfaces.d.ts +72 -8
- package/package.json +54 -54
package/LICENSE.MD
CHANGED
|
@@ -1,5 +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
|
-
|
|
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
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.
|
|
@@ -1,15 +1,52 @@
|
|
|
1
1
|
import { DecimalString, Timestamp } from '../common';
|
|
2
2
|
/**
|
|
3
3
|
* Leverage configuration for a perpetual position.
|
|
4
|
+
*
|
|
5
|
+
* ============================================================================
|
|
6
|
+
* UNE UNION, PARCE QUE LES DEUX MODES NE PORTENT PAS LES MÊMES CHAMPS
|
|
7
|
+
*
|
|
8
|
+
* `rawUsd` était déclaré **obligatoire** pour les deux modes, et le faux
|
|
9
|
+
* gateway devait donc mentir par une assertion de type pour construire une
|
|
10
|
+
* position cross plausible — exactement ce qu'un double n'a pas le droit de
|
|
11
|
+
* faire.
|
|
12
|
+
*
|
|
13
|
+
* La forme vient du **SDK Python officiel** (`hyperliquid-dex/
|
|
14
|
+
* hyperliquid-python-sdk`, `hyperliquid/utils/types.py`), qui déclare la même
|
|
15
|
+
* union, discriminée sur `type` :
|
|
16
|
+
*
|
|
17
|
+
* CrossLeverage = {"type": Literal["cross"], "value": int}
|
|
18
|
+
* IsolatedLeverage = {"type": Literal["isolated"], "value": int,
|
|
19
|
+
* "rawUsd": str}
|
|
20
|
+
* Leverage = Union[CrossLeverage, IsolatedLeverage]
|
|
21
|
+
*
|
|
22
|
+
* Deux relevés la recoupent, chacun pour une branche : les captures du gateway
|
|
23
|
+
* du 2026-09-22 n'ont que des leviers `cross`, tous en `{ type, value }` nus ;
|
|
24
|
+
* l'exemple de la doc de `clearinghouseState` n'a qu'une position isolée, qui
|
|
25
|
+
* porte `rawUsd: "-95.059824"`. Aucun des deux ne couvre l'autre branche — le
|
|
26
|
+
* SDK, lui, les couvre toutes les deux.
|
|
27
|
+
*
|
|
28
|
+
* Pourquoi l'union et non `rawUsd?: DecimalString` : l'optionnel rendrait
|
|
29
|
+
* `lev.rawUsd` lisible sans vérifier `type`, et `Number(undefined)` rend `NaN`
|
|
30
|
+
* sans un mot. L'union en fait une erreur de compilation. Et si un cross
|
|
31
|
+
* portait un jour `rawUsd`, le coût de s'être trompé ici est nul — personne ne
|
|
32
|
+
* lit ce champ, il serait simplement invisible — là où le coût du `NaN`
|
|
33
|
+
* silencieux se paierait sur un dimensionnement.
|
|
34
|
+
* ============================================================================
|
|
4
35
|
*/
|
|
5
|
-
export
|
|
6
|
-
/** Notional value in USD used for leverage calculation. */
|
|
7
|
-
rawUsd: DecimalString;
|
|
36
|
+
export type HLPerpLeverage = {
|
|
8
37
|
/** Margin mode used for the position. */
|
|
9
|
-
type: '
|
|
38
|
+
type: 'cross';
|
|
10
39
|
/** Current leverage multiplier. */
|
|
11
40
|
value: number;
|
|
12
|
-
}
|
|
41
|
+
} | {
|
|
42
|
+
type: 'isolated';
|
|
43
|
+
value: number;
|
|
44
|
+
/**
|
|
45
|
+
* Notional value in USD used for leverage calculation. Propre à l'isolé,
|
|
46
|
+
* où la marge est cantonnée à la position.
|
|
47
|
+
*/
|
|
48
|
+
rawUsd: DecimalString;
|
|
49
|
+
};
|
|
13
50
|
/**
|
|
14
51
|
* Funding payments accumulated for a perpetual position.
|
|
15
52
|
*/
|
|
@@ -33,8 +70,25 @@ export interface HLPerpPositionDetail {
|
|
|
33
70
|
entryPx: DecimalString;
|
|
34
71
|
/** Leverage configuration. */
|
|
35
72
|
leverage: HLPerpLeverage;
|
|
36
|
-
/**
|
|
37
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Estimated liquidation price, **`null`** quand l'exchange n'en publie pas.
|
|
75
|
+
*
|
|
76
|
+
* Relevé le 2026-09-22 dans les captures réelles du gateway : sur 6 états
|
|
77
|
+
* distincts d'une même paire (`xyz:MU`, cross), les 3 **longs** rendent
|
|
78
|
+
* `null` et les 2 **shorts** rendent une chaîne. Un seul coin sur un seul
|
|
79
|
+
* dex : cette corrélation avec le sens de la position n'explique rien, et je
|
|
80
|
+
* ne connais pas la règle.
|
|
81
|
+
*
|
|
82
|
+
* Ce qui est établi suffit pourtant, et c'est asymétrique : une nullité se
|
|
83
|
+
* prouve par un seul contre-exemple, alors que la non-nullité demanderait de
|
|
84
|
+
* l'avoir épuisée. Trois `null` mesurés closent la question du type ; ils ne
|
|
85
|
+
* disent rien de *quand*.
|
|
86
|
+
*
|
|
87
|
+
* Conséquence pour un consommateur : le `null` s'écarte, il ne se convertit
|
|
88
|
+
* pas. `Number(null)` rend `0`, et un prix de liquidation à zéro est le plus
|
|
89
|
+
* rassurant des mensonges — il paraît infiniment loin du prix courant.
|
|
90
|
+
*/
|
|
91
|
+
liquidationPx: DecimalString | null;
|
|
38
92
|
/** Margin currently used by the position. */
|
|
39
93
|
marginUsed: DecimalString;
|
|
40
94
|
/** Maximum allowed leverage for this market. */
|
|
@@ -52,7 +106,17 @@ export interface HLPerpPositionDetail {
|
|
|
52
106
|
* Wrapper describing a perpetual asset position.
|
|
53
107
|
*/
|
|
54
108
|
export interface HLPerpAssetPosition {
|
|
55
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* Position details (null if no active position).
|
|
111
|
+
*
|
|
112
|
+
* ⚠️ Laissé nullable bien qu'aucune des entrées relevées le 2026-09-22 ne
|
|
113
|
+
* soit nulle : des observations d'une valeur présente ne prouvent pas qu'elle
|
|
114
|
+
* le soit toujours — et celles-ci portent sur une seule paire —, la doc nomme
|
|
115
|
+
* le cas, et deux des trois lecteurs du bot le gardaient déjà. Le troisième
|
|
116
|
+
* ne le gardait pas, et levait un `Cannot read properties of null` juste
|
|
117
|
+
* après une entrée remplie : c'est ce défaut qui a fait garder ce `| null`
|
|
118
|
+
* plutôt que le resserrer.
|
|
119
|
+
*/
|
|
56
120
|
position: HLPerpPositionDetail | null;
|
|
57
121
|
/** Position mode configuration. */
|
|
58
122
|
type: 'oneWay' | 'hedged';
|
package/package.json
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@syldel/hl-shared-types",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Shared TypeScript interfaces and types for Hyperliquid integration.",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/Syldel/hl-shared-types.git"
|
|
10
|
-
},
|
|
11
|
-
"bugs": {
|
|
12
|
-
"url": "https://github.com/Syldel/hl-shared-types/issues"
|
|
13
|
-
},
|
|
14
|
-
"homepage": "https://github.com/Syldel/hl-shared-types#readme",
|
|
15
|
-
"files": [
|
|
16
|
-
"dist"
|
|
17
|
-
],
|
|
18
|
-
"scripts": {
|
|
19
|
-
"test": "jest",
|
|
20
|
-
"lint": "eslint .",
|
|
21
|
-
"lint:fix": "eslint . --fix",
|
|
22
|
-
"clean": "rm -rf dist",
|
|
23
|
-
"build": "npm run lint && npm run test && npm run clean && tsc",
|
|
24
|
-
"prepublishOnly": "npm run build",
|
|
25
|
-
"release": "npm run build && npm version patch && npm publish"
|
|
26
|
-
},
|
|
27
|
-
"publishConfig": {
|
|
28
|
-
"access": "public"
|
|
29
|
-
},
|
|
30
|
-
"keywords": [
|
|
31
|
-
"hyperliquid",
|
|
32
|
-
"trading",
|
|
33
|
-
"types",
|
|
34
|
-
"interfaces",
|
|
35
|
-
"crypto",
|
|
36
|
-
"exchange",
|
|
37
|
-
"defi"
|
|
38
|
-
],
|
|
39
|
-
"author": "Syl. D.",
|
|
40
|
-
"license": "ISC",
|
|
41
|
-
"devDependencies": {
|
|
42
|
-
"@types/jest": "^30.0.0",
|
|
43
|
-
"eslint": "^9.39.2",
|
|
44
|
-
"eslint-config-prettier": "^10.1.8",
|
|
45
|
-
"eslint-plugin-jsonc": "^2.21.0",
|
|
46
|
-
"eslint-plugin-prettier": "^5.5.5",
|
|
47
|
-
"jest": "^30.5.2",
|
|
48
|
-
"jsonc-eslint-parser": "^2.4.2",
|
|
49
|
-
"prettier": "^3.8.0",
|
|
50
|
-
"ts-jest": "^29.4.13",
|
|
51
|
-
"typescript": "^5.3.3",
|
|
52
|
-
"typescript-eslint": "^8.53.0"
|
|
53
|
-
}
|
|
54
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@syldel/hl-shared-types",
|
|
3
|
+
"version": "0.0.23",
|
|
4
|
+
"description": "Shared TypeScript interfaces and types for Hyperliquid integration.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/Syldel/hl-shared-types.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/Syldel/hl-shared-types/issues"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/Syldel/hl-shared-types#readme",
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"test": "jest",
|
|
20
|
+
"lint": "eslint .",
|
|
21
|
+
"lint:fix": "eslint . --fix",
|
|
22
|
+
"clean": "rm -rf dist",
|
|
23
|
+
"build": "npm run lint && npm run test && npm run clean && tsc",
|
|
24
|
+
"prepublishOnly": "npm run build",
|
|
25
|
+
"release": "npm run build && npm version patch && npm publish"
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"hyperliquid",
|
|
32
|
+
"trading",
|
|
33
|
+
"types",
|
|
34
|
+
"interfaces",
|
|
35
|
+
"crypto",
|
|
36
|
+
"exchange",
|
|
37
|
+
"defi"
|
|
38
|
+
],
|
|
39
|
+
"author": "Syl. D.",
|
|
40
|
+
"license": "ISC",
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/jest": "^30.0.0",
|
|
43
|
+
"eslint": "^9.39.2",
|
|
44
|
+
"eslint-config-prettier": "^10.1.8",
|
|
45
|
+
"eslint-plugin-jsonc": "^2.21.0",
|
|
46
|
+
"eslint-plugin-prettier": "^5.5.5",
|
|
47
|
+
"jest": "^30.5.2",
|
|
48
|
+
"jsonc-eslint-parser": "^2.4.2",
|
|
49
|
+
"prettier": "^3.8.0",
|
|
50
|
+
"ts-jest": "^29.4.13",
|
|
51
|
+
"typescript": "^5.3.3",
|
|
52
|
+
"typescript-eslint": "^8.53.0"
|
|
53
|
+
}
|
|
54
|
+
}
|