@nktkas/hyperliquid 0.25.6 → 0.25.8

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 (544) hide show
  1. package/CONTRIBUTING.md +26 -19
  2. package/README.md +106 -9
  3. package/esm/bin/cli.js +1 -0
  4. package/esm/bin/cli.js.map +1 -1
  5. package/esm/src/api/_common_schemas.d.ts +19 -0
  6. package/esm/src/api/_common_schemas.d.ts.map +1 -1
  7. package/esm/src/api/_common_schemas.js +15 -0
  8. package/esm/src/api/_common_schemas.js.map +1 -1
  9. package/esm/src/api/exchange/_base/_execute.d.ts +6 -7
  10. package/esm/src/api/exchange/_base/_execute.d.ts.map +1 -1
  11. package/esm/src/api/exchange/_base/_execute.js +67 -43
  12. package/esm/src/api/exchange/_base/_execute.js.map +1 -1
  13. package/esm/src/api/exchange/_base/_types.d.ts +0 -7
  14. package/esm/src/api/exchange/_base/_types.d.ts.map +1 -1
  15. package/esm/src/api/exchange/_base/mod.d.ts +0 -2
  16. package/esm/src/api/exchange/_base/mod.d.ts.map +1 -1
  17. package/esm/src/api/exchange/_base/mod.js +0 -2
  18. package/esm/src/api/exchange/_base/mod.js.map +1 -1
  19. package/esm/src/api/exchange/agentEnableDexAbstraction.d.ts.map +1 -1
  20. package/esm/src/api/exchange/agentEnableDexAbstraction.js +14 -7
  21. package/esm/src/api/exchange/agentEnableDexAbstraction.js.map +1 -1
  22. package/esm/src/api/exchange/approveAgent.d.ts.map +1 -1
  23. package/esm/src/api/exchange/approveAgent.js +16 -8
  24. package/esm/src/api/exchange/approveAgent.js.map +1 -1
  25. package/esm/src/api/exchange/approveBuilderFee.d.ts.map +1 -1
  26. package/esm/src/api/exchange/approveBuilderFee.js +16 -8
  27. package/esm/src/api/exchange/approveBuilderFee.js.map +1 -1
  28. package/esm/src/api/exchange/batchModify.d.ts.map +1 -1
  29. package/esm/src/api/exchange/batchModify.js +16 -10
  30. package/esm/src/api/exchange/batchModify.js.map +1 -1
  31. package/esm/src/api/exchange/cDeposit.d.ts.map +1 -1
  32. package/esm/src/api/exchange/cDeposit.js +16 -8
  33. package/esm/src/api/exchange/cDeposit.js.map +1 -1
  34. package/esm/src/api/exchange/cSignerAction.d.ts.map +1 -1
  35. package/esm/src/api/exchange/cSignerAction.js +15 -8
  36. package/esm/src/api/exchange/cSignerAction.js.map +1 -1
  37. package/esm/src/api/exchange/cValidatorAction.d.ts.map +1 -1
  38. package/esm/src/api/exchange/cValidatorAction.js +15 -8
  39. package/esm/src/api/exchange/cValidatorAction.js.map +1 -1
  40. package/esm/src/api/exchange/cWithdraw.d.ts.map +1 -1
  41. package/esm/src/api/exchange/cWithdraw.js +16 -8
  42. package/esm/src/api/exchange/cWithdraw.js.map +1 -1
  43. package/esm/src/api/exchange/cancel.d.ts.map +1 -1
  44. package/esm/src/api/exchange/cancel.js +16 -10
  45. package/esm/src/api/exchange/cancel.js.map +1 -1
  46. package/esm/src/api/exchange/cancelByCloid.d.ts.map +1 -1
  47. package/esm/src/api/exchange/cancelByCloid.js +16 -10
  48. package/esm/src/api/exchange/cancelByCloid.js.map +1 -1
  49. package/esm/src/api/exchange/claimRewards.d.ts.map +1 -1
  50. package/esm/src/api/exchange/claimRewards.js +14 -7
  51. package/esm/src/api/exchange/claimRewards.js.map +1 -1
  52. package/esm/src/api/exchange/convertToMultiSigUser.d.ts.map +1 -1
  53. package/esm/src/api/exchange/convertToMultiSigUser.js +16 -8
  54. package/esm/src/api/exchange/convertToMultiSigUser.js.map +1 -1
  55. package/esm/src/api/exchange/createSubAccount.d.ts.map +1 -1
  56. package/esm/src/api/exchange/createSubAccount.js +15 -8
  57. package/esm/src/api/exchange/createSubAccount.js.map +1 -1
  58. package/esm/src/api/exchange/createVault.d.ts.map +1 -1
  59. package/esm/src/api/exchange/createVault.js +15 -8
  60. package/esm/src/api/exchange/createVault.js.map +1 -1
  61. package/esm/src/api/exchange/evmUserModify.d.ts +1 -1
  62. package/esm/src/api/exchange/evmUserModify.d.ts.map +1 -1
  63. package/esm/src/api/exchange/evmUserModify.js +16 -9
  64. package/esm/src/api/exchange/evmUserModify.js.map +1 -1
  65. package/esm/src/api/exchange/linkStakingUser.d.ts +112 -0
  66. package/esm/src/api/exchange/linkStakingUser.d.ts.map +1 -0
  67. package/esm/src/api/exchange/linkStakingUser.js +99 -0
  68. package/esm/src/api/exchange/linkStakingUser.js.map +1 -0
  69. package/esm/src/api/exchange/modify.d.ts.map +1 -1
  70. package/esm/src/api/exchange/modify.js +16 -10
  71. package/esm/src/api/exchange/modify.js.map +1 -1
  72. package/esm/src/api/exchange/multiSig.d.ts.map +1 -1
  73. package/esm/src/api/exchange/multiSig.js +17 -16
  74. package/esm/src/api/exchange/multiSig.js.map +1 -1
  75. package/esm/src/api/exchange/noop.d.ts.map +1 -1
  76. package/esm/src/api/exchange/noop.js +14 -7
  77. package/esm/src/api/exchange/noop.js.map +1 -1
  78. package/esm/src/api/exchange/order.d.ts.map +1 -1
  79. package/esm/src/api/exchange/order.js +16 -10
  80. package/esm/src/api/exchange/order.js.map +1 -1
  81. package/esm/src/api/exchange/perpDeploy.d.ts.map +1 -1
  82. package/esm/src/api/exchange/perpDeploy.js +15 -8
  83. package/esm/src/api/exchange/perpDeploy.js.map +1 -1
  84. package/esm/src/api/exchange/registerReferrer.d.ts.map +1 -1
  85. package/esm/src/api/exchange/registerReferrer.js +15 -8
  86. package/esm/src/api/exchange/registerReferrer.js.map +1 -1
  87. package/esm/src/api/exchange/reserveRequestWeight.d.ts.map +1 -1
  88. package/esm/src/api/exchange/reserveRequestWeight.js +15 -8
  89. package/esm/src/api/exchange/reserveRequestWeight.js.map +1 -1
  90. package/esm/src/api/exchange/scheduleCancel.js +16 -10
  91. package/esm/src/api/exchange/scheduleCancel.js.map +1 -1
  92. package/esm/src/api/exchange/sendAsset.d.ts.map +1 -1
  93. package/esm/src/api/exchange/sendAsset.js +16 -8
  94. package/esm/src/api/exchange/sendAsset.js.map +1 -1
  95. package/esm/src/api/exchange/setDisplayName.d.ts.map +1 -1
  96. package/esm/src/api/exchange/setDisplayName.js +15 -8
  97. package/esm/src/api/exchange/setDisplayName.js.map +1 -1
  98. package/esm/src/api/exchange/setReferrer.d.ts.map +1 -1
  99. package/esm/src/api/exchange/setReferrer.js +15 -8
  100. package/esm/src/api/exchange/setReferrer.js.map +1 -1
  101. package/esm/src/api/exchange/spotDeploy.d.ts.map +1 -1
  102. package/esm/src/api/exchange/spotDeploy.js +15 -8
  103. package/esm/src/api/exchange/spotDeploy.js.map +1 -1
  104. package/esm/src/api/exchange/spotSend.d.ts.map +1 -1
  105. package/esm/src/api/exchange/spotSend.js +16 -8
  106. package/esm/src/api/exchange/spotSend.js.map +1 -1
  107. package/esm/src/api/exchange/spotUser.d.ts.map +1 -1
  108. package/esm/src/api/exchange/spotUser.js +15 -8
  109. package/esm/src/api/exchange/spotUser.js.map +1 -1
  110. package/esm/src/api/exchange/subAccountModify.d.ts.map +1 -1
  111. package/esm/src/api/exchange/subAccountModify.js +15 -8
  112. package/esm/src/api/exchange/subAccountModify.js.map +1 -1
  113. package/esm/src/api/exchange/subAccountSpotTransfer.d.ts.map +1 -1
  114. package/esm/src/api/exchange/subAccountSpotTransfer.js +15 -8
  115. package/esm/src/api/exchange/subAccountSpotTransfer.js.map +1 -1
  116. package/esm/src/api/exchange/subAccountTransfer.d.ts.map +1 -1
  117. package/esm/src/api/exchange/subAccountTransfer.js +15 -8
  118. package/esm/src/api/exchange/subAccountTransfer.js.map +1 -1
  119. package/esm/src/api/exchange/tokenDelegate.d.ts.map +1 -1
  120. package/esm/src/api/exchange/tokenDelegate.js +16 -8
  121. package/esm/src/api/exchange/tokenDelegate.js.map +1 -1
  122. package/esm/src/api/exchange/twapCancel.d.ts.map +1 -1
  123. package/esm/src/api/exchange/twapCancel.js +16 -10
  124. package/esm/src/api/exchange/twapCancel.js.map +1 -1
  125. package/esm/src/api/exchange/twapOrder.d.ts.map +1 -1
  126. package/esm/src/api/exchange/twapOrder.js +16 -10
  127. package/esm/src/api/exchange/twapOrder.js.map +1 -1
  128. package/esm/src/api/exchange/updateIsolatedMargin.d.ts.map +1 -1
  129. package/esm/src/api/exchange/updateIsolatedMargin.js +16 -10
  130. package/esm/src/api/exchange/updateIsolatedMargin.js.map +1 -1
  131. package/esm/src/api/exchange/updateLeverage.d.ts.map +1 -1
  132. package/esm/src/api/exchange/updateLeverage.js +16 -10
  133. package/esm/src/api/exchange/updateLeverage.js.map +1 -1
  134. package/esm/src/api/exchange/usdClassTransfer.d.ts.map +1 -1
  135. package/esm/src/api/exchange/usdClassTransfer.js +16 -8
  136. package/esm/src/api/exchange/usdClassTransfer.js.map +1 -1
  137. package/esm/src/api/exchange/usdSend.d.ts.map +1 -1
  138. package/esm/src/api/exchange/usdSend.js +16 -8
  139. package/esm/src/api/exchange/usdSend.js.map +1 -1
  140. package/esm/src/api/exchange/userDexAbstraction.d.ts.map +1 -1
  141. package/esm/src/api/exchange/userDexAbstraction.js +16 -8
  142. package/esm/src/api/exchange/userDexAbstraction.js.map +1 -1
  143. package/esm/src/api/exchange/vaultDistribute.d.ts.map +1 -1
  144. package/esm/src/api/exchange/vaultDistribute.js +15 -8
  145. package/esm/src/api/exchange/vaultDistribute.js.map +1 -1
  146. package/esm/src/api/exchange/vaultModify.d.ts.map +1 -1
  147. package/esm/src/api/exchange/vaultModify.js +15 -8
  148. package/esm/src/api/exchange/vaultModify.js.map +1 -1
  149. package/esm/src/api/exchange/vaultTransfer.d.ts.map +1 -1
  150. package/esm/src/api/exchange/vaultTransfer.js +15 -8
  151. package/esm/src/api/exchange/vaultTransfer.js.map +1 -1
  152. package/esm/src/api/exchange/withdraw3.d.ts.map +1 -1
  153. package/esm/src/api/exchange/withdraw3.js +16 -8
  154. package/esm/src/api/exchange/withdraw3.js.map +1 -1
  155. package/esm/src/api/exchange/~client.d.ts +31 -3
  156. package/esm/src/api/exchange/~client.d.ts.map +1 -1
  157. package/esm/src/api/exchange/~client.js +27 -4
  158. package/esm/src/api/exchange/~client.js.map +1 -1
  159. package/esm/src/api/exchange/~mod.d.ts +1 -0
  160. package/esm/src/api/exchange/~mod.d.ts.map +1 -1
  161. package/esm/src/api/exchange/~mod.js +1 -0
  162. package/esm/src/api/exchange/~mod.js.map +1 -1
  163. package/esm/src/api/info/allPerpMetas.d.ts +5 -0
  164. package/esm/src/api/info/allPerpMetas.d.ts.map +1 -1
  165. package/esm/src/api/info/meta.d.ts +5 -0
  166. package/esm/src/api/info/meta.d.ts.map +1 -1
  167. package/esm/src/api/info/meta.js +2 -0
  168. package/esm/src/api/info/meta.js.map +1 -1
  169. package/esm/src/api/info/metaAndAssetCtxs.d.ts +5 -0
  170. package/esm/src/api/info/metaAndAssetCtxs.d.ts.map +1 -1
  171. package/esm/src/api/info/perpDexs.d.ts +4 -0
  172. package/esm/src/api/info/perpDexs.d.ts.map +1 -1
  173. package/esm/src/api/info/perpDexs.js +5 -0
  174. package/esm/src/api/info/perpDexs.js.map +1 -1
  175. package/esm/src/api/info/spotClearinghouseState.d.ts +0 -5
  176. package/esm/src/api/info/spotClearinghouseState.d.ts.map +1 -1
  177. package/esm/src/api/info/spotClearinghouseState.js +2 -14
  178. package/esm/src/api/info/spotClearinghouseState.js.map +1 -1
  179. package/esm/src/api/info/userFees.d.ts +27 -2
  180. package/esm/src/api/info/userFees.d.ts.map +1 -1
  181. package/esm/src/api/info/userFees.js +29 -1
  182. package/esm/src/api/info/userFees.js.map +1 -1
  183. package/esm/src/api/info/webData2.d.ts +152 -23
  184. package/esm/src/api/info/webData2.d.ts.map +1 -1
  185. package/esm/src/api/info/webData2.js +3 -54
  186. package/esm/src/api/info/webData2.js.map +1 -1
  187. package/esm/src/api/info/~client.d.ts +11 -3
  188. package/esm/src/api/info/~client.d.ts.map +1 -1
  189. package/esm/src/api/subscription/spotState.d.ts +91 -0
  190. package/esm/src/api/subscription/spotState.d.ts.map +1 -0
  191. package/esm/src/api/subscription/spotState.js +58 -0
  192. package/esm/src/api/subscription/spotState.js.map +1 -0
  193. package/esm/src/api/subscription/webData2.d.ts +9 -4
  194. package/esm/src/api/subscription/webData2.d.ts.map +1 -1
  195. package/esm/src/api/subscription/webData2.js +1 -1
  196. package/esm/src/api/subscription/webData2.js.map +1 -1
  197. package/esm/src/api/subscription/webData3.d.ts +541 -0
  198. package/esm/src/api/subscription/webData3.d.ts.map +1 -0
  199. package/esm/src/api/subscription/webData3.js +94 -0
  200. package/esm/src/api/subscription/webData3.js.map +1 -0
  201. package/esm/src/api/subscription/~client.d.ts +44 -0
  202. package/esm/src/api/subscription/~client.d.ts.map +1 -1
  203. package/esm/src/api/subscription/~client.js +46 -0
  204. package/esm/src/api/subscription/~client.js.map +1 -1
  205. package/esm/src/api/subscription/~mod.d.ts +2 -0
  206. package/esm/src/api/subscription/~mod.d.ts.map +1 -1
  207. package/esm/src/api/subscription/~mod.js +2 -0
  208. package/esm/src/api/subscription/~mod.js.map +1 -1
  209. package/esm/src/signing/_signTypedData.d.ts +1 -1
  210. package/esm/src/signing/_signTypedData.d.ts.map +1 -1
  211. package/esm/src/signing/_signTypedData.js +1 -1
  212. package/esm/src/signing/_signTypedData.js.map +1 -1
  213. package/esm/src/utils/{_minimalEIP712Signer.d.ts → _eip712.d.ts} +16 -1
  214. package/esm/src/utils/_eip712.d.ts.map +1 -0
  215. package/esm/src/utils/{_minimalEIP712Signer.js → _eip712.js} +14 -11
  216. package/esm/src/utils/_eip712.js.map +1 -0
  217. package/esm/src/utils/_format.d.ts +28 -0
  218. package/esm/src/utils/_format.d.ts.map +1 -0
  219. package/esm/src/utils/_format.js +157 -0
  220. package/esm/src/utils/_format.js.map +1 -0
  221. package/esm/src/utils/_recover.d.ts +89 -0
  222. package/esm/src/utils/_recover.d.ts.map +1 -0
  223. package/esm/src/utils/_recover.js +119 -0
  224. package/esm/src/utils/_recover.js.map +1 -0
  225. package/esm/src/utils/_symbolConverter.d.ts +13 -0
  226. package/esm/src/utils/_symbolConverter.d.ts.map +1 -1
  227. package/esm/src/utils/_symbolConverter.js +17 -0
  228. package/esm/src/utils/_symbolConverter.js.map +1 -1
  229. package/esm/src/utils/mod.d.ts +2 -0
  230. package/esm/src/utils/mod.d.ts.map +1 -1
  231. package/esm/src/utils/mod.js +2 -0
  232. package/esm/src/utils/mod.js.map +1 -1
  233. package/package.json +3 -2
  234. package/script/bin/cli.js +1 -0
  235. package/script/bin/cli.js.map +1 -1
  236. package/script/src/api/_common_schemas.d.ts +19 -0
  237. package/script/src/api/_common_schemas.d.ts.map +1 -1
  238. package/script/src/api/_common_schemas.js +16 -1
  239. package/script/src/api/_common_schemas.js.map +1 -1
  240. package/script/src/api/exchange/_base/_execute.d.ts +6 -7
  241. package/script/src/api/exchange/_base/_execute.d.ts.map +1 -1
  242. package/script/src/api/exchange/_base/_execute.js +67 -43
  243. package/script/src/api/exchange/_base/_execute.js.map +1 -1
  244. package/script/src/api/exchange/_base/_types.d.ts +0 -7
  245. package/script/src/api/exchange/_base/_types.d.ts.map +1 -1
  246. package/script/src/api/exchange/_base/mod.d.ts +0 -2
  247. package/script/src/api/exchange/_base/mod.d.ts.map +1 -1
  248. package/script/src/api/exchange/_base/mod.js +0 -2
  249. package/script/src/api/exchange/_base/mod.js.map +1 -1
  250. package/script/src/api/exchange/agentEnableDexAbstraction.d.ts.map +1 -1
  251. package/script/src/api/exchange/agentEnableDexAbstraction.js +14 -7
  252. package/script/src/api/exchange/agentEnableDexAbstraction.js.map +1 -1
  253. package/script/src/api/exchange/approveAgent.d.ts.map +1 -1
  254. package/script/src/api/exchange/approveAgent.js +15 -7
  255. package/script/src/api/exchange/approveAgent.js.map +1 -1
  256. package/script/src/api/exchange/approveBuilderFee.d.ts.map +1 -1
  257. package/script/src/api/exchange/approveBuilderFee.js +15 -7
  258. package/script/src/api/exchange/approveBuilderFee.js.map +1 -1
  259. package/script/src/api/exchange/batchModify.d.ts.map +1 -1
  260. package/script/src/api/exchange/batchModify.js +16 -10
  261. package/script/src/api/exchange/batchModify.js.map +1 -1
  262. package/script/src/api/exchange/cDeposit.d.ts.map +1 -1
  263. package/script/src/api/exchange/cDeposit.js +15 -7
  264. package/script/src/api/exchange/cDeposit.js.map +1 -1
  265. package/script/src/api/exchange/cSignerAction.d.ts.map +1 -1
  266. package/script/src/api/exchange/cSignerAction.js +15 -8
  267. package/script/src/api/exchange/cSignerAction.js.map +1 -1
  268. package/script/src/api/exchange/cValidatorAction.d.ts.map +1 -1
  269. package/script/src/api/exchange/cValidatorAction.js +15 -8
  270. package/script/src/api/exchange/cValidatorAction.js.map +1 -1
  271. package/script/src/api/exchange/cWithdraw.d.ts.map +1 -1
  272. package/script/src/api/exchange/cWithdraw.js +15 -7
  273. package/script/src/api/exchange/cWithdraw.js.map +1 -1
  274. package/script/src/api/exchange/cancel.d.ts.map +1 -1
  275. package/script/src/api/exchange/cancel.js +16 -10
  276. package/script/src/api/exchange/cancel.js.map +1 -1
  277. package/script/src/api/exchange/cancelByCloid.d.ts.map +1 -1
  278. package/script/src/api/exchange/cancelByCloid.js +16 -10
  279. package/script/src/api/exchange/cancelByCloid.js.map +1 -1
  280. package/script/src/api/exchange/claimRewards.d.ts.map +1 -1
  281. package/script/src/api/exchange/claimRewards.js +14 -7
  282. package/script/src/api/exchange/claimRewards.js.map +1 -1
  283. package/script/src/api/exchange/convertToMultiSigUser.d.ts.map +1 -1
  284. package/script/src/api/exchange/convertToMultiSigUser.js +15 -7
  285. package/script/src/api/exchange/convertToMultiSigUser.js.map +1 -1
  286. package/script/src/api/exchange/createSubAccount.d.ts.map +1 -1
  287. package/script/src/api/exchange/createSubAccount.js +15 -8
  288. package/script/src/api/exchange/createSubAccount.js.map +1 -1
  289. package/script/src/api/exchange/createVault.d.ts.map +1 -1
  290. package/script/src/api/exchange/createVault.js +15 -8
  291. package/script/src/api/exchange/createVault.js.map +1 -1
  292. package/script/src/api/exchange/evmUserModify.d.ts +1 -1
  293. package/script/src/api/exchange/evmUserModify.d.ts.map +1 -1
  294. package/script/src/api/exchange/evmUserModify.js +16 -9
  295. package/script/src/api/exchange/evmUserModify.js.map +1 -1
  296. package/script/src/api/exchange/linkStakingUser.d.ts +112 -0
  297. package/script/src/api/exchange/linkStakingUser.d.ts.map +1 -0
  298. package/script/src/api/exchange/linkStakingUser.js +136 -0
  299. package/script/src/api/exchange/linkStakingUser.js.map +1 -0
  300. package/script/src/api/exchange/modify.d.ts.map +1 -1
  301. package/script/src/api/exchange/modify.js +16 -10
  302. package/script/src/api/exchange/modify.js.map +1 -1
  303. package/script/src/api/exchange/multiSig.d.ts.map +1 -1
  304. package/script/src/api/exchange/multiSig.js +17 -16
  305. package/script/src/api/exchange/multiSig.js.map +1 -1
  306. package/script/src/api/exchange/noop.d.ts.map +1 -1
  307. package/script/src/api/exchange/noop.js +14 -7
  308. package/script/src/api/exchange/noop.js.map +1 -1
  309. package/script/src/api/exchange/order.d.ts.map +1 -1
  310. package/script/src/api/exchange/order.js +16 -10
  311. package/script/src/api/exchange/order.js.map +1 -1
  312. package/script/src/api/exchange/perpDeploy.d.ts.map +1 -1
  313. package/script/src/api/exchange/perpDeploy.js +15 -8
  314. package/script/src/api/exchange/perpDeploy.js.map +1 -1
  315. package/script/src/api/exchange/registerReferrer.d.ts.map +1 -1
  316. package/script/src/api/exchange/registerReferrer.js +15 -8
  317. package/script/src/api/exchange/registerReferrer.js.map +1 -1
  318. package/script/src/api/exchange/reserveRequestWeight.d.ts.map +1 -1
  319. package/script/src/api/exchange/reserveRequestWeight.js +15 -8
  320. package/script/src/api/exchange/reserveRequestWeight.js.map +1 -1
  321. package/script/src/api/exchange/scheduleCancel.js +16 -10
  322. package/script/src/api/exchange/scheduleCancel.js.map +1 -1
  323. package/script/src/api/exchange/sendAsset.d.ts.map +1 -1
  324. package/script/src/api/exchange/sendAsset.js +15 -7
  325. package/script/src/api/exchange/sendAsset.js.map +1 -1
  326. package/script/src/api/exchange/setDisplayName.d.ts.map +1 -1
  327. package/script/src/api/exchange/setDisplayName.js +15 -8
  328. package/script/src/api/exchange/setDisplayName.js.map +1 -1
  329. package/script/src/api/exchange/setReferrer.d.ts.map +1 -1
  330. package/script/src/api/exchange/setReferrer.js +15 -8
  331. package/script/src/api/exchange/setReferrer.js.map +1 -1
  332. package/script/src/api/exchange/spotDeploy.d.ts.map +1 -1
  333. package/script/src/api/exchange/spotDeploy.js +15 -8
  334. package/script/src/api/exchange/spotDeploy.js.map +1 -1
  335. package/script/src/api/exchange/spotSend.d.ts.map +1 -1
  336. package/script/src/api/exchange/spotSend.js +15 -7
  337. package/script/src/api/exchange/spotSend.js.map +1 -1
  338. package/script/src/api/exchange/spotUser.d.ts.map +1 -1
  339. package/script/src/api/exchange/spotUser.js +15 -8
  340. package/script/src/api/exchange/spotUser.js.map +1 -1
  341. package/script/src/api/exchange/subAccountModify.d.ts.map +1 -1
  342. package/script/src/api/exchange/subAccountModify.js +15 -8
  343. package/script/src/api/exchange/subAccountModify.js.map +1 -1
  344. package/script/src/api/exchange/subAccountSpotTransfer.d.ts.map +1 -1
  345. package/script/src/api/exchange/subAccountSpotTransfer.js +15 -8
  346. package/script/src/api/exchange/subAccountSpotTransfer.js.map +1 -1
  347. package/script/src/api/exchange/subAccountTransfer.d.ts.map +1 -1
  348. package/script/src/api/exchange/subAccountTransfer.js +15 -8
  349. package/script/src/api/exchange/subAccountTransfer.js.map +1 -1
  350. package/script/src/api/exchange/tokenDelegate.d.ts.map +1 -1
  351. package/script/src/api/exchange/tokenDelegate.js +15 -7
  352. package/script/src/api/exchange/tokenDelegate.js.map +1 -1
  353. package/script/src/api/exchange/twapCancel.d.ts.map +1 -1
  354. package/script/src/api/exchange/twapCancel.js +16 -10
  355. package/script/src/api/exchange/twapCancel.js.map +1 -1
  356. package/script/src/api/exchange/twapOrder.d.ts.map +1 -1
  357. package/script/src/api/exchange/twapOrder.js +16 -10
  358. package/script/src/api/exchange/twapOrder.js.map +1 -1
  359. package/script/src/api/exchange/updateIsolatedMargin.d.ts.map +1 -1
  360. package/script/src/api/exchange/updateIsolatedMargin.js +16 -10
  361. package/script/src/api/exchange/updateIsolatedMargin.js.map +1 -1
  362. package/script/src/api/exchange/updateLeverage.d.ts.map +1 -1
  363. package/script/src/api/exchange/updateLeverage.js +16 -10
  364. package/script/src/api/exchange/updateLeverage.js.map +1 -1
  365. package/script/src/api/exchange/usdClassTransfer.d.ts.map +1 -1
  366. package/script/src/api/exchange/usdClassTransfer.js +15 -7
  367. package/script/src/api/exchange/usdClassTransfer.js.map +1 -1
  368. package/script/src/api/exchange/usdSend.d.ts.map +1 -1
  369. package/script/src/api/exchange/usdSend.js +15 -7
  370. package/script/src/api/exchange/usdSend.js.map +1 -1
  371. package/script/src/api/exchange/userDexAbstraction.d.ts.map +1 -1
  372. package/script/src/api/exchange/userDexAbstraction.js +15 -7
  373. package/script/src/api/exchange/userDexAbstraction.js.map +1 -1
  374. package/script/src/api/exchange/vaultDistribute.d.ts.map +1 -1
  375. package/script/src/api/exchange/vaultDistribute.js +15 -8
  376. package/script/src/api/exchange/vaultDistribute.js.map +1 -1
  377. package/script/src/api/exchange/vaultModify.d.ts.map +1 -1
  378. package/script/src/api/exchange/vaultModify.js +15 -8
  379. package/script/src/api/exchange/vaultModify.js.map +1 -1
  380. package/script/src/api/exchange/vaultTransfer.d.ts.map +1 -1
  381. package/script/src/api/exchange/vaultTransfer.js +15 -8
  382. package/script/src/api/exchange/vaultTransfer.js.map +1 -1
  383. package/script/src/api/exchange/withdraw3.d.ts.map +1 -1
  384. package/script/src/api/exchange/withdraw3.js +15 -7
  385. package/script/src/api/exchange/withdraw3.js.map +1 -1
  386. package/script/src/api/exchange/~client.d.ts +31 -3
  387. package/script/src/api/exchange/~client.d.ts.map +1 -1
  388. package/script/src/api/exchange/~client.js +29 -6
  389. package/script/src/api/exchange/~client.js.map +1 -1
  390. package/script/src/api/exchange/~mod.d.ts +1 -0
  391. package/script/src/api/exchange/~mod.d.ts.map +1 -1
  392. package/script/src/api/exchange/~mod.js +1 -0
  393. package/script/src/api/exchange/~mod.js.map +1 -1
  394. package/script/src/api/info/allPerpMetas.d.ts +5 -0
  395. package/script/src/api/info/allPerpMetas.d.ts.map +1 -1
  396. package/script/src/api/info/meta.d.ts +5 -0
  397. package/script/src/api/info/meta.d.ts.map +1 -1
  398. package/script/src/api/info/meta.js +2 -0
  399. package/script/src/api/info/meta.js.map +1 -1
  400. package/script/src/api/info/metaAndAssetCtxs.d.ts +5 -0
  401. package/script/src/api/info/metaAndAssetCtxs.d.ts.map +1 -1
  402. package/script/src/api/info/perpDexs.d.ts +4 -0
  403. package/script/src/api/info/perpDexs.d.ts.map +1 -1
  404. package/script/src/api/info/perpDexs.js +5 -0
  405. package/script/src/api/info/perpDexs.js.map +1 -1
  406. package/script/src/api/info/spotClearinghouseState.d.ts +0 -5
  407. package/script/src/api/info/spotClearinghouseState.d.ts.map +1 -1
  408. package/script/src/api/info/spotClearinghouseState.js +2 -14
  409. package/script/src/api/info/spotClearinghouseState.js.map +1 -1
  410. package/script/src/api/info/userFees.d.ts +27 -2
  411. package/script/src/api/info/userFees.d.ts.map +1 -1
  412. package/script/src/api/info/userFees.js +29 -1
  413. package/script/src/api/info/userFees.js.map +1 -1
  414. package/script/src/api/info/webData2.d.ts +152 -23
  415. package/script/src/api/info/webData2.d.ts.map +1 -1
  416. package/script/src/api/info/webData2.js +2 -53
  417. package/script/src/api/info/webData2.js.map +1 -1
  418. package/script/src/api/info/~client.d.ts +11 -3
  419. package/script/src/api/info/~client.d.ts.map +1 -1
  420. package/script/src/api/subscription/spotState.d.ts +91 -0
  421. package/script/src/api/subscription/spotState.d.ts.map +1 -0
  422. package/script/src/api/subscription/spotState.js +95 -0
  423. package/script/src/api/subscription/spotState.js.map +1 -0
  424. package/script/src/api/subscription/webData2.d.ts +9 -4
  425. package/script/src/api/subscription/webData2.d.ts.map +1 -1
  426. package/script/src/api/subscription/webData2.js +1 -1
  427. package/script/src/api/subscription/webData2.js.map +1 -1
  428. package/script/src/api/subscription/webData3.d.ts +541 -0
  429. package/script/src/api/subscription/webData3.d.ts.map +1 -0
  430. package/script/src/api/subscription/webData3.js +131 -0
  431. package/script/src/api/subscription/webData3.js.map +1 -0
  432. package/script/src/api/subscription/~client.d.ts +44 -0
  433. package/script/src/api/subscription/~client.d.ts.map +1 -1
  434. package/script/src/api/subscription/~client.js +46 -0
  435. package/script/src/api/subscription/~client.js.map +1 -1
  436. package/script/src/api/subscription/~mod.d.ts +2 -0
  437. package/script/src/api/subscription/~mod.d.ts.map +1 -1
  438. package/script/src/api/subscription/~mod.js +2 -0
  439. package/script/src/api/subscription/~mod.js.map +1 -1
  440. package/script/src/signing/_signTypedData.d.ts +1 -1
  441. package/script/src/signing/_signTypedData.d.ts.map +1 -1
  442. package/script/src/signing/_signTypedData.js +1 -1
  443. package/script/src/signing/_signTypedData.js.map +1 -1
  444. package/script/src/utils/{_minimalEIP712Signer.d.ts → _eip712.d.ts} +16 -1
  445. package/script/src/utils/_eip712.d.ts.map +1 -0
  446. package/script/src/utils/{_minimalEIP712Signer.js → _eip712.js} +14 -9
  447. package/script/src/utils/_eip712.js.map +1 -0
  448. package/script/src/utils/_format.d.ts +28 -0
  449. package/script/src/utils/_format.d.ts.map +1 -0
  450. package/script/src/utils/_format.js +161 -0
  451. package/script/src/utils/_format.js.map +1 -0
  452. package/script/src/utils/_recover.d.ts +89 -0
  453. package/script/src/utils/_recover.d.ts.map +1 -0
  454. package/script/src/utils/_recover.js +156 -0
  455. package/script/src/utils/_recover.js.map +1 -0
  456. package/script/src/utils/_symbolConverter.d.ts +13 -0
  457. package/script/src/utils/_symbolConverter.d.ts.map +1 -1
  458. package/script/src/utils/_symbolConverter.js +17 -0
  459. package/script/src/utils/_symbolConverter.js.map +1 -1
  460. package/script/src/utils/mod.d.ts +2 -0
  461. package/script/src/utils/mod.d.ts.map +1 -1
  462. package/script/src/utils/mod.js +2 -0
  463. package/script/src/utils/mod.js.map +1 -1
  464. package/src/bin/cli.ts +1 -0
  465. package/src/src/api/_common_schemas.ts +34 -0
  466. package/src/src/api/exchange/_base/_execute.ts +73 -49
  467. package/src/src/api/exchange/_base/_types.ts +0 -7
  468. package/src/src/api/exchange/_base/mod.ts +0 -2
  469. package/src/src/api/exchange/agentEnableDexAbstraction.ts +14 -9
  470. package/src/src/api/exchange/approveAgent.ts +15 -12
  471. package/src/src/api/exchange/approveBuilderFee.ts +15 -12
  472. package/src/src/api/exchange/batchModify.ts +16 -13
  473. package/src/src/api/exchange/cDeposit.ts +15 -12
  474. package/src/src/api/exchange/cSignerAction.ts +15 -10
  475. package/src/src/api/exchange/cValidatorAction.ts +15 -10
  476. package/src/src/api/exchange/cWithdraw.ts +15 -12
  477. package/src/src/api/exchange/cancel.ts +16 -13
  478. package/src/src/api/exchange/cancelByCloid.ts +16 -13
  479. package/src/src/api/exchange/claimRewards.ts +14 -9
  480. package/src/src/api/exchange/convertToMultiSigUser.ts +15 -12
  481. package/src/src/api/exchange/createSubAccount.ts +15 -10
  482. package/src/src/api/exchange/createVault.ts +15 -10
  483. package/src/src/api/exchange/evmUserModify.ts +16 -11
  484. package/src/src/api/exchange/linkStakingUser.ts +157 -0
  485. package/src/src/api/exchange/modify.ts +16 -13
  486. package/src/src/api/exchange/multiSig.ts +17 -23
  487. package/src/src/api/exchange/noop.ts +14 -9
  488. package/src/src/api/exchange/order.ts +16 -13
  489. package/src/src/api/exchange/perpDeploy.ts +15 -10
  490. package/src/src/api/exchange/registerReferrer.ts +15 -10
  491. package/src/src/api/exchange/reserveRequestWeight.ts +15 -10
  492. package/src/src/api/exchange/scheduleCancel.ts +16 -13
  493. package/src/src/api/exchange/sendAsset.ts +15 -12
  494. package/src/src/api/exchange/setDisplayName.ts +15 -10
  495. package/src/src/api/exchange/setReferrer.ts +15 -10
  496. package/src/src/api/exchange/spotDeploy.ts +15 -10
  497. package/src/src/api/exchange/spotSend.ts +15 -12
  498. package/src/src/api/exchange/spotUser.ts +15 -10
  499. package/src/src/api/exchange/subAccountModify.ts +15 -10
  500. package/src/src/api/exchange/subAccountSpotTransfer.ts +15 -10
  501. package/src/src/api/exchange/subAccountTransfer.ts +15 -10
  502. package/src/src/api/exchange/tokenDelegate.ts +15 -12
  503. package/src/src/api/exchange/twapCancel.ts +16 -13
  504. package/src/src/api/exchange/twapOrder.ts +16 -13
  505. package/src/src/api/exchange/updateIsolatedMargin.ts +16 -13
  506. package/src/src/api/exchange/updateLeverage.ts +16 -13
  507. package/src/src/api/exchange/usdClassTransfer.ts +15 -12
  508. package/src/src/api/exchange/usdSend.ts +15 -12
  509. package/src/src/api/exchange/userDexAbstraction.ts +15 -12
  510. package/src/src/api/exchange/vaultDistribute.ts +15 -10
  511. package/src/src/api/exchange/vaultModify.ts +15 -10
  512. package/src/src/api/exchange/vaultTransfer.ts +15 -10
  513. package/src/src/api/exchange/withdraw3.ts +15 -12
  514. package/src/src/api/exchange/~client.ts +30 -5
  515. package/src/src/api/exchange/~mod.ts +1 -0
  516. package/src/src/api/info/meta.ts +7 -0
  517. package/src/src/api/info/perpDexs.ts +10 -0
  518. package/src/src/api/info/spotClearinghouseState.ts +3 -33
  519. package/src/src/api/info/userFees.ts +46 -1
  520. package/src/src/api/info/webData2.ts +3 -104
  521. package/src/src/api/subscription/spotState.ts +96 -0
  522. package/src/src/api/subscription/webData2.ts +1 -1
  523. package/src/src/api/subscription/webData3.ts +179 -0
  524. package/src/src/api/subscription/~client.ts +50 -0
  525. package/src/src/api/subscription/~mod.ts +2 -0
  526. package/src/src/signing/_signTypedData.ts +1 -1
  527. package/src/src/utils/{_minimalEIP712Signer.ts → _eip712.ts} +22 -29
  528. package/src/src/utils/_format.ts +173 -0
  529. package/src/src/utils/_recover.ts +178 -0
  530. package/src/src/utils/_symbolConverter.ts +18 -0
  531. package/src/src/utils/mod.ts +2 -0
  532. package/esm/src/api/exchange/_base/_sequential.d.ts +0 -30
  533. package/esm/src/api/exchange/_base/_sequential.d.ts.map +0 -1
  534. package/esm/src/api/exchange/_base/_sequential.js +0 -69
  535. package/esm/src/api/exchange/_base/_sequential.js.map +0 -1
  536. package/esm/src/utils/_minimalEIP712Signer.d.ts.map +0 -1
  537. package/esm/src/utils/_minimalEIP712Signer.js.map +0 -1
  538. package/script/src/api/exchange/_base/_sequential.d.ts +0 -30
  539. package/script/src/api/exchange/_base/_sequential.d.ts.map +0 -1
  540. package/script/src/api/exchange/_base/_sequential.js +0 -72
  541. package/script/src/api/exchange/_base/_sequential.js.map +0 -1
  542. package/script/src/utils/_minimalEIP712Signer.d.ts.map +0 -1
  543. package/script/src/utils/_minimalEIP712Signer.js.map +0 -1
  544. package/src/src/api/exchange/_base/_sequential.ts +0 -82
