@lifi/perps-sdk-provider-hyperliquid 0.0.0-preview-b10f0cd → 0.0.0-preview-a5dca06

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 (150) hide show
  1. package/README.md +9 -2
  2. package/dist/cjs/constants.d.ts +1 -0
  3. package/dist/cjs/constants.d.ts.map +1 -1
  4. package/dist/cjs/constants.js +2 -1
  5. package/dist/cjs/constants.js.map +1 -1
  6. package/dist/cjs/index.d.ts +1 -1
  7. package/dist/cjs/index.d.ts.map +1 -1
  8. package/dist/cjs/index.js +2 -1
  9. package/dist/cjs/index.js.map +1 -1
  10. package/dist/cjs/services/getAccount.d.ts.map +1 -1
  11. package/dist/cjs/services/getAccount.js +5 -2
  12. package/dist/cjs/services/getAccount.js.map +1 -1
  13. package/dist/cjs/services/getFills.d.ts.map +1 -1
  14. package/dist/cjs/services/getFills.js +3 -0
  15. package/dist/cjs/services/getFills.js.map +1 -1
  16. package/dist/cjs/services/getOrder.d.ts.map +1 -1
  17. package/dist/cjs/services/getOrder.js +3 -1
  18. package/dist/cjs/services/getOrder.js.map +1 -1
  19. package/dist/cjs/services/getOrders.d.ts.map +1 -1
  20. package/dist/cjs/services/getOrders.js +31 -7
  21. package/dist/cjs/services/getOrders.js.map +1 -1
  22. package/dist/cjs/services/getPositions.d.ts.map +1 -1
  23. package/dist/cjs/services/getPositions.js +1 -1
  24. package/dist/cjs/services/getPositions.js.map +1 -1
  25. package/dist/cjs/types/explorer.d.ts +10 -0
  26. package/dist/cjs/types/explorer.d.ts.map +1 -0
  27. package/dist/cjs/types/explorer.js +17 -0
  28. package/dist/cjs/types/explorer.js.map +1 -0
  29. package/dist/cjs/types/index.d.ts +1 -0
  30. package/dist/cjs/types/index.d.ts.map +1 -1
  31. package/dist/cjs/types/index.js +1 -0
  32. package/dist/cjs/types/index.js.map +1 -1
  33. package/dist/cjs/utils/assetId.d.ts +1 -0
  34. package/dist/cjs/utils/assetId.d.ts.map +1 -1
  35. package/dist/cjs/utils/assetId.js +6 -1
  36. package/dist/cjs/utils/assetId.js.map +1 -1
  37. package/dist/cjs/utils/explorer.d.ts +7 -0
  38. package/dist/cjs/utils/explorer.d.ts.map +1 -0
  39. package/dist/cjs/utils/explorer.js +49 -0
  40. package/dist/cjs/utils/explorer.js.map +1 -0
  41. package/dist/cjs/utils/index.d.ts +2 -1
  42. package/dist/cjs/utils/index.d.ts.map +1 -1
  43. package/dist/cjs/utils/index.js +6 -1
  44. package/dist/cjs/utils/index.js.map +1 -1
  45. package/dist/cjs/utils/infoClient.d.ts +1 -0
  46. package/dist/cjs/utils/infoClient.d.ts.map +1 -1
  47. package/dist/cjs/utils/infoClient.js +16 -10
  48. package/dist/cjs/utils/infoClient.js.map +1 -1
  49. package/dist/cjs/utils/spotBalance.d.ts.map +1 -1
  50. package/dist/cjs/utils/spotBalance.js +10 -6
  51. package/dist/cjs/utils/spotBalance.js.map +1 -1
  52. package/dist/cjs/websocket/HyperliquidWsProvider.d.ts.map +1 -1
  53. package/dist/cjs/websocket/HyperliquidWsProvider.js +37 -7
  54. package/dist/cjs/websocket/HyperliquidWsProvider.js.map +1 -1
  55. package/dist/esm/constants.d.ts +8 -0
  56. package/dist/esm/constants.d.ts.map +1 -1
  57. package/dist/esm/constants.js +8 -0
  58. package/dist/esm/constants.js.map +1 -1
  59. package/dist/esm/index.d.ts +1 -1
  60. package/dist/esm/index.d.ts.map +1 -1
  61. package/dist/esm/index.js +1 -1
  62. package/dist/esm/index.js.map +1 -1
  63. package/dist/esm/services/getAccount.d.ts.map +1 -1
  64. package/dist/esm/services/getAccount.js +6 -3
  65. package/dist/esm/services/getAccount.js.map +1 -1
  66. package/dist/esm/services/getFills.d.ts.map +1 -1
  67. package/dist/esm/services/getFills.js +4 -1
  68. package/dist/esm/services/getFills.js.map +1 -1
  69. package/dist/esm/services/getOrder.d.ts.map +1 -1
  70. package/dist/esm/services/getOrder.js +4 -2
  71. package/dist/esm/services/getOrder.js.map +1 -1
  72. package/dist/esm/services/getOrders.d.ts.map +1 -1
  73. package/dist/esm/services/getOrders.js +47 -13
  74. package/dist/esm/services/getOrders.js.map +1 -1
  75. package/dist/esm/services/getPositions.d.ts.map +1 -1
  76. package/dist/esm/services/getPositions.js +2 -2
  77. package/dist/esm/services/getPositions.js.map +1 -1
  78. package/dist/esm/types/explorer.d.ts +27 -0
  79. package/dist/esm/types/explorer.d.ts.map +1 -0
  80. package/dist/esm/types/explorer.js +20 -0
  81. package/dist/esm/types/explorer.js.map +1 -0
  82. package/dist/esm/types/index.d.ts +1 -0
  83. package/dist/esm/types/index.d.ts.map +1 -1
  84. package/dist/esm/types/index.js +1 -0
  85. package/dist/esm/types/index.js.map +1 -1
  86. package/dist/esm/utils/assetId.d.ts +9 -0
  87. package/dist/esm/utils/assetId.d.ts.map +1 -1
  88. package/dist/esm/utils/assetId.js +13 -0
  89. package/dist/esm/utils/assetId.js.map +1 -1
  90. package/dist/esm/utils/explorer.d.ts +31 -0
  91. package/dist/esm/utils/explorer.d.ts.map +1 -0
  92. package/dist/esm/utils/explorer.js +68 -0
  93. package/dist/esm/utils/explorer.js.map +1 -0
  94. package/dist/esm/utils/index.d.ts +2 -1
  95. package/dist/esm/utils/index.d.ts.map +1 -1
  96. package/dist/esm/utils/index.js +2 -1
  97. package/dist/esm/utils/index.js.map +1 -1
  98. package/dist/esm/utils/infoClient.d.ts +14 -3
  99. package/dist/esm/utils/infoClient.d.ts.map +1 -1
  100. package/dist/esm/utils/infoClient.js +29 -14
  101. package/dist/esm/utils/infoClient.js.map +1 -1
  102. package/dist/esm/utils/spotBalance.d.ts +1 -1
  103. package/dist/esm/utils/spotBalance.d.ts.map +1 -1
  104. package/dist/esm/utils/spotBalance.js +12 -7
  105. package/dist/esm/utils/spotBalance.js.map +1 -1
  106. package/dist/esm/websocket/HyperliquidWsProvider.d.ts +2 -1
  107. package/dist/esm/websocket/HyperliquidWsProvider.d.ts.map +1 -1
  108. package/dist/esm/websocket/HyperliquidWsProvider.js +40 -9
  109. package/dist/esm/websocket/HyperliquidWsProvider.js.map +1 -1
  110. package/dist/types/constants.d.ts +8 -0
  111. package/dist/types/constants.d.ts.map +1 -1
  112. package/dist/types/index.d.ts +1 -1
  113. package/dist/types/index.d.ts.map +1 -1
  114. package/dist/types/services/getAccount.d.ts.map +1 -1
  115. package/dist/types/services/getFills.d.ts.map +1 -1
  116. package/dist/types/services/getOrder.d.ts.map +1 -1
  117. package/dist/types/services/getOrders.d.ts.map +1 -1
  118. package/dist/types/services/getPositions.d.ts.map +1 -1
  119. package/dist/types/types/explorer.d.ts +27 -0
  120. package/dist/types/types/explorer.d.ts.map +1 -0
  121. package/dist/types/types/index.d.ts +1 -0
  122. package/dist/types/types/index.d.ts.map +1 -1
  123. package/dist/types/utils/assetId.d.ts +9 -0
  124. package/dist/types/utils/assetId.d.ts.map +1 -1
  125. package/dist/types/utils/explorer.d.ts +31 -0
  126. package/dist/types/utils/explorer.d.ts.map +1 -0
  127. package/dist/types/utils/index.d.ts +2 -1
  128. package/dist/types/utils/index.d.ts.map +1 -1
  129. package/dist/types/utils/infoClient.d.ts +14 -3
  130. package/dist/types/utils/infoClient.d.ts.map +1 -1
  131. package/dist/types/utils/spotBalance.d.ts +1 -1
  132. package/dist/types/utils/spotBalance.d.ts.map +1 -1
  133. package/dist/types/websocket/HyperliquidWsProvider.d.ts +2 -1
  134. package/dist/types/websocket/HyperliquidWsProvider.d.ts.map +1 -1
  135. package/package.json +3 -3
  136. package/src/constants.ts +10 -0
  137. package/src/index.ts +1 -0
  138. package/src/services/getAccount.ts +8 -4
  139. package/src/services/getFills.ts +4 -1
  140. package/src/services/getOrder.ts +8 -2
  141. package/src/services/getOrders.ts +71 -12
  142. package/src/services/getPositions.ts +4 -1
  143. package/src/types/explorer.ts +39 -0
  144. package/src/types/index.ts +1 -0
  145. package/src/utils/assetId.ts +16 -0
  146. package/src/utils/explorer.ts +93 -0
  147. package/src/utils/index.ts +11 -1
  148. package/src/utils/infoClient.ts +46 -24
  149. package/src/utils/spotBalance.ts +12 -7
  150. package/src/websocket/HyperliquidWsProvider.ts +44 -9
