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