@@ -6,7 +6,6 @@ import {
6
6
  type ExtractRequestAction,
7
7
  type ExtractRequestOptions,
8
8
  getSignatureChainId,
9
- globalNonceManager,
10
9
  type MultiSignRequestConfig,
11
10
  Signature,
12
11
  } from "./_base/mod.js";
@@ -123,16 +122,20 @@ export async function withdraw3(
123
122
  params: DeepImmutable<Withdraw3Parameters>,
124
123
  opts?: Withdraw3Options,
125
124
  ): Promise<SuccessResponse> {
126
- const action = parser(Withdraw3Request.entries.action)({
127
- type: "withdraw3",
128
- hyperliquidChain: config.transport.isTestnet ? "Testnet" : "Mainnet",
129
- signatureChainId: await getSignatureChainId(config),
130
- time: globalNonceManager.getNonce(),
131
- ...params,
125
+ const request = parser(Withdraw3Request)({
126
+ action: {
127
+ type: "withdraw3",
128
+ hyperliquidChain: config.transport.isTestnet ? "Testnet" : "Mainnet",
129
+ signatureChainId: await getSignatureChainId(config),
130
+ time: 0, // Placeholder; actual nonce generated in `executeUserSignedAction` to prevent race conditions
131
+ ...params,
132
+ },
133
+ nonce: 0, // Placeholder; actual nonce generated in `executeUserSignedAction` to prevent race conditions
134
+ signature: { // Placeholder; actual signature generated in `executeUserSignedAction`
135
+ r: "0x0000000000000000000000000000000000000000000000000000000000000000",
136
+ s: "0x0000000000000000000000000000000000000000000000000000000000000000",
137
+ v: 27,
138
+ },
132
139
  });
133
- return await executeUserSignedAction(
134
- config,
135
- { action, types: Withdraw3Types },
136
- opts?.signal,
137
- );
140
+ return await executeUserSignedAction(config, request, Withdraw3Types, opts?.signal);
138
141
  }
@@ -2,7 +2,7 @@ import type { MaybePromise, OmitFirst, OverloadedParameters } from "../_base.js"
2
2
  import type { ExchangeRequestConfig, MultiSignRequestConfig } from "./_base/mod.js";
3
3
  import type { IRequestTransport } from "../../transport/base.js";
4
4
  import type { AbstractWallet } from "../../signing/mod.js";
5
- import { PrivateKeyEIP712Signer } from "../../utils/_minimalEIP712Signer.js";
5
+ import { PrivateKeyEIP712Signer } from "../../utils/_eip712.js";
6
6
 
7
7
  import { agentEnableDexAbstraction } from "./agentEnableDexAbstraction.js";
8
8
  import { approveAgent } from "./approveAgent.js";
@@ -19,6 +19,7 @@ import { cSignerAction } from "./cSignerAction.js";
19
19
  import { cValidatorAction } from "./cValidatorAction.js";
20
20
  import { cWithdraw } from "./cWithdraw.js";
21
21
  import { evmUserModify } from "./evmUserModify.js";
22
+ import { linkStakingUser } from "./linkStakingUser.js";
22
23
  import { modify } from "./modify.js";
23
24
  import { multiSig } from "./multiSig.js";
24
25
  import { order } from "./order.js";
@@ -64,6 +65,7 @@ export type { CSignerActionOptions, CSignerActionParameters } from "./cSignerAct
64
65
  export type { CValidatorActionOptions, CValidatorActionParameters } from "./cValidatorAction.js";
65
66
  export type { CWithdrawOptions, CWithdrawParameters } from "./cWithdraw.js";
66
67
  export type { EvmUserModifyOptions, EvmUserModifyParameters } from "./evmUserModify.js";
68
+ export type { LinkStakingUserOptions, LinkStakingUserParameters } from "./linkStakingUser.js";
67
69
  export type { ModifyOptions, ModifyParameters } from "./modify.js";
68
70
  export type { MultiSigOptions, MultiSigParameters } from "./multiSig.js";
69
71
  export type { OrderOptions, OrderParameters } from "./order.js";
@@ -118,7 +120,6 @@ export class ExchangeClient<
118
120
  signatureChainId?: string | (() => MaybePromise<string>);
119
121
  defaultVaultAddress?: string;
120
122
  defaultExpiresAfter?: number | (() => MaybePromise<number>);
121
- sequentialRequests?: boolean;
122
123
 
123
124
  /**
124
125
  * Initialises a new instance.
@@ -181,7 +182,6 @@ export class ExchangeClient<
181
182
  this.defaultVaultAddress = args.defaultVaultAddress;
182
183
  this.defaultExpiresAfter = args.defaultExpiresAfter;
183
184
  this.signatureChainId = args.signatureChainId;
184
- this.sequentialRequests = args.sequentialRequests;
185
185
  }
186
186
 
187
187
  /**
@@ -609,7 +609,7 @@ export class ExchangeClient<
609
609
  * Configure block type for EVM transactions.
610
610
  * @param params - Parameters specific to the API request.
611
611
  * @param opts - Request execution options.
612
- * @returns Response for creating a sub-account.
612
+ * @returns Successful response without specific data.
613
613
  *
614
614
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
615
615
  * @throws {TransportError} When the transport layer throws an error.
@@ -630,6 +630,31 @@ export class ExchangeClient<
630
630
  return evmUserModify(this, ...args);
631
631
  }
632
632
 
633
+ /**
634
+ * Link staking and trading accounts for fee discount attribution.
635
+ * @param params - Parameters specific to the API request.
636
+ * @param opts - Request execution options.
637
+ * @returns Successful response without specific data.
638
+ *
639
+ * @throws {ApiRequestError} When the API returns an unsuccessful response.
640
+ * @throws {TransportError} When the transport layer throws an error.
641
+ *
642
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/trading/fees#staking-linking
643
+ * @example
644
+ * ```ts
645
+ * import * as hl from "@nktkas/hyperliquid";
646
+ *
647
+ * const pk = "0x..."; // viem, ethers or private key
648
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
649
+ *
650
+ * const client = new hl.ExchangeClient({ transport, wallet: pk });
651
+ * await client.linkStakingUser({ user: "0x...", isFinalize: false });
652
+ * ```
653
+ */
654
+ linkStakingUser(...args: OmitFirst<OverloadedParameters<typeof linkStakingUser>>) {
655
+ return linkStakingUser(this, ...args);
656
+ }
657
+
633
658
  /**
634
659
  * Modify an order.
635
660
  * @param params - Parameters specific to the API request.
@@ -1492,7 +1517,7 @@ export class MultiSignClient<
1492
1517
  /**
1493
1518
  * @note Is the first wallet from {@linkcode signers}. Changing the property also changes the first element in the {@linkcode signers} array.
1494
1519
  */
1495
- declare readonly wallet: S[0];
1520
+ declare wallet: S[0];
1496
1521
 
1497
1522
  /**
1498
1523
  * Initialises a new multi-signature client instance.
@@ -55,6 +55,7 @@ export * from "./cSignerAction.js";
55
55
  export * from "./cValidatorAction.js";
56
56
  export * from "./cWithdraw.js";
57
57
  export * from "./evmUserModify.js";
58
+ export * from "./linkStakingUser.js";
58
59
  export * from "./modify.js";
59
60
  export * from "./multiSig.js";
60
61
  export * from "./order.js";
@@ -73,6 +73,13 @@ export const MetaResponse = /* @__PURE__ */ (() => {
73
73
  v.optional(v.literal(true)),
74
74
  v.description("Indicates if the universe is delisted."),
75
75
  ),
76
+ /** Trading margin mode constraint. */
77
+ marginMode: v.pipe(
78
+ v.optional(
79
+ v.union([v.literal("strictIsolated"), v.literal("noCross")]),
80
+ ),
81
+ v.description("Trading margin mode constraint."),
82
+ ),
76
83
  }),
77
84
  v.description("Trading universe parameters for perpetual asset."),
78
85
  ),
