@nktkas/hyperliquid 0.24.3 → 0.25.0-beta.2

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 (358) hide show
  1. package/README.md +141 -32
  2. package/esm/mod.d.ts +11 -11
  3. package/esm/mod.d.ts.map +1 -1
  4. package/esm/mod.js +2 -1
  5. package/esm/mod.js.map +1 -0
  6. package/esm/src/clients/exchange.d.ts +29 -25
  7. package/esm/src/clients/exchange.d.ts.map +1 -1
  8. package/esm/src/clients/exchange.js +54 -53
  9. package/esm/src/clients/exchange.js.map +1 -0
  10. package/esm/src/clients/info.d.ts +80 -20
  11. package/esm/src/clients/info.d.ts.map +1 -1
  12. package/esm/src/clients/info.js +312 -73
  13. package/esm/src/clients/info.js.map +1 -0
  14. package/esm/src/clients/multiSign.d.ts +11 -7
  15. package/esm/src/clients/multiSign.d.ts.map +1 -1
  16. package/esm/src/clients/multiSign.js +2 -1
  17. package/esm/src/clients/multiSign.js.map +1 -0
  18. package/esm/src/clients/subscription.d.ts +9 -9
  19. package/esm/src/clients/subscription.d.ts.map +1 -1
  20. package/esm/src/clients/subscription.js +29 -27
  21. package/esm/src/clients/subscription.js.map +1 -0
  22. package/esm/src/{base.d.ts → errors.d.ts} +1 -1
  23. package/esm/src/errors.d.ts.map +1 -0
  24. package/esm/src/{base.js → errors.js} +1 -0
  25. package/esm/src/errors.js.map +1 -0
  26. package/esm/src/schemas/_base.d.ts +14 -0
  27. package/esm/src/schemas/_base.d.ts.map +1 -0
  28. package/esm/src/schemas/_base.js +15 -0
  29. package/esm/src/schemas/_base.js.map +1 -0
  30. package/esm/src/schemas/exchange/requests.d.ts +8953 -0
  31. package/esm/src/schemas/exchange/requests.d.ts.map +1 -0
  32. package/esm/src/schemas/exchange/requests.js +1414 -0
  33. package/esm/src/schemas/exchange/requests.js.map +1 -0
  34. package/esm/src/schemas/exchange/responses.d.ts +567 -0
  35. package/esm/src/schemas/exchange/responses.d.ts.map +1 -0
  36. package/esm/src/schemas/exchange/responses.js +244 -0
  37. package/esm/src/schemas/exchange/responses.js.map +1 -0
  38. package/esm/src/schemas/explorer/requests.d.ts +44 -0
  39. package/esm/src/schemas/explorer/requests.d.ts.map +1 -0
  40. package/esm/src/schemas/explorer/requests.js +33 -0
  41. package/esm/src/schemas/explorer/requests.js.map +1 -0
  42. package/esm/src/schemas/explorer/responses.d.ts +360 -0
  43. package/esm/src/schemas/explorer/responses.d.ts.map +1 -0
  44. package/esm/src/schemas/explorer/responses.js +57 -0
  45. package/esm/src/schemas/explorer/responses.js.map +1 -0
  46. package/esm/src/schemas/info/accounts.d.ts +2159 -0
  47. package/esm/src/schemas/info/accounts.d.ts.map +1 -0
  48. package/esm/src/schemas/info/accounts.js +623 -0
  49. package/esm/src/schemas/info/accounts.js.map +1 -0
  50. package/esm/src/schemas/info/assets.d.ts +974 -0
  51. package/esm/src/schemas/info/assets.d.ts.map +1 -0
  52. package/esm/src/schemas/info/assets.js +285 -0
  53. package/esm/src/schemas/info/assets.js.map +1 -0
  54. package/esm/src/schemas/info/markets.d.ts +155 -0
  55. package/esm/src/schemas/info/markets.d.ts.map +1 -0
  56. package/esm/src/schemas/info/markets.js +70 -0
  57. package/esm/src/schemas/info/markets.js.map +1 -0
  58. package/esm/src/schemas/info/orders.d.ts +957 -0
  59. package/esm/src/schemas/info/orders.d.ts.map +1 -0
  60. package/esm/src/schemas/info/orders.js +298 -0
  61. package/esm/src/schemas/info/orders.js.map +1 -0
  62. package/esm/src/schemas/info/requests.d.ts +924 -0
  63. package/esm/src/schemas/info/requests.d.ts.map +1 -0
  64. package/esm/src/schemas/info/requests.js +687 -0
  65. package/esm/src/schemas/info/requests.js.map +1 -0
  66. package/esm/src/schemas/info/validators.d.ts +326 -0
  67. package/esm/src/schemas/info/validators.d.ts.map +1 -0
  68. package/esm/src/schemas/info/validators.js +126 -0
  69. package/esm/src/schemas/info/validators.js.map +1 -0
  70. package/esm/src/schemas/info/vaults.d.ts +447 -0
  71. package/esm/src/schemas/info/vaults.d.ts.map +1 -0
  72. package/esm/src/schemas/info/vaults.js +111 -0
  73. package/esm/src/schemas/info/vaults.js.map +1 -0
  74. package/esm/src/schemas/mod.d.ts +101 -0
  75. package/esm/src/schemas/mod.d.ts.map +1 -0
  76. package/esm/src/schemas/mod.js +115 -0
  77. package/esm/src/schemas/mod.js.map +1 -0
  78. package/esm/src/schemas/subscriptions/requests.d.ts +332 -0
  79. package/esm/src/schemas/subscriptions/requests.d.ts.map +1 -0
  80. package/esm/src/schemas/subscriptions/requests.js +259 -0
  81. package/esm/src/schemas/subscriptions/requests.js.map +1 -0
  82. package/esm/src/schemas/subscriptions/responses.d.ts +3643 -0
  83. package/esm/src/schemas/subscriptions/responses.d.ts.map +1 -0
  84. package/esm/src/schemas/subscriptions/responses.js +234 -0
  85. package/esm/src/schemas/subscriptions/responses.js.map +1 -0
  86. package/esm/src/signing/_signTypedData/ethers.js +1 -0
  87. package/esm/src/signing/_signTypedData/ethers.js.map +1 -0
  88. package/esm/src/signing/_signTypedData/mod.js +1 -0
  89. package/esm/src/signing/_signTypedData/mod.js.map +1 -0
  90. package/esm/src/signing/_signTypedData/private_key.js +1 -0
  91. package/esm/src/signing/_signTypedData/private_key.js.map +1 -0
  92. package/esm/src/signing/_signTypedData/viem.js +1 -0
  93. package/esm/src/signing/_signTypedData/viem.js.map +1 -0
  94. package/esm/src/signing/mod.d.ts +109 -29
  95. package/esm/src/signing/mod.d.ts.map +1 -1
  96. package/esm/src/signing/mod.js +136 -29
  97. package/esm/src/signing/mod.js.map +1 -0
  98. package/esm/src/transports/base.d.ts +4 -4
  99. package/esm/src/transports/base.d.ts.map +1 -1
  100. package/esm/src/transports/base.js +3 -2
  101. package/esm/src/transports/base.js.map +1 -0
  102. package/esm/src/transports/http/http_transport.d.ts +3 -2
  103. package/esm/src/transports/http/http_transport.d.ts.map +1 -1
  104. package/esm/src/transports/http/http_transport.js +1 -0
  105. package/esm/src/transports/http/http_transport.js.map +1 -0
  106. package/esm/src/transports/websocket/_hyperliquid_event_target.d.ts +1 -1
  107. package/esm/src/transports/websocket/_hyperliquid_event_target.d.ts.map +1 -1
  108. package/esm/src/transports/websocket/_hyperliquid_event_target.js +1 -0
  109. package/esm/src/transports/websocket/_hyperliquid_event_target.js.map +1 -0
  110. package/esm/src/transports/websocket/_reconnecting_websocket.js +1 -0
  111. package/esm/src/transports/websocket/_reconnecting_websocket.js.map +1 -0
  112. package/esm/src/transports/websocket/_websocket_async_request.js +1 -0
  113. package/esm/src/transports/websocket/_websocket_async_request.js.map +1 -0
  114. package/esm/src/transports/websocket/websocket_transport.d.ts +9 -1
  115. package/esm/src/transports/websocket/websocket_transport.d.ts.map +1 -1
  116. package/esm/src/transports/websocket/websocket_transport.js +4 -0
  117. package/esm/src/transports/websocket/websocket_transport.js.map +1 -0
  118. package/package.json +6 -5
  119. package/script/mod.d.ts +11 -11
  120. package/script/mod.d.ts.map +1 -1
  121. package/script/mod.js +2 -1
  122. package/script/mod.js.map +1 -0
  123. package/script/src/clients/exchange.d.ts +29 -25
  124. package/script/src/clients/exchange.d.ts.map +1 -1
  125. package/script/src/clients/exchange.js +60 -59
  126. package/script/src/clients/exchange.js.map +1 -0
  127. package/script/src/clients/info.d.ts +80 -20
  128. package/script/src/clients/info.d.ts.map +1 -1
  129. package/script/src/clients/info.js +312 -73
  130. package/script/src/clients/info.js.map +1 -0
  131. package/script/src/clients/multiSign.d.ts +11 -7
  132. package/script/src/clients/multiSign.d.ts.map +1 -1
  133. package/script/src/clients/multiSign.js +2 -1
  134. package/script/src/clients/multiSign.js.map +1 -0
  135. package/script/src/clients/subscription.d.ts +9 -9
  136. package/script/src/clients/subscription.d.ts.map +1 -1
  137. package/script/src/clients/subscription.js +29 -27
  138. package/script/src/clients/subscription.js.map +1 -0
  139. package/script/src/{base.d.ts → errors.d.ts} +1 -1
  140. package/script/src/errors.d.ts.map +1 -0
  141. package/script/src/{base.js → errors.js} +1 -0
  142. package/script/src/errors.js.map +1 -0
  143. package/script/src/schemas/_base.d.ts +14 -0
  144. package/script/src/schemas/_base.d.ts.map +1 -0
  145. package/script/src/schemas/_base.js +51 -0
  146. package/script/src/schemas/_base.js.map +1 -0
  147. package/script/src/schemas/exchange/requests.d.ts +8953 -0
  148. package/script/src/schemas/exchange/requests.d.ts.map +1 -0
  149. package/script/src/schemas/exchange/requests.js +1450 -0
  150. package/script/src/schemas/exchange/requests.js.map +1 -0
  151. package/script/src/schemas/exchange/responses.d.ts +567 -0
  152. package/script/src/schemas/exchange/responses.d.ts.map +1 -0
  153. package/script/src/schemas/exchange/responses.js +280 -0
  154. package/script/src/schemas/exchange/responses.js.map +1 -0
  155. package/script/src/schemas/explorer/requests.d.ts +44 -0
  156. package/script/src/schemas/explorer/requests.d.ts.map +1 -0
  157. package/script/src/schemas/explorer/requests.js +69 -0
  158. package/script/src/schemas/explorer/requests.js.map +1 -0
  159. package/script/src/schemas/explorer/responses.d.ts +360 -0
  160. package/script/src/schemas/explorer/responses.d.ts.map +1 -0
  161. package/script/src/schemas/explorer/responses.js +93 -0
  162. package/script/src/schemas/explorer/responses.js.map +1 -0
  163. package/script/src/schemas/info/accounts.d.ts +2159 -0
  164. package/script/src/schemas/info/accounts.d.ts.map +1 -0
  165. package/script/src/schemas/info/accounts.js +659 -0
  166. package/script/src/schemas/info/accounts.js.map +1 -0
  167. package/script/src/schemas/info/assets.d.ts +974 -0
  168. package/script/src/schemas/info/assets.d.ts.map +1 -0
  169. package/script/src/schemas/info/assets.js +321 -0
  170. package/script/src/schemas/info/assets.js.map +1 -0
  171. package/script/src/schemas/info/markets.d.ts +155 -0
  172. package/script/src/schemas/info/markets.d.ts.map +1 -0
  173. package/script/src/schemas/info/markets.js +106 -0
  174. package/script/src/schemas/info/markets.js.map +1 -0
  175. package/script/src/schemas/info/orders.d.ts +957 -0
  176. package/script/src/schemas/info/orders.d.ts.map +1 -0
  177. package/script/src/schemas/info/orders.js +334 -0
  178. package/script/src/schemas/info/orders.js.map +1 -0
  179. package/script/src/schemas/info/requests.d.ts +924 -0
  180. package/script/src/schemas/info/requests.d.ts.map +1 -0
  181. package/script/src/schemas/info/requests.js +724 -0
  182. package/script/src/schemas/info/requests.js.map +1 -0
  183. package/script/src/schemas/info/validators.d.ts +326 -0
  184. package/script/src/schemas/info/validators.d.ts.map +1 -0
  185. package/script/src/schemas/info/validators.js +162 -0
  186. package/script/src/schemas/info/validators.js.map +1 -0
  187. package/script/src/schemas/info/vaults.d.ts +447 -0
  188. package/script/src/schemas/info/vaults.d.ts.map +1 -0
  189. package/script/src/schemas/info/vaults.js +147 -0
  190. package/script/src/schemas/info/vaults.js.map +1 -0
  191. package/script/src/schemas/mod.d.ts +101 -0
  192. package/script/src/schemas/mod.d.ts.map +1 -0
  193. package/script/src/schemas/mod.js +157 -0
  194. package/script/src/schemas/mod.js.map +1 -0
  195. package/script/src/schemas/subscriptions/requests.d.ts +332 -0
  196. package/script/src/schemas/subscriptions/requests.d.ts.map +1 -0
  197. package/script/src/schemas/subscriptions/requests.js +295 -0
  198. package/script/src/schemas/subscriptions/requests.js.map +1 -0
  199. package/script/src/schemas/subscriptions/responses.d.ts +3643 -0
  200. package/script/src/schemas/subscriptions/responses.d.ts.map +1 -0
  201. package/script/src/schemas/subscriptions/responses.js +270 -0
  202. package/script/src/schemas/subscriptions/responses.js.map +1 -0
  203. package/script/src/signing/_signTypedData/ethers.js +1 -0
  204. package/script/src/signing/_signTypedData/ethers.js.map +1 -0
  205. package/script/src/signing/_signTypedData/mod.js +1 -0
  206. package/script/src/signing/_signTypedData/mod.js.map +1 -0
  207. package/script/src/signing/_signTypedData/private_key.js +1 -0
  208. package/script/src/signing/_signTypedData/private_key.js.map +1 -0
  209. package/script/src/signing/_signTypedData/viem.js +1 -0
  210. package/script/src/signing/_signTypedData/viem.js.map +1 -0
  211. package/script/src/signing/mod.d.ts +109 -29
  212. package/script/src/signing/mod.d.ts.map +1 -1
  213. package/script/src/signing/mod.js +138 -33
  214. package/script/src/signing/mod.js.map +1 -0
  215. package/script/src/transports/base.d.ts +4 -4
  216. package/script/src/transports/base.d.ts.map +1 -1
  217. package/script/src/transports/base.js +4 -3
  218. package/script/src/transports/base.js.map +1 -0
  219. package/script/src/transports/http/http_transport.d.ts +3 -2
  220. package/script/src/transports/http/http_transport.d.ts.map +1 -1
  221. package/script/src/transports/http/http_transport.js +1 -0
  222. package/script/src/transports/http/http_transport.js.map +1 -0
  223. package/script/src/transports/websocket/_hyperliquid_event_target.d.ts +1 -1
  224. package/script/src/transports/websocket/_hyperliquid_event_target.d.ts.map +1 -1
  225. package/script/src/transports/websocket/_hyperliquid_event_target.js +1 -0
  226. package/script/src/transports/websocket/_hyperliquid_event_target.js.map +1 -0
  227. package/script/src/transports/websocket/_reconnecting_websocket.js +1 -0
  228. package/script/src/transports/websocket/_reconnecting_websocket.js.map +1 -0
  229. package/script/src/transports/websocket/_websocket_async_request.js +1 -0
  230. package/script/src/transports/websocket/_websocket_async_request.js.map +1 -0
  231. package/script/src/transports/websocket/websocket_transport.d.ts +9 -1
  232. package/script/src/transports/websocket/websocket_transport.d.ts.map +1 -1
  233. package/script/src/transports/websocket/websocket_transport.js +4 -0
  234. package/script/src/transports/websocket/websocket_transport.js.map +1 -0
  235. package/src/mod.ts +28 -0
  236. package/src/src/clients/exchange.ts +2246 -0
  237. package/src/src/clients/info.ts +2076 -0
  238. package/src/src/clients/multiSign.ts +183 -0
  239. package/src/src/clients/subscription.ts +841 -0
  240. package/src/src/errors.ts +7 -0
  241. package/src/src/schemas/_base.ts +43 -0
  242. package/src/src/schemas/exchange/requests.ts +3057 -0
  243. package/src/src/schemas/exchange/responses.ts +540 -0
  244. package/src/src/schemas/explorer/requests.ts +65 -0
  245. package/src/src/schemas/explorer/responses.ts +138 -0
  246. package/src/src/schemas/info/accounts.ts +1490 -0
  247. package/src/src/schemas/info/assets.ts +693 -0
  248. package/src/src/schemas/info/markets.ts +171 -0
  249. package/src/src/schemas/info/orders.ts +597 -0
  250. package/src/src/schemas/info/requests.ts +1369 -0
  251. package/src/src/schemas/info/validators.ts +299 -0
  252. package/src/src/schemas/info/vaults.ts +262 -0
  253. package/src/src/schemas/mod.ts +121 -0
  254. package/src/src/schemas/subscriptions/requests.ts +504 -0
  255. package/src/src/schemas/subscriptions/responses.ts +576 -0
  256. package/src/src/signing/_signTypedData/ethers.ts +59 -0
  257. package/src/src/signing/_signTypedData/mod.ts +121 -0
  258. package/src/src/signing/_signTypedData/private_key.ts +229 -0
  259. package/src/src/signing/_signTypedData/viem.ts +55 -0
  260. package/src/src/signing/mod.ts +572 -0
  261. package/src/src/transports/base.ts +54 -0
  262. package/src/src/transports/http/http_transport.ts +208 -0
  263. package/src/src/transports/websocket/_hyperliquid_event_target.ts +118 -0
  264. package/src/src/transports/websocket/_reconnecting_websocket.ts +404 -0
  265. package/src/src/transports/websocket/_websocket_async_request.ts +229 -0
  266. package/src/src/transports/websocket/websocket_transport.ts +394 -0
  267. package/esm/src/base.d.ts.map +0 -1
  268. package/esm/src/signing/_sorter.d.ts +0 -127
  269. package/esm/src/signing/_sorter.d.ts.map +0 -1
  270. package/esm/src/signing/_sorter.js +0 -693
  271. package/esm/src/types/exchange/requests.d.ts +0 -1345
  272. package/esm/src/types/exchange/requests.d.ts.map +0 -1
  273. package/esm/src/types/exchange/requests.js +0 -1
  274. package/esm/src/types/exchange/responses.d.ts +0 -233
  275. package/esm/src/types/exchange/responses.d.ts.map +0 -1
  276. package/esm/src/types/exchange/responses.js +0 -1
  277. package/esm/src/types/explorer/requests.d.ts +0 -32
  278. package/esm/src/types/explorer/requests.d.ts.map +0 -1
  279. package/esm/src/types/explorer/requests.js +0 -1
  280. package/esm/src/types/explorer/responses.d.ts +0 -58
  281. package/esm/src/types/explorer/responses.d.ts.map +0 -1
  282. package/esm/src/types/explorer/responses.js +0 -1
  283. package/esm/src/types/info/accounts.d.ts +0 -864
  284. package/esm/src/types/info/accounts.d.ts.map +0 -1
  285. package/esm/src/types/info/accounts.js +0 -1
  286. package/esm/src/types/info/assets.d.ts +0 -354
  287. package/esm/src/types/info/assets.d.ts.map +0 -1
  288. package/esm/src/types/info/assets.js +0 -1
  289. package/esm/src/types/info/markets.d.ts +0 -79
  290. package/esm/src/types/info/markets.d.ts.map +0 -1
  291. package/esm/src/types/info/markets.js +0 -1
  292. package/esm/src/types/info/orders.d.ts +0 -266
  293. package/esm/src/types/info/orders.d.ts.map +0 -1
  294. package/esm/src/types/info/orders.js +0 -1
  295. package/esm/src/types/info/requests.d.ts +0 -640
  296. package/esm/src/types/info/requests.d.ts.map +0 -1
  297. package/esm/src/types/info/requests.js +0 -1
  298. package/esm/src/types/info/validators.d.ts +0 -147
  299. package/esm/src/types/info/validators.d.ts.map +0 -1
  300. package/esm/src/types/info/validators.js +0 -1
  301. package/esm/src/types/info/vaults.d.ts +0 -119
  302. package/esm/src/types/info/vaults.d.ts.map +0 -1
  303. package/esm/src/types/info/vaults.js +0 -1
  304. package/esm/src/types/mod.d.ts +0 -38
  305. package/esm/src/types/mod.d.ts.map +0 -1
  306. package/esm/src/types/mod.js +0 -24
  307. package/esm/src/types/subscriptions/requests.d.ts +0 -154
  308. package/esm/src/types/subscriptions/requests.d.ts.map +0 -1
  309. package/esm/src/types/subscriptions/requests.js +0 -1
  310. package/esm/src/types/subscriptions/responses.d.ts +0 -238
  311. package/esm/src/types/subscriptions/responses.d.ts.map +0 -1
  312. package/esm/src/types/subscriptions/responses.js +0 -1
  313. package/script/src/base.d.ts.map +0 -1
  314. package/script/src/signing/_sorter.d.ts +0 -127
  315. package/script/src/signing/_sorter.d.ts.map +0 -1
  316. package/script/src/signing/_sorter.js +0 -696
  317. package/script/src/types/exchange/requests.d.ts +0 -1345
  318. package/script/src/types/exchange/requests.d.ts.map +0 -1
  319. package/script/src/types/exchange/requests.js +0 -2
  320. package/script/src/types/exchange/responses.d.ts +0 -233
  321. package/script/src/types/exchange/responses.d.ts.map +0 -1
  322. package/script/src/types/exchange/responses.js +0 -2
  323. package/script/src/types/explorer/requests.d.ts +0 -32
  324. package/script/src/types/explorer/requests.d.ts.map +0 -1
  325. package/script/src/types/explorer/requests.js +0 -2
  326. package/script/src/types/explorer/responses.d.ts +0 -58
  327. package/script/src/types/explorer/responses.d.ts.map +0 -1
  328. package/script/src/types/explorer/responses.js +0 -2
  329. package/script/src/types/info/accounts.d.ts +0 -864
  330. package/script/src/types/info/accounts.d.ts.map +0 -1
  331. package/script/src/types/info/accounts.js +0 -2
  332. package/script/src/types/info/assets.d.ts +0 -354
  333. package/script/src/types/info/assets.d.ts.map +0 -1
  334. package/script/src/types/info/assets.js +0 -2
  335. package/script/src/types/info/markets.d.ts +0 -79
  336. package/script/src/types/info/markets.d.ts.map +0 -1
  337. package/script/src/types/info/markets.js +0 -2
  338. package/script/src/types/info/orders.d.ts +0 -266
  339. package/script/src/types/info/orders.d.ts.map +0 -1
  340. package/script/src/types/info/orders.js +0 -2
  341. package/script/src/types/info/requests.d.ts +0 -640
  342. package/script/src/types/info/requests.d.ts.map +0 -1
  343. package/script/src/types/info/requests.js +0 -2
  344. package/script/src/types/info/validators.d.ts +0 -147
  345. package/script/src/types/info/validators.d.ts.map +0 -1
  346. package/script/src/types/info/validators.js +0 -2
  347. package/script/src/types/info/vaults.d.ts +0 -119
  348. package/script/src/types/info/vaults.d.ts.map +0 -1
  349. package/script/src/types/info/vaults.js +0 -2
  350. package/script/src/types/mod.d.ts +0 -38
  351. package/script/src/types/mod.d.ts.map +0 -1
  352. package/script/src/types/mod.js +0 -25
  353. package/script/src/types/subscriptions/requests.d.ts +0 -154
  354. package/script/src/types/subscriptions/requests.d.ts.map +0 -1
  355. package/script/src/types/subscriptions/requests.js +0 -2
  356. package/script/src/types/subscriptions/responses.d.ts +0 -238
  357. package/script/src/types/subscriptions/responses.d.ts.map +0 -1
  358. package/script/src/types/subscriptions/responses.js +0 -2
