@nktkas/hyperliquid 0.25.0-beta.2 → 0.25.0-beta.4

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 (329) hide show
  1. package/README.md +114 -106
  2. package/esm/bin/_utils.d.ts +80 -0
  3. package/esm/bin/_utils.d.ts.map +1 -0
  4. package/esm/bin/_utils.js +112 -0
  5. package/esm/bin/_utils.js.map +1 -0
  6. package/esm/bin/cli.d.ts +3 -0
  7. package/esm/bin/cli.d.ts.map +1 -0
  8. package/esm/bin/cli.js +334 -0
  9. package/esm/bin/cli.js.map +1 -0
  10. package/esm/src/{errors.d.ts → _errors.d.ts} +1 -1
  11. package/esm/src/_errors.d.ts.map +1 -0
  12. package/esm/src/{errors.js → _errors.js} +1 -1
  13. package/esm/src/_errors.js.map +1 -0
  14. package/esm/src/clients/exchange.d.ts +91 -91
  15. package/esm/src/clients/exchange.d.ts.map +1 -1
  16. package/esm/src/clients/exchange.js +61 -56
  17. package/esm/src/clients/exchange.js.map +1 -1
  18. package/esm/src/clients/info.d.ts +134 -112
  19. package/esm/src/clients/info.d.ts.map +1 -1
  20. package/esm/src/clients/info.js +95 -72
  21. package/esm/src/clients/info.js.map +1 -1
  22. package/esm/src/clients/multiSign.d.ts +2 -2
  23. package/esm/src/clients/multiSign.d.ts.map +1 -1
  24. package/esm/src/clients/multiSign.js +3 -1
  25. package/esm/src/clients/multiSign.js.map +1 -1
  26. package/esm/src/clients/subscription.d.ts +23 -23
  27. package/esm/src/clients/subscription.d.ts.map +1 -1
  28. package/esm/src/clients/subscription.js +8 -11
  29. package/esm/src/clients/subscription.js.map +1 -1
  30. package/esm/src/mod.d.ts +21 -0
  31. package/esm/src/mod.d.ts.map +1 -0
  32. package/esm/src/mod.js +14 -0
  33. package/esm/src/mod.js.map +1 -0
  34. package/esm/src/schemas/_base.d.ts +8 -6
  35. package/esm/src/schemas/_base.d.ts.map +1 -1
  36. package/esm/src/schemas/_base.js +6 -4
  37. package/esm/src/schemas/_base.js.map +1 -1
  38. package/esm/src/schemas/exchange/requests.d.ts +332 -313
  39. package/esm/src/schemas/exchange/requests.d.ts.map +1 -1
  40. package/esm/src/schemas/exchange/requests.js +52 -61
  41. package/esm/src/schemas/exchange/requests.js.map +1 -1
  42. package/esm/src/schemas/exchange/responses.d.ts +10 -10
  43. package/esm/src/schemas/exchange/responses.js +3 -3
  44. package/esm/src/schemas/exchange/responses.js.map +1 -1
  45. package/esm/src/schemas/explorer/requests.d.ts +1 -1
  46. package/esm/src/schemas/explorer/requests.js +2 -2
  47. package/esm/src/schemas/explorer/requests.js.map +1 -1
  48. package/esm/src/schemas/explorer/responses.d.ts +16 -16
  49. package/esm/src/schemas/explorer/responses.js +3 -3
  50. package/esm/src/schemas/explorer/responses.js.map +1 -1
  51. package/esm/src/schemas/info/accounts.d.ts +975 -229
  52. package/esm/src/schemas/info/accounts.d.ts.map +1 -1
  53. package/esm/src/schemas/info/accounts.js +65 -21
  54. package/esm/src/schemas/info/accounts.js.map +1 -1
  55. package/esm/src/schemas/info/assets.d.ts +110 -110
  56. package/esm/src/schemas/info/assets.js +9 -9
  57. package/esm/src/schemas/info/assets.js.map +1 -1
  58. package/esm/src/schemas/info/markets.d.ts +25 -25
  59. package/esm/src/schemas/info/markets.js +3 -3
  60. package/esm/src/schemas/info/markets.js.map +1 -1
  61. package/esm/src/schemas/info/orders.d.ts +175 -175
  62. package/esm/src/schemas/info/orders.js +3 -3
  63. package/esm/src/schemas/info/orders.js.map +1 -1
  64. package/esm/src/schemas/info/requests.d.ts +31 -16
  65. package/esm/src/schemas/info/requests.d.ts.map +1 -1
  66. package/esm/src/schemas/info/requests.js +51 -40
  67. package/esm/src/schemas/info/requests.js.map +1 -1
  68. package/esm/src/schemas/info/validators.d.ts +30 -30
  69. package/esm/src/schemas/info/validators.d.ts.map +1 -1
  70. package/esm/src/schemas/info/validators.js +8 -8
  71. package/esm/src/schemas/info/validators.js.map +1 -1
  72. package/esm/src/schemas/info/vaults.d.ts +46 -46
  73. package/esm/src/schemas/info/vaults.js +10 -10
  74. package/esm/src/schemas/info/vaults.js.map +1 -1
  75. package/esm/src/schemas/mod.d.ts +3 -3
  76. package/esm/src/schemas/mod.d.ts.map +1 -1
  77. package/esm/src/schemas/mod.js +3 -3
  78. package/esm/src/schemas/mod.js.map +1 -1
  79. package/esm/src/schemas/subscriptions/requests.d.ts +4 -4
  80. package/esm/src/schemas/subscriptions/requests.d.ts.map +1 -1
  81. package/esm/src/schemas/subscriptions/requests.js +17 -17
  82. package/esm/src/schemas/subscriptions/requests.js.map +1 -1
  83. package/esm/src/schemas/subscriptions/responses.d.ts +618 -618
  84. package/esm/src/schemas/subscriptions/responses.js +14 -14
  85. package/esm/src/schemas/subscriptions/responses.js.map +1 -1
  86. package/esm/src/signing/mod.d.ts +1 -1
  87. package/esm/src/signing/mod.d.ts.map +1 -1
  88. package/esm/src/signing/mod.js +6 -6
  89. package/esm/src/signing/mod.js.map +1 -1
  90. package/esm/src/signing/signTypedData/ethers.d.ts.map +1 -0
  91. package/esm/src/signing/signTypedData/ethers.js.map +1 -0
  92. package/esm/src/signing/signTypedData/mod.d.ts.map +1 -0
  93. package/esm/src/signing/signTypedData/mod.js.map +1 -0
  94. package/esm/src/signing/signTypedData/private_key.d.ts.map +1 -0
  95. package/esm/src/signing/{_signTypedData → signTypedData}/private_key.js +18 -17
  96. package/esm/src/signing/signTypedData/private_key.js.map +1 -0
  97. package/esm/src/signing/signTypedData/viem.d.ts.map +1 -0
  98. package/esm/src/signing/signTypedData/viem.js.map +1 -0
  99. package/esm/src/transports/_polyfills.d.ts +12 -0
  100. package/esm/src/transports/_polyfills.d.ts.map +1 -0
  101. package/esm/src/transports/_polyfills.js +40 -0
  102. package/esm/src/transports/_polyfills.js.map +1 -0
  103. package/esm/src/transports/base.d.ts +8 -8
  104. package/esm/src/transports/base.d.ts.map +1 -1
  105. package/esm/src/transports/base.js +2 -2
  106. package/esm/src/transports/base.js.map +1 -1
  107. package/esm/src/transports/http/http_transport.d.ts +11 -4
  108. package/esm/src/transports/http/http_transport.d.ts.map +1 -1
  109. package/esm/src/transports/http/http_transport.js +17 -6
  110. package/esm/src/transports/http/http_transport.js.map +1 -1
  111. package/esm/src/transports/websocket/_hyperliquid_event_target.d.ts +8 -7
  112. package/esm/src/transports/websocket/_hyperliquid_event_target.d.ts.map +1 -1
  113. package/esm/src/transports/websocket/_hyperliquid_event_target.js +14 -33
  114. package/esm/src/transports/websocket/_hyperliquid_event_target.js.map +1 -1
  115. package/esm/src/transports/websocket/_reconnecting_websocket.d.ts +26 -29
  116. package/esm/src/transports/websocket/_reconnecting_websocket.d.ts.map +1 -1
  117. package/esm/src/transports/websocket/_reconnecting_websocket.js +82 -76
  118. package/esm/src/transports/websocket/_reconnecting_websocket.js.map +1 -1
  119. package/esm/src/transports/websocket/_websocket_async_request.d.ts +6 -0
  120. package/esm/src/transports/websocket/_websocket_async_request.d.ts.map +1 -1
  121. package/esm/src/transports/websocket/_websocket_async_request.js +49 -41
  122. package/esm/src/transports/websocket/_websocket_async_request.js.map +1 -1
  123. package/esm/src/transports/websocket/websocket_transport.d.ts +48 -70
  124. package/esm/src/transports/websocket/websocket_transport.d.ts.map +1 -1
  125. package/esm/src/transports/websocket/websocket_transport.js +90 -103
  126. package/esm/src/transports/websocket/websocket_transport.js.map +1 -1
  127. package/package.json +12 -8
  128. package/script/bin/_utils.d.ts +80 -0
  129. package/script/bin/_utils.d.ts.map +1 -0
  130. package/script/bin/_utils.js +116 -0
  131. package/script/bin/_utils.js.map +1 -0
  132. package/script/bin/cli.d.ts +3 -0
  133. package/script/bin/cli.d.ts.map +1 -0
  134. package/script/bin/cli.js +369 -0
  135. package/script/bin/cli.js.map +1 -0
  136. package/script/src/{errors.d.ts → _errors.d.ts} +1 -1
  137. package/script/src/_errors.d.ts.map +1 -0
  138. package/script/src/{errors.js → _errors.js} +1 -1
  139. package/script/src/_errors.js.map +1 -0
  140. package/script/src/clients/exchange.d.ts +91 -91
  141. package/script/src/clients/exchange.d.ts.map +1 -1
  142. package/script/src/clients/exchange.js +61 -56
  143. package/script/src/clients/exchange.js.map +1 -1
  144. package/script/src/clients/info.d.ts +134 -112
  145. package/script/src/clients/info.d.ts.map +1 -1
  146. package/script/src/clients/info.js +94 -71
  147. package/script/src/clients/info.js.map +1 -1
  148. package/script/src/clients/multiSign.d.ts +2 -2
  149. package/script/src/clients/multiSign.d.ts.map +1 -1
  150. package/script/src/clients/multiSign.js +9 -7
  151. package/script/src/clients/multiSign.js.map +1 -1
  152. package/script/src/clients/subscription.d.ts +23 -23
  153. package/script/src/clients/subscription.d.ts.map +1 -1
  154. package/script/src/clients/subscription.js +8 -11
  155. package/script/src/clients/subscription.js.map +1 -1
  156. package/script/src/mod.d.ts +21 -0
  157. package/script/src/mod.d.ts.map +1 -0
  158. package/script/{mod.js → src/mod.js} +12 -8
  159. package/script/src/mod.js.map +1 -0
  160. package/script/src/schemas/_base.d.ts +8 -6
  161. package/script/src/schemas/_base.d.ts.map +1 -1
  162. package/script/src/schemas/_base.js +7 -5
  163. package/script/src/schemas/_base.js.map +1 -1
  164. package/script/src/schemas/exchange/requests.d.ts +332 -313
  165. package/script/src/schemas/exchange/requests.d.ts.map +1 -1
  166. package/script/src/schemas/exchange/requests.js +51 -60
  167. package/script/src/schemas/exchange/requests.js.map +1 -1
  168. package/script/src/schemas/exchange/responses.d.ts +10 -10
  169. package/script/src/schemas/exchange/responses.js +2 -2
  170. package/script/src/schemas/exchange/responses.js.map +1 -1
  171. package/script/src/schemas/explorer/requests.d.ts +1 -1
  172. package/script/src/schemas/explorer/requests.js +1 -1
  173. package/script/src/schemas/explorer/requests.js.map +1 -1
  174. package/script/src/schemas/explorer/responses.d.ts +16 -16
  175. package/script/src/schemas/explorer/responses.js +2 -2
  176. package/script/src/schemas/explorer/responses.js.map +1 -1
  177. package/script/src/schemas/info/accounts.d.ts +975 -229
  178. package/script/src/schemas/info/accounts.d.ts.map +1 -1
  179. package/script/src/schemas/info/accounts.js +65 -21
  180. package/script/src/schemas/info/accounts.js.map +1 -1
  181. package/script/src/schemas/info/assets.d.ts +110 -110
  182. package/script/src/schemas/info/assets.js +8 -8
  183. package/script/src/schemas/info/assets.js.map +1 -1
  184. package/script/src/schemas/info/markets.d.ts +25 -25
  185. package/script/src/schemas/info/markets.js +2 -2
  186. package/script/src/schemas/info/markets.js.map +1 -1
  187. package/script/src/schemas/info/orders.d.ts +175 -175
  188. package/script/src/schemas/info/orders.js +2 -2
  189. package/script/src/schemas/info/orders.js.map +1 -1
  190. package/script/src/schemas/info/requests.d.ts +31 -16
  191. package/script/src/schemas/info/requests.d.ts.map +1 -1
  192. package/script/src/schemas/info/requests.js +51 -40
  193. package/script/src/schemas/info/requests.js.map +1 -1
  194. package/script/src/schemas/info/validators.d.ts +30 -30
  195. package/script/src/schemas/info/validators.d.ts.map +1 -1
  196. package/script/src/schemas/info/validators.js +7 -7
  197. package/script/src/schemas/info/validators.js.map +1 -1
  198. package/script/src/schemas/info/vaults.d.ts +46 -46
  199. package/script/src/schemas/info/vaults.js +9 -9
  200. package/script/src/schemas/info/vaults.js.map +1 -1
  201. package/script/src/schemas/mod.d.ts +3 -3
  202. package/script/src/schemas/mod.d.ts.map +1 -1
  203. package/script/src/schemas/mod.js +4 -4
  204. package/script/src/schemas/mod.js.map +1 -1
  205. package/script/src/schemas/subscriptions/requests.d.ts +4 -4
  206. package/script/src/schemas/subscriptions/requests.d.ts.map +1 -1
  207. package/script/src/schemas/subscriptions/requests.js +16 -16
  208. package/script/src/schemas/subscriptions/requests.js.map +1 -1
  209. package/script/src/schemas/subscriptions/responses.d.ts +618 -618
  210. package/script/src/schemas/subscriptions/responses.js +13 -13
  211. package/script/src/schemas/subscriptions/responses.js.map +1 -1
  212. package/script/src/signing/mod.d.ts +1 -1
  213. package/script/src/signing/mod.d.ts.map +1 -1
  214. package/script/src/signing/mod.js +40 -7
  215. package/script/src/signing/mod.js.map +1 -1
  216. package/script/src/signing/signTypedData/ethers.d.ts.map +1 -0
  217. package/script/src/signing/signTypedData/ethers.js.map +1 -0
  218. package/script/src/signing/signTypedData/mod.d.ts.map +1 -0
  219. package/script/src/signing/signTypedData/mod.js.map +1 -0
  220. package/script/src/signing/signTypedData/private_key.d.ts.map +1 -0
  221. package/script/src/signing/{_signTypedData → signTypedData}/private_key.js +55 -21
  222. package/script/src/signing/signTypedData/private_key.js.map +1 -0
  223. package/script/src/signing/signTypedData/viem.d.ts.map +1 -0
  224. package/script/src/signing/signTypedData/viem.js.map +1 -0
  225. package/script/src/transports/_polyfills.d.ts +12 -0
  226. package/script/src/transports/_polyfills.d.ts.map +1 -0
  227. package/script/src/transports/_polyfills.js +43 -0
  228. package/script/src/transports/_polyfills.js.map +1 -0
  229. package/script/src/transports/base.d.ts +8 -8
  230. package/script/src/transports/base.d.ts.map +1 -1
  231. package/script/src/transports/base.js +3 -3
  232. package/script/src/transports/base.js.map +1 -1
  233. package/script/src/transports/http/http_transport.d.ts +11 -4
  234. package/script/src/transports/http/http_transport.d.ts.map +1 -1
  235. package/script/src/transports/http/http_transport.js +17 -6
  236. package/script/src/transports/http/http_transport.js.map +1 -1
  237. package/script/src/transports/websocket/_hyperliquid_event_target.d.ts +8 -7
  238. package/script/src/transports/websocket/_hyperliquid_event_target.d.ts.map +1 -1
  239. package/script/src/transports/websocket/_hyperliquid_event_target.js +47 -33
  240. package/script/src/transports/websocket/_hyperliquid_event_target.js.map +1 -1
  241. package/script/src/transports/websocket/_reconnecting_websocket.d.ts +26 -29
  242. package/script/src/transports/websocket/_reconnecting_websocket.d.ts.map +1 -1
  243. package/script/src/transports/websocket/_reconnecting_websocket.js +82 -76
  244. package/script/src/transports/websocket/_reconnecting_websocket.js.map +1 -1
  245. package/script/src/transports/websocket/_websocket_async_request.d.ts +6 -0
  246. package/script/src/transports/websocket/_websocket_async_request.d.ts.map +1 -1
  247. package/script/src/transports/websocket/_websocket_async_request.js +52 -43
  248. package/script/src/transports/websocket/_websocket_async_request.js.map +1 -1
  249. package/script/src/transports/websocket/websocket_transport.d.ts +48 -70
  250. package/script/src/transports/websocket/websocket_transport.d.ts.map +1 -1
  251. package/script/src/transports/websocket/websocket_transport.js +92 -105
  252. package/script/src/transports/websocket/websocket_transport.js.map +1 -1
  253. package/src/bin/_utils.ts +185 -0
  254. package/src/bin/cli.ts +359 -0
  255. package/src/src/clients/exchange.ts +155 -144
  256. package/src/src/clients/info.ts +158 -124
  257. package/src/src/clients/multiSign.ts +13 -11
  258. package/src/src/clients/subscription.ts +32 -32
  259. package/src/src/mod.ts +29 -0
  260. package/src/src/schemas/_base.ts +25 -8
  261. package/src/src/schemas/exchange/requests.ts +59 -61
  262. package/src/src/schemas/exchange/responses.ts +3 -3
  263. package/src/src/schemas/explorer/requests.ts +2 -2
  264. package/src/src/schemas/explorer/responses.ts +3 -3
  265. package/src/src/schemas/info/accounts.ts +129 -21
  266. package/src/src/schemas/info/assets.ts +9 -9
  267. package/src/src/schemas/info/markets.ts +3 -3
  268. package/src/src/schemas/info/orders.ts +3 -3
  269. package/src/src/schemas/info/requests.ts +72 -40
  270. package/src/src/schemas/info/validators.ts +22 -24
  271. package/src/src/schemas/info/vaults.ts +10 -10
  272. package/src/src/schemas/mod.ts +3 -3
  273. package/src/src/schemas/subscriptions/requests.ts +27 -17
  274. package/src/src/schemas/subscriptions/responses.ts +14 -14
  275. package/src/src/signing/mod.ts +6 -6
  276. package/src/src/signing/{_signTypedData → signTypedData}/private_key.ts +22 -17
  277. package/src/src/transports/_polyfills.ts +41 -0
  278. package/src/src/transports/base.ts +8 -8
  279. package/src/src/transports/http/http_transport.ts +25 -14
  280. package/src/src/transports/websocket/_hyperliquid_event_target.ts +24 -51
  281. package/src/src/transports/websocket/_reconnecting_websocket.ts +107 -119
  282. package/src/src/transports/websocket/_websocket_async_request.ts +57 -59
  283. package/src/src/transports/websocket/websocket_transport.ts +126 -167
  284. package/esm/mod.d.ts +0 -20
  285. package/esm/mod.d.ts.map +0 -1
  286. package/esm/mod.js +0 -12
  287. package/esm/mod.js.map +0 -1
  288. package/esm/src/errors.d.ts.map +0 -1
  289. package/esm/src/errors.js.map +0 -1
  290. package/esm/src/signing/_signTypedData/ethers.d.ts.map +0 -1
  291. package/esm/src/signing/_signTypedData/ethers.js.map +0 -1
  292. package/esm/src/signing/_signTypedData/mod.d.ts.map +0 -1
  293. package/esm/src/signing/_signTypedData/mod.js.map +0 -1
  294. package/esm/src/signing/_signTypedData/private_key.d.ts.map +0 -1
  295. package/esm/src/signing/_signTypedData/private_key.js.map +0 -1
  296. package/esm/src/signing/_signTypedData/viem.d.ts.map +0 -1
  297. package/esm/src/signing/_signTypedData/viem.js.map +0 -1
  298. package/script/mod.d.ts +0 -20
  299. package/script/mod.d.ts.map +0 -1
  300. package/script/mod.js.map +0 -1
  301. package/script/src/errors.d.ts.map +0 -1
  302. package/script/src/errors.js.map +0 -1
  303. package/script/src/signing/_signTypedData/ethers.d.ts.map +0 -1
  304. package/script/src/signing/_signTypedData/ethers.js.map +0 -1
  305. package/script/src/signing/_signTypedData/mod.d.ts.map +0 -1
  306. package/script/src/signing/_signTypedData/mod.js.map +0 -1
  307. package/script/src/signing/_signTypedData/private_key.d.ts.map +0 -1
  308. package/script/src/signing/_signTypedData/private_key.js.map +0 -1
  309. package/script/src/signing/_signTypedData/viem.d.ts.map +0 -1
  310. package/script/src/signing/_signTypedData/viem.js.map +0 -1
  311. package/src/mod.ts +0 -28
  312. /package/esm/src/signing/{_signTypedData → signTypedData}/ethers.d.ts +0 -0
  313. /package/esm/src/signing/{_signTypedData → signTypedData}/ethers.js +0 -0
  314. /package/esm/src/signing/{_signTypedData → signTypedData}/mod.d.ts +0 -0
  315. /package/esm/src/signing/{_signTypedData → signTypedData}/mod.js +0 -0
  316. /package/esm/src/signing/{_signTypedData → signTypedData}/private_key.d.ts +0 -0
  317. /package/esm/src/signing/{_signTypedData → signTypedData}/viem.d.ts +0 -0
  318. /package/esm/src/signing/{_signTypedData → signTypedData}/viem.js +0 -0
  319. /package/script/src/signing/{_signTypedData → signTypedData}/ethers.d.ts +0 -0
  320. /package/script/src/signing/{_signTypedData → signTypedData}/ethers.js +0 -0
  321. /package/script/src/signing/{_signTypedData → signTypedData}/mod.d.ts +0 -0
  322. /package/script/src/signing/{_signTypedData → signTypedData}/mod.js +0 -0
  323. /package/script/src/signing/{_signTypedData → signTypedData}/private_key.d.ts +0 -0
  324. /package/script/src/signing/{_signTypedData → signTypedData}/viem.d.ts +0 -0
  325. /package/script/src/signing/{_signTypedData → signTypedData}/viem.js +0 -0
  326. /package/src/src/{errors.ts → _errors.ts} +0 -0
  327. /package/src/src/signing/{_signTypedData → signTypedData}/ethers.ts +0 -0
  328. /package/src/src/signing/{_signTypedData → signTypedData}/mod.ts +0 -0
  329. /package/src/src/signing/{_signTypedData → signTypedData}/viem.ts +0 -0
