@syldel/hl-shared-types 0.0.7 → 0.0.9

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.
@@ -1,22 +1,43 @@
1
1
  import { DecimalString, Timestamp } from '../common';
2
- /** Intervalles supportés pour les bougies Hyperliquid */
2
+ /**
3
+ * Supported Hyperliquid candle intervals.
4
+ */
3
5
  export type CandleInterval = '1m' | '3m' | '5m' | '15m' | '30m' | '1h' | '2h' | '4h' | '8h' | '12h' | '1d' | '3d' | '1w' | '1M';
4
- /** Réponse brute d'une bougie (Candle) selon l'API Hyperliquid */
6
+ /**
7
+ * Raw candle data returned by the Hyperliquid `candleSnapshot` endpoint.
8
+ */
5
9
  export interface CandleSnapshot {
10
+ /** Candle open timestamp (ms). */
6
11
  t: Timestamp;
12
+ /** Candle close timestamp (ms). */
7
13
  T: Timestamp;
14
+ /** Asset symbol (e.g. BTC or xyz:XYZ100 for HIP-3 markets). */
8
15
  s: string;
16
+ /** Candle interval. */
9
17
  i: CandleInterval;
18
+ /** Open price. */
10
19
  o: DecimalString;
20
+ /** Close price. */
11
21
  c: DecimalString;
22
+ /** Highest traded price during the interval. */
12
23
  h: DecimalString;
24
+ /** Lowest traded price during the interval. */
13
25
  l: DecimalString;
26
+ /** Traded volume in base asset. */
14
27
  v: DecimalString;
28
+ /** Number of trades included in the candle. */
15
29
  n: number;
16
30
  }
31
+ /**
32
+ * Parameters for querying historical candles.
33
+ */
17
34
  export interface CandleSnapshotRequest {
35
+ /** Asset symbol (e.g. BTC or xyz:XYZ100 for HIP-3 markets). */
18
36
  coin: string;
37
+ /** Candle interval. */
19
38
  interval: CandleInterval;
39
+ /** Start timestamp in milliseconds (inclusive). */
20
40
  startTime: Timestamp;
41
+ /** End timestamp in milliseconds (inclusive). Defaults to current time. */
21
42
  endTime?: Timestamp;
22
43
  }
@@ -1,15 +1,29 @@
1
1
  import { DecimalString, Timestamp } from '../common';
2
- /** Un point de donnée : [Timestamp, Valeur] */
2
+ /**
3
+ * Time-series data point represented as [timestamp, value].
4
+ */
3
5
  export type PortfolioPoint = [Timestamp, DecimalString];
4
- /** Données de portfolio pour une période donnée */
6
+ /**
7
+ * Portfolio statistics for a given time period.
8
+ */
5
9
  export interface PortfolioStats {
10
+ /** Historical account value over time. */
6
11
  accountValueHistory: PortfolioPoint[];
12
+ /** Historical profit and loss over time. */
7
13
  pnlHistory: PortfolioPoint[];
14
+ /** Total traded volume for the period. */
8
15
  vlm: DecimalString;
9
16
  }
10
- /** Labels de périodes supportés par Hyperliquid */
17
+ /**
18
+ * Supported portfolio time ranges returned by the API.
19
+ */
11
20
  export type PortfolioPeriod = 'day' | 'week' | 'month' | 'allTime' | 'perpDay' | 'perpWeek' | 'perpMonth' | 'perpAllTime';
12
- /** * La réponse est un tableau de tuples : [Période, Stats]
13
- * Exemple: ["day", { accountValueHistory: [...], ... }]
21
+ /**
22
+ * Portfolio response returned by the `portfolio` endpoint.
23
+ *
24
+ * Each entry is a tuple: [period, stats].
25
+ *
26
+ * Example:
27
+ * ["day", { accountValueHistory: [...], pnlHistory: [...], vlm: "12345.67" }]
14
28
  */
15
29
  export type PortfolioResponse = [PortfolioPeriod, PortfolioStats][];
@@ -1,26 +1,57 @@
1
1
  import { Timestamp } from '../common';