@@ -1,693 +0,0 @@
1
- /** Action sorter and formatter for correct signature generation. */
2
- export const actionSorter = {
3
- approveAgent: (action) => {
4
- return {
5
- type: action.type,
6
- signatureChainId: action.signatureChainId,
7
- hyperliquidChain: action.hyperliquidChain,
8
- agentAddress: action.agentAddress.toLowerCase(),
9
- agentName: action.agentName,
10
- nonce: action.nonce,
11
- };
12
- },
13
- approveBuilderFee: (action) => {
14
- return {
15
- type: action.type,
16
- signatureChainId: action.signatureChainId,
17
- hyperliquidChain: action.hyperliquidChain,
18
- maxFeeRate: action.maxFeeRate,
19
- builder: action.builder.toLowerCase(),
20
- nonce: action.nonce,
21
- };
22
- },
23
- batchModify: (action) => {
24
- return {
25
- type: action.type,
26
- modifies: action.modifies.map((modify) => {
27
- const sortedModify = {
28
- oid: modify.oid,
29
- order: {
30
- a: modify.order.a,
31
- b: modify.order.b,
32
- p: formatDecimal(modify.order.p),
33
- s: formatDecimal(modify.order.s),
34
- r: modify.order.r,
35
- t: "limit" in modify.order.t
36
- ? {
37
- limit: {
38
- tif: modify.order.t.limit.tif,
39
- },
40
- }
41
- : {
42
- trigger: {
43
- isMarket: modify.order.t.trigger.isMarket,
44
- triggerPx: formatDecimal(modify.order.t.trigger.triggerPx),
45
- tpsl: modify.order.t.trigger.tpsl,
46
- },
47
- },
48
- c: modify.order.c,
49
- },
50
- };
51
- if (sortedModify.order.c === undefined)
52
- delete sortedModify.order.c;
53
- return sortedModify;
54
- }),
55
- };
56
- },
57
- cancel: (action) => {
58
- return {
59
- type: action.type,
60
- cancels: action.cancels.map((cancel) => ({
61
- a: cancel.a,
62
- o: cancel.o,
63
- })),
64
- };
65
- },
66
- cancelByCloid: (action) => {
67
- return {
68
- type: action.type,
69
- cancels: action.cancels.map((cancel) => ({
70
- asset: cancel.asset,
71
- cloid: cancel.cloid,
72
- })),
73
- };
74
- },
75
- cDeposit: (action) => {
76
- return {
77
- type: action.type,
78
- signatureChainId: action.signatureChainId,
79
- hyperliquidChain: action.hyperliquidChain,
80
- wei: action.wei,
81
- nonce: action.nonce,
82
- };
83
- },
84
- claimRewards: (action) => {
85
- return {
86
- type: action.type,
87
- };
88
- },
89
- convertToMultiSigUser: (action) => {
90
- return {
91
- type: action.type,
92
- signatureChainId: action.signatureChainId,
93
- hyperliquidChain: action.hyperliquidChain,
94
- signers: typeof action.signers === "string" ? action.signers : JSON.stringify(action.signers === null ? action.signers : {
95
- authorizedUsers: action.signers.authorizedUsers,
96
- threshold: action.signers.threshold,
97
- }),
98
- nonce: action.nonce,
99
- };
100
- },
101
- createSubAccount: (action) => {
102
- return {
103
- type: action.type,
104
- name: action.name,
105
- };
106
- },
107
- createVault: (action) => {
108
- return {
109
- type: action.type,
110
- name: action.name,
111
- description: action.description,
112
- initialUsd: action.initialUsd,
113
- nonce: action.nonce,
114
- };
115
- },
116
- CSignerAction: (action) => {
117
- if ("jailSelf" in action) {
118
- return {
119
- type: action.type,
120
- jailSelf: action.jailSelf,
121
- };
122
- }
123
- else {
124
- return {
125
- type: action.type,
126
- unjailSelf: action.unjailSelf,
127
- };
128
- }
129
- },
130
- CValidatorAction: (action) => {
131
- if ("changeProfile" in action) {
132
- return {
133
- type: action.type,
134
- changeProfile: {
135
- node_ip: action.changeProfile.node_ip,
136
- name: action.changeProfile.name,
137
- description: action.changeProfile.description,
138
- unjailed: action.changeProfile.unjailed,
139
- disable_delegations: action.changeProfile.disable_delegations,
140
- commission_bps: action.changeProfile.commission_bps,
141
- signer: action.changeProfile.signer?.toLowerCase(),
142
- },
143
- };
144
- }
145
- else if ("register" in action) {
146
- return {
147
- type: action.type,
148
- register: {
149
- profile: {
150
- node_ip: {
151
- Ip: action.register.profile.node_ip.Ip,
152
- },
153
- name: action.register.profile.name,
154
- description: action.register.profile.description,
155
- delegations_disabled: action.register.profile.delegations_disabled,
156
- commission_bps: action.register.profile.commission_bps,
157
- signer: action.register.profile.signer.toLowerCase(),
158
- },
159
- unjailed: action.register.unjailed,
160
- initial_wei: action.register.initial_wei,
161
- },
162
- };
163
- }
164
- else {
165
- return {
166
- type: action.type,
167
- unregister: action.unregister,
168
- };
169
- }
170
- },
171
- cWithdraw: (action) => {
172
- return {
173
- type: action.type,
174
- signatureChainId: action.signatureChainId,
175
- hyperliquidChain: action.hyperliquidChain,
176
- wei: action.wei,
177
- nonce: action.nonce,
178
- };
179
- },
180
- evmUserModify: (action) => {
181
- return {
182
- type: action.type,
183
- usingBigBlocks: action.usingBigBlocks,
184
- };
185
- },
186
- modify: (action) => {
187
- const sortedAction = {
188
- type: action.type,
189
- oid: action.oid,
190
- order: {
191
- a: action.order.a,
192
- b: action.order.b,
193
- p: formatDecimal(action.order.p),
194
- s: formatDecimal(action.order.s),
195
- r: action.order.r,
196
- t: "limit" in action.order.t
197
- ? {
198
- limit: {
199
- tif: action.order.t.limit.tif,
200
- },
201
- }
202
- : {
203
- trigger: {
204
- isMarket: action.order.t.trigger.isMarket,
205
- triggerPx: formatDecimal(action.order.t.trigger.triggerPx),
206
- tpsl: action.order.t.trigger.tpsl,
207
- },
208
- },
209
- c: action.order.c,
210
- },
211
- };
212
- if (sortedAction.order.c === undefined)
213
- delete sortedAction.order.c;
214
- return sortedAction;
215
- },
216
- multiSig: (action) => {
217
- return {
218
- type: action.type,
219
- signatureChainId: action.signatureChainId,
220
- signatures: action.signatures.map((signature) => ({
221
- r: signature.r.replace(/^0x0+/, "0x").toLowerCase(),
222
- s: signature.s.replace(/^0x0+/, "0x").toLowerCase(),
223
- v: signature.v,
224
- })),
225
- payload: {
226
- multiSigUser: action.payload.multiSigUser.toLowerCase(),
227
- outerSigner: action.payload.outerSigner.toLowerCase(),
228
- action: actionSorter[action.payload.action.type](
229
- // @ts-ignore - TypeScript cannot infer the type correctly
230
- action.payload.action),
231
- },
232
- };
233
- },
234
- noop: (action) => {
235
- return {
236
- type: action.type,
237
- };
238
- },
239
- order: (action) => {
240
- const sortedAction = {
241
- type: action.type,
242
- orders: action.orders.map((order) => {
243
- const sortedOrder = {
244
- a: order.a,
245
- b: order.b,
246
- p: formatDecimal(order.p),
247
- s: formatDecimal(order.s),
248
- r: order.r,
249
- t: "limit" in order.t
250
- ? {
251
- limit: {
252
- tif: order.t.limit.tif,
253
- },
254
- }
255
- : {
256
- trigger: {
257
- isMarket: order.t.trigger.isMarket,
258
- triggerPx: formatDecimal(order.t.trigger.triggerPx),
259
- tpsl: order.t.trigger.tpsl,
260
- },
261
- },
262
- c: order.c,
263
- };
264
- if (order.c === undefined)
265
- delete sortedOrder.c;
266
- return sortedOrder;
267
- }),
268
- grouping: action.grouping,
269
- builder: action.builder
270
- ? {
271
- b: action.builder.b.toLowerCase(),
272
- f: action.builder.f,
273
- }
274
- : action.builder,
275
- };
276
- if (sortedAction.builder === undefined)
277
- delete sortedAction.builder;
278
- return sortedAction;
279
- },
280
- perpDeploy: (action) => {
281
- if ("registerAsset" in action) {
282
- return {
283
- type: action.type,
284
- registerAsset: {
285
- maxGas: action.registerAsset.maxGas,
286
- assetRequest: {
287
- coin: action.registerAsset.assetRequest.coin,
288
- szDecimals: action.registerAsset.assetRequest.szDecimals,
289
- oraclePx: action.registerAsset.assetRequest.oraclePx,
290
- marginTableId: action.registerAsset.assetRequest.marginTableId,
291
- onlyIsolated: action.registerAsset.assetRequest.onlyIsolated,
292
- },
293
- dex: action.registerAsset.dex,
294
- schema: action.registerAsset.schema
295
- ? {
296
- fullName: action.registerAsset.schema.fullName,
297
- collateralToken: action.registerAsset.schema.collateralToken,
298
- oracleUpdater: action.registerAsset.schema.oracleUpdater?.toLowerCase(),
299
- }
300
- : action.registerAsset.schema,
301
- },
302
- };
303
- }
304
- else {
305
- return {
306
- type: action.type,
307
- setOracle: {
308
- dex: action.setOracle.dex,
309
- oraclePxs: action.setOracle.oraclePxs.map((el) => [...el]),
310
- markPxs: action.setOracle.markPxs.map((el) => el.map((el2) => [...el2])),
311
- },
312
- };
313
- }
314
- },
315
- registerReferrer: (action) => {
316
- return {
317
- type: action.type,
318
- code: action.code,
319
- };
320
- },
321
- reserveRequestWeight: (action) => {
322
- return {
323
- type: action.type,
324
- weight: action.weight,
325
- };
326
- },
327
- scheduleCancel: (action) => {
328
- const sortedAction = {
329
- type: action.type,
330
- time: action.time,
331
- };
332
- if (sortedAction.time === undefined)
333
- delete sortedAction.time;
334
- return sortedAction;
335
- },
336
- sendAsset: (action) => {
337
- return {
338
- type: action.type,
339
- signatureChainId: action.signatureChainId,
340
- hyperliquidChain: action.hyperliquidChain,
341
- destination: action.destination.toLowerCase(),
342
- sourceDex: action.sourceDex,
343
- destinationDex: action.destinationDex,
344
- token: action.token,
345
- amount: action.amount,
346
- fromSubAccount: action.fromSubAccount.toLowerCase(),
347
- nonce: action.nonce,
348
- };
349
- },
350
- setDisplayName: (action) => {
351
- return {
352
- type: action.type,
353
- displayName: action.displayName,
354
- };
355
- },
356
- setReferrer: (action) => {
357
- return {
358
- type: action.type,
359
- code: action.code,
360
- };
361
- },
362
- spotDeploy: (action) => {
363
- if ("genesis" in action) {
364
- const sortedAction = {
365
- type: action.type,
366
- genesis: {
367
- token: action.genesis.token,
368
- maxSupply: action.genesis.maxSupply,
369
- noHyperliquidity: action.genesis.noHyperliquidity,
370
- },
371
- };
372
- if (sortedAction.genesis.noHyperliquidity === undefined)
373
- delete sortedAction.genesis.noHyperliquidity;
374
- return sortedAction;
375
- }
376
- else if ("registerHyperliquidity" in action) {
377
- const sortedAction = {
378
- type: action.type,
379
- registerHyperliquidity: {
380
- spot: action.registerHyperliquidity.spot,
381
- startPx: action.registerHyperliquidity.startPx,
382
- orderSz: action.registerHyperliquidity.orderSz,
383
- nOrders: action.registerHyperliquidity.nOrders,
384
- nSeededLevels: action.registerHyperliquidity.nSeededLevels,
385
- },
386
- };
387
- if (sortedAction.registerHyperliquidity.nSeededLevels === undefined) {
388
- delete sortedAction.registerHyperliquidity.nSeededLevels;
389
- }
390
- return sortedAction;
391
- }
392
- else if ("registerSpot" in action) {
393
- return {
394
- type: action.type,
395
- registerSpot: {
396
- tokens: [...action.registerSpot.tokens],
397
- },
398
- };
399
- }
400
- else if ("registerToken2" in action) {
401
- const sortedAction = {
402
- type: action.type,
403
- registerToken2: {
404
- spec: {
405
- name: action.registerToken2.spec.name,
406
- szDecimals: action.registerToken2.spec.szDecimals,
407
- weiDecimals: action.registerToken2.spec.weiDecimals,
408
- },
409
- maxGas: action.registerToken2.maxGas,
410
- fullName: action.registerToken2.fullName,
411
- },
412
- };
413
- if (sortedAction.registerToken2.fullName === undefined)
414
- delete sortedAction.registerToken2.fullName;
415
- return sortedAction;
416
- }
417
- else if ("setDeployerTradingFeeShare" in action) {
418
- return {
419
- type: action.type,
420
- setDeployerTradingFeeShare: {
421
- token: action.setDeployerTradingFeeShare.token,
422
- share: action.setDeployerTradingFeeShare.share,
423
- },
424
- };
425
- }
426
- else {
427
- const sortedAction = {
428
- type: action.type,
429
- userGenesis: {
430
- token: action.userGenesis.token,
431
- userAndWei: action.userGenesis.userAndWei.map((el) => [...el]),
432
- existingTokenAndWei: action.userGenesis.existingTokenAndWei.map((el) => [...el]),
433
- blacklistUsers: action.userGenesis.blacklistUsers?.map((el) => [...el]),
434
- },
435
- };
436
- if (sortedAction.userGenesis.blacklistUsers === undefined)
437
- delete sortedAction.userGenesis.blacklistUsers;
438
- return sortedAction;
439
- }
440
- },
441
- spotSend: (action) => {
442
- return {
443
- type: action.type,
444
- signatureChainId: action.signatureChainId,
445
- hyperliquidChain: action.hyperliquidChain,
446
- destination: action.destination.toLowerCase(),
447
- token: action.token,
448
- amount: action.amount,
449
- time: action.time,
450
- };
451
- },
452
- spotUser: (action) => {
453
- return {
454
- type: action.type,
455
- toggleSpotDusting: {
456
- optOut: action.toggleSpotDusting.optOut,
457
- },
458
- };
459
- },
460
- subAccountModify: (action) => {
461
- return {
462
- type: action.type,
463
- subAccountUser: action.subAccountUser.toLowerCase(),
464
- name: action.name,
465
- };
466
- },
467
- subAccountSpotTransfer: (action) => {
468
- return {
469
- type: action.type,
470
- subAccountUser: action.subAccountUser.toLowerCase(),
471
- isDeposit: action.isDeposit,
472
- token: action.token,
473
- amount: action.amount,
474
- };
475
- },
476
- subAccountTransfer: (action) => {
477
- return {
478
- type: action.type,
479
- subAccountUser: action.subAccountUser.toLowerCase(),
480
- isDeposit: action.isDeposit,
481
- usd: action.usd,
482
- };
483
- },
484
- tokenDelegate: (action) => {
485
- return {
486
- type: action.type,
487
- signatureChainId: action.signatureChainId,
488
- hyperliquidChain: action.hyperliquidChain,
489
- validator: action.validator.toLowerCase(),
490
- wei: action.wei,
491
- isUndelegate: action.isUndelegate,
492
- nonce: action.nonce,
493
- };
494
- },
495
- twapCancel: (action) => {
496
- return {
497
- type: action.type,
498
- a: action.a,
499
- t: action.t,
500
- };
501
- },
502
- twapOrder: (action) => {
503
- return {
504
- type: action.type,
505
- twap: {
506
- a: action.twap.a,
507
- b: action.twap.b,
508
- s: formatDecimal(action.twap.s),
509
- r: action.twap.r,
510
- m: action.twap.m,
511
- t: action.twap.t,
512
- },
513
- };
514
- },
515
- updateIsolatedMargin: (action) => {
516
- return {
517
- type: action.type,
518
- asset: action.asset,
519
- isBuy: action.isBuy,
520
- ntli: action.ntli,
521
- };
522
- },
523
- updateLeverage: (action) => {
524
- return {
525
- type: action.type,
526
- asset: action.asset,
527
- isCross: action.isCross,
528
- leverage: action.leverage,
529
- };
530
- },
531
- usdClassTransfer: (action) => {
532
- return {
533
- type: action.type,
534
- signatureChainId: action.signatureChainId,
535
- hyperliquidChain: action.hyperliquidChain,
536
- amount: action.amount,
537
- toPerp: action.toPerp,
538
- nonce: action.nonce,
539
- };
540
- },
541
- usdSend: (action) => {
542
- return {
543
- type: action.type,
544
- signatureChainId: action.signatureChainId,
545
- hyperliquidChain: action.hyperliquidChain,
546
- destination: action.destination.toLowerCase(),
547
- amount: action.amount,
548
- time: action.time,
549
- };
550
- },
551
- vaultDistribute: (action) => {
552
- return {
553
- type: action.type,
554
- vaultAddress: action.vaultAddress,
555
- usd: action.usd,
556
- };
557
- },
558
- vaultModify: (action) => {
559
- return {
560
- type: action.type,
561
- vaultAddress: action.vaultAddress,
562
- allowDeposits: action.allowDeposits,
563
- alwaysCloseOnWithdraw: action.alwaysCloseOnWithdraw,
564
- };
565
- },
566
- vaultTransfer: (action) => {
567
- return {
568
- type: action.type,
569
- vaultAddress: action.vaultAddress,
570
- isDeposit: action.isDeposit,
571
- usd: action.usd,
572
- };
573
- },
574
- withdraw3: (action) => {
575
- return {
576
- type: action.type,
577
- signatureChainId: action.signatureChainId,
578
- hyperliquidChain: action.hyperliquidChain,
579
- destination: action.destination.toLowerCase(),
580
- amount: action.amount,
581
- time: action.time,
582
- };
583
- },
584
- };
585
- /** Removes trailing zeros from decimal string. */
586
- function formatDecimal(numStr) {
587
- if (!numStr.includes("."))
588
- return numStr;
589
- const [intPart, fracPart] = numStr.split(".");
590
- const newFrac = fracPart.replace(/0+$/, "");
591
- return newFrac ? `${intPart}.${newFrac}` : intPart;
592
- }
593
- /** EIP-712 type definitions for user-signed actions. */
594
- export const userSignedActionEip712Types = {
595
- approveAgent: {
596
- "HyperliquidTransaction:ApproveAgent": [
597
- { name: "hyperliquidChain", type: "string" },
598
- { name: "agentAddress", type: "address" },
599
- { name: "agentName", type: "string" },
600
- { name: "nonce", type: "uint64" },
601
- ],
602
- },
603
- approveBuilderFee: {
604
- "HyperliquidTransaction:ApproveBuilderFee": [
605
- { name: "hyperliquidChain", type: "string" },
606
- { name: "maxFeeRate", type: "string" },
607
- { name: "builder", type: "address" },
608
- { name: "nonce", type: "uint64" },
609
- ],
610
- },
611
- cDeposit: {
612
- "HyperliquidTransaction:CDeposit": [
613
- { name: "hyperliquidChain", type: "string" },
614
- { name: "wei", type: "uint64" },
615
- { name: "nonce", type: "uint64" },
616
- ],
617
- },
618
- convertToMultiSigUser: {
619
- "HyperliquidTransaction:ConvertToMultiSigUser": [
620
- { name: "hyperliquidChain", type: "string" },
621
- { name: "signers", type: "string" },
622
- { name: "nonce", type: "uint64" },
623
- ],
624
- },
625
- cWithdraw: {
626
- "HyperliquidTransaction:CWithdraw": [
627
- { name: "hyperliquidChain", type: "string" },
628
- { name: "wei", type: "uint64" },
629
- { name: "nonce", type: "uint64" },
630
- ],
631
- },
632
- multiSig: {
633
- "HyperliquidTransaction:SendMultiSig": [
634
- { name: "hyperliquidChain", type: "string" },
635
- { name: "multiSigActionHash", type: "bytes32" },
636
- { name: "nonce", type: "uint64" },
637
- ],
638
- },
639
- sendAsset: {
640
- "HyperliquidTransaction:SendAsset": [
641
- { name: "hyperliquidChain", type: "string" },
642
- { name: "destination", type: "string" },
643
- { name: "sourceDex", type: "string" },
644
- { name: "destinationDex", type: "string" },
645
- { name: "token", type: "string" },
646
- { name: "amount", type: "string" },
647
- { name: "fromSubAccount", type: "string" },
648
- { name: "nonce", type: "uint64" },
649
- ],
650
- },
651
- spotSend: {
652
- "HyperliquidTransaction:SpotSend": [
653
- { name: "hyperliquidChain", type: "string" },
654
- { name: "destination", type: "string" },
655
- { name: "token", type: "string" },
656
- { name: "amount", type: "string" },
657
- { name: "time", type: "uint64" },
658
- ],
659
- },
660
- tokenDelegate: {
661
- "HyperliquidTransaction:TokenDelegate": [
662
- { name: "hyperliquidChain", type: "string" },
663
- { name: "validator", type: "address" },
664
- { name: "wei", type: "uint64" },
665
- { name: "isUndelegate", type: "bool" },
666
- { name: "nonce", type: "uint64" },
667
- ],
668
- },
669
- usdClassTransfer: {
670
- "HyperliquidTransaction:UsdClassTransfer": [
671
- { name: "hyperliquidChain", type: "string" },
672
- { name: "amount", type: "string" },
673
- { name: "toPerp", type: "bool" },
674
- { name: "nonce", type: "uint64" },
675
- ],
676
- },
677
- usdSend: {
678
- "HyperliquidTransaction:UsdSend": [
679
- { name: "hyperliquidChain", type: "string" },
680
- { name: "destination", type: "string" },
681
- { name: "amount", type: "string" },
682
- { name: "time", type: "uint64" },
683
- ],
684
- },
685
- withdraw3: {
686
- "HyperliquidTransaction:Withdraw": [
687
- { name: "hyperliquidChain", type: "string" },
688
- { name: "destination", type: "string" },
689
- { name: "amount", type: "string" },
690
- { name: "time", type: "uint64" },
691
- ],
692
- },
693
- };