@@ -63,6 +63,16 @@ export const PerpDexsResponse = /* @__PURE__ */ (() => {
63
63
  v.array(v.tuple([v.string(), v.string()])),
64
64
  v.description("Mapping of asset names to their streaming open interest caps."),
65
65
  ),
66
+ /** List of delegated function names and their authorized executor addresses. */
67
+ subDeployers: v.pipe(
68
+ v.array(
69
+ v.tuple([
70
+ v.string(),
71
+ v.array(Address),
72
+ ]),
73
+ ),
74
+ v.description("List of delegated function names and their authorized executor addresses."),
75
+ ),
66
76
  }),
67
77
  v.description(" Perpetual dex metadata."),
68
78
  ),
@@ -2,6 +2,8 @@ import * as v from "valibot";
2
2
  import { Address, type DeepImmutable, parser, UnsignedDecimal, UnsignedInteger } from "../_base.js";
3
3
  import type { InfoRequestConfig } from "./_types.js";
4
4
 
5
+ import { BalanceSchema } from "../_common_schemas.js";
6
+
5
7
  // -------------------- Schemas --------------------
6
8
 
7
9
  /**
@@ -41,39 +43,7 @@ export const SpotClearinghouseStateResponse = /* @__PURE__ */ (() => {
41
43
  v.object({
42
44
  /** Balance for each token. */
43
45
  balances: v.pipe(
44
- v.array(
45
- /** Balance for a specific spot token. */
46
- v.pipe(
47
- v.object({
48
- /** Asset symbol. */
49
- coin: v.pipe(
50
- v.string(),
51
- v.description("Asset symbol."),
52
- ),
53
- /** Unique identifier for the token. */
54
- token: v.pipe(
55
- UnsignedInteger,
56
- v.description("Unique identifier for the token."),
57
- ),
58
- /** Total balance. */
59
- total: v.pipe(
60
- UnsignedDecimal,
61
- v.description("Total balance."),
62
- ),
63
- /** Amount on hold. */
64
- hold: v.pipe(
65
- UnsignedDecimal,
66
- v.description("Amount on hold."),
67
- ),
68
- /** Entry notional value. */
69
- entryNtl: v.pipe(
70
- UnsignedDecimal,
71
- v.description("Entry notional value."),
72
- ),
73
- }),
74
- v.description("Balance for a specific spot token."),
75
- ),
76
- ),
46
+ v.array(BalanceSchema),
77
47
  v.description("Balance for each token."),
78
48
  ),
79
49
  /** Escrowed balances. */
@@ -225,7 +225,52 @@ export const UserFeesResponse = /* @__PURE__ */ (() => {
225
225
  v.nullable(v.unknown()),
226
226
  v.description("Timestamp when next trial becomes available."),
227
227
  ),
228
- stakingLink: v.nullable(v.unknown()),
228
+ /**
229
+ * Permanent link between staking and trading accounts.
230
+ * Staking user gains full control of trading account funds.
231
+ * Staking user forfeits own fee discounts.
232
+ */
233
+ stakingLink: v.pipe(
234
+ v.nullable(
235
+ v.object({
236
+ /**
237
+ * Linked account address:
238
+ * - When queried by staking account: contains trading account address.
239
+ * - When queried by trading account: contains staking account address.
240
+ */
241
+ stakingUser: v.pipe(
242
+ Address,
243
+ v.description(
244
+ "Linked account address:" +
245
+ "\n- When queried by staking account: contains trading account address." +
246
+ "\n- When queried by trading account: contains staking account address.",
247
+ ),
248
+ ),
249
+ /**
250
+ * Link status:
251
+ * - `requested` = link initiated by trading user, awaiting staking user confirmation.
252
+ * - `stakingUser` = response queried by staking account.
253
+ * - `tradingUser` = response queried by trading account.
254
+ */
255
+ type: v.pipe(
256
+ v.union([
257
+ v.literal("requested"),
258
+ v.literal("stakingUser"),
259
+ v.literal("tradingUser"),
260
+ ]),
261
+ v.description(
262
+ "Link status:" +
263
+ "\n- `requested` = link initiated by trading user, awaiting staking user confirmation" +
264
+ "\n- `stakingUser` = response queried by staking account" +
265
+ "\n- `tradingUser` = response queried by trading account",
266
+ ),
267
+ ),
268
+ }),
269
+ ),
270
+ v.description(
271
+ "Permanent link between staking and trading accounts. Staking user gains full control of trading account funds. Staking user forfeits own fee discounts.",
272
+ ),
273
+ ),
229
274
  /** Active staking discount details. */
230
275
  activeStakingDiscount: v.pipe(
231
276
  v.object({
@@ -1,12 +1,8 @@
1
1
  import * as v from "valibot";
2
- import { Address, type DeepImmutable, parser, UnsignedDecimal, UnsignedInteger } from "../_base.js";
2
+ import { Address, type DeepImmutable, parser } from "../_base.js";
3
3
  import type { InfoRequestConfig } from "./_types.js";
4
4
 
5
- import { DetailedOrderSchema, TwapStateSchema } from "../_common_schemas.js";
6
- import { MetaAndAssetCtxsResponse } from "./metaAndAssetCtxs.js";
7
- import { ClearinghouseStateResponse } from "./clearinghouseState.js";
8
- import { SpotClearinghouseStateResponse } from "./spotClearinghouseState.js";
9
- import { SpotMetaAndAssetCtxsResponse } from "./spotMetaAndAssetCtxs.js";
5
+ import { WebData2Event } from "../subscription/webData2.js";
10
6
 
11
7
  // -------------------- Schemas --------------------
12
8
 
@@ -39,104 +35,7 @@ export type WebData2Request = v.InferOutput<typeof WebData2Request>;
39
35
  */
40
36
  export const WebData2Response = /* @__PURE__ */ (() => {
41
37
  return v.pipe(
42
- v.object({
43
- /** Account summary for perpetual trading. */
44
- clearinghouseState: ClearinghouseStateResponse,
45
- /** Array of leading vaults. */
46
- leadingVaults: v.pipe(
47
- v.array(
48
- /** Vault that a user is leading. */
49
- v.pipe(
50
- v.object({
51
- /** Address of the vault. */
52
- address: v.pipe(
53
- Address,
54
- v.description("Address of the vault."),
55
- ),
56
- /** Name of the vault. */
57
- name: v.pipe(
58
- v.string(),
59
- v.description("Name of the vault."),
60
- ),
61
- }),
62
- v.description("Vault that a user is leading."),
63
- ),
64
- ),
65
- v.description("Array of leading vaults."),
66
- ),
67
- /** Total equity in vaults. */
68
- totalVaultEquity: v.pipe(
69
- UnsignedDecimal,
70
- v.description("Total equity in vaults."),
71
- ),
72
- /** Array of user open orders with frontend information. */
73
- openOrders: v.pipe(
74
- v.array(DetailedOrderSchema),
75
- v.description("User open orders with frontend information."),
76
- ),
77
- /** Agent address if one exists. */
78
- agentAddress: v.pipe(
79
- v.nullable(Address),
80
- v.description("Agent address if one exists."),
81
- ),
82
- /** Timestamp until which the agent is valid. */
83
- agentValidUntil: v.pipe(
84
- v.nullable(UnsignedInteger),
85
- v.description("Timestamp until which the agent is valid."),
86
- ),
87
- /** Cumulative ledger value. */
88
- cumLedger: v.pipe(
89
- UnsignedDecimal,
90
- v.description("Cumulative ledger value."),
91
- ),
92
- /** Metadata for perpetual assets. */
93
- meta: MetaAndAssetCtxsResponse.items[0],
94
- /** Context for each perpetual asset. */
95
- assetCtxs: MetaAndAssetCtxsResponse.items[1],
96
- /** Server timestamp (in ms since epoch). */
97
- serverTime: v.pipe(
98
- UnsignedInteger,
99
- v.description("Server timestamp (in ms since epoch)."),
100
- ),
101
- /** Whether this account is a vault. */
102
- isVault: v.pipe(
103
- v.boolean(),
104
- v.description("Whether this account is a vault."),
105
- ),
106
- /** User address. */
107
- user: v.pipe(
108
- Address,
109
- v.description("User address."),
110
- ),
111
- /** Array of TWAP states. */
112
- twapStates: v.pipe(
113
- v.array(
114
- /** TWAP ID and state. */
115
- v.pipe(
116
- v.tuple([
117
- UnsignedInteger,
118
- TwapStateSchema,
119
- ]),
120
- v.description("TWAP ID and state."),
121
- ),
122
- ),
123
- v.description("Array of TWAP states."),
124
- ),
125
- /** Account summary for spot trading. */
126
- spotState: SpotClearinghouseStateResponse,
127
- /** Context for each spot asset. */
128
- spotAssetCtxs: SpotMetaAndAssetCtxsResponse.items[1],
129
- /** Whether the user has opted out of spot dusting. */
130
- optOutOfSpotDusting: v.pipe(
131
- v.optional(v.literal(true)),
132
- v.description("Whether the user has opted out of spot dusting."),
133
- ),
134
- /** Assets currently at their open interest cap. */
135
- perpsAtOpenInterestCap: v.pipe(
136
- v.optional(v.array(v.string())),
137
- v.description("Assets currently at their open interest cap."),
138
- ),
139
- }),
38
+ WebData2Event,
140
39
  v.description("Comprehensive user and market data."),
141
40
  );
142
41
  })();
@@ -0,0 +1,96 @@
1
+ import * as v from "valibot";
2
+ import { Address, type DeepImmutable, parser } from "../_base.js";
3
+ import type { SubscriptionRequestConfig } from "./_types.js";
4
+ import type { Subscription } from "../../transport/base.js";
5
+
6
+ import { BalanceSchema } from "../_common_schemas.js";
7
+
8
+ // -------------------- Schemas --------------------
9
+
10
+ /** Subscription to spot state events for a specific user. */
11
+ export const SpotStateRequest = /* @__PURE__ */ (() => {
12
+ return v.pipe(
13
+ v.object({
14
+ /** Type of subscription. */
15
+ type: v.pipe(
16
+ v.literal("spotState"),
17
+ v.description("Type of subscription."),
18
+ ),
19
+ /** User address. */
20
+ user: v.pipe(
21
+ Address,
22
+ v.description("User address."),
23
+ ),
24
+ }),
25
+ v.description("Subscription to spot state events for a specific user."),
26
+ );
27
+ })();
28
+ export type SpotStateRequest = v.InferOutput<typeof SpotStateRequest>;
29
+
30
+ /** Event of user spot state. */
31
+ export const SpotStateEvent = /* @__PURE__ */ (() => {
32
+ return v.pipe(
33
+ v.object({
34
+ /** User address. */
35
+ user: v.pipe(
36
+ Address,
37
+ v.description("User address."),
38
+ ),
39
+ /** Spot state of the user. */
40
+ spotState: v.pipe(
41
+ v.object({
42
+ /** Balance for each token. */
43
+ balances: v.pipe(
44
+ v.array(BalanceSchema),
45
+ v.description("Balance for each token."),
46
+ ),
47
+ }),
48
+ v.description("Spot state of the user."),
49
+ ),
50
+ }),
51
+ v.description("Event of user spot state."),
52
+ );
53
+ })();
54
+ export type SpotStateEvent = v.InferOutput<typeof SpotStateEvent>;
55
+
56
+ // -------------------- Function --------------------
57
+
58
+ /** Request parameters for the {@linkcode spotState} function. */
59
+ export type SpotStateParameters = Omit<v.InferInput<typeof SpotStateRequest>, "type">;
60
+
61
+ /**
62
+ * Subscribe to spot state updates for a specific user.
63
+ * @param config - General configuration for Subscription API subscriptions.
64
+ * @param params - Parameters specific to the API subscription.
65
+ * @param listener - A callback function to be called when the event is received.
66
+ * @returns A request-promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
67
+ *
68
+ * @throws {TransportError} When the transport layer throws an error.
69
+ *
70
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
71
+ * @example
72
+ * ```ts
73
+ * import { WebSocketTransport } from "@nktkas/hyperliquid";
74
+ * import { spotState } from "@nktkas/hyperliquid/api/subscription";
75
+ *
76
+ * const transport = new WebSocketTransport();
77
+ *
78
+ * const sub = await spotState(
79
+ * { transport },
80
+ * { user: "0x..." },
81
+ * (data) => console.log(data),
82
+ * );
83
+ * ```
84
+ */
85
+ export function spotState(
86
+ config: SubscriptionRequestConfig,
87
+ params: DeepImmutable<SpotStateParameters>,
88
+ listener: (data: SpotStateEvent) => void,
89
+ ): Promise<Subscription> {
90
+ const payload = parser(SpotStateRequest)({ type: "spotState", user: params.user });
91
+ return config.transport.subscribe<SpotStateEvent>(payload.type, payload, (e) => {
92
+ if (e.detail.user === payload.user) {
93
+ listener(e.detail);
94
+ }
95
+ });
96
+ }
@@ -118,7 +118,7 @@ export const WebData2Event = /* @__PURE__ */ (() => {
118
118
  v.description("Array of TWAP states."),
119
119
  ),
120
120
  /** Account summary for spot trading. */
121
- spotState: SpotClearinghouseStateResponse,
121
+ spotState: v.optional(SpotClearinghouseStateResponse),
122
122
  /** Context for each spot asset. */
123
123
  spotAssetCtxs: SpotMetaAndAssetCtxsResponse.items[1],
124
124
  /** Whether the user has opted out of spot dusting. */
@@ -0,0 +1,179 @@
1
+ import * as v from "valibot";
2
+ import { Address, type DeepImmutable, parser, UnsignedDecimal, UnsignedInteger } from "../_base.js";
3
+ import type { SubscriptionRequestConfig } from "./_types.js";
4
+ import type { Subscription } from "../../transport/base.js";
5
+
6
+ import { DetailedOrderSchema } from "../_common_schemas.js";
7
+ import { MetaAndAssetCtxsResponse } from "../info/metaAndAssetCtxs.js";
8
+ import { ClearinghouseStateResponse } from "../info/clearinghouseState.js";
9
+
10
+ // -------------------- Schemas --------------------
11
+
12
+ /** Subscription to comprehensive user and market data events. */
13
+ export const WebData3Request = /* @__PURE__ */ (() => {
14
+ return v.pipe(
15
+ v.object({
16
+ /** Type of subscription. */
17
+ type: v.pipe(
18
+ v.literal("webData3"),
19
+ v.description("Type of subscription."),
20
+ ),
21
+ /** User address. */
22
+ user: v.pipe(
23
+ Address,
24
+ v.description("User address."),
25
+ ),
26
+ }),
27
+ v.description("Subscription to comprehensive user and market data events."),
28
+ );
29
+ })();
30
+ export type WebData3Request = v.InferOutput<typeof WebData3Request>;
31
+
32
+ /** Event of comprehensive user and market data. */
33
+ export const WebData3Event = /* @__PURE__ */ (() => {
34
+ return v.pipe(
35
+ v.object({
36
+ /** User state information. */
37
+ userState: v.pipe(
38
+ v.object({
39
+ /** Agent address if one exists. */
40
+ agentAddress: v.pipe(
41
+ v.nullable(Address),
42
+ v.description("Agent address if one exists."),
43
+ ),
44
+ /** Timestamp until which the agent is valid. */
45
+ agentValidUntil: v.pipe(
46
+ v.nullable(UnsignedInteger),
47
+ v.description("Timestamp until which the agent is valid."),
48
+ ),
49
+ /** Cumulative ledger value. */
50
+ cumLedger: v.pipe(
51
+ UnsignedDecimal,
52
+ v.description("Cumulative ledger value."),
53
+ ),
54
+ /** Server timestamp (in ms since epoch). */
55
+ serverTime: v.pipe(
56
+ UnsignedInteger,
57
+ v.description("Server timestamp (in ms since epoch)."),
58
+ ),
59
+ /** Whether this account is a vault. */
60
+ isVault: v.pipe(
61
+ v.boolean(),
62
+ v.description("Whether this account is a vault."),
63
+ ),
64
+ /** User address. */
65
+ user: v.pipe(
66
+ Address,
67
+ v.description("User address."),
68
+ ),
69
+ /** Whether the user has opted out of spot dusting. */
70
+ optOutOfSpotDusting: v.pipe(
71
+ v.optional(v.literal(true)),
72
+ v.description("Whether the user has opted out of spot dusting."),
73
+ ),
74
+ /** Whether DEX abstraction is enabled. */
75
+ dexAbstractionEnabled: v.pipe(
76
+ v.optional(v.boolean()),
77
+ v.description("Whether DEX abstraction is enabled."),
78
+ ),
79
+ }),
80
+ v.description("User state information."),
81
+ ),
82
+ /** Array of perpetual DEX states. */
83
+ perpDexStates: v.pipe(
84
+ v.array(
85
+ v.object({
86
+ /** Account summary for perpetual trading. */
87
+ clearinghouseState: ClearinghouseStateResponse,
88
+ /** Total equity in vaults. */
89
+ totalVaultEquity: v.pipe(
90
+ UnsignedDecimal,
91
+ v.description("Total equity in vaults."),
92
+ ),
93
+ /** Array of user open orders with frontend information. */
94
+ openOrders: v.pipe(
95
+ v.optional(v.array(DetailedOrderSchema)),
96
+ v.description("User open orders with frontend information."),
97
+ ),
98
+ /** Context for each perpetual asset. */
99
+ assetCtxs: MetaAndAssetCtxsResponse.items[1],
100
+ /** Assets currently at their open interest cap. */
101
+ perpsAtOpenInterestCap: v.pipe(
102
+ v.optional(v.array(v.string())),
103
+ v.description("Assets currently at their open interest cap."),
104
+ ),
105
+ /** Array of leading vaults. */
106
+ leadingVaults: v.pipe(
107
+ v.optional(
108
+ v.array(
109
+ /** Vault that a user is leading. */
110
+ v.pipe(
111
+ v.object({
112
+ /** Address of the vault. */
113
+ address: v.pipe(
114
+ Address,
115
+ v.description("Address of the vault."),
116
+ ),
117
+ /** Name of the vault. */
118
+ name: v.pipe(
119
+ v.string(),
120
+ v.description("Name of the vault."),
121
+ ),
122
+ }),
123
+ v.description("Vault that a user is leading."),
124
+ ),
125
+ ),
126
+ ),
127
+ v.description("Array of leading vaults."),
128
+ ),
129
+ }),
130
+ ),
131
+ v.description("Array of perpetual DEX states."),
132
+ ),
133
+ }),
134
+ v.description("Comprehensive user and market data."),
135
+ );
136
+ })();
137
+ export type WebData3Event = v.InferOutput<typeof WebData3Event>;
138
+
139
+ // -------------------- Function --------------------
140
+
141
+ /** Request parameters for the {@linkcode webData3} function. */
142
+ export type WebData3Parameters = Omit<v.InferInput<typeof WebData3Request>, "type">;
143
+
144
+ /**
145
+ * Subscribe to comprehensive user and market data updates.
146
+ * @param config - General configuration for Subscription API subscriptions.
147
+ * @param params - Parameters specific to the API subscription.
148
+ * @param listener - A callback function to be called when the event is received.
149
+ * @returns A request-promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
150
+ *
151
+ * @throws {TransportError} When the transport layer throws an error.
152
+ *
153
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
154
+ * @example
155
+ * ```ts
156
+ * import { WebSocketTransport } from "@nktkas/hyperliquid";
157
+ * import { webData3 } from "@nktkas/hyperliquid/api/subscription";
158
+ *
159
+ * const transport = new WebSocketTransport();
160
+ *
161
+ * const sub = await webData3(
162
+ * { transport },
163
+ * { user: "0x..." },
164
+ * (data) => console.log(data),
165
+ * );
166
+ * ```
167
+ */
168
+ export function webData3(
169
+ config: SubscriptionRequestConfig,
170
+ params: DeepImmutable<WebData3Parameters>,
171
+ listener: (data: WebData3Event) => void,
172
+ ): Promise<Subscription> {
173
+ const payload = parser(WebData3Request)({ type: "webData3", ...params });
174
+ return config.transport.subscribe<WebData3Event>(payload.type, payload, (e) => {
175
+ if (e.detail.userState.user === payload.user) {
176
+ listener(e.detail);
177
+ }
178
+ });
179
+ }