@@ -0,0 +1,27 @@
1
+ /**
2
+ * One HyperCore transaction as the explorer `userDetails` RPC reports it.
3
+ *
4
+ * @public
5
+ */
6
+ export interface HlExplorerTx {
7
+ time: number;
8
+ user: string;
9
+ /**
10
+ * The action body HyperCore received. Untyped because the shape varies by
11
+ * action type; read it through `getClientOrderIds`, not by field name.
12
+ */
13
+ action: unknown;
14
+ block: number;
15
+ hash: string;
16
+ /** `null` on a tx the engine applied, a message on one it landed but refused. */
17
+ error: string | null;
18
+ }
19
+ /**
20
+ * Whether one `userDetails` entry carries every field this package reads. The
21
+ * explorer RPC is undocumented, so entries are checked one at a time and a
22
+ * drifted entry drops on its own instead of failing the whole window.
23
+ *
24
+ * @public
25
+ */
26
+ export declare const isHlExplorerTx: (value: unknown) => value is HlExplorerTx;
27
+ //# sourceMappingURL=explorer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"explorer.d.ts","sourceRoot":"","sources":["../../../src/types/explorer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ;;;OAGG;IACH,MAAM,EAAE,OAAO,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,iFAAiF;IACjF,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,YAYE,CAAA"}
@@ -1,6 +1,7 @@
1
1
  export * from './account.js';