2
+ /**
3
+ * User trade fill returned by the Hyperliquid `userFills` endpoints.
4
+ */
2
5
  export interface HLUserFill {
6
+ /** Asset symbol or asset id (e.g. "BTC" or "@107" for spot markets). */
3
7
  coin: string;
8
+ /** Execution price. */
4
9
  px: string;
10
+ /** Executed size (base asset). */
5
11
  sz: string;
12
+ /** Liquidity side: A = ask (sell), B = bid (buy). */
6
13
  side: 'A' | 'B';
14
+ /** Execution timestamp (ms). */
7
15
  time: Timestamp;
16
+ /** Order identifier. */
8
17
  oid: number;
18
+ /** Trade identifier. */
9
19
  tid: number;
20
+ /** Trade direction (e.g. "Open Long", "Close Short"). */
10
21
  dir: string;
22
+ /** Position size before this fill. */
11
23
  startPosition: string;
24
+ /** Realized PnL from the fill. */
12
25
  closedPnl: string;
26
+ /** Whether the trade executed via crossing order logic. */
13
27
  crossed: boolean;
28
+ /** Transaction hash on Hyperliquid. */
14
29
  hash: `0x${string}`;
30
+ /** Trading fee paid. */
15
31
  fee: string;
32
+ /** Token used to pay the fee. */
16
33
  feeToken: string;
34
+ /** Optional builder/referral fee applied to the trade. */
17
35
  builderFee?: string;
18
36
  }
37
+ /**
38
+ * List of fills returned by the `userFills` endpoints.
39
+ */
19
40
  export type HLUserFillsResponse = HLUserFill[];
20
41
  export interface HLUserFillsRequest {
42
+ /**
43
+ * Whether to aggregate partial fills by block/time.
44
+ */
21
45
  aggregateByTime?: boolean;
22
46
  }
23
47
  export interface HLUserFillsByTimeRequest extends HLUserFillsRequest {
48
+ /**
49
+ * Start timestamp in milliseconds (inclusive).
50
+ */
24
51
  startTime: Timestamp;
52
+ /**
53
+ * End timestamp in milliseconds (inclusive).
54
+ * Defaults to the current time if omitted.
55
+ */
25
56
  endTime?: Timestamp;
26
57
  }
@@ -1,42 +1,89 @@
1
1
  import { DecimalString, Timestamp } from '../common';
2
+ /**
3
+ * Leverage configuration for a perpetual position.
4
+ */
2
5
  export interface HLPerpLeverage {
6
+ /** Notional value in USD used for leverage calculation. */
3
7
  rawUsd: DecimalString;
8
+ /** Margin mode used for the position. */
4
9
  type: 'isolated' | 'cross';
10
+ /** Current leverage multiplier. */
5
11
  value: number;
6
12
  }
13
+ /**
14
+ * Funding payments accumulated for a perpetual position.
15
+ */
7
16
  export interface HLPerpCumFunding {
17
+ /** Total funding paid or received since account creation. */
8
18
  allTime: DecimalString;
19
+ /** Funding accumulated since the last position change. */
9
20
  sinceChange: DecimalString;
21
+ /** Funding accumulated since the position was opened. */
10
22
  sinceOpen: DecimalString;
11
23
  }
24
+ /**
25
+ * Detailed information about a perpetual position.
26
+ */
12
27
  export interface HLPerpPositionDetail {
28
+ /** Asset symbol (e.g. BTC, ETH). */
13
29
  coin: string;
30
+ /** Funding payments history. */
14
31
  cumFunding: HLPerpCumFunding;
32
+ /** Average entry price of the position. */
15
33
  entryPx: DecimalString;
34
+ /** Leverage configuration. */
16
35
  leverage: HLPerpLeverage;
36
+ /** Estimated liquidation price. */
17
37
  liquidationPx: DecimalString;
38
+ /** Margin currently used by the position. */
18
39
  marginUsed: DecimalString;
40
+ /** Maximum allowed leverage for this market. */
19
41
  maxLeverage: number;
42
+ /** Notional value of the position. */
20
43
  positionValue: DecimalString;
44
+ /** Return on equity (ROE). */
21
45
  returnOnEquity: DecimalString;
46
+ /** Position size (positive = long, negative = short). */
22
47
  szi: DecimalString;
48
+ /** Unrealized profit or loss. */
23
49
  unrealizedPnl: DecimalString;
24
50
  }
51
+ /**
52
+ * Wrapper describing a perpetual asset position.
53
+ */
25
54
  export interface HLPerpAssetPosition {
55
+ /** Position details (null if no active position). */
26
56
  position: HLPerpPositionDetail | null;
57
+ /** Position mode configuration. */
27
58
  type: 'oneWay' | 'hedged';
28
59
  }
