@nktkas/hyperliquid 0.24.2 → 0.25.0-beta.1

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