@@ -1,5 +1,6 @@
1
1
  import * as v from "valibot";
2
- import { Hex, TokenId, UnsignedDecimal, UnsignedInteger } from "../_base.js";
2
+ import { Address, Hex, Integer, TokenId, UnsignedDecimal, UnsignedInteger } from "../_base.js";
3
+ import { TIF } from "../info/orders.js";
3
4
 
4
5
  /** Deeply removes undefined keys from an object. */
5
6
  function removeUndefinedKeys<T>(obj: T): T {
@@ -47,7 +48,10 @@ export const Signature = v.pipe(
47
48
  ),
48
49
  /** Recovery identifier. */
49
50
  v: v.pipe(
50
- v.union([v.literal(27), v.literal(28)]),
51
+ v.pipe(
52
+ Integer,
53
+ v.union([v.literal(27), v.literal(28)]),
54
+ ),
51
55
  v.description("Recovery identifier."),
52
56
  ),
53
57
  }),
@@ -92,13 +96,7 @@ export const OrderParams = v.pipe(
92
96
  v.object({
93
97
  /** Time-in-force. */
94
98
  tif: v.pipe(
95
- v.union([
96
- v.literal("Gtc"),
97
- v.literal("Ioc"),
98
- v.literal("Alo"),
99
- v.literal("FrontendMarket"),
100
- v.literal("LiquidationMarket"),
101
- ]),
99
+ TIF,
102
100
  v.description("Time-in-force."),
103
101
  ),
104
102
  }),
@@ -169,12 +167,12 @@ export const ApproveAgentRequest = v.pipe(
169
167
  ),
170
168
  /** Agent address. */
171
169
  agentAddress: v.pipe(
172
- v.pipe(Hex, v.length(42)),
170
+ Address,
173
171
  v.description("Agent address."),
174
172
  ),
175
- /** Agent name or null for unnamed agent. */
173
+ /** Agent name or null for unnamed agent (default: null). */
176
174
  agentName: v.pipe(
177
- v.nullable(v.string()),
175
+ v.optional(v.nullable(v.string()), null),
178
176
  v.description("Agent name or null for unnamed agent."),
179
177
  ),
180
178
  /** Unique request identifier (current timestamp in ms). */
@@ -233,7 +231,7 @@ export const ApproveBuilderFeeRequest = v.pipe(
233
231
  ),
234
232
  /** Builder address. */
235
233
  builder: v.pipe(
236
- v.pipe(Hex, v.length(42)),
234
+ Address,
237
235
  v.description("Builder address."),
238
236
  ),
239
237
  /** Unique request identifier (current timestamp in ms). */
@@ -309,7 +307,7 @@ export const BatchModifyRequest = v.pipe(
309
307
  ),
310
308
  /** Vault address (for vault trading). */
311
309
  vaultAddress: v.pipe(
312
- v.optional(v.pipe(Hex, v.length(42))),
310
+ v.optional(Address),
313
311
  v.description("Vault address (for vault trading)."),
314
312
  ),
315
313
  /** Expiration time of the action. */
@@ -369,7 +367,7 @@ export const CancelRequest = v.pipe(
369
367
  ),
370
368
  /** Vault address (for vault trading). */
371
369
  vaultAddress: v.pipe(
372
- v.optional(v.pipe(Hex, v.length(42))),
370
+ v.optional(Address),
373
371
  v.description("Vault address (for vault trading)."),
374
372
  ),
375
373
  /** Expiration time of the action. */
@@ -429,7 +427,7 @@ export const CancelByCloidRequest = v.pipe(
429
427
  ),
430
428
  /** Vault address (for vault trading). */
431
429
  vaultAddress: v.pipe(
432
- v.optional(v.pipe(Hex, v.length(42))),
430
+ v.optional(Address),
433
431
  v.description("Vault address (for vault trading)."),
434
432
  ),
435
433
  /** Expiration time of the action. */
@@ -542,7 +540,7 @@ export const ConvertToMultiSigUserRequestSigners = v.pipe(
542
540
  v.object({
543
541
  /** List of authorized user addresses. */
544
542
  authorizedUsers: v.pipe(
545
- v.array(v.pipe(Hex, v.length(42))),
543
+ v.array(Address),
546
544
  v.description("List of authorized user addresses."),
547
545
  ),
548
546
  /** Minimum number of signatures required. */
@@ -711,9 +709,9 @@ export const CreateVaultRequest = v.pipe(
711
709
  v.minValue(100000000), // 100 USDC
712
710
  v.description("Initial balance (float * 1e6)."),
713
711
  ),
714
- /** Unique request identifier (current timestamp in ms). */
712
+ /** Unique request identifier (current timestamp in ms) (default: Date.now()). */
715
713
  nonce: v.pipe(
716
- UnsignedInteger,
714
+ v.optional(UnsignedInteger, () => Date.now()), // default value is allowed because this is an L1 action
717
715
  v.description("Unique request identifier (current timestamp in ms)."),
718
716
  ),
719
717
  }),
@@ -868,7 +866,7 @@ export const CValidatorActionRequest = v.pipe(
868
866
  ),
869
867
  /** Signer address. */
870
868
  signer: v.pipe(
871
- v.nullable(v.pipe(Hex, v.length(42))),
869
+ v.nullable(Address),
872
870
  v.description("Signer address."),
873
871
  ),
874
872
  }),