60
+ /**
61
+ * Margin summary for a perpetual account.
62
+ */
29
63
  export interface HLPerpMarginSummary {
64
+ /** Total account value. */
30
65
  accountValue: DecimalString;
66
+ /** Margin currently used by open positions. */
31
67
  totalMarginUsed: DecimalString;
68
+ /** Total notional position value. */
32
69
  totalNtlPos: DecimalString;
70
+ /** Raw USD balance before adjustments. */
33
71
  totalRawUsd: DecimalString;
34
72
  }
73
+ /**
74
+ * Clearinghouse state for a perpetual trading account.
75
+ */
35
76
  export interface HLClearinghouseState {
77
+ /** List of perpetual positions. */
36
78
  assetPositions: HLPerpAssetPosition[];
79
+ /** Cross maintenance margin currently required. */
37
80
  crossMaintenanceMarginUsed: DecimalString;
81
+ /** Cross margin account summary. */
38
82
  crossMarginSummary: HLPerpMarginSummary;
83
+ /** Global margin summary. */
39
84
  marginSummary: HLPerpMarginSummary;
85
+ /** Timestamp of the snapshot. */
40
86
  time: Timestamp;
87
+ /** Amount available for withdrawal. */
41
88
  withdrawable: DecimalString;
42
89
  }
@@ -1,50 +1,108 @@
1
1
  import { DecimalString } from '../common';
2
+ /**
3
+ * Metadata describing a perpetual market.
4
+ */
2
5
  export interface HLPerpMarketInfo {
6
+ /** Market symbol (e.g. BTC, ETH). */
3
7
  name: string;
8
+ /** Number of decimals used for order size. */
4
9
  szDecimals: number;
10
+ /** Maximum leverage allowed. */
5
11
  maxLeverage: number;
12
+ /** Whether the market only supports isolated margin. */
6
13
  onlyIsolated?: boolean;
14
+ /** Whether the market has been delisted. */
7
15
  isDelisted?: boolean;
16
+ /** Optional margin mode restriction. */
8
17
  marginMode?: 'strictIsolated' | 'noCross';
9
18
  }
19
+ /**
20
+ * Margin tier defining leverage limits for a position size range.
21
+ */
10
22
  export interface HLPerpMarginTier {
23
+ /** Minimum notional value for the tier. */
11
24
  lowerBound: string;
25
+ /** Maximum leverage allowed in this tier. */
12
26
  maxLeverage: number;
13
27
  }
28
+ /**
29
+ * Margin configuration table for a perpetual market.
30
+ */
14
31
  export interface HLPerpMarginTable {
32
+ /** Human-readable description. */
15
33
  description: string;
34
+ /** Margin tiers applied to this market. */
16
35
  marginTiers: HLPerpMarginTier[];
17
36
  }
37
+ /**
38
+ * Entry linking a margin table ID to its configuration.
39
+ */
18
40
  export type HLPerpMarginTableEntry = [number, HLPerpMarginTable];
41
+ /**
42
+ * Metadata returned by the `meta` endpoint.
43
+ */
19
44
  export interface HLPerpMeta {
45
+ /** List of available perpetual markets. */
20
46
  universe: HLPerpMarketInfo[];
47
+ /** Margin configuration tables. */
21
48
  marginTables: HLPerpMarginTableEntry[];
22
49
  }
50
+ /**
51
+ * Market metadata including its index in the universe list.
52
+ */
23
53
  export interface HLPerpMarketUniverse extends HLPerpMarketInfo {
54
+ /** Market index in the universe array. */
24
55
  index: number;
25
56
  }
57
+ /**
58
+ * Runtime market data for a perpetual asset.
59
+ */
26
60
  export interface HLPerpAssetCtx {
61
+ /** Daily notional trading volume. */
27
62
  dayNtlVlm: string;
63
+ /** Current funding rate. */
28
64
  funding: string;
65
+ /** Impact price levels used for slippage estimation. */
29
66
  impactPxs: string[];
67
+ /** Mark price used for PnL calculations. */
30
68
  markPx: string;
69
+ /** Mid price between best bid and ask. */
31
70
  midPx: string;
71
+ /** Total open interest. */
32
72
  openInterest: string;
73
+ /** Oracle price reference. */
33
74
  oraclePx: string;
75
+ /** Price premium relative to the oracle. */
34
76
  premium: string;
77
+ /** Previous day's closing price. */
35
78
  prevDayPx: string;
36
79
  }