2
2
  export * from './action.js';
3
3
  export * from './asset.js';
4
+ export * from './explorer.js';
4
5
  export * from './fill.js';
5
6
  export * from './ledger.js';
6
7
  export * from './order.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAIA,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAIA,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,SAAS,CAAA"}
@@ -4,6 +4,15 @@
4
4
  * @public
5
5
  */
6
6
  export declare const assetIsSpot: (assetId: string) => boolean;
7
+ /**
8
+ * Return whether a Hyperliquid asset identity belongs to an HIP-4 outcome
9
+ * market: spot coin `#<encoding>`, token name `+<encoding>`, or numeric asset
10
+ * ID `100000000 + encoding`. LI.FI supports no outcome market, and the backend
11
+ * market list holds none, so the provider skips every such identity.
12
+ * @param assetId - Raw Hyperliquid coin, token name, or numeric asset ID.
13
+ * @public
14
+ */
15
+ export declare const assetIsOutcome: (assetId: string | number) => boolean;
7
16
  /**
8
17
  * Calculate Hyperliquid's numeric asset ID from a perp DEX index and the
9
18
  * asset's zero-based index within that DEX. The main DEX uses the index
@@ -1 +1 @@
1
- {"version":3,"file":"assetId.d.ts","sourceRoot":"","sources":["../../../src/utils/assetId.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,SAAS,MAAM,KAAG,OAAkC,CAAA;AAEhF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAC3B,eAAe,MAAM,EACrB,iBAAiB,MAAM,KACtB,MAKF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAC3B,UAAU,MAAM,EAChB,eAAe,MAAM,EAAE,KACtB,MAMF,CAAA"}
1
+ {"version":3,"file":"assetId.d.ts","sourceRoot":"","sources":["../../../src/utils/assetId.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,SAAS,MAAM,KAAG,OAAkC,CAAA;AAKhF;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,GAAI,SAAS,MAAM,GAAG,MAAM,KAAG,OAGF,CAAA;AAExD;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAC3B,eAAe,MAAM,EACrB,iBAAiB,MAAM,KACtB,MAKF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAC3B,UAAU,MAAM,EAChB,eAAe,MAAM,EAAE,KACtB,MAMF,CAAA"}
@@ -0,0 +1,31 @@
1
+ import type { OrderBase } from '@lifi/perps-types';
2
+ import { type HlExplorerTx } from '../types/explorer.js';
3
+ import { type InfoRequestOptions } from './infoClient.js';
4
+ /**
5
+ * Read the address's recent HyperCore transactions from the explorer RPC.
6
+ *
7
+ * The surface is undocumented, so it is read defensively: an address the
8
+ * explorer has never indexed answers `200` with no `txs` array, and each entry
9
+ * is checked on its own so one drifted entry cannot drop the rest.
10
+ *
11
+ * @throws {PerpsError} On a non-2xx status or a transport failure.
12
+ * @public
13
+ */
14
+ export declare const fetchUserTransactions: (address: string, options?: InfoRequestOptions) => Promise<HlExplorerTx[]>;
15
+ /**
16
+ * Every client order id an action names: `orders[].c` on a placement, `order.c`
17
+ * on a single modify, and `modifies[].order.c` on a batch modify. A batched
18
+ * placement names one id per leg, so every id is returned, not just the first.
19
+ *
20
+ * @public
21
+ */
22
+ export declare const getClientOrderIds: (action: Record<string, unknown>) => string[];
23
+ /**
24
+ * The hash of the transaction whose action names the order's client order id.
25
+ *
26
+ * @returns The transaction hash, or `undefined` when the order carries no
27
+ * client order id or no transaction in the window names it.
28
+ * @public
29
+ */
30
+ export declare const matchOrderActionHash: (txs: HlExplorerTx[], order: Pick<OrderBase, "clientOrderId">) => string | undefined;
31
+ //# sourceMappingURL=explorer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"explorer.d.ts","sourceRoot":"","sources":["../../../src/utils/explorer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAGlD,OAAO,EAAE,KAAK,YAAY,EAAkB,MAAM,sBAAsB,CAAA;AACxE,OAAO,EAAc,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAKrE;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,GAChC,SAAS,MAAM,EACf,UAAU,kBAAkB,KAC3B,OAAO,CAAC,YAAY,EAAE,CASxB,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC9B,MAAM,EAyBR,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAC/B,KAAK,YAAY,EAAE,EACnB,OAAO,IAAI,CAAC,SAAS,EAAE,eAAe,CAAC,KACtC,MAAM,GAAG,SAaX,CAAA"}
@@ -1,6 +1,7 @@
1
- export { assetIsSpot, calculateAssetId, getProviderIndex } from './assetId.js';
1
+ export { assetIsOutcome, assetIsSpot, calculateAssetId, getProviderIndex, } from './assetId.js';
2
2
  export { applyLogoOverride, spotLogoURI, UNIT_TOKEN_NAMES, } from './assetLogo.js';