@@ -921,7 +919,7 @@ export const CValidatorActionRequest = v.pipe(
921
919
  ),
922
920
  /** Signer address. */
923
921
  signer: v.pipe(
924
- v.pipe(Hex, v.length(42)),
922
+ Address,
925
923
  v.description("Signer address."),
926
924
  ),
927
925
  }),
@@ -1123,7 +1121,7 @@ export const ModifyRequest = v.pipe(
1123
1121
  ),
1124
1122
  /** Vault address (for vault trading). */
1125
1123
  vaultAddress: v.pipe(
1126
- v.optional(v.pipe(Hex, v.length(42))),
1124
+ v.optional(Address),
1127
1125
  v.description("Vault address (for vault trading)."),
1128
1126
  ),
1129
1127
  /** Expiration time of the action. */
@@ -1198,16 +1196,12 @@ export const OrderRequest = v.pipe(
1198
1196
  ),
1199
1197
  /**
1200
1198
  * Order grouping strategy:
1201
- * - `na`: Standard order without grouping.
1199
+ * - `na`: Standard order without grouping (default).
1202
1200
  * - `normalTpsl`: TP/SL order with fixed size that doesn't adjust with position changes.
1203
1201
  * - `positionTpsl`: TP/SL order that adjusts proportionally with the position size.
1204
1202
  */
