@nktkas/hyperliquid 0.13.1 → 0.14.0

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 (243) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +334 -107
  3. package/esm/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts +9 -0
  4. package/esm/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts.map +1 -0
  5. package/esm/deps/jsr.io/@std/bytes/1.0.5/_types.js +2 -0
  6. package/esm/deps/jsr.io/@std/bytes/{1.0.4 → 1.0.5}/concat.d.ts +3 -1
  7. package/esm/deps/jsr.io/@std/bytes/1.0.5/concat.d.ts.map +1 -0
  8. package/esm/deps/jsr.io/@std/bytes/{1.0.4 → 1.0.5}/concat.js +1 -1
  9. package/esm/deps/jsr.io/@std/encoding/1.0.7/_types.d.ts +9 -0
  10. package/esm/deps/jsr.io/@std/encoding/1.0.7/_types.d.ts.map +1 -0
  11. package/esm/deps/jsr.io/@std/encoding/1.0.7/_types.js +2 -0
  12. package/esm/deps/jsr.io/@std/encoding/{1.0.6 → 1.0.7}/_validate_binary_like.d.ts.map +1 -1
  13. package/esm/deps/jsr.io/@std/encoding/{1.0.6 → 1.0.7}/_validate_binary_like.js +1 -1
  14. package/{script/deps/jsr.io/@std/encoding/1.0.6 → esm/deps/jsr.io/@std/encoding/1.0.7}/hex.d.ts +3 -1
  15. package/esm/deps/jsr.io/@std/encoding/1.0.7/hex.d.ts.map +1 -0
  16. package/esm/deps/jsr.io/@std/encoding/{1.0.6 → 1.0.7}/hex.js +1 -1
  17. package/esm/deps/jsr.io/@std/msgpack/1.0.3/_types.d.ts +9 -0
  18. package/esm/deps/jsr.io/@std/msgpack/1.0.3/_types.d.ts.map +1 -0
  19. package/esm/deps/jsr.io/@std/msgpack/1.0.3/_types.js +2 -0
  20. package/esm/deps/jsr.io/@std/msgpack/{1.0.2 → 1.0.3}/encode.d.ts +3 -1
  21. package/esm/deps/jsr.io/@std/msgpack/1.0.3/encode.d.ts.map +1 -0
  22. package/esm/deps/jsr.io/@std/msgpack/{1.0.2 → 1.0.3}/encode.js +2 -2
  23. package/esm/mod.d.ts +4 -12
  24. package/esm/mod.d.ts.map +1 -1
  25. package/esm/mod.js +2 -2
  26. package/{script/src/transports → esm/src}/base.d.ts +10 -13
  27. package/esm/src/base.d.ts.map +1 -0
  28. package/esm/src/base.js +14 -0
  29. package/esm/src/clients/event.d.ts +59 -18
  30. package/esm/src/clients/event.d.ts.map +1 -1
  31. package/esm/src/clients/event.js +74 -18
  32. package/esm/src/clients/public.d.ts +348 -53
  33. package/esm/src/clients/public.d.ts.map +1 -1
  34. package/esm/src/clients/public.js +349 -50
  35. package/esm/src/clients/wallet.d.ts +345 -73
  36. package/esm/src/clients/wallet.d.ts.map +1 -1
  37. package/esm/src/clients/wallet.js +979 -229
  38. package/esm/src/signing.d.ts +135 -0
  39. package/esm/src/signing.d.ts.map +1 -0
  40. package/esm/src/signing.js +188 -0
  41. package/esm/src/transports/http/http_transport.d.ts +1 -1
  42. package/esm/src/transports/http/http_transport.d.ts.map +1 -1
  43. package/esm/src/transports/http/http_transport.js +1 -1
  44. package/esm/src/transports/websocket/_hyperliquid_event_target.d.ts +64 -0
  45. package/esm/src/transports/websocket/_hyperliquid_event_target.d.ts.map +1 -0
  46. package/esm/src/transports/websocket/_hyperliquid_event_target.js +52 -0
  47. package/esm/src/transports/websocket/{reconnecting_websocket.d.ts → _reconnecting_websocket.d.ts} +26 -26
  48. package/esm/src/transports/websocket/_reconnecting_websocket.d.ts.map +1 -0
  49. package/esm/src/transports/websocket/{reconnecting_websocket.js → _reconnecting_websocket.js} +91 -76
  50. package/{script/src/transports/websocket/websocket_request_dispatcher.d.ts → esm/src/transports/websocket/_websocket_request_dispatcher.d.ts} +3 -7
  51. package/esm/src/transports/websocket/_websocket_request_dispatcher.d.ts.map +1 -0
  52. package/esm/src/transports/websocket/{websocket_request_dispatcher.js → _websocket_request_dispatcher.js} +6 -10
  53. package/esm/src/transports/websocket/websocket_transport.d.ts +15 -21
  54. package/esm/src/transports/websocket/websocket_transport.d.ts.map +1 -1
  55. package/esm/src/transports/websocket/websocket_transport.js +55 -52
  56. package/esm/src/types/exchange/requests.d.ts +298 -79
  57. package/esm/src/types/exchange/requests.d.ts.map +1 -1
  58. package/esm/src/types/exchange/responses.d.ts +38 -38
  59. package/esm/src/types/exchange/responses.d.ts.map +1 -1
  60. package/esm/src/types/explorer/requests.d.ts +23 -10
  61. package/esm/src/types/explorer/requests.d.ts.map +1 -1
  62. package/esm/src/types/explorer/responses.d.ts +45 -3
  63. package/esm/src/types/explorer/responses.d.ts.map +1 -1
  64. package/esm/src/types/info/accounts.d.ts +279 -189
  65. package/esm/src/types/info/accounts.d.ts.map +1 -1
  66. package/esm/src/types/info/assets.d.ts +191 -185
  67. package/esm/src/types/info/assets.d.ts.map +1 -1
  68. package/esm/src/types/info/delegations.d.ts +117 -0
  69. package/esm/src/types/info/delegations.d.ts.map +1 -0
  70. package/esm/src/types/info/orders.d.ts +94 -94
  71. package/esm/src/types/info/orders.d.ts.map +1 -1
  72. package/esm/src/types/info/requests.d.ts +192 -64
  73. package/esm/src/types/info/requests.d.ts.map +1 -1
  74. package/esm/src/types/info/vaults.d.ts +42 -85
  75. package/esm/src/types/info/vaults.d.ts.map +1 -1
  76. package/esm/src/types/mod.d.ts +14 -0
  77. package/esm/src/types/mod.d.ts.map +1 -0
  78. package/esm/src/types/subscriptions/requests.d.ts +11 -1
  79. package/esm/src/types/subscriptions/requests.d.ts.map +1 -1
  80. package/{script/src/types/subscriptions/common.d.ts → esm/src/types/subscriptions/responses.d.ts} +18 -3
  81. package/esm/src/types/subscriptions/responses.d.ts.map +1 -0
  82. package/package.json +20 -4
  83. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.js +13 -3
  84. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.js +23 -13
  85. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.js +55 -45
  86. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_u64.js +97 -87
  87. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/crypto.js +14 -4
  88. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/sha3.js +288 -278
  89. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/utils.js +238 -228
  90. package/script/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts +9 -0
  91. package/script/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts.map +1 -0
  92. package/script/deps/jsr.io/@std/bytes/1.0.5/_types.js +13 -0
  93. package/script/deps/jsr.io/@std/bytes/{1.0.4 → 1.0.5}/concat.d.ts +3 -1
  94. package/script/deps/jsr.io/@std/bytes/1.0.5/concat.d.ts.map +1 -0
  95. package/script/deps/jsr.io/@std/bytes/1.0.5/concat.js +45 -0
  96. package/script/deps/jsr.io/@std/encoding/1.0.7/_types.d.ts +9 -0
  97. package/script/deps/jsr.io/@std/encoding/1.0.7/_types.d.ts.map +1 -0
  98. package/script/deps/jsr.io/@std/encoding/1.0.7/_types.js +13 -0
  99. package/script/deps/jsr.io/@std/encoding/{1.0.6 → 1.0.7}/_validate_binary_like.d.ts.map +1 -1
  100. package/script/deps/jsr.io/@std/encoding/1.0.7/_validate_binary_like.js +39 -0
  101. package/{esm/deps/jsr.io/@std/encoding/1.0.6 → script/deps/jsr.io/@std/encoding/1.0.7}/hex.d.ts +3 -1
  102. package/script/deps/jsr.io/@std/encoding/1.0.7/hex.d.ts.map +1 -0
  103. package/script/deps/jsr.io/@std/encoding/1.0.7/hex.js +123 -0
  104. package/script/deps/jsr.io/@std/msgpack/1.0.3/_types.d.ts +9 -0
  105. package/script/deps/jsr.io/@std/msgpack/1.0.3/_types.d.ts.map +1 -0
  106. package/script/deps/jsr.io/@std/msgpack/1.0.3/_types.js +13 -0
  107. package/script/deps/jsr.io/@std/msgpack/{1.0.2 → 1.0.3}/encode.d.ts +3 -1
  108. package/script/deps/jsr.io/@std/msgpack/1.0.3/encode.d.ts.map +1 -0
  109. package/script/deps/jsr.io/@std/msgpack/1.0.3/encode.js +250 -0
  110. package/script/mod.d.ts +4 -12
  111. package/script/mod.d.ts.map +1 -1
  112. package/script/mod.js +21 -13
  113. package/{esm/src/transports → script/src}/base.d.ts +10 -13
  114. package/script/src/base.d.ts.map +1 -0
  115. package/script/src/base.js +29 -0
  116. package/script/src/clients/event.d.ts +59 -18
  117. package/script/src/clients/event.d.ts.map +1 -1
  118. package/script/src/clients/event.js +551 -485
  119. package/script/src/clients/public.d.ts +348 -53
  120. package/script/src/clients/public.d.ts.map +1 -1
  121. package/script/src/clients/public.js +1017 -708
  122. package/script/src/clients/wallet.d.ts +345 -73
  123. package/script/src/clients/wallet.d.ts.map +1 -1
  124. package/script/src/clients/wallet.js +1737 -977
  125. package/script/src/signing.d.ts +135 -0
  126. package/script/src/signing.d.ts.map +1 -0
  127. package/script/src/signing.js +203 -0
  128. package/script/src/transports/http/http_transport.d.ts +1 -1
  129. package/script/src/transports/http/http_transport.d.ts.map +1 -1
  130. package/script/src/transports/http/http_transport.js +174 -164
  131. package/script/src/transports/websocket/_hyperliquid_event_target.d.ts +64 -0
  132. package/script/src/transports/websocket/_hyperliquid_event_target.d.ts.map +1 -0
  133. package/script/src/transports/websocket/_hyperliquid_event_target.js +66 -0
  134. package/script/src/transports/websocket/{reconnecting_websocket.d.ts → _reconnecting_websocket.d.ts} +26 -26
  135. package/script/src/transports/websocket/_reconnecting_websocket.d.ts.map +1 -0
  136. package/script/src/transports/websocket/_reconnecting_websocket.js +400 -0
  137. package/{esm/src/transports/websocket/websocket_request_dispatcher.d.ts → script/src/transports/websocket/_websocket_request_dispatcher.d.ts} +3 -7
  138. package/script/src/transports/websocket/_websocket_request_dispatcher.d.ts.map +1 -0
  139. package/script/src/transports/websocket/_websocket_request_dispatcher.js +212 -0
  140. package/script/src/transports/websocket/websocket_transport.d.ts +15 -21
  141. package/script/src/transports/websocket/websocket_transport.d.ts.map +1 -1
  142. package/script/src/transports/websocket/websocket_transport.js +235 -222
  143. package/script/src/types/exchange/requests.d.ts +298 -79
  144. package/script/src/types/exchange/requests.d.ts.map +1 -1
  145. package/script/src/types/exchange/requests.js +12 -2
  146. package/script/src/types/exchange/responses.d.ts +38 -38
  147. package/script/src/types/exchange/responses.d.ts.map +1 -1
  148. package/script/src/types/exchange/responses.js +12 -2
  149. package/script/src/types/explorer/requests.d.ts +23 -10
  150. package/script/src/types/explorer/requests.d.ts.map +1 -1
  151. package/script/src/types/explorer/requests.js +12 -2
  152. package/script/src/types/explorer/responses.d.ts +45 -3
  153. package/script/src/types/explorer/responses.d.ts.map +1 -1
  154. package/script/src/types/explorer/responses.js +12 -2
  155. package/script/src/types/info/accounts.d.ts +279 -189
  156. package/script/src/types/info/accounts.d.ts.map +1 -1
  157. package/script/src/types/info/accounts.js +12 -2
  158. package/script/src/types/info/assets.d.ts +191 -185
  159. package/script/src/types/info/assets.d.ts.map +1 -1
  160. package/script/src/types/info/assets.js +12 -2
  161. package/script/src/types/info/delegations.d.ts +117 -0
  162. package/script/src/types/info/delegations.d.ts.map +1 -0
  163. package/script/src/types/info/delegations.js +12 -0
  164. package/script/src/types/info/orders.d.ts +94 -94
  165. package/script/src/types/info/orders.d.ts.map +1 -1
  166. package/script/src/types/info/orders.js +12 -2
  167. package/script/src/types/info/requests.d.ts +192 -64
  168. package/script/src/types/info/requests.d.ts.map +1 -1
  169. package/script/src/types/info/requests.js +12 -2
  170. package/script/src/types/info/vaults.d.ts +42 -85
  171. package/script/src/types/info/vaults.d.ts.map +1 -1
  172. package/script/src/types/info/vaults.js +12 -2
  173. package/script/src/types/mod.d.ts +14 -0
  174. package/script/src/types/mod.d.ts.map +1 -0
  175. package/script/src/types/mod.js +12 -0
  176. package/script/src/types/subscriptions/requests.d.ts +11 -1
  177. package/script/src/types/subscriptions/requests.d.ts.map +1 -1
  178. package/script/src/types/subscriptions/requests.js +12 -2
  179. package/{esm/src/types/subscriptions/common.d.ts → script/src/types/subscriptions/responses.d.ts} +18 -3
  180. package/script/src/types/subscriptions/responses.d.ts.map +1 -0
  181. package/script/src/types/subscriptions/responses.js +12 -0
  182. package/esm/deps/jsr.io/@std/bytes/1.0.4/concat.d.ts.map +0 -1
  183. package/esm/deps/jsr.io/@std/encoding/1.0.6/hex.d.ts.map +0 -1
  184. package/esm/deps/jsr.io/@std/msgpack/1.0.2/encode.d.ts.map +0 -1
  185. package/esm/src/transports/base.d.ts.map +0 -1
  186. package/esm/src/transports/base.js +0 -14
  187. package/esm/src/transports/websocket/hyperliquid_event_target.d.ts +0 -66
  188. package/esm/src/transports/websocket/hyperliquid_event_target.d.ts.map +0 -1
  189. package/esm/src/transports/websocket/hyperliquid_event_target.js +0 -33
  190. package/esm/src/transports/websocket/reconnecting_websocket.d.ts.map +0 -1
  191. package/esm/src/transports/websocket/websocket_request_dispatcher.d.ts.map +0 -1
  192. package/esm/src/types/common.d.ts +0 -3
  193. package/esm/src/types/common.d.ts.map +0 -1
  194. package/esm/src/types/exchange/common.d.ts +0 -36
  195. package/esm/src/types/exchange/common.d.ts.map +0 -1
  196. package/esm/src/types/explorer/common.d.ts +0 -37
  197. package/esm/src/types/explorer/common.d.ts.map +0 -1
  198. package/esm/src/types/subscriptions/common.d.ts.map +0 -1
  199. package/esm/src/types/subscriptions/common.js +0 -1
  200. package/esm/src/utils/key_sort.d.ts +0 -21
  201. package/esm/src/utils/key_sort.d.ts.map +0 -1
  202. package/esm/src/utils/key_sort.js +0 -124
  203. package/esm/src/utils/signing.d.ts +0 -109
  204. package/esm/src/utils/signing.d.ts.map +0 -1
  205. package/esm/src/utils/signing.js +0 -164
  206. package/script/deps/jsr.io/@std/bytes/1.0.4/concat.d.ts.map +0 -1
  207. package/script/deps/jsr.io/@std/bytes/1.0.4/concat.js +0 -35
  208. package/script/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.js +0 -29
  209. package/script/deps/jsr.io/@std/encoding/1.0.6/hex.d.ts.map +0 -1
  210. package/script/deps/jsr.io/@std/encoding/1.0.6/hex.js +0 -113
  211. package/script/deps/jsr.io/@std/msgpack/1.0.2/encode.d.ts.map +0 -1
  212. package/script/deps/jsr.io/@std/msgpack/1.0.2/encode.js +0 -240
  213. package/script/src/transports/base.d.ts.map +0 -1
  214. package/script/src/transports/base.js +0 -18
  215. package/script/src/transports/websocket/hyperliquid_event_target.d.ts +0 -66
  216. package/script/src/transports/websocket/hyperliquid_event_target.d.ts.map +0 -1
  217. package/script/src/transports/websocket/hyperliquid_event_target.js +0 -37
  218. package/script/src/transports/websocket/reconnecting_websocket.d.ts.map +0 -1
  219. package/script/src/transports/websocket/reconnecting_websocket.js +0 -374
  220. package/script/src/transports/websocket/websocket_request_dispatcher.d.ts.map +0 -1
  221. package/script/src/transports/websocket/websocket_request_dispatcher.js +0 -206
  222. package/script/src/types/common.d.ts +0 -3
  223. package/script/src/types/common.d.ts.map +0 -1
  224. package/script/src/types/common.js +0 -2
  225. package/script/src/types/exchange/common.d.ts +0 -36
  226. package/script/src/types/exchange/common.d.ts.map +0 -1
  227. package/script/src/types/exchange/common.js +0 -2
  228. package/script/src/types/explorer/common.d.ts +0 -37
  229. package/script/src/types/explorer/common.d.ts.map +0 -1
  230. package/script/src/types/explorer/common.js +0 -2
  231. package/script/src/types/subscriptions/common.d.ts.map +0 -1
  232. package/script/src/types/subscriptions/common.js +0 -2
  233. package/script/src/utils/key_sort.d.ts +0 -21
  234. package/script/src/utils/key_sort.d.ts.map +0 -1
  235. package/script/src/utils/key_sort.js +0 -127
  236. package/script/src/utils/signing.d.ts +0 -109
  237. package/script/src/utils/signing.d.ts.map +0 -1
  238. package/script/src/utils/signing.js +0 -172
  239. /package/esm/deps/jsr.io/@std/encoding/{1.0.6 → 1.0.7}/_validate_binary_like.d.ts +0 -0
  240. /package/esm/src/types/{common.js → info/delegations.js} +0 -0
  241. /package/esm/src/types/{exchange/common.js → mod.js} +0 -0
  242. /package/esm/src/types/{explorer/common.js → subscriptions/responses.js} +0 -0
  243. /package/script/deps/jsr.io/@std/encoding/{1.0.6 → 1.0.7}/_validate_binary_like.d.ts +0 -0