3
3
  export { decodeCompressedJson, decodeFastAssetCtxs, } from './decodeFastAssetCtxs.js';
4
+ export { fetchUserTransactions, getClientOrderIds, matchOrderActionHash, } from './explorer.js';
4
5
  export type { InfoRequestOptions } from './infoClient.js';
5
6
  export { hlInfoOptions, infoRequest } from './infoClient.js';
6
7
  export { calculateLiquidationPrice, calculateMaintenanceMarginRate, } from './liquidation.js';
@@ -1 +1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E,yBAAyB,EAAE,MAAM,qBAAqB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,gBAAgB,GACjB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,eAAe,CAAA;AACtB,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC5D,OAAO,EACL,yBAAyB,EACzB,8BAA8B,GAC/B,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,mBAAmB,GACpB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,wBAAwB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EACL,KAAK,WAAW,EAChB,QAAQ,EACR,cAAc,EACd,YAAY,GACb,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,mBAAmB,GACpB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,aAAa,GACd,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,qBAAqB,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAC/E,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA"}
@@ -2,7 +2,7 @@ import { type PerpsSDKClient, type ResolvedRetryPolicy, type SDKRequestOptions }
2
2
  /** @internal */
3
3
  export declare const HYPERLIQUID_RETRY_DEFAULTS: ResolvedRetryPolicy;
4
4
  /**
5
- * Transport options for a direct Hyperliquid `/info` request. `policy`
5
+ * Transport options for a direct Hyperliquid REST request. `policy`
6
6
  * controls retries, `signal` cancels the request, and `fetchImpl` overrides
7
7
  * the runtime's global `fetch` implementation.
8
8
  * @public
@@ -19,7 +19,7 @@ export interface InfoRequestOptions {
19
19
  */
20
20
  export declare const hlInfoOptions: (client: PerpsSDKClient, options?: SDKRequestOptions) => InfoRequestOptions;
21
21
  /**
22
- * POST to the Hyperliquid `/info` endpoint and return the parsed JSON body.
22
+ * POST a JSON body to a Hyperliquid REST surface and return the parsed body.
23
23
  *
24
24
  * Direct-to-venue: no proxy, no AJV validation, no cache. The caller's type
25
25
  * parameter is trusted; consumers should treat the response shape as
@@ -29,7 +29,18 @@ export declare const hlInfoOptions: (client: PerpsSDKClient, options?: SDKReques
29
29
  * Non-2xx responses raise a {@link PerpsError} tagged with the Hyperliquid
30
30
  * provider key, carrying the code the status resolves to: `RateLimitExceeded`
31
31
  * for a 429, `Unauthorized` for a 401, `AgentUnauthorized` for a 403, and
32
- * `ThirdPartyError` for every other status.
32
+ * `ThirdPartyError` for every other status. A transport failure and a 2xx body
33
+ * that is not JSON both raise `ServerError`, so every failure but a caller
34
+ * abort reaches the caller as a `PerpsError`. An abort rejects untouched.
35
+ *
36
+ * @param label - Names the surface in the error message, e.g. `info request`.
37
+ * @internal
38
+ */
39
+ export declare function hlPostJson<T>(url: string, label: string, body: Record<string, unknown>, options?: InfoRequestOptions): Promise<T>;
40
+ /**
41
+ * POST to the Hyperliquid `/info` endpoint and return the parsed JSON body.
42
+ * See {@link hlPostJson} for the transport and error contract.
43
+ *
33
44
  * @public
34
45
  */
35
46
  export declare function infoRequest<T>(apiUrl: string, body: Record<string, unknown>, options?: InfoRequestOptions): Promise<T>;