80
+ /**
81
+ * Response combining market metadata and runtime context.
82
+ */
37
83
  export type HLPerpMetaAndCtx = [{
38
84
  universe: HLPerpMarketInfo[];
39
85
  }, HLPerpAssetCtx[]];
86
+ /**
87
+ * Normalized representation of a perpetual market used by the SDK.
88
+ */
40
89
  export interface HLPerpMarket {
90
+ /** Market index in the universe list. */
41
91
  index: number;
92
+ /** Market symbol (e.g. BTC). */
42
93
  name: string;
94
+ /** Size precision for orders. */
43
95
  szDecimals: number;
96
+ /** Maximum leverage allowed. */
44
97
  maxLeverage: number;
98
+ /** Margin table identifier. */
45
99
  marginTableId?: number;
100
+ /** Current mark price. */
46
101
  markPrice?: DecimalString;
102
+ /** Current mid price. */
47
103
  midPrice?: DecimalString;
104
+ /** Current funding rate. */
48
105
  funding?: DecimalString;
106
+ /** Current open interest. */
49
107
  openInterest?: DecimalString;
50
108
  }
@@ -1,11 +1,23 @@
1
1
  import { DecimalString } from '../common';
2
+ /**
3
+ * User's balance for a spot asset.
4
+ */
2
5
  export interface HLSpotBalance {
6
+ /** Asset symbol, e.g. "USDC" or "ETH". */
3
7
  coin: string;
8
+ /** Token index in Hyperliquid's system. */
4
9
  token: number;
10
+ /** Amount currently on hold / reserved. */
5
11
  hold: DecimalString;
12
+ /** Total amount owned (available + hold). */
6
13
  total: DecimalString;
14
+ /** Entry notional for the position. */
7
15
  entryNtl: DecimalString;
8
16
  }
17
+ /**
18
+ * Spot clearinghouse state containing all balances.
19
+ */
9
20
  export interface HLSpotClearinghouseState {
21
+ /** Array of spot balances for this user. */
10
22
  balances: HLSpotBalance[];
11
23
  }
@@ -1,23 +1,50 @@
1
+ /**
2
+ * Metadata for a spot token.
3
+ */
1
4
  export interface HLSpotTokenMeta {
5
+ /** Token symbol, e.g. "USDC". */
2
6
  name: string;
7
+ /** Number of decimals for display purposes. */
3
8
  szDecimals: number;
9
+ /** Number of decimals used on-chain (wei). */
4
10
  weiDecimals: number;
11
+ /** Token index in Hyperliquid system. */
5
12
  index: number;
13
+ /** Unique token identifier. */
6
14
  tokenId: string;
15
+ /** Whether this is the canonical token in the system. */
7
16
  isCanonical: boolean;
17
+ /** EVM contract address (if applicable). */
8
18
  evmContract: string | null;
19
+ /** Full token name, optional. */
9
20
  fullName: string | null;
10
21
  }
22
+ /**
23
+ * Metadata for a spot market.
24
+ */
11
25
  export interface HLSpotMarketMeta {
26
+ /** Market symbol, e.g. "ETH/USDC". */
12
27
  name: string;
28
+ /** Indexes of the base and quote tokens. */
13
29
  tokens: [number, number];
30
+ /** Market index in Hyperliquid system. */
14
31
  index: number;
32
+ /** Whether the market uses canonical tokens. */
15
33
  isCanonical: boolean;
16
34
  }
35
+ /**
36
+ * Complete spot metadata including tokens and markets.
37
+ */
17
38
  export interface HLSpotMeta {
39
+ /** All spot tokens. */
18
40
  tokens: HLSpotTokenMeta[];
41
+ /** All spot markets (universe). */
19
42
  universe: HLSpotMarketMeta[];
20
43
  }
44
+ /**
45
+ * Summary of a spot asset, extending market metadata.
46
+ */
21
47
  export interface HLSpotAssetSummary extends HLSpotMarketMeta {
48
+ /** Optional: number of decimals for size/amount display. */
22
49
  szDecimals?: number;
23
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syldel/hl-shared-types",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "Shared TypeScript interfaces and types for Hyperliquid integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",