@@ -1,5 +1,5 @@
1
- import type { Hex } from "../common.js";
2
- /** Position in a specific asset. */
1
+ import type { Hex } from "../../base.js";
2
+ /** Position for a specific asset. */
3
3
  export interface AssetPosition {
4
4
  /** Position type. */
5
5
  type: "oneWay";
@@ -27,7 +27,7 @@ export interface AssetPosition {
27
27
  entryPx: string;
28
28
  /** Position value. */
29
29
  positionValue: string;
30
- /** Unrealized PnL. */
30
+ /** Unrealized profit and loss. */
31
31
  unrealizedPnl: string;
32
32
  /** Return on equity. */
33
33
  returnOnEquity: string;
@@ -41,31 +41,56 @@ export interface AssetPosition {
41
41
  cumFunding: {
42
42
  /** Total funding paid or received since account opening. */
43
43
  allTime: string;
44
- /** Funding since the position was opened. */
44
+ /** Funding accumulated since the position was opened. */
45
45
  sinceOpen: string;
46
- /** Funding since the last position size change. */
46
+ /** Funding accumulated since the last change in position size. */
47
47
  sinceChange: string;
48
48
  };
49
49
  };
50
50
  }
51
- /** Account summary for perpetual trading. */
51
+ /** Extra agent details for a user. */
52
+ export interface ExtraAgent {
53
+ /** Extra agent address. */
54
+ address: Hex;
55
+ /** Extra agent name. */
56
+ name: string;
57
+ /** Validity period as a timestamp (in ms since epoch). */
58
+ validUntil: number;
59
+ }
60
+ /** Legal verification status for a user. */
61
+ export interface LegalCheck {
62
+ /** Whether the user's IP address is allowed. */
63
+ ipAllowed: boolean;
64
+ /** Whether the user has accepted the terms of service. */
65
+ acceptedTerms: boolean;
66
+ /** Whether the user is allowed to use the platform. */
67
+ userAllowed: boolean;
68
+ }
69
+ /** Multi-sig signers for a user. */
70
+ export interface MultiSigSigners {
71
+ /** Authorized users addresses. */
72
+ authorizedUsers: Hex[];
73
+ /** Threshold number of signatures required. */
74
+ threshold: number;
75
+ }
76
+ /** Perpetual trading clearinghouse state summary. */
52
77
  export interface PerpsClearinghouseState {
53
- /** Margin details. */
78
+ /** Margin summary details. */
54
79
  marginSummary: {
55
80
  /** Total account value. */
56
81
  accountValue: string;
57
- /** Total notional value. */
82
+ /** Total notional position value. */
58
83
  totalNtlPos: string;
59
84
  /** Total raw USD value. */
60
85
  totalRawUsd: string;
61
86
  /** Total margin used. */
62
87
  totalMarginUsed: string;
63
88
  };
64
- /** Cross-margin details. */
89
+ /** Cross-margin summary details. */
65
90
  crossMarginSummary: {
66
91
  /** Total account value. */
67
92
  accountValue: string;
68
- /** Total notional value. */
93
+ /** Total notional position value. */
69
94
  totalNtlPos: string;
70
95
  /** Total raw USD value. */
71
96
  totalRawUsd: string;
@@ -76,11 +101,127 @@ export interface PerpsClearinghouseState {
76
101
  crossMaintenanceMarginUsed: string;
77
102
  /** Amount available for withdrawal. */
78
103
  withdrawable: string;
79
- /** Positions in various assets. */
104
+ /** List of asset positions. */
80
105
  assetPositions: AssetPosition[];
81
- /** Timestamp when the data was retrieved (in ms since epoch). */
106
+ /** Timestamp when data was retrieved (in ms since epoch). */
82
107
  time: number;
83
108
  }
109
+ /** Portfolio metrics snapshot. */
110
+ export interface Portfolio {
111
+ /** History entries for account value as [timestamp, value]. */
112
+ accountValueHistory: [number, string][];
113
+ /** History entries for profit and loss as [timestamp, value]. */
114
+ pnlHistory: [number, string][];
115
+ /** Volume metric for the portfolio. */
116
+ vlm: string;
117
+ }
118
+ /** Portfolio metrics grouped by time periods. */
119
+ export type PortfolioPeriods = [
120
+ [
121
+ "day",
122
+ Portfolio
123
+ ],
124
+ [
125
+ "week",
126
+ Portfolio
127
+ ],
128
+ [
129
+ "month",
130
+ Portfolio
131
+ ],
132
+ [
133
+ "allTime",
134
+ Portfolio
135
+ ],
136
+ [
137
+ "perpDay",
138
+ Portfolio
139
+ ],
140
+ [
141
+ "perpWeek",
142
+ Portfolio
143
+ ],
144
+ [
145
+ "perpMonth",
146
+ Portfolio
147
+ ],
148
+ [
149
+ "perpAllTime",
150
+ Portfolio
151
+ ]
152
+ ];
153
+ /** Pre-transfer user existence check result. */
154
+ export interface PreTransferCheck {
155
+ /** Activation fee. */
156
+ fee: string;
157
+ /** Whether the user is sanctioned. */
158
+ isSanctioned: boolean;
159
+ /** Whether the user exists. */
160
+ userExists: boolean;
161
+ }
162
+ /** Referral details for a user. */
163
+ export interface Referral {
164
+ /** Referrer details. */
165
+ referredBy: {
166
+ /** Referrer address. */
167
+ referrer: Hex;
168
+ /** Referral code used. */
169
+ code: string;
170
+ } | null;
171
+ /** Cumulative traded volume. */
172
+ cumVlm: string;
173
+ /** Rewards earned but not yet claimed. */
174
+ unclaimedRewards: string;
175
+ /** Rewards that have been claimed. */
176
+ claimedRewards: string;
177
+ /** Builder reward amount. */
178
+ builderRewards: string;
179
+ /** Current state of the referrer. */
180
+ referrerState: {
181
+ /** Referrer is ready to receive rewards. */
182
+ stage: "ready";
183
+ /** Referral program details. */
184
+ data: {
185
+ /** Assigned referral code. */
186
+ code: string;
187
+ /** Summary of each referral state. */
188
+ referralStates: {
189
+ /** Cumulative traded volume. */
190
+ cumVlm: string;
191
+ /** Total fees rewarded to the referred user since referral. */
192
+ cumRewardedFeesSinceReferred: string;
193
+ /** Total fees rewarded to the referrer from referred trades. */
194
+ cumFeesRewardedToReferrer: string;
195
+ /** Timestamp when the referred user joined (in ms since epoch). */
196
+ timeJoined: number;
197
+ /** Address of the referred user. */
198
+ user: string;
199
+ }[];
200
+ };
201
+ } | {
202
+ /** Referrer needs to create a referral code. */
203
+ stage: "needToCreateCode";
204
+ } | {
205
+ /** Referrer must complete a trade before earning rewards. */
206
+ stage: "needToTrade";
207
+ /** Required trading volume details for activation. */
208
+ data: {
209
+ /** Required trading volume. */
210
+ required: string;
211
+ };
212
+ };
213
+ /** History of referral rewards. */
214
+ rewardHistory: {
215
+ /** Amount of earned rewards. */
216
+ earned: string;
217
+ /** Traded volume at the time of reward. */
218
+ vlm: string;
219
+ /** Traded volume via referrals. */
220
+ referralVlm: string;
221
+ /** Timestamp when the reward was earned (in ms since epoch). */
222
+ time: number;
223
+ }[];
224
+ }
84
225
  /** Balance for a specific spot token. */
85
226
  export interface SpotBalance {
86
227
  /** Asset symbol. */
@@ -94,79 +235,103 @@ export interface SpotBalance {
94
235
  /** Entry notional value. */
95
236
  entryNtl: string;
96
237
  }
97
- /** Balances for spot tokens. */
238
+ /** Clearinghouse state for spot tokens. */
98
239
  export interface SpotClearinghouseState {
99
240
  /** Balance for each token. */
100
241
  balances: SpotBalance[];
101
242
  }
102
- /** User sub-accounts. */
243
+ /** Sub-account details for a user. */
103
244
  export interface SubAccount {
104
- /** Name of the sub-account. */
245
+ /** Sub-account name. */
105
246
  name: string;
106
- /** Address of the sub-account. */
247
+ /** Sub-account address. */
107
248
  subAccountUser: Hex;
108
- /** Address of the master account. */
249
+ /** Master account address. */
109
250
  master: Hex;
110
- /** Account summary for perpetual trading. */
251
+ /** Perpetual trading clearinghouse state summary. */
111
252
  clearinghouseState: PerpsClearinghouseState;
112
- /** Balances for spot tokens. */
253
+ /** Spot tokens clearinghouse state. */
113
254
  spotState: SpotClearinghouseState;
114
255
  }
115
- /** User fees. */
256
+ /** User fee details. */
116
257
  export interface UserFees {
117
- /** User's daily volume. */
258
+ /** Daily user volume metrics. */
118
259
  dailyUserVlm: {
119
- /** Date. */
260
+ /** Date in YYYY-M-D format. */
120
261
  date: `${number}-${number}-${number}`;
121
- /** User's cross-trade volume. */
262
+ /** User cross-trade volume. */
122
263
  userCross: string;
123
- /** User's add liquidity volume. */
264
+ /** User add-liquidity volume. */
124
265
  userAdd: string;
125
- /** Total exchange volume. */
266
+ /** Exchange total volume. */
126
267
  exchange: string;
127
268
  }[];
128
- /** Fee schedule. */
269
+ /** Fee schedule information. */
129
270
  feeSchedule: {
130
271
  /** Cross-trade fee rate. */
131
272
  cross: string;
132
- /** Add liquidity fee rate. */
273
+ /** Add-liquidity fee rate. */
133
274
  add: string;
134
- /** Fee tiers. */
275
+ /** Fee tiers details. */
135
276
  tiers: {
136
- /** VIP fee tiers. */
277
+ /** VIP fee tier information. */
137
278
  vip: {
138
279
  /** Notional volume cutoff. */
139
280
  ntlCutoff: string;
140
281
  /** Cross-trade fee rate. */
141
282
  cross: string;
142
- /** Add liquidity fee rate. */
283
+ /** Add-liquidity fee rate. */
143
284
  add: string;
144
285
  }[];
145
- /** MM fee tiers. */
286
+ /** Market maker fee tier information. */
146
287
  mm: {
147
288
  /** Maker fraction cutoff. */
148
289
  makerFractionCutoff: string;
149
- /** Add liquidity fee rate. */
290
+ /** Add-liquidity fee rate. */
150
291
  add: string;
151
292
  }[];
152
293
  };
153
- /** Referral discount. */
294
+ /** Referral discount rate. */
154
295
  referralDiscount: string;
155
296
  };
156
- /** User's cross-trade rate. */
297
+ /** User cross-trade rate. */
157
298
  userCrossRate: string;
158
- /** User's add liquidity rate. */
299
+ /** User add-liquidity rate. */
159
300
  userAddRate: string;
160
- /** Active referral discount. */
301
+ /** Active referral discount rate. */
161
302
  activeReferralDiscount: string;
162
303
  /** Trial details. */
163
304
  trial: unknown | null;
164
- /** Fee trial reward. */
305
+ /** Fee trial reward amount. */
165
306
  feeTrialReward: string;
166
- /** Next trial available timestamp. */
307
+ /** Timestamp when next trial becomes available. */
167
308
  nextTrialAvailableTimestamp: unknown | null;
168
309
  }
169
- /** User's rate limits. */
310
+ /** Funding ledger update for a user. */
311
+ export interface UserFundingUpdate {
312
+ /** Timestamp of the update (in ms since epoch). */
313
+ time: number;
314
+ /** L1 transaction hash. */
315
+ hash: Hex;
316
+ /** Update details. */
317
+ delta: FundingUpdate;
318
+ }
319
+ /** Funding update details. */
320
+ export interface FundingUpdate {
321
+ /** Update type. */
322
+ type: "funding";
323
+ /** Asset symbol. */
324
+ coin: string;
325
+ /** Amount transferred in USDC. */
326
+ usdc: string;
327
+ /** Signed position size. */
328
+ szi: string;
329
+ /** Applied funding rate. */
330
+ fundingRate: string;
331
+ /** Number of samples. */
332
+ nSamples: number | null;
333
+ }
334
+ /** Rate limits for a user. */
170
335
  export interface UserRateLimit {
171
336
  /** Cumulative trading volume. */
172
337
  cumVlm: string;
@@ -175,250 +340,175 @@ export interface UserRateLimit {
175
340
  /** Maximum allowed API requests. */
176
341
  nRequestsCap: number;
177
342
  }
178
- /** User's extra agent. */
179
- export interface ExtraAgent {
180
- /** The address of the extra agent. */
181
- address: Hex;
182
- /** The name of the extra agent. */
183
- name: string;
184
- /** The validity period of the extra agent. */
185
- validUntil: number;
186
- }
187
- /** Referral information for a user. */
188
- export interface Referral {
189
- /** Details about who referred this user, or `null` if no referrer exists. */
190
- referredBy: {
191
- /** Referrer's address. */
192
- referrer: Hex;
193
- /** Referral code used. */
194
- code: string;
195
- } | null;
196
- /** Cumulative volume traded. */
197
- cumVlm: string;
198
- /** Rewards earned but not yet claimed. */
199
- unclaimedRewards: string;
200
- /** Rewards claimed. */
201
- claimedRewards: string;
202
- /** Rewards builder. */
203
- builderRewards: string;
204
- /** Current state of the referrer. */
205
- referrerState: {
206
- /** Referrer is ready to receive rewards. */
207
- stage: "ready";
208
- /** Data related to the referrer's referral program. */
209
- data: {
210
- /** Referral code assigned. */
211
- code: string;
212
- /** Summary of each user's activity. */
213
- referralStates: {
214
- /** Cumulative volume traded. */
215
- cumVlm: string;
216
- /** Total fees rewarded to the referred user since being referred. */
217
- cumRewardedFeesSinceReferred: string;
218
- /** Total fees rewarded to the referrer from the referred user's trades. */
219
- cumFeesRewardedToReferrer: string;
220
- /** Timestamp when the referred user joined (in ms since epoch). */
221
- timeJoined: number;
222
- /** Address of the referred user. */
223
- user: string;
224
- }[];
225
- };
226
- } | {
227
- /** Referrer needs to create a referral code to start receiving rewards. */
228
- stage: "needToCreateCode";
229
- } | {
230
- /** Referrer must complete a trade before receiving rewards. */
231
- stage: "needToTrade";
232
- /** Additional information about the required volume to start earning rewards. */
233
- data: {
234
- /** Required trading volume to activate rewards. */
235
- required: string;
236
- };
343
+ /** User role details. */
344
+ export type UserRole = {
345
+ /** Role identifier. */
346
+ role: "missing" | "user" | "vault";
347
+ } | {
348
+ /** Role identifier. */
349
+ role: "agent";
350
+ /** Details for agent role. */
351
+ data: {
352
+ /** Master account address associated with the agent. */
353
+ user: Hex;
237
354
  };
238
- /** History of rewards. */
239
- rewardHistory: {
240
- /** Amount of rewards earned. */
241
- earned: string;
242
- /** Volume traded. */
243
- vlm: string;
244
- /** Volume traded through referrals. */
245
- referralVlm: string;
246
- /** Timestamp when the rewards were earned (in ms since epoch). */
247
- time: number;
248
- }[];
249
- }
250
- /** User's funding ledger update. */
251
- export interface UserFundingUpdate {
252
- /** Timestamp of the update (in ms since epoch). */
253
- time: number;
254
- /** L1 transaction hash. */
255
- hash: Hex;
256
- /** Details of the update. */
257
- delta: FundingUpdate;
258
- }
259
- /** User's non-funding ledger update. */
355
+ } | {
356
+ /** Role identifier. */
357
+ role: "subAccount";
358
+ /** Details for sub-account role. */
359
+ data: {
360
+ /** Master account address associated with the sub-account. */
361
+ master: Hex;
362
+ };
363
+ };
364
+ /** Non-funding ledger update for a user. */
260
365
  export interface UserNonFundingLedgerUpdate {
261
366
  /** Timestamp of the update (in ms since epoch). */
262
367
  time: number;
263
368
  /** L1 transaction hash. */
264
369
  hash: Hex;
265
- /** Details of the update. */
370
+ /** Update details. */
266
371
  delta: AccountClassTransferUpdate | DepositUpdate | InternalTransferUpdate | LiquidationUpdate | RewardsClaimUpdate | SpotTransferUpdate | SubAccountTransferUpdate | VaultCreateUpdate | VaultDepositUpdate | VaultDistributionUpdate | VaultWithdrawUpdate | WithdrawUpdate;
267
372
  }
268
373
  /** Transfer between spot and perpetual accounts. */
269
374
  export interface AccountClassTransferUpdate {
270
- /** Type of update. */
375
+ /** Update type. */
271
376
  type: "accountClassTransfer";
272
- /** Amount. */
377
+ /** Amount transferred in USDC. */
273
378
  usdc: string;
274
- /** Whether the transfer is to the perpetual account. */
379
+ /** Indicates if the transfer is to the perpetual account. */
275
380
  toPerp: boolean;
276
381
  }
277
- /** Deposit to account. */
382
+ /** Deposit update to an account. */
278
383
  export interface DepositUpdate {
279
- /** Type of update. */
384
+ /** Update type. */
280
385
  type: "deposit";
281
- /** Amount. */
386
+ /** Amount deposited in USDC. */
282
387
  usdc: string;
283
388
  }
284
389
  /** Internal transfer between accounts. */
285
390
  export interface InternalTransferUpdate {
286
- /** Type of update. */
391
+ /** Update type. */
287
392
  type: "internalTransfer";
288
- /** Amount. */
393
+ /** Amount transferred in USDC. */
289
394
  usdc: string;
290
- /** Address of the user initiating the transfer. */
395
+ /** Initiator's address. */
291
396
  user: Hex;
292
397
  /** Destination address. */
293
398
  destination: Hex;
294
- /** Fee. */
399
+ /** Transfer fee. */
295
400
  fee: string;
296
401
  }
297
- /** Update representing a liquidation event. */
402
+ /** Liquidation event update. */
298
403
  export interface LiquidationUpdate {
299
- /** Type of update. */
404
+ /** Update type. */
300
405
  type: "liquidation";
301
406
  /** Total notional value of liquidated positions. */
302
407
  liquidatedNtlPos: string;
303
- /** Account value at the time of liquidation. */
408
+ /** Account value at liquidation time. */
304
409
  accountValue: string;
305
- /** Type of leverage used for the liquidated positions. */
410
+ /** Leverage type for liquidated positions. */
306
411
  leverageType: "Cross" | "Isolated";
307
- /** Details of individual positions that were liquidated. */
412
+ /** Details of each liquidated position. */
308
413
  liquidatedPositions: {
309
414
  /** Asset symbol of the liquidated position. */
310
415
  coin: string;
311
- /** Signed position size that was liquidated. */
416
+ /** Signed position size liquidated. */
312
417
  szi: string;
313
418
  }[];
314
419
  }
315
- /** Funding update. */
316
- export interface FundingUpdate {
317
- /** Type of update. */
318
- type: "funding";
319
- /** Asset symbol. */
320
- coin: string;
321
- /** Amount. */
322
- usdc: string;
323
- /** Signed position size. */
324
- szi: string;
325
- /** Funding rate. */
326
- fundingRate: string;
327
- /** Number of samples. */
328
- nSamples: number | null;
329
- }
330
- /** Rewards claim update. */
420
+ /** Rewards claim event update. */
331
421
  export interface RewardsClaimUpdate {
332
- /** Type of update. */
422
+ /** Update type. */
333
423
  type: "rewardsClaim";
334
424
  /** Amount of rewards claimed. */
335
425
  amount: string;
336
426
  }
337
- /** Spot transfer between accounts. */
427
+ /** Spot transfer update between accounts. */
338
428
  export interface SpotTransferUpdate {
339
- /** Type of update. */
429
+ /** Update type. */
340
430
  type: "spotTransfer";
341
- /** Token. */
431
+ /** Token symbol. */
342
432
  token: string;
343
- /** Amount. */
433
+ /** Amount transferred. */
344
434
  amount: string;
345
- /** Equivalent USDC value of the amount. */
435
+ /** Equivalent USDC value. */
346
436
  usdcValue: string;
347
- /** Address of the user initiating the transfer. */
437
+ /** Initiator's address. */
348
438
  user: Hex;
349
439
  /** Destination address. */
350
440
  destination: Hex;
351
- /** Fee. */
441
+ /** Transfer fee. */
352
442
  fee: string;
353
443
  }
354
- /** Transfer between sub-accounts. */
444
+ /** Transfer update between sub-accounts. */
355
445
  export interface SubAccountTransferUpdate {
356
- /** Type of update. */
446
+ /** Update type. */
357
447
  type: "subAccountTransfer";
358
- /** Amount. */
448
+ /** Amount transferred in USDC. */
359
449
  usdc: string;
360
- /** Address of the user initiating the transfer. */
450
+ /** Initiator's address. */
361
451
  user: Hex;
362
452
  /** Destination address. */
363
453
  destination: Hex;
364
454
  }
365
- /** Creating a vault. */
455
+ /** Vault creation update. */
366
456
  export interface VaultCreateUpdate {
367
- /** Type of update. */
457
+ /** Update type. */
368
458
  type: "vaultCreate";
369
459
  /** Address of the created vault. */
370
460
  vault: Hex;
371
- /** Initial amount allocated. */
461
+ /** Initial allocated amount in USDC. */
372
462
  usdc: string;
373
- /** Fee for creating the vault. */
463
+ /** Vault creation fee. */
374
464
  fee: string;
375
465
  }
376
- /** Deposit to a vault. */
466
+ /** Vault deposit update. */
377
467
  export interface VaultDepositUpdate {
378
- /** Type of update. */
468
+ /** Update type. */
379
469
  type: "vaultDeposit";
380
- /** Address of the vault receiving funds. */
470
+ /** Address of the target vault. */
381
471
  vault: Hex;
382
- /** Amount deposited. */
472
+ /** Amount deposited in USDC. */
383
473
  usdc: string;
384
474
  }
385
- /** Distribution event from a vault. */
475
+ /** Vault distribution update. */
386
476
  export interface VaultDistributionUpdate {
387
- /** Type of update. */
477
+ /** Update type. */
388
478
  type: "vaultDistribution";
389
479
  /** Address of the vault distributing funds. */
390
480
  vault: Hex;
391
- /** Amount. */
481
+ /** Amount distributed in USDC. */
392
482
  usdc: string;
393
483
  }
394
- /** Withdrawal from a vault. */
484
+ /** Vault withdrawal event update. */
395
485
  export interface VaultWithdrawUpdate {
396
- /** Type of update. */
486
+ /** Update type. */
397
487
  type: "vaultWithdraw";
398
- /** Address of the vault. */
488
+ /** Vault address. */
399
489
  vault: Hex;
400
490
  /** Address of the user withdrawing funds. */
401
491
  user: Hex;
402
- /** Amount requested for withdrawal in USD. */
492
+ /** Withdrawal request amount in USD. */
403
493
  requestedUsd: string;
404
- /** Commission charged for the withdrawal. */
494
+ /** Withdrawal commission fee. */
405
495
  commission: string;
406
- /** Cost associated with closing positions. */
496
+ /** Closing cost associated with positions. */
407
497
  closingCost: string;
408
- /** Basis value for the withdrawal calculation. */
498
+ /** Basis value for withdrawal calculation. */
409
499
  basis: string;
410
- /** Final amount withdrawn after deducting fees and costs. */
500
+ /** Net withdrawn amount in USD after fees and costs. */
411
501
  netWithdrawnUsd: string;
412
502
  }
413
- /** Withdrawal from account. */
503
+ /** Withdrawal update from an account. */
414
504
  export interface WithdrawUpdate {
415
- /** Type of update. */
505
+ /** Update type. */
416
506
  type: "withdraw";
417
- /** Amount. */
507
+ /** Amount withdrawn in USDC. */
418
508
  usdc: string;
419
- /** Unique request identifier. */
509
+ /** Unique nonce for the withdrawal request. */
420
510
  nonce: number;
421
- /** Fee. */
511
+ /** Withdrawal fee. */
422
512
  fee: string;
423
513
  }
424
514
  //# sourceMappingURL=accounts.d.ts.map