@@ -1 +1 @@
1
- {"version":3,"file":"infoClient.d.ts","sourceRoot":"","sources":["../../../src/utils/infoClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,mBAAmB,EAExB,KAAK,iBAAiB,EACvB,MAAM,iBAAiB,CAAA;AA4BxB,gBAAgB;AAChB,eAAO,MAAM,0BAA0B,EAAE,mBAmBxC,CAAA;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,MAAM,CAAC,EAAE,mBAAmB,CAAA;IAC5B,SAAS,CAAC,EAAE,OAAO,KAAK,CAAA;CACzB;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,GACxB,QAAQ,cAAc,EACtB,UAAU,iBAAiB,KAC1B,kBAQD,CAAA;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAsB,WAAW,CAAC,CAAC,EACjC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,CAAC,CAAC,CAyCZ"}
1
+ {"version":3,"file":"infoClient.d.ts","sourceRoot":"","sources":["../../../src/utils/infoClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,cAAc,EACnB,KAAK,mBAAmB,EAExB,KAAK,iBAAiB,EACvB,MAAM,iBAAiB,CAAA;AA4BxB,gBAAgB;AAChB,eAAO,MAAM,0BAA0B,EAAE,mBAmBxC,CAAA;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,MAAM,CAAC,EAAE,mBAAmB,CAAA;IAC5B,SAAS,CAAC,EAAE,OAAO,KAAK,CAAA;CACzB;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,GACxB,QAAQ,cAAc,EACtB,UAAU,iBAAiB,KAC1B,kBAQD,CAAA;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,UAAU,CAAC,CAAC,EAChC,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,CAAC,CAAC,CA2CZ;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,CAAC,CAAC,CAEZ"}
@@ -14,6 +14,6 @@ export declare const spotPriceById: (markets: readonly Market[], priceByMarketId
14
14
  * @public
15
15
  */
16
16
  export declare const spotAssetFromToken: (b: HlSpotBalance) => Asset;
17
- /** Assemble a typed spot {@link Balance}; `total` is native token units and its USD value uses `priceById`. @public */
17
+ /** Assemble a typed spot {@link Balance}; `total` is native token units and its unit price and USD value use `priceById`. @public */
18
18
  export declare const spotBalance: (asset: Asset, total: string, priceById: Map<string, number>) => Balance;
19
19
  //# sourceMappingURL=spotBalance.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"spotBalance.d.ts","sourceRoot":"","sources":["../../../src/utils/spotBalance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAItD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GACxB,SAAS,SAAS,MAAM,EAAE,EAC1B,iBAAiB,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,KAC3C,GAAG,CAAC,MAAM,EAAE,MAAM,CAapB,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,GAAG,aAAa,KAAG,KAIpD,CAAA;AAEF,uHAAuH;AACvH,eAAO,MAAM,WAAW,GACtB,OAAO,KAAK,EACZ,OAAO,MAAM,EACb,WAAW,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,KAC7B,OAKD,CAAA"}
1
+ {"version":3,"file":"spotBalance.d.ts","sourceRoot":"","sources":["../../../src/utils/spotBalance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAItD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GACxB,SAAS,SAAS,MAAM,EAAE,EAC1B,iBAAiB,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,KAC3C,GAAG,CAAC,MAAM,EAAE,MAAM,CAapB,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,GAAG,aAAa,KAAG,KAIpD,CAAA;AAEF,qIAAqI;AACrI,eAAO,MAAM,WAAW,GACtB,OAAO,KAAK,EACZ,OAAO,MAAM,EACb,WAAW,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,KAC7B,OAUF,CAAA"}
@@ -100,7 +100,8 @@ export declare class HyperliquidWsProvider extends WsProviderBase<object> {
100
100
  * Context for one market from the cached feeds: spot asset context when it
101
101
  * maps, else perp asset context with mid + mark overlaid from
102
102
  * `fastAssetCtxs`, else the fast feed alone — each price standing in for the
103
- * other where it carries only one of mid/mark.
103
+ * other where it carries only one of mid/mark. An attached registry gates the
104
+ * market id: an id it does not list, or lists as delisted, yields no context.
104
105
  */
105
106
  private computeMarketContext;
106
107
  private handleActiveAssetCtx;
@@ -1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BpB,OAAO,CAAC,kBAAkB;IAyE1B,OAAO,CAAC,eAAe;IAqBvB,OAAO,CAAC,+BAA+B;IAiDvC;0EACsE;IACtE,OAAO,CAAC,MAAM,CAAC,oBAAoB;YAOrB,eAAe;IA8B7B,8EAA8E;IAC9E,OAAO,CAAC,mBAAmB;IAoB3B,OAAO,CAAC,kBAAkB;IAuB1B;2EACuE;IACvE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAS;IAEnD;;+BAE2B;IAC3B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAM;IAEjD,OAAO,CAAC,uBAAuB;IAyC/B,OAAO,CAAC,oBAAoB;IA4C5B,OAAO,CAAC,eAAe;CAwCxB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/perps-sdk-provider-hyperliquid",
3
- "version": "0.0.0-preview-b10f0cd",
3
+ "version": "0.0.0-preview-a5dca06",
4
4
  "description": "Hyperliquid provider plugin for @lifi/perps-sdk",
5
5
  "homepage": "https://github.com/lifinance/perps-sdk",
6
6
  "bugs": {
@@ -49,10 +49,10 @@
49
49
  "dependencies": {
50
50
  "big.js": "^7.0.1",
51
51
  "viem": "^2.55.18",
52
- "@lifi/perps-types": "^0.0.0-preview-b10f0cd"
52
+ "@lifi/perps-types": "^0.0.0-preview-a5dca06"
53
53
  },
54
54
  "peerDependencies": {
55
- "@lifi/perps-sdk": "^0.0.0-preview-b10f0cd"
55
+ "@lifi/perps-sdk": "^0.0.0-preview-a5dca06"
56
56
  },
57
57
  "publishConfig": {
58
58
  "access": "public"
package/src/constants.ts CHANGED
@@ -15,6 +15,16 @@ export const PROVIDER_KEY = 'hyperliquid'
15
15
  */
16
16
  export const DEFAULT_HYPERLIQUID_API_URL = 'https://api.hyperliquid.xyz'
17
17
 
18
+ /**
19
+ * Hyperliquid explorer RPC endpoint. It serves the `userDetails` transaction
20
+ * window from a host separate from the REST API, and it answers a browser
21
+ * cross-origin POST.
22
+ *
23
+ * @public
24
+ */
25
+ export const HYPERLIQUID_EXPLORER_RPC_URL =
26
+ 'https://rpc.hyperliquid.xyz/explorer'
27
+
18
28
  /**
19
29
  * Approximate published baseline maker/taker fee tier for Hyperliquid, used to
20
30
  * seed fee math before the live account `feeTier` resolves. Rates are fractions
package/src/index.ts CHANGED
@@ -15,6 +15,7 @@ export { projectHyperliquidConfigSettings } from './accountConfig.js'
15
15
  export { getAccountSummary } from './accountSummary.js'
16
16
  export {
17
17
  DEFAULT_HYPERLIQUID_API_URL,
18
+ HYPERLIQUID_EXPLORER_RPC_URL,
18
19
  HYPERLIQUID_FEE_TIER_FALLBACK,
19
20
  PROVIDER_KEY as HYPERLIQUID_PROVIDER_KEY,
20
21
  } from './constants.js'
@@ -26,6 +26,7 @@ import {
26
26
  import { isUnifiedAbstraction } from '../utils/abstractionMode.js'
27
27
  import { toWireBig } from '../utils/decimal.js'
28
28
  import {
29
+ assetIsOutcome,
29
30
  partitionSpotBalances,
30
31
  perpsDexNames,
31
32
  spotAssetFromToken,
@@ -102,9 +103,9 @@ const buildBalances = (
102
103
  quoteAssetByCategory: Map<string, Asset>
103
104
  ): BalancePartition => {
104
105
  const { balances, collateralBalances } = partitionSpotBalances(
105
- spotState.balances.map((b) =>
106
- spotBalance(spotAssetFromToken(b), b.total, priceById)
107
- ),
106
+ spotState.balances
107
+ .filter((b) => !assetIsOutcome(b.coin))
108
+ .map((b) => spotBalance(spotAssetFromToken(b), b.total, priceById)),
108
109
  quoteAssetIds,
109
110
  abstraction === HlAbstractionMode.PORTFOLIO_MARGIN
110
111
  )
@@ -127,6 +128,7 @@ const buildBalances = (
127
128
  asset: quoteAssetByCategory.get(categoryId)!,
128
129
  units: value.toFixed(),
129
130
  valueUsd: value.toFixed(),
131
+ price: '1',
130
132
  })
131
133
  }
132
134
  }
@@ -220,7 +222,9 @@ export const getAccount = async (
220
222
 
221
223
  const positions: Position[] = stateResults.flatMap((state) =>
222
224
  state.assetPositions
223
- .filter(isOpenAssetPosition)
225
+ .filter(
226
+ (ap) => !assetIsOutcome(ap.position.coin) && isOpenAssetPosition(ap)
227
+ )
224
228
  .map((ap) =>
225
229
  mapPosition(
226
230
  ap,
@@ -12,7 +12,7 @@ import type {
12
12
  HlUserFills,
13
13
  HlUserFillsByTime,
14
14
  } from '../types/index.js'
15
- import { mapFill } from '../utils/index.js'
15
+ import { assetIsOutcome, mapFill } from '../utils/index.js'
16
16
  import { hlInfoOptions, infoRequest } from '../utils/infoClient.js'
17
17
 
18
18
  /**
@@ -112,6 +112,9 @@ export const getFills = async (
112
112
  // only its own row instead of rejecting the whole page. The registry warns
113
113
  // once per unresolved id. A delisted market still resolves, so its rows stay.
114
114
  const items = page.flatMap((f): Fill[] => {
115
+ if (assetIsOutcome(f.coin)) {
116
+ return []
117
+ }
115
118
  const market = registry.get(f.coin)
116
119
  return market === undefined ? [] : [mapFill(f, market)]
117
120
  })
@@ -12,7 +12,7 @@ import type {
12
12
  HlOrderStatusResponse,
13
13
  HlTwapHistoryEntry,
14
14
  } from '../types/index.js'
15
- import { mapOrder } from '../utils/index.js'
15
+ import { assetIsOutcome, mapOrder } from '../utils/index.js'
16
16
  import { hlInfoOptions, infoRequest } from '../utils/infoClient.js'
17
17
 
18
18
  /**
@@ -59,12 +59,18 @@ export const getOrder = async (
59
59
  { type: 'twapHistory', user: params.address },
60
60
  hlInfoOptions(client, options)
61
61
  )
62
- const twap = history.find((entry) => String(entry.twapId) === params.id)
62
+ const twap = history.find(
63
+ (entry) =>
64
+ String(entry.twapId) === params.id && !assetIsOutcome(entry.state.coin)
65
+ )
63
66
  if (twap !== undefined) {
64
67
  const registry = getMarketRegistry(client, PROVIDER_KEY)
65
68
  await registry.sync()
66
69
  return mapOrder(twap, registry.require(twap.state.coin))
67
70
  }
71
+ }
72
+
73
+ if (status.status !== 'order' || assetIsOutcome(status.order.order.coin)) {
68
74
  const err = new PerpsError(
69
75
  PerpsErrorCode.OrderNotFound,
70
76
  `Order not found: ${params.id}`
@@ -1,5 +1,8 @@
1
1
  import {
2
2
  ACTIVE_ORDER_STATUSES,
3
+ createWarnOnce,
4
+ ExplorerChainId,
5
+ explorerTxUrl,
3
6
  getMarketRegistry,
4
7
  isActiveOrderStatus,
5
8
  type MarketRegistry,
@@ -11,28 +14,50 @@ import type { MarketDisplay, Order, OrdersResponse } from '@lifi/perps-types'
11
14
  import { PROVIDER_KEY } from '../constants.js'
12
15
  import type { HyperliquidContext } from '../context.js'
13
16
  import type {
17
+ HlExplorerTx,
14
18
  HlFrontendOpenOrders,
15
19
  HlHistoricalOrders,
16
20
  HlTwapHistoryEntry,
17
21
  } from '../types/index.js'
18
- import { mapOrder, perpsDexNames } from '../utils/index.js'
19
- import { hlInfoOptions, infoRequest } from '../utils/infoClient.js'
22
+ import {
23
+ assetIsOutcome,
24
+ fetchUserTransactions,
25
+ mapOrder,
26
+ matchOrderActionHash,
27
+ perpsDexNames,
28
+ } from '../utils/index.js'
29
+ import {
30
+ hlInfoOptions,
31
+ type InfoRequestOptions,
32
+ infoRequest,
33
+ } from '../utils/infoClient.js'
20
34
 
21
35
  /** Parameters for a lifecycle-filtered Hyperliquid order read. */
22
36
  export type GetOrdersParams = ProviderGetOrdersParams
23
37
 
24
- const warnedRows = new Set<string>()
38
+ const warn = createWarnOnce()
39
+
40
+ const warnOnce = (key: string, detail?: string): void => {
41
+ warn(
42
+ key,
43
+ `[${PROVIDER_KEY}] ${detail === undefined ? key : `${key}: ${detail}`}`
44
+ )
45
+ }
25
46
 
26
47
  /**
27
- * Map one venue row, or drop it. A coin the backend market list does not hold
28
- * and a row the mapper rejects each drop only their own row instead of
29
- * rejecting the whole page; each distinct mapper message warns once.
48
+ * Map one venue row, or drop it. An outcome market identity, a coin the backend
49
+ * market list does not hold, and a row the mapper rejects each drop only their
50
+ * own row instead of rejecting the whole page; each distinct mapper message
51
+ * warns once.
30
52
  */
31
53
  const mapRow = (
32
54
  coin: string,
33
55
  registry: MarketRegistry,
34
56
  map: (market: MarketDisplay) => Order
35
57
  ): Order | undefined => {
58
+ if (assetIsOutcome(coin)) {
59
+ return undefined
60
+ }
36
61
  const market = registry.get(coin)
37
62
  if (market === undefined) {
38
63
  return undefined
@@ -43,14 +68,47 @@ const mapRow = (
43
68
  if (!(error instanceof PerpsError)) {
44
69
  throw error
45
70
  }
46
- if (!warnedRows.has(error.message)) {
47
- warnedRows.add(error.message)
48
- console.warn(`[${PROVIDER_KEY}] dropped order row: ${error.message}`)
49
- }
71
+ warnOnce(`dropped order row: ${error.message}`)
50
72
  return undefined
51
73
  }
52
74
  }
53
75
 
76
+ /**
77
+ * Set `explorerLink` on each row whose placement transaction the explorer
78
+ * window still holds. One explorer read serves the whole page, and it is
79
+ * skipped when no row carries a client order id to match on. The link is
80
+ * supplementary, so an explorer failure warns and leaves the rows unlinked
81
+ * instead of failing the order read.
82
+ */
83
+ const withExplorerLinks = async (
84
+ orders: Order[],
85
+ address: string,
86
+ options: InfoRequestOptions
87
+ ): Promise<Order[]> => {
88
+ if (!orders.some((order) => order.clientOrderId !== undefined)) {
89
+ return orders
90
+ }
91
+ let txs: HlExplorerTx[]
92
+ try {
93
+ txs = await fetchUserTransactions(address, options)
94
+ } catch (error) {
95
+ if (!(error instanceof PerpsError)) {
96
+ throw error
97
+ }
98
+ // The message stays out of the key: a transport failure names hosts and
99
+ // ports, so keying on it would let the dedupe set grow without bound.
100
+ warnOnce('explorer link lookup failed', error.message)
101
+ return orders
102
+ }
103
+ return orders.map((order) => {
104
+ const explorerLink = explorerTxUrl(
105
+ ExplorerChainId.HYPERLIQUID,
106
+ matchOrderActionHash(txs, order)
107
+ )
108
+ return explorerLink === undefined ? order : { ...order, explorerLink }
109
+ })
110
+ }
111
+
54
112
  /** Read regular, trigger, and TWAP orders from the requested lifecycle feeds. */
55
113
  export const getOrders = async (
56
114
  { client, apiUrl }: HyperliquidContext,
@@ -150,9 +208,10 @@ export const getOrders = async (
150
208
  statuses.includes(order.status) &&
151
209
  (params.marketId === undefined || order.market.id === params.marketId)
152
210
  )
211
+ const orders = await withExplorerLinks(matching, params.address, infoOpts)
153
212
  return {
154
213
  provider: PROVIDER_KEY,
155
- orders: matching,
156
- pagination: { limit: params.limit ?? matching.length, hasMore: false },
214
+ orders,
215
+ pagination: { limit: params.limit ?? orders.length, hasMore: false },
157
216
  }
158
217
  }
@@ -9,6 +9,7 @@ import { PROVIDER_KEY } from '../constants.js'
9
9
  import type { HyperliquidContext } from '../context.js'
10
10
  import type { HlClearinghouseState } from '../types/index.js'
11
11
  import {
12
+ assetIsOutcome,
12
13
  isOpenAssetPosition,
13
14
  mapPosition,
14
15
  perpsDexNames,
@@ -61,7 +62,9 @@ export const getPositions = async (
61
62
 
62
63
  let positions = stateResults.flatMap((state) =>
63
64
  state.assetPositions
64
- .filter(isOpenAssetPosition)
65
+ .filter(
66
+ (ap) => !assetIsOutcome(ap.position.coin) && isOpenAssetPosition(ap)
67
+ )
65
68
  .map((ap) =>
66
69
  mapPosition(
67
70
  ap,
@@ -0,0 +1,39 @@
1
+ /**
2
+ * One HyperCore transaction as the explorer `userDetails` RPC reports it.
3
+ *
4
+ * @public
5
+ */
6
+ export interface HlExplorerTx {
7
+ time: number
8
+ user: string
9
+ /**
10
+ * The action body HyperCore received. Untyped because the shape varies by
11
+ * action type; read it through `getClientOrderIds`, not by field name.
12
+ */
13
+ action: unknown
14
+ block: number
15
+ hash: string
16
+ /** `null` on a tx the engine applied, a message on one it landed but refused. */
17
+ error: string | null
18
+ }
19
+
20
+ /**
21
+ * Whether one `userDetails` entry carries every field this package reads. The
22
+ * explorer RPC is undocumented, so entries are checked one at a time and a
23
+ * drifted entry drops on its own instead of failing the whole window.
24
+ *
25
+ * @public
26
+ */
27
+ export const isHlExplorerTx = (value: unknown): value is HlExplorerTx =>
28
+ typeof value === 'object' &&
29
+ value !== null &&
30
+ 'time' in value &&
31
+ typeof value.time === 'number' &&
32
+ 'user' in value &&
33
+ typeof value.user === 'string' &&
34
+ 'block' in value &&
35
+ typeof value.block === 'number' &&
36
+ 'hash' in value &&
37
+ typeof value.hash === 'string' &&
38
+ 'error' in value &&
39
+ (value.error === null || typeof value.error === 'string')
@@ -5,6 +5,7 @@
5
5
  export * from './account.js'
6
6
  export * from './action.js'
7
7
  export * from './asset.js'
8
+ export * from './explorer.js'
8
9
  export * from './fill.js'
9
10
  export * from './ledger.js'
10
11
  export * from './order.js'
@@ -5,6 +5,22 @@
5
5
  */
6
6
  export const assetIsSpot = (assetId: string): boolean => assetId.startsWith('@')
7
7
 
8
+ /** Lowest numeric asset ID Hyperliquid assigns to an outcome market. */
9
+ const OUTCOME_ASSET_ID_BASE = 100_000_000
10
+
11
+ /**
12
+ * Return whether a Hyperliquid asset identity belongs to an HIP-4 outcome
13
+ * market: spot coin `#<encoding>`, token name `+<encoding>`, or numeric asset
14
+ * ID `100000000 + encoding`. LI.FI supports no outcome market, and the backend
15
+ * market list holds none, so the provider skips every such identity.
16
+ * @param assetId - Raw Hyperliquid coin, token name, or numeric asset ID.
17
+ * @public
18
+ */
19
+ export const assetIsOutcome = (assetId: string | number): boolean =>
20
+ typeof assetId === 'number'
21
+ ? assetId >= OUTCOME_ASSET_ID_BASE
22
+ : assetId.startsWith('#') || assetId.startsWith('+')
23
+
8
24
  /**
9
25
  * Calculate Hyperliquid's numeric asset ID from a perp DEX index and the
10
26
  * asset's zero-based index within that DEX. The main DEX uses the index