1205
1203
  grouping: v.pipe(
1206
- v.union([
1207
- v.literal("na"),
1208
- v.literal("normalTpsl"),
1209
- v.literal("positionTpsl"),
1210
- ]),
1204
+ v.optional(v.union([v.literal("na"), v.literal("normalTpsl"), v.literal("positionTpsl")]), "na"),
1211
1205
  v.description(
1212
1206
  "Order grouping strategy:" +
1213
1207
  "\n- `na`: Standard order without grouping." +
@@ -1220,7 +1214,7 @@ export const OrderRequest = v.pipe(
1220
1214
  v.optional(v.object({
1221
1215
  /** Builder address. */
1222
1216
  b: v.pipe(
1223
- v.pipe(Hex, v.length(42)),
1217
+ Address,
1224
1218
  v.description("Builder address."),
1225
1219
  ),
1226
1220
  /** Builder fee in 0.1bps (1 = 0.0001%). */
@@ -1246,7 +1240,7 @@ export const OrderRequest = v.pipe(
1246
1240
  ),
1247
1241
  /** Vault address (for vault trading). */
1248
1242
  vaultAddress: v.pipe(
1249
- v.optional(v.pipe(Hex, v.length(42))),
1243
+ v.optional(Address),
1250
1244
  v.description("Vault address (for vault trading)."),
1251
1245
  ),
1252
1246
  /** Expiration time of the action. */
@@ -1340,7 +1334,7 @@ export const PerpDeployRequest = v.pipe(
1340
1334
  ),
1341
1335
  /** User to update oracles. If not provided, then deployer is assumed to be oracle updater. */
1342
1336
  oracleUpdater: v.pipe(
1343
- v.nullable(v.pipe(Hex, v.length(42))),
1337
+ v.nullable(Address),
1344
1338
  v.description(
1345
1339
  "User to update oracles. If not provided, then deployer is assumed to be oracle updater.",
1346
1340
  ),
@@ -1382,6 +1376,13 @@ export const PerpDeployRequest = v.pipe(
1382
1376
  "An outer list of inner lists (inner list sorted by key) of asset and mark prices.",
1383
1377
  ),
1384
1378
  ),
1379
+ /** A list (sorted by key) of asset and external prices which prevent sudden mark price deviations. */
1380
+ externalPerpPxs: v.pipe(
1381
+ v.array(v.tuple([v.string(), UnsignedDecimal])),
1382
+ v.description(
1383
+ "A list (sorted by key) of asset and external prices which prevent sudden mark price deviations.",
1384
+ ),
1385
+ ),
1385
1386
  }),
1386
1387
  v.description("Parameters for setting oracle and mark prices for assets."),
1387
1388
  ),
@@ -1549,7 +1550,7 @@ export const ScheduleCancelRequest = v.pipe(
1549
1550
  ),
1550
1551
  /** Vault address (for vault trading). */
1551
1552
  vaultAddress: v.pipe(
1552
- v.optional(v.pipe(Hex, v.length(42))),
1553
+ v.optional(Address),
1553
1554
  v.description("Vault address (for vault trading)."),
1554
1555
  ),
1555
1556
  /** Expiration time of the action. */
@@ -1590,7 +1591,7 @@ export const SendAssetRequest = v.pipe(
1590
1591
  ),
1591
1592
  /** Destination address. */
1592
1593
  destination: v.pipe(
1593
- v.pipe(Hex, v.length(42)),
1594
+ Address,
1594
1595
  v.description("Destination address."),
1595
1596
  ),
1596
1597
  /** Source DEX ("" for default USDC perp DEX, "spot" for spot). */
@@ -1613,12 +1614,9 @@ export const SendAssetRequest = v.pipe(
1613
1614
  UnsignedDecimal,
1614
1615
  v.description("Amount to send (not in wei)."),
1615
1616
  ),
1616
- /** Source sub-account address ("" for main account). */
1617
+ /** Source sub-account address ("" for main account) (default: ""). */
1617
1618
  fromSubAccount: v.pipe(
1618
- v.union([
1619
- v.literal(""),
1620
- v.pipe(Hex, v.length(42)),
1621
- ]),
1619
+ v.optional(v.union([v.literal(""), Address]), ""),
1622
1620
  v.description('Source sub-account address ("" for main account).'),
1623
1621
  ),
1624
1622
  /** Unique request identifier (current timestamp in ms). */
@@ -1943,7 +1941,7 @@ export const SpotDeployRequest = v.pipe(
1943
1941
  ),
1944
1942
  /** Array of tuples: [user address, genesis amount in wei]. */
1945
1943
  userAndWei: v.pipe(
1946
- v.array(v.tuple([v.pipe(Hex, v.length(42)), UnsignedDecimal])),
1944
+ v.array(v.tuple([Address, UnsignedDecimal])),
1947
1945
  v.description("Array of tuples: [user address, genesis amount in wei]."),
1948
1946
  ),
1949
1947
  /** Array of tuples: [existing token identifier, genesis amount in wei]. */
@@ -1960,7 +1958,7 @@ export const SpotDeployRequest = v.pipe(
1960
1958
  ),
1961
1959
  /** Array of tuples: [user address, blacklist status] (`true` for blacklist, `false` to remove existing blacklisted user). */
1962
1960
  blacklistUsers: v.pipe(
1963
- v.optional(v.array(v.tuple([v.pipe(Hex, v.length(42)), v.boolean()]))),
1961
+ v.optional(v.array(v.tuple([Address, v.boolean()]))),
1964
1962
  v.description(
1965
1963
  "Array of tuples: [user address, blacklist status] (`true` for blacklist, `false` to remove existing blacklisted user).",
1966
1964
  ),
@@ -2030,7 +2028,7 @@ export const SpotSendRequest = v.pipe(
2030
2028
  ),
2031
2029
  /** Destination address. */
2032
2030
  destination: v.pipe(
2033
- v.pipe(Hex, v.length(42)),
2031
+ Address,
2034
2032
  v.description("Destination address."),
2035
2033
  ),
2036
2034
  /** Token identifier. */
@@ -2134,7 +2132,7 @@ export const SubAccountModifyRequest = v.pipe(
2134
2132
  ),
2135
2133
  /** Sub-account address to modify. */
2136
2134
  subAccountUser: v.pipe(
2137
- v.pipe(Hex, v.length(42)),
2135
+ Address,
2138
2136
  v.description("Sub-account address to modify."),
2139
2137
  ),
2140
2138
  /** New sub-account name. */
@@ -2184,7 +2182,7 @@ export const SubAccountSpotTransferRequest = v.pipe(
2184
2182
  ),
2185
2183
  /** Sub-account address. */
2186
2184
  subAccountUser: v.pipe(
2187
- v.pipe(Hex, v.length(42)),
2185
+ Address,
2188
2186
  v.description("Sub-account address."),
2189
2187
  ),
2190
2188
  /** `true` for deposit, `false` for withdrawal. */
@@ -2243,7 +2241,7 @@ export const SubAccountTransferRequest = v.pipe(
2243
2241
  ),
2244
2242
  /** Sub-account address. */
2245
2243
  subAccountUser: v.pipe(
2246
- v.pipe(Hex, v.length(42)),
2244
+ Address,
2247
2245
  v.description("Sub-account address."),
2248
2246
  ),
2249
2247
  /** `true` for deposit, `false` for withdrawal. */
@@ -2307,7 +2305,7 @@ export const TokenDelegateRequest = v.pipe(
2307
2305
  ),
2308
2306
  /** Validator address. */
2309
2307
  validator: v.pipe(
2310
- v.pipe(Hex, v.length(42)),
2308
+ Address,
2311
2309
  v.description("Validator address."),
2312
2310
  ),
2313
2311
  /** Amount for delegate/undelegate (float * 1e8). */
@@ -2384,7 +2382,7 @@ export const TwapCancelRequest = v.pipe(
2384
2382
  ),
2385
2383
  /** Vault address (for vault trading). */
2386
2384
  vaultAddress: v.pipe(
2387
- v.optional(v.pipe(Hex, v.length(42))),
2385
+ v.optional(Address),
2388
2386
  v.description("Vault address (for vault trading)."),
2389
2387
  ),
2390
2388
  /** Expiration time of the action. */
@@ -2464,7 +2462,7 @@ export const TwapOrderRequest = v.pipe(
2464
2462
  ),
2465
2463
  /** Vault address (for vault trading). */
2466
2464
  vaultAddress: v.pipe(
2467
- v.optional(v.pipe(Hex, v.length(42))),
2465
+ v.optional(Address),
2468
2466
  v.description("Vault address (for vault trading)."),
2469
2467
  ),
2470
2468
  /** Expiration time of the action. */
@@ -2523,7 +2521,7 @@ export const UpdateIsolatedMarginRequest = v.pipe(
2523
2521
  ),
2524
2522
  /** Vault address (for vault trading). */
2525
2523
  vaultAddress: v.pipe(
2526
- v.optional(v.pipe(Hex, v.length(42))),
2524
+ v.optional(Address),
2527
2525
  v.description("Vault address (for vault trading)."),
2528
2526
  ),
2529
2527
  /** Expiration time of the action. */
@@ -2582,7 +2580,7 @@ export const UpdateLeverageRequest = v.pipe(
2582
2580
  ),
2583
2581
  /** Vault address (for vault trading). */
2584
2582
  vaultAddress: v.pipe(
2585
- v.optional(v.pipe(Hex, v.length(42))),
2583
+ v.optional(Address),
2586
2584
  v.description("Vault address (for vault trading)."),
2587
2585
  ),
2588
2586
  /** Expiration time of the action. */
@@ -2682,7 +2680,7 @@ export const UsdSendRequest = v.pipe(
2682
2680
  ),
2683
2681
  /** Destination address. */
2684
2682
  destination: v.pipe(
2685
- v.pipe(Hex, v.length(42)),
2683
+ Address,
2686
2684
  v.description("Destination address."),
2687
2685
  ),
2688
2686
  /** Amount to send (1 = 1$). */
@@ -2731,7 +2729,7 @@ export const VaultDistributeRequest = v.pipe(
2731
2729
  ),
2732
2730
  /** Vault address. */
2733
2731
  vaultAddress: v.pipe(
2734
- v.pipe(Hex, v.length(42)),
2732
+ Address,
2735
2733
  v.description("Vault address."),
2736
2734
  ),
2737
2735
  /**
@@ -2787,17 +2785,17 @@ export const VaultModifyRequest = v.pipe(
2787
2785
  ),
2788
2786
  /** Vault address. */
2789
2787
  vaultAddress: v.pipe(
2790
- v.pipe(Hex, v.length(42)),
2788
+ Address,
2791
2789
  v.description("Vault address."),
2792
2790
  ),
2793
- /** Allow deposits from followers. */
2791
+ /** Allow deposits from followers (default: null). */
2794
2792
  allowDeposits: v.pipe(
2795
- v.nullable(v.boolean()),
2793
+ v.optional(v.nullable(v.boolean()), null),
2796
2794
  v.description("Allow deposits from followers."),
2797
2795
  ),
2798
- /** Always close positions on withdrawal. */
2796
+ /** Always close positions on withdrawal (default: null). */
2799
2797
  alwaysCloseOnWithdraw: v.pipe(
2800
- v.nullable(v.boolean()),
2798
+ v.optional(v.nullable(v.boolean()), null),
2801
2799
  v.description("Always close positions on withdrawal."),
2802
2800
  ),
2803
2801
  }),
@@ -2841,7 +2839,7 @@ export const VaultTransferRequest = v.pipe(
2841
2839
  ),
2842
2840
  /** Vault address. */
2843
2841
  vaultAddress: v.pipe(
2844
- v.pipe(Hex, v.length(42)),
2842
+ Address,
2845
2843
  v.description("Vault address."),
2846
2844
  ),
2847
2845
  /** `true` for deposit, `false` for withdrawal. */
@@ -2905,7 +2903,7 @@ export const Withdraw3Request = v.pipe(
2905
2903
  ),
2906
2904
  /** Destination address. */
2907
2905
  destination: v.pipe(
2908
- v.pipe(Hex, v.length(42)),
2906
+ Address,
2909
2907
  v.description("Destination address."),
2910
2908
  ),
2911
2909
  /** Amount to withdraw (1 = 1$). */
@@ -2967,12 +2965,12 @@ export const MultiSigRequest = v.pipe(
2967
2965
  v.object({
2968
2966
  /** Address of the multi-signature user account. */
2969
2967
  multiSigUser: v.pipe(
2970
- v.pipe(Hex, v.length(42)),
2968
+ Address,
2971
2969
  v.description("Address of the multi-signature user account."),
2972
2970
  ),
2973
2971
  /** Address of the authorized user initiating the request (any authorized user). */
2974
2972
  outerSigner: v.pipe(
2975
- v.pipe(Hex, v.length(42)),
2973
+ Address,
2976
2974
  v.description(
2977
2975
  "Address of the authorized user initiating the request (any authorized user).",
2978
2976
  ),
@@ -3042,7 +3040,7 @@ export const MultiSigRequest = v.pipe(
3042
3040
  ),
3043
3041
  /** Vault address (for vault trading). */
3044
3042
  vaultAddress: v.pipe(
3045
- v.optional(v.pipe(Hex, v.length(42))),
3043
+ v.optional(Address),
3046
3044
  v.description("Vault address (for vault trading)."),
3047
3045
  ),
3048
3046
  /** Expiration time of the action. */
@@ -1,5 +1,5 @@
1
1
  import * as v from "valibot";
2
- import { Hex, UnsignedDecimal, UnsignedInteger } from "../_base.js";
2
+ import { Address, Hex, UnsignedDecimal, UnsignedInteger } from "../_base.js";
3
3
 
4
4
  /** Response for order cancellation. */
5
5
  export const CancelResponse = v.pipe(
@@ -100,7 +100,7 @@ export const CreateSubAccountResponse = v.pipe(
100
100
  ),
101
101
  /** Sub-account address. */
102
102
  data: v.pipe(
103
- v.pipe(Hex, v.length(42)),
103
+ Address,
104
104
  v.description("Sub-account address."),
105
105
  ),
106
106
  }),
@@ -129,7 +129,7 @@ export const CreateVaultResponse = v.pipe(
129
129
  ),
130
130
  /** Vault address. */
131
131
  data: v.pipe(
132
- v.pipe(Hex, v.length(42)),
132
+ Address,
133
133
  v.description("Vault address."),
134
134
  ),
135
135
  }),
@@ -1,5 +1,5 @@
1
1
  import * as v from "valibot";
2
- import { Hex, UnsignedInteger } from "../_base.js";
2
+ import { Address, Hex, UnsignedInteger } from "../_base.js";
3
3
 
4
4
  /**
5
5
  * Request block details by block height.
@@ -56,7 +56,7 @@ export const UserDetailsRequest = v.pipe(
56
56
  ),
57
57
  /** User address. */
58
58
  user: v.pipe(
59
- v.pipe(Hex, v.length(42)),
59
+ Address,
60
60
  v.description("User address."),
61
61
  ),
62
62
  }),
@@ -1,5 +1,5 @@
1
1
  import * as v from "valibot";
2
- import { Hex, UnsignedInteger } from "../_base.js";
2
+ import { Address, Hex, UnsignedInteger } from "../_base.js";
3
3
 
4
4
  /** Transaction details. */
5
5
  export const TxDetails = v.pipe(
@@ -37,7 +37,7 @@ export const TxDetails = v.pipe(
37
37
  ),
38
38
  /** Creator's address. */
39
39
  user: v.pipe(
40
- v.pipe(Hex, v.length(42)),
40
+ Address,
41
41
  v.description("Creator's address."),
42
42
  ),
43
43
  }),
@@ -88,7 +88,7 @@ export const BlockDetails = v.pipe(
88
88
  ),
89
89
  /** Block proposer address. */
90
90
  proposer: v.pipe(
91
- v.pipe(Hex, v.length(42)),
91
+ Address,
92
92
  v.description("Block proposer address."),
93
93
  ),
94
94
  /** List of transactions. */