@nktkas/hyperliquid 0.22.1 → 0.23.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.
- package/README.md +125 -70
- 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 +420 -368
- package/esm/src/clients/exchange.d.ts.map +1 -1
- package/esm/src/clients/exchange.js +721 -551
- package/esm/src/clients/info.d.ts +137 -41
- package/esm/src/clients/info.d.ts.map +1 -1
- package/esm/src/clients/info.js +124 -28
- package/esm/src/clients/multiSign.d.ts +406 -484
- package/esm/src/clients/multiSign.d.ts.map +1 -1
- package/esm/src/clients/multiSign.js +639 -734
- 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/_signTypedData/ethers.d.ts +33 -0
- package/esm/src/signing/_signTypedData/ethers.d.ts.map +1 -0
- package/esm/src/signing/_signTypedData/ethers.js +12 -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/_signTypedData/viem.d.ts +23 -0
- package/esm/src/signing/_signTypedData/viem.d.ts.map +1 -0
- package/esm/src/signing/_signTypedData/viem.js +6 -0
- package/esm/src/signing/_signTypedData/window.d.ts +29 -0
- package/esm/src/signing/_signTypedData/window.d.ts.map +1 -0
- package/esm/src/signing/_signTypedData/window.js +30 -0
- package/esm/src/signing/_sorter.d.ts +128 -0
- package/esm/src/signing/_sorter.d.ts.map +1 -0
- package/esm/src/{signing.js → signing/_sorter.js} +36 -449
- package/esm/src/signing/mod.d.ts +272 -0
- package/esm/src/signing/mod.d.ts.map +1 -0
- package/esm/src/signing/mod.js +306 -0
- 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/delegations.d.ts +1 -1
- package/esm/src/types/info/delegations.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 +49 -96
- package/esm/src/types/info/requests.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 +12 -8
- 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 +420 -368
- package/script/src/clients/exchange.d.ts.map +1 -1
- package/script/src/clients/exchange.js +2000 -1840
- package/script/src/clients/info.d.ts +137 -41
- package/script/src/clients/info.d.ts.map +1 -1
- package/script/src/clients/info.js +1296 -1210
- package/script/src/clients/multiSign.d.ts +406 -484
- package/script/src/clients/multiSign.d.ts.map +1 -1
- package/script/src/clients/multiSign.js +2043 -2148
- 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/_signTypedData/ethers.d.ts +33 -0
- 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/_signTypedData/viem.d.ts +23 -0
- package/script/src/signing/_signTypedData/viem.d.ts.map +1 -0
- package/script/src/signing/_signTypedData/viem.js +9 -0
- package/script/src/signing/_signTypedData/window.d.ts +29 -0
- 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 +128 -0
- package/script/src/signing/_sorter.d.ts.map +1 -0
- package/script/src/signing/_sorter.js +698 -0
- package/script/src/signing/mod.d.ts +272 -0
- package/script/src/signing/mod.d.ts.map +1 -0
- package/script/src/signing/mod.js +331 -0
- 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/delegations.d.ts +1 -1
- package/script/src/types/info/delegations.d.ts.map +1 -1
- package/script/src/types/info/delegations.js +2 -12
- 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 +49 -96
- package/script/src/types/info/requests.d.ts.map +1 -1
- package/script/src/types/info/requests.js +2 -12
- package/script/src/types/info/vaults.js +2 -12
- 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.d.ts +0 -463
- package/esm/src/signing.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.d.ts +0 -463
- package/script/src/signing.d.ts.map +0 -1
- package/script/src/signing.js +0 -1129
package/script/src/signing.js
DELETED
|
@@ -1,1129 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This module contains functions for generating Hyperliquid transaction signatures
|
|
3
|
-
* and interfaces to various wallet implementations.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* ```ts
|
|
7
|
-
* import { signL1Action } from "@nktkas/hyperliquid/signing";
|
|
8
|
-
*
|
|
9
|
-
* const action = {
|
|
10
|
-
* type: "cancel",
|
|
11
|
-
* cancels: [{ a: 0, o: 12345 }],
|
|
12
|
-
* };
|
|
13
|
-
* const nonce = Date.now();
|
|
14
|
-
*
|
|
15
|
-
* const signature = await signL1Action({
|
|
16
|
-
* wallet,
|
|
17
|
-
* action,
|
|
18
|
-
* nonce,
|
|
19
|
-
* isTestnet: true, // Change to false for mainnet
|
|
20
|
-
* });
|
|
21
|
-
* ```
|
|
22
|
-
* @example
|
|
23
|
-
* ```ts
|
|
24
|
-
* import { signUserSignedAction } from "@nktkas/hyperliquid/signing";
|
|
25
|
-
*
|
|
26
|
-
* const action = {
|
|
27
|
-
* type: "approveAgent",
|
|
28
|
-
* hyperliquidChain: "Testnet", // "Mainnet" or "Testnet"
|
|
29
|
-
* signatureChainId: "0x66eee",
|
|
30
|
-
* nonce: Date.now(),
|
|
31
|
-
* agentAddress: "0x...",
|
|
32
|
-
* agentName: "Agent",
|
|
33
|
-
* };
|
|
34
|
-
*
|
|
35
|
-
* const signature = await signUserSignedAction({
|
|
36
|
-
* wallet,
|
|
37
|
-
* action,
|
|
38
|
-
* types: {
|
|
39
|
-
* "HyperliquidTransaction:ApproveAgent": [
|
|
40
|
-
* { name: "hyperliquidChain", type: "string" },
|
|
41
|
-
* { name: "agentAddress", type: "address" },
|
|
42
|
-
* { name: "agentName", type: "string" },
|
|
43
|
-
* { name: "nonce", type: "uint64" },
|
|
44
|
-
* ],
|
|
45
|
-
* },
|
|
46
|
-
* chainId: parseInt(action.signatureChainId, 16),
|
|
47
|
-
* });
|
|
48
|
-
* ```
|
|
49
|
-
*
|
|
50
|
-
* @module
|
|
51
|
-
*/
|
|
52
|
-
(function (factory) {
|
|
53
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
54
|
-
var v = factory(require, exports);
|
|
55
|
-
if (v !== undefined) module.exports = v;
|
|
56
|
-
}
|
|
57
|
-
else if (typeof define === "function" && define.amd) {
|
|
58
|
-
define(["require", "exports", "@noble/hashes/sha3", "../deps/jsr.io/@std/msgpack/1.0.3/encode.js", "../deps/jsr.io/@std/encoding/1.0.10/hex.js", "../deps/jsr.io/@std/bytes/1.0.6/concat.js"], factory);
|
|
59
|
-
}
|
|
60
|
-
})(function (require, exports) {
|
|
61
|
-
"use strict";
|
|
62
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
63
|
-
exports.userSignedActionEip712Types = exports.actionSorter = void 0;
|
|
64
|
-
exports.createL1ActionHash = createL1ActionHash;
|
|
65
|
-
exports.signL1Action = signL1Action;
|
|
66
|
-
exports.signUserSignedAction = signUserSignedAction;
|
|
67
|
-
exports.signMultiSigAction = signMultiSigAction;
|
|
68
|
-
exports.isAbstractViemWalletClient = isAbstractViemWalletClient;
|
|
69
|
-
exports.isAbstractEthersSigner = isAbstractEthersSigner;
|
|
70
|
-
exports.isAbstractEthersV5Signer = isAbstractEthersV5Signer;
|
|
71
|
-
exports.isAbstractWindowEthereum = isAbstractWindowEthereum;
|
|
72
|
-
const sha3_1 = require("@noble/hashes/sha3");
|
|
73
|
-
const encode_js_1 = require("../deps/jsr.io/@std/msgpack/1.0.3/encode.js");
|
|
74
|
-
const hex_js_1 = require("../deps/jsr.io/@std/encoding/1.0.10/hex.js");
|
|
75
|
-
const concat_js_1 = require("../deps/jsr.io/@std/bytes/1.0.6/concat.js");
|
|
76
|
-
/**
|
|
77
|
-
* Create a hash of the L1 action.
|
|
78
|
-
*
|
|
79
|
-
* Note: Hash generation depends on the order of the action keys.
|
|
80
|
-
* @param action - The action to be hashed.
|
|
81
|
-
* @param nonce - Unique request identifier (recommended current timestamp in ms).
|
|
82
|
-
* @param vaultAddress - Optional vault address used in the action.
|
|
83
|
-
* @param expiresAfter - Optional expiration time of the action in milliseconds since the epoch.
|
|
84
|
-
* @returns The hash of the action.
|
|
85
|
-
*/
|
|
86
|
-
function createL1ActionHash(action, nonce, vaultAddress, expiresAfter) {
|
|
87
|
-
// 1. Action
|
|
88
|
-
const actionBytes = (0, encode_js_1.encode)(normalizeIntegersForMsgPack(action));
|
|
89
|
-
// 2. Nonce
|
|
90
|
-
const nonceBytes = new Uint8Array(8);
|
|
91
|
-
new DataView(nonceBytes.buffer).setBigUint64(0, BigInt(nonce));
|
|
92
|
-
// 3. Vault address
|
|
93
|
-
let vaultMarker;
|
|
94
|
-
let vaultBytes;
|
|
95
|
-
if (vaultAddress) {
|
|
96
|
-
vaultMarker = Uint8Array.of(1);
|
|
97
|
-
vaultBytes = (0, hex_js_1.decodeHex)(vaultAddress.slice(2));
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
vaultMarker = new Uint8Array(1);
|
|
101
|
-
vaultBytes = new Uint8Array();
|
|
102
|
-
}
|
|
103
|
-
// 4. Expires after
|
|
104
|
-
let expiresMarker;
|
|
105
|
-
let expiresBytes;
|
|
106
|
-
if (expiresAfter !== undefined) {
|
|
107
|
-
expiresMarker = new Uint8Array(1);
|
|
108
|
-
expiresBytes = new Uint8Array(8);
|
|
109
|
-
new DataView(expiresBytes.buffer).setBigUint64(0, BigInt(expiresAfter));
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
expiresMarker = new Uint8Array();
|
|
113
|
-
expiresBytes = new Uint8Array();
|
|
114
|
-
}
|
|
115
|
-
// Create a keccak256 hash
|
|
116
|
-
const chunks = [
|
|
117
|
-
actionBytes,
|
|
118
|
-
nonceBytes,
|
|
119
|
-
vaultMarker,
|
|
120
|
-
vaultBytes,
|
|
121
|
-
expiresMarker,
|
|
122
|
-
expiresBytes,
|
|
123
|
-
];
|
|
124
|
-
const bytes = (0, concat_js_1.concat)(chunks);
|
|
125
|
-
const hash = (0, sha3_1.keccak_256)(bytes);
|
|
126
|
-
return `0x${(0, hex_js_1.encodeHex)(hash)}`;
|
|
127
|
-
}
|
|
128
|
-
/** Layer to make {@link https://jsr.io/@std/msgpack | @std/msgpack} compatible with {@link https://github.com/msgpack/msgpack-javascript | @msgpack/msgpack}. */
|
|
129
|
-
function normalizeIntegersForMsgPack(obj) {
|
|
130
|
-
const THIRTY_ONE_BITS = 2147483648;
|
|
131
|
-
const THIRTY_TWO_BITS = 4294967296;
|
|
132
|
-
if (typeof obj === "number" && Number.isInteger(obj) &&
|
|
133
|
-
obj <= Number.MAX_SAFE_INTEGER && obj >= Number.MIN_SAFE_INTEGER &&
|
|
134
|
-
(obj >= THIRTY_TWO_BITS || obj < -THIRTY_ONE_BITS)) {
|
|
135
|
-
return BigInt(obj);
|
|
136
|
-
}
|
|
137
|
-
if (Array.isArray(obj)) {
|
|
138
|
-
return obj.map(normalizeIntegersForMsgPack);
|
|
139
|
-
}
|
|
140
|
-
if (obj && typeof obj === "object" && obj !== null) {
|
|
141
|
-
return Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, normalizeIntegersForMsgPack(value)]));
|
|
142
|
-
}
|
|
143
|
-
return obj;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Sign an L1 action.
|
|
147
|
-
*
|
|
148
|
-
* Note: Signature generation depends on the order of the action keys.
|
|
149
|
-
* @param args - Arguments for signing the action.
|
|
150
|
-
* @returns The signature components r, s, and v.
|
|
151
|
-
* @example
|
|
152
|
-
* ```ts
|
|
153
|
-
* import { signL1Action } from "@nktkas/hyperliquid/signing";
|
|
154
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
155
|
-
*
|
|
156
|
-
* const wallet = privateKeyToAccount("0x..."); // Your private key
|
|
157
|
-
*
|
|
158
|
-
* const action = {
|
|
159
|
-
* type: "cancel",
|
|
160
|
-
* cancels: [
|
|
161
|
-
* { a: 0, o: 12345 }, // Asset index and order ID
|
|
162
|
-
* ],
|
|
163
|
-
* };
|
|
164
|
-
* const nonce = Date.now();
|
|
165
|
-
*
|
|
166
|
-
* const signature = await signL1Action({
|
|
167
|
-
* wallet,
|
|
168
|
-
* action,
|
|
169
|
-
* nonce,
|
|
170
|
-
* isTestnet: true, // Change to false for mainnet
|
|
171
|
-
* });
|
|
172
|
-
*
|
|
173
|
-
* const response = await fetch("https://api.hyperliquid-testnet.xyz/exchange", {
|
|
174
|
-
* method: "POST",
|
|
175
|
-
* headers: { "Content-Type": "application/json" },
|
|
176
|
-
* body: JSON.stringify({ action, signature, nonce }),
|
|
177
|
-
* });
|
|
178
|
-
* const body = await response.json();
|
|
179
|
-
* ```
|
|
180
|
-
*/
|
|
181
|
-
async function signL1Action(args) {
|
|
182
|
-
const { wallet, action, nonce, isTestnet = false, vaultAddress, expiresAfter, } = args;
|
|
183
|
-
const domain = {
|
|
184
|
-
name: "Exchange",
|
|
185
|
-
version: "1",
|
|
186
|
-
chainId: 1337,
|
|
187
|
-
verifyingContract: "0x0000000000000000000000000000000000000000",
|
|
188
|
-
};
|
|
189
|
-
const types = {
|
|
190
|
-
Agent: [
|
|
191
|
-
{ name: "source", type: "string" },
|
|
192
|
-
{ name: "connectionId", type: "bytes32" },
|
|
193
|
-
],
|
|
194
|
-
};
|
|
195
|
-
const actionHash = createL1ActionHash(action, nonce, vaultAddress, expiresAfter);
|
|
196
|
-
const message = {
|
|
197
|
-
source: isTestnet ? "b" : "a",
|
|
198
|
-
connectionId: actionHash,
|
|
199
|
-
};
|
|
200
|
-
const signature = await abstractSignTypedData({ wallet, domain, types, message });
|
|
201
|
-
return splitSignature(signature);
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Sign a user-signed action.
|
|
205
|
-
*
|
|
206
|
-
* Note: Signature generation depends on the order of types.
|
|
207
|
-
*
|
|
208
|
-
* @param args - Arguments for signing the action.
|
|
209
|
-
* @returns The signature components r, s, and v.
|
|
210
|
-
* @example
|
|
211
|
-
* ```ts
|
|
212
|
-
* import { signUserSignedAction } from "@nktkas/hyperliquid/signing";
|
|
213
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
214
|
-
*
|
|
215
|
-
* const wallet = privateKeyToAccount("0x..."); // Your private key
|
|
216
|
-
*
|
|
217
|
-
* const action = {
|
|
218
|
-
* type: "approveAgent",
|
|
219
|
-
* hyperliquidChain: "Testnet", // "Mainnet" or "Testnet"
|
|
220
|
-
* signatureChainId: "0x66eee",
|
|
221
|
-
* nonce: Date.now(),
|
|
222
|
-
* agentAddress: "0x...", // Change to your agent address
|
|
223
|
-
* agentName: "Agent",
|
|
224
|
-
* };
|
|
225
|
-
*
|
|
226
|
-
* const signature = await signUserSignedAction({
|
|
227
|
-
* wallet,
|
|
228
|
-
* action,
|
|
229
|
-
* types: {
|
|
230
|
-
* "HyperliquidTransaction:ApproveAgent": [
|
|
231
|
-
* { name: "hyperliquidChain", type: "string" },
|
|
232
|
-
* { name: "agentAddress", type: "address" },
|
|
233
|
-
* { name: "agentName", type: "string" },
|
|
234
|
-
* { name: "nonce", type: "uint64" },
|
|
235
|
-
* ],
|
|
236
|
-
* },
|
|
237
|
-
* chainId: parseInt(action.signatureChainId, 16),
|
|
238
|
-
* });
|
|
239
|
-
*
|
|
240
|
-
* const response = await fetch("https://api.hyperliquid-testnet.xyz/exchange", {
|
|
241
|
-
* method: "POST",
|
|
242
|
-
* headers: { "Content-Type": "application/json" },
|
|
243
|
-
* body: JSON.stringify({ action, signature, nonce: action.nonce }),
|
|
244
|
-
* });
|
|
245
|
-
* const body = await response.json();
|
|
246
|
-
* ```
|
|
247
|
-
*/
|
|
248
|
-
async function signUserSignedAction(args) {
|
|
249
|
-
const { wallet, action, types, chainId } = args;
|
|
250
|
-
const domain = {
|
|
251
|
-
name: "HyperliquidSignTransaction",
|
|
252
|
-
version: "1",
|
|
253
|
-
chainId,
|
|
254
|
-
verifyingContract: "0x0000000000000000000000000000000000000000",
|
|
255
|
-
};
|
|
256
|
-
const signature = await abstractSignTypedData({ wallet, domain, types, message: action });
|
|
257
|
-
return splitSignature(signature);
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Sign a multi-signature action.
|
|
261
|
-
*
|
|
262
|
-
* Note: Signature generation depends on the order of the action keys.
|
|
263
|
-
*
|
|
264
|
-
* @param args - Arguments for signing the action.
|
|
265
|
-
* @returns The signature components r, s, and v.
|
|
266
|
-
* @example
|
|
267
|
-
* ```ts
|
|
268
|
-
* import { signL1Action, signMultiSigAction } from "@nktkas/hyperliquid/signing";
|
|
269
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
270
|
-
*
|
|
271
|
-
* const wallet = privateKeyToAccount("0x..."); // Your private key
|
|
272
|
-
* const multiSigUser = "0x..."; // Multi-sig user address
|
|
273
|
-
*
|
|
274
|
-
* const nonce = Date.now();
|
|
275
|
-
* const action = { // Example action
|
|
276
|
-
* type: "scheduleCancel",
|
|
277
|
-
* time: Date.now() + 10000
|
|
278
|
-
* };
|
|
279
|
-
*
|
|
280
|
-
* // First, create signature from one of the authorized signers
|
|
281
|
-
* const signature = await signL1Action({
|
|
282
|
-
* wallet,
|
|
283
|
-
* action: [multiSigUser.toLowerCase(), wallet.address.toLowerCase(), action],
|
|
284
|
-
* nonce,
|
|
285
|
-
* isTestnet: true,
|
|
286
|
-
* });
|
|
287
|
-
*
|
|
288
|
-
* // Then use it in the multi-sig action
|
|
289
|
-
* const multiSigSignature = await signMultiSigAction({
|
|
290
|
-
* wallet,
|
|
291
|
-
* action: {
|
|
292
|
-
* type: "multiSig",
|
|
293
|
-
* signatureChainId: "0x66eee",
|
|
294
|
-
* signatures: [signature],
|
|
295
|
-
* payload: {
|
|
296
|
-
* multiSigUser,
|
|
297
|
-
* outerSigner: wallet.address,
|
|
298
|
-
* action,
|
|
299
|
-
* }
|
|
300
|
-
* },
|
|
301
|
-
* nonce,
|
|
302
|
-
* hyperliquidChain: "Testnet",
|
|
303
|
-
* signatureChainId: "0x66eee",
|
|
304
|
-
* });
|
|
305
|
-
* ```
|
|
306
|
-
*/
|
|
307
|
-
async function signMultiSigAction(args) {
|
|
308
|
-
const { wallet, action, nonce, hyperliquidChain, signatureChainId, vaultAddress, expiresAfter, } = args;
|
|
309
|
-
const multiSigActionHash = createL1ActionHash(action, nonce, vaultAddress, expiresAfter);
|
|
310
|
-
const message = {
|
|
311
|
-
multiSigActionHash,
|
|
312
|
-
hyperliquidChain,
|
|
313
|
-
signatureChainId,
|
|
314
|
-
nonce,
|
|
315
|
-
};
|
|
316
|
-
return await signUserSignedAction({
|
|
317
|
-
wallet,
|
|
318
|
-
action: message,
|
|
319
|
-
types: {
|
|
320
|
-
"HyperliquidTransaction:SendMultiSig": [
|
|
321
|
-
{ name: "hyperliquidChain", type: "string" },
|
|
322
|
-
{ name: "multiSigActionHash", type: "bytes32" },
|
|
323
|
-
{ name: "nonce", type: "uint64" },
|
|
324
|
-
],
|
|
325
|
-
},
|
|
326
|
-
chainId: parseInt(signatureChainId, 16),
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
/** Signs typed data with the provided wallet using EIP-712. */
|
|
330
|
-
async function abstractSignTypedData(args) {
|
|
331
|
-
const { wallet, domain, types, message } = args;
|
|
332
|
-
if (isAbstractViemWalletClient(wallet)) {
|
|
333
|
-
return await wallet.signTypedData({
|
|
334
|
-
domain,
|
|
335
|
-
types: {
|
|
336
|
-
EIP712Domain: [
|
|
337
|
-
{ name: "name", type: "string" },
|
|
338
|
-
{ name: "version", type: "string" },
|
|
339
|
-
{ name: "chainId", type: "uint256" },
|
|
340
|
-
{ name: "verifyingContract", type: "address" },
|
|
341
|
-
],
|
|
342
|
-
...types,
|
|
343
|
-
},
|
|
344
|
-
primaryType: Object.keys(types)[0],
|
|
345
|
-
message,
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
else if (isAbstractEthersSigner(wallet)) {
|
|
349
|
-
return await wallet.signTypedData(domain, types, message);
|
|
350
|
-
}
|
|
351
|
-
else if (isAbstractEthersV5Signer(wallet)) {
|
|
352
|
-
return await wallet._signTypedData(domain, types, message);
|
|
353
|
-
}
|
|
354
|
-
else if (isAbstractWindowEthereum(wallet)) {
|
|
355
|
-
return await signTypedDataWithWindowEthereum(wallet, domain, types, message);
|
|
356
|
-
}
|
|
357
|
-
else {
|
|
358
|
-
throw new Error("Unsupported wallet for signing typed data");
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
/** Signs typed data using `window.ethereum` (EIP-1193) with `eth_signTypedData_v4` (EIP-712). */
|
|
362
|
-
async function signTypedDataWithWindowEthereum(ethereum, domain, types, message) {
|
|
363
|
-
const accounts = await ethereum.request({
|
|
364
|
-
method: "eth_requestAccounts",
|
|
365
|
-
params: [],
|
|
366
|
-
});
|
|
367
|
-
if (!Array.isArray(accounts) || accounts.length === 0) {
|
|
368
|
-
throw new Error("No Ethereum accounts available");
|
|
369
|
-
}
|
|
370
|
-
const from = accounts[0];
|
|
371
|
-
const dataToSign = JSON.stringify({
|
|
372
|
-
domain,
|
|
373
|
-
types: {
|
|
374
|
-
EIP712Domain: [
|
|
375
|
-
{ name: "name", type: "string" },
|
|
376
|
-
{ name: "version", type: "string" },
|
|
377
|
-
{ name: "chainId", type: "uint256" },
|
|
378
|
-
{ name: "verifyingContract", type: "address" },
|
|
379
|
-
],
|
|
380
|
-
...types,
|
|
381
|
-
},
|
|
382
|
-
primaryType: Object.keys(types)[0],
|
|
383
|
-
message,
|
|
384
|
-
});
|
|
385
|
-
return await ethereum.request({
|
|
386
|
-
method: "eth_signTypedData_v4",
|
|
387
|
-
params: [from, dataToSign],
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
/** Splits a signature hexadecimal string into its components. */
|
|
391
|
-
function splitSignature(signature) {
|
|
392
|
-
const r = `0x${signature.slice(2, 66)}`;
|
|
393
|
-
const s = `0x${signature.slice(66, 130)}`;
|
|
394
|
-
const v = parseInt(signature.slice(130, 132), 16);
|
|
395
|
-
return { r, s, v };
|
|
396
|
-
}
|
|
397
|
-
/** Checks if the given value is an abstract viem wallet. */
|
|
398
|
-
function isAbstractViemWalletClient(client) {
|
|
399
|
-
return typeof client === "object" && client !== null &&
|
|
400
|
-
"signTypedData" in client && typeof client.signTypedData === "function" &&
|
|
401
|
-
(client.signTypedData.length === 1 || client.signTypedData.length === 2);
|
|
402
|
-
}
|
|
403
|
-
/** Checks if the given value is an abstract ethers signer. */
|
|
404
|
-
function isAbstractEthersSigner(client) {
|
|
405
|
-
return typeof client === "object" && client !== null &&
|
|
406
|
-
"signTypedData" in client && typeof client.signTypedData === "function" &&
|
|
407
|
-
client.signTypedData.length === 3;
|
|
408
|
-
}
|
|
409
|
-
/** Checks if the given value is an abstract ethers v5 signer. */
|
|
410
|
-
function isAbstractEthersV5Signer(client) {
|
|
411
|
-
return typeof client === "object" && client !== null &&
|
|
412
|
-
"_signTypedData" in client && typeof client._signTypedData === "function" &&
|
|
413
|
-
client._signTypedData.length === 3;
|
|
414
|
-
}
|
|
415
|
-
/** Checks if the given value is an abstract `window.ethereum` object. */
|
|
416
|
-
function isAbstractWindowEthereum(client) {
|
|
417
|
-
return typeof client === "object" && client !== null &&
|
|
418
|
-
"request" in client && typeof client.request === "function" &&
|
|
419
|
-
client.request.length >= 1;
|
|
420
|
-
}
|
|
421
|
-
/** Action sorter for correct signature generation. */
|
|
422
|
-
exports.actionSorter = {
|
|
423
|
-
/** Sorts and formats an `approveAgent` action. */
|
|
424
|
-
approveAgent: (action) => {
|
|
425
|
-
return {
|
|
426
|
-
type: action.type,
|
|
427
|
-
signatureChainId: action.signatureChainId,
|
|
428
|
-
hyperliquidChain: action.hyperliquidChain,
|
|
429
|
-
agentAddress: action.agentAddress.toLowerCase(),
|
|
430
|
-
agentName: action.agentName ?? "",
|
|
431
|
-
nonce: action.nonce,
|
|
432
|
-
};
|
|
433
|
-
},
|
|
434
|
-
/** Sorts and formats an `approveBuilderFee` action. */
|
|
435
|
-
approveBuilderFee: (action) => {
|
|
436
|
-
return {
|
|
437
|
-
type: action.type,
|
|
438
|
-
signatureChainId: action.signatureChainId,
|
|
439
|
-
hyperliquidChain: action.hyperliquidChain,
|
|
440
|
-
maxFeeRate: action.maxFeeRate,
|
|
441
|
-
builder: action.builder.toLowerCase(),
|
|
442
|
-
nonce: action.nonce,
|
|
443
|
-
};
|
|
444
|
-
},
|
|
445
|
-
/** Sorts and formats a `batchModify` action. */
|
|
446
|
-
batchModify: (action) => {
|
|
447
|
-
return {
|
|
448
|
-
type: action.type,
|
|
449
|
-
modifies: action.modifies.map((modify) => {
|
|
450
|
-
const sortedModify = {
|
|
451
|
-
oid: modify.oid,
|
|
452
|
-
order: {
|
|
453
|
-
a: modify.order.a,
|
|
454
|
-
b: modify.order.b,
|
|
455
|
-
p: formatDecimal(modify.order.p),
|
|
456
|
-
s: formatDecimal(modify.order.s),
|
|
457
|
-
r: modify.order.r,
|
|
458
|
-
t: "limit" in modify.order.t
|
|
459
|
-
? {
|
|
460
|
-
limit: {
|
|
461
|
-
tif: modify.order.t.limit.tif,
|
|
462
|
-
},
|
|
463
|
-
}
|
|
464
|
-
: {
|
|
465
|
-
trigger: {
|
|
466
|
-
isMarket: modify.order.t.trigger.isMarket,
|
|
467
|
-
triggerPx: formatDecimal(modify.order.t.trigger.triggerPx),
|
|
468
|
-
tpsl: modify.order.t.trigger.tpsl,
|
|
469
|
-
},
|
|
470
|
-
},
|
|
471
|
-
c: modify.order.c,
|
|
472
|
-
},
|
|
473
|
-
};
|
|
474
|
-
if (sortedModify.order.c === undefined)
|
|
475
|
-
delete sortedModify.order.c;
|
|
476
|
-
return sortedModify;
|
|
477
|
-
}),
|
|
478
|
-
};
|
|
479
|
-
},
|
|
480
|
-
/** Sorts and formats a `cancel` action. */
|
|
481
|
-
cancel: (action) => {
|
|
482
|
-
return {
|
|
483
|
-
type: action.type,
|
|
484
|
-
cancels: action.cancels.map((cancel) => ({
|
|
485
|
-
a: cancel.a,
|
|
486
|
-
o: cancel.o,
|
|
487
|
-
})),
|
|
488
|
-
};
|
|
489
|
-
},
|
|
490
|
-
/** Sorts and formats a `cancelByCloid` action. */
|
|
491
|
-
cancelByCloid: (action) => {
|
|
492
|
-
return {
|
|
493
|
-
type: action.type,
|
|
494
|
-
cancels: action.cancels.map((cancel) => ({
|
|
495
|
-
asset: cancel.asset,
|
|
496
|
-
cloid: cancel.cloid,
|
|
497
|
-
})),
|
|
498
|
-
};
|
|
499
|
-
},
|
|
500
|
-
/** Sorts and formats a `cDeposit` action. */
|
|
501
|
-
cDeposit: (action) => {
|
|
502
|
-
return {
|
|
503
|
-
type: action.type,
|
|
504
|
-
signatureChainId: action.signatureChainId,
|
|
505
|
-
hyperliquidChain: action.hyperliquidChain,
|
|
506
|
-
wei: action.wei,
|
|
507
|
-
nonce: action.nonce,
|
|
508
|
-
};
|
|
509
|
-
},
|
|
510
|
-
/** Sorts and formats a `claimRewards` action. */
|
|
511
|
-
claimRewards: (action) => {
|
|
512
|
-
return {
|
|
513
|
-
type: action.type,
|
|
514
|
-
};
|
|
515
|
-
},
|
|
516
|
-
/** Sorts and formats a `convertToMultiSigUser` action. */
|
|
517
|
-
convertToMultiSigUser: (action) => {
|
|
518
|
-
return {
|
|
519
|
-
type: action.type,
|
|
520
|
-
signatureChainId: action.signatureChainId,
|
|
521
|
-
hyperliquidChain: action.hyperliquidChain,
|
|
522
|
-
signers: action.signers,
|
|
523
|
-
nonce: action.nonce,
|
|
524
|
-
};
|
|
525
|
-
},
|
|
526
|
-
/** Sorts and formats a `createSubAccount` action. */
|
|
527
|
-
createSubAccount: (action) => {
|
|
528
|
-
return {
|
|
529
|
-
type: action.type,
|
|
530
|
-
name: action.name,
|
|
531
|
-
};
|
|
532
|
-
},
|
|
533
|
-
/** Sorts and formats a `createVault` action. */
|
|
534
|
-
createVault: (action) => {
|
|
535
|
-
return {
|
|
536
|
-
type: action.type,
|
|
537
|
-
name: action.name,
|
|
538
|
-
description: action.description,
|
|
539
|
-
initialUsd: action.initialUsd,
|
|
540
|
-
nonce: action.nonce,
|
|
541
|
-
};
|
|
542
|
-
},
|
|
543
|
-
/** Sorts and formats a `CSignerAction` action (jail/unjail). */
|
|
544
|
-
CSignerAction: (action) => {
|
|
545
|
-
if ("jailSelf" in action) {
|
|
546
|
-
return {
|
|
547
|
-
type: action.type,
|
|
548
|
-
jailSelf: action.jailSelf,
|
|
549
|
-
};
|
|
550
|
-
}
|
|
551
|
-
else {
|
|
552
|
-
return {
|
|
553
|
-
type: action.type,
|
|
554
|
-
unjailSelf: action.unjailSelf,
|
|
555
|
-
};
|
|
556
|
-
}
|
|
557
|
-
},
|
|
558
|
-
/** Sorts and formats a `CValidatorAction` action (register/unregister/change profile). */
|
|
559
|
-
CValidatorAction: (action) => {
|
|
560
|
-
if ("changeProfile" in action) {
|
|
561
|
-
return {
|
|
562
|
-
type: action.type,
|
|
563
|
-
changeProfile: {
|
|
564
|
-
node_ip: action.changeProfile.node_ip ?? null,
|
|
565
|
-
name: action.changeProfile.name ?? null,
|
|
566
|
-
description: action.changeProfile.description ?? null,
|
|
567
|
-
unjailed: action.changeProfile.unjailed,
|
|
568
|
-
disable_delegations: action.changeProfile.disable_delegations ?? null,
|
|
569
|
-
commission_bps: action.changeProfile.commission_bps ?? null,
|
|
570
|
-
signer: action.changeProfile.signer?.toLowerCase() ?? null,
|
|
571
|
-
},
|
|
572
|
-
};
|
|
573
|
-
}
|
|
574
|
-
else if ("register" in action) {
|
|
575
|
-
return {
|
|
576
|
-
type: action.type,
|
|
577
|
-
register: {
|
|
578
|
-
profile: {
|
|
579
|
-
node_ip: {
|
|
580
|
-
Ip: action.register.profile.node_ip.Ip,
|
|
581
|
-
},
|
|
582
|
-
name: action.register.profile.name,
|
|
583
|
-
description: action.register.profile.description,
|
|
584
|
-
delegations_disabled: action.register.profile.delegations_disabled,
|
|
585
|
-
commission_bps: action.register.profile.commission_bps,
|
|
586
|
-
signer: action.register.profile.signer.toLowerCase(),
|
|
587
|
-
},
|
|
588
|
-
unjailed: action.register.unjailed,
|
|
589
|
-
initial_wei: action.register.initial_wei,
|
|
590
|
-
},
|
|
591
|
-
};
|
|
592
|
-
}
|
|
593
|
-
else { // "unregister" in action
|
|
594
|
-
return {
|
|
595
|
-
type: action.type,
|
|
596
|
-
unregister: action.unregister,
|
|
597
|
-
};
|
|
598
|
-
}
|
|
599
|
-
},
|
|
600
|
-
/** Sorts and formats a `cWithdraw` action. */
|
|
601
|
-
cWithdraw: (action) => {
|
|
602
|
-
return {
|
|
603
|
-
type: action.type,
|
|
604
|
-
signatureChainId: action.signatureChainId,
|
|
605
|
-
hyperliquidChain: action.hyperliquidChain,
|
|
606
|
-
wei: action.wei,
|
|
607
|
-
nonce: action.nonce,
|
|
608
|
-
};
|
|
609
|
-
},
|
|
610
|
-
/** Sorts and formats an `evmUserModify` action. */
|
|
611
|
-
evmUserModify: (action) => {
|
|
612
|
-
return {
|
|
613
|
-
type: action.type,
|
|
614
|
-
usingBigBlocks: action.usingBigBlocks,
|
|
615
|
-
};
|
|
616
|
-
},
|
|
617
|
-
/** Sorts and formats a `modify` action. */
|
|
618
|
-
modify: (action) => {
|
|
619
|
-
const sortedAction = {
|
|
620
|
-
type: action.type,
|
|
621
|
-
oid: action.oid,
|
|
622
|
-
order: {
|
|
623
|
-
a: action.order.a,
|
|
624
|
-
b: action.order.b,
|
|
625
|
-
p: formatDecimal(action.order.p),
|
|
626
|
-
s: formatDecimal(action.order.s),
|
|
627
|
-
r: action.order.r,
|
|
628
|
-
t: "limit" in action.order.t
|
|
629
|
-
? {
|
|
630
|
-
limit: {
|
|
631
|
-
tif: action.order.t.limit.tif,
|
|
632
|
-
},
|
|
633
|
-
}
|
|
634
|
-
: {
|
|
635
|
-
trigger: {
|
|
636
|
-
isMarket: action.order.t.trigger.isMarket,
|
|
637
|
-
triggerPx: formatDecimal(action.order.t.trigger.triggerPx),
|
|
638
|
-
tpsl: action.order.t.trigger.tpsl,
|
|
639
|
-
},
|
|
640
|
-
},
|
|
641
|
-
c: action.order.c,
|
|
642
|
-
},
|
|
643
|
-
};
|
|
644
|
-
if (sortedAction.order.c === undefined)
|
|
645
|
-
delete sortedAction.order.c;
|
|
646
|
-
return sortedAction;
|
|
647
|
-
},
|
|
648
|
-
/** Sorts and formats a `multiSig` action. */
|
|
649
|
-
multiSig: (action) => {
|
|
650
|
-
return {
|
|
651
|
-
type: action.type,
|
|
652
|
-
signatureChainId: action.signatureChainId,
|
|
653
|
-
signatures: action.signatures.map((signature) => ({
|
|
654
|
-
r: signature.r.replace(/^0x0+/, "0x").toLowerCase(),
|
|
655
|
-
s: signature.s.replace(/^0x0+/, "0x").toLowerCase(),
|
|
656
|
-
v: signature.v,
|
|
657
|
-
})),
|
|
658
|
-
payload: {
|
|
659
|
-
multiSigUser: action.payload.multiSigUser.toLowerCase(),
|
|
660
|
-
outerSigner: action.payload.outerSigner.toLowerCase(),
|
|
661
|
-
action: action.payload.action,
|
|
662
|
-
},
|
|
663
|
-
};
|
|
664
|
-
},
|
|
665
|
-
/** Sorts and formats an `order` action. */
|
|
666
|
-
order: (action) => {
|
|
667
|
-
const sortedAction = {
|
|
668
|
-
type: action.type,
|
|
669
|
-
orders: action.orders.map((order) => {
|
|
670
|
-
const sortedOrder = {
|
|
671
|
-
a: order.a,
|
|
672
|
-
b: order.b,
|
|
673
|
-
p: formatDecimal(order.p),
|
|
674
|
-
s: formatDecimal(order.s),
|
|
675
|
-
r: order.r,
|
|
676
|
-
t: "limit" in order.t
|
|
677
|
-
? {
|
|
678
|
-
limit: {
|
|
679
|
-
tif: order.t.limit.tif,
|
|
680
|
-
},
|
|
681
|
-
}
|
|
682
|
-
: {
|
|
683
|
-
trigger: {
|
|
684
|
-
isMarket: order.t.trigger.isMarket,
|
|
685
|
-
triggerPx: formatDecimal(order.t.trigger.triggerPx),
|
|
686
|
-
tpsl: order.t.trigger.tpsl,
|
|
687
|
-
},
|
|
688
|
-
},
|
|
689
|
-
c: order.c,
|
|
690
|
-
};
|
|
691
|
-
if (order.c === undefined)
|
|
692
|
-
delete sortedOrder.c;
|
|
693
|
-
return sortedOrder;
|
|
694
|
-
}),
|
|
695
|
-
grouping: action.grouping,
|
|
696
|
-
builder: action.builder
|
|
697
|
-
? {
|
|
698
|
-
b: action.builder.b.toLowerCase(),
|
|
699
|
-
f: action.builder.f,
|
|
700
|
-
}
|
|
701
|
-
: action.builder,
|
|
702
|
-
};
|
|
703
|
-
if (sortedAction.builder === undefined)
|
|
704
|
-
delete sortedAction.builder;
|
|
705
|
-
return sortedAction;
|
|
706
|
-
},
|
|
707
|
-
/** Sorts and formats a `perpDeploy` action. */
|
|
708
|
-
perpDeploy: (action) => {
|
|
709
|
-
if ("registerAsset" in action) {
|
|
710
|
-
return {
|
|
711
|
-
type: action.type,
|
|
712
|
-
registerAsset: {
|
|
713
|
-
maxGas: action.registerAsset.maxGas ?? null,
|
|
714
|
-
assetRequest: {
|
|
715
|
-
coin: action.registerAsset.assetRequest.coin,
|
|
716
|
-
szDecimals: action.registerAsset.assetRequest.szDecimals,
|
|
717
|
-
oraclePx: action.registerAsset.assetRequest.oraclePx,
|
|
718
|
-
marginTableId: action.registerAsset.assetRequest.marginTableId,
|
|
719
|
-
onlyIsolated: action.registerAsset.assetRequest.onlyIsolated,
|
|
720
|
-
},
|
|
721
|
-
dex: action.registerAsset.dex,
|
|
722
|
-
schema: action.registerAsset.schema
|
|
723
|
-
? {
|
|
724
|
-
fullName: action.registerAsset.schema.fullName,
|
|
725
|
-
collateralToken: action.registerAsset.schema.collateralToken,
|
|
726
|
-
oracleUpdater: action.registerAsset.schema.oracleUpdater?.toLowerCase() ?? null,
|
|
727
|
-
}
|
|
728
|
-
: null,
|
|
729
|
-
},
|
|
730
|
-
};
|
|
731
|
-
}
|
|
732
|
-
else {
|
|
733
|
-
return {
|
|
734
|
-
type: action.type,
|
|
735
|
-
setOracle: {
|
|
736
|
-
dex: action.setOracle.dex,
|
|
737
|
-
oraclePxs: action.setOracle.oraclePxs,
|
|
738
|
-
markPxs: action.setOracle.markPxs,
|
|
739
|
-
},
|
|
740
|
-
};
|
|
741
|
-
}
|
|
742
|
-
},
|
|
743
|
-
/** Sorts and formats a `PerpDexClassTransfer` action. */
|
|
744
|
-
PerpDexClassTransfer: (action) => {
|
|
745
|
-
return {
|
|
746
|
-
type: action.type,
|
|
747
|
-
signatureChainId: action.signatureChainId,
|
|
748
|
-
hyperliquidChain: action.hyperliquidChain,
|
|
749
|
-
dex: action.dex,
|
|
750
|
-
token: action.token,
|
|
751
|
-
amount: action.amount,
|
|
752
|
-
toPerp: action.toPerp,
|
|
753
|
-
nonce: action.nonce,
|
|
754
|
-
};
|
|
755
|
-
},
|
|
756
|
-
/** Sorts and formats a `registerReferrer` action. */
|
|
757
|
-
registerReferrer: (action) => {
|
|
758
|
-
return {
|
|
759
|
-
type: action.type,
|
|
760
|
-
code: action.code,
|
|
761
|
-
};
|
|
762
|
-
},
|
|
763
|
-
/** Sorts and formats a `reserveRequestWeight` action. */
|
|
764
|
-
reserveRequestWeight: (action) => {
|
|
765
|
-
return {
|
|
766
|
-
type: action.type,
|
|
767
|
-
weight: action.weight,
|
|
768
|
-
};
|
|
769
|
-
},
|
|
770
|
-
/** Sorts and formats a `scheduleCancel` action. */
|
|
771
|
-
scheduleCancel: (action) => {
|
|
772
|
-
const sortedAction = {
|
|
773
|
-
type: action.type,
|
|
774
|
-
time: action.time,
|
|
775
|
-
};
|
|
776
|
-
if (sortedAction.time === undefined)
|
|
777
|
-
delete sortedAction.time;
|
|
778
|
-
return sortedAction;
|
|
779
|
-
},
|
|
780
|
-
/** Sorts and formats a `setDisplayName` action. */
|
|
781
|
-
setDisplayName: (action) => {
|
|
782
|
-
return {
|
|
783
|
-
type: action.type,
|
|
784
|
-
displayName: action.displayName,
|
|
785
|
-
};
|
|
786
|
-
},
|
|
787
|
-
/** Sorts and formats a `setReferrer` action. */
|
|
788
|
-
setReferrer: (action) => {
|
|
789
|
-
return {
|
|
790
|
-
type: action.type,
|
|
791
|
-
code: action.code,
|
|
792
|
-
};
|
|
793
|
-
},
|
|
794
|
-
/** Sorts and formats a `spotDeploy` action. */
|
|
795
|
-
spotDeploy: (action) => {
|
|
796
|
-
if ("genesis" in action) {
|
|
797
|
-
const sortedAction = {
|
|
798
|
-
type: action.type,
|
|
799
|
-
genesis: {
|
|
800
|
-
token: action.genesis.token,
|
|
801
|
-
maxSupply: action.genesis.maxSupply,
|
|
802
|
-
noHyperliquidity: action.genesis.noHyperliquidity,
|
|
803
|
-
},
|
|
804
|
-
};
|
|
805
|
-
if (sortedAction.genesis.noHyperliquidity === undefined) {
|
|
806
|
-
delete sortedAction.genesis.noHyperliquidity;
|
|
807
|
-
}
|
|
808
|
-
return sortedAction;
|
|
809
|
-
}
|
|
810
|
-
else if ("registerHyperliquidity" in action) {
|
|
811
|
-
const sortedAction = {
|
|
812
|
-
type: action.type,
|
|
813
|
-
registerHyperliquidity: {
|
|
814
|
-
spot: action.registerHyperliquidity.spot,
|
|
815
|
-
startPx: action.registerHyperliquidity.startPx,
|
|
816
|
-
orderSz: action.registerHyperliquidity.orderSz,
|
|
817
|
-
nOrders: action.registerHyperliquidity.nOrders,
|
|
818
|
-
nSeededLevels: action.registerHyperliquidity.nSeededLevels,
|
|
819
|
-
},
|
|
820
|
-
};
|
|
821
|
-
if (sortedAction.registerHyperliquidity.nSeededLevels === undefined) {
|
|
822
|
-
delete sortedAction.registerHyperliquidity.nSeededLevels;
|
|
823
|
-
}
|
|
824
|
-
return sortedAction;
|
|
825
|
-
}
|
|
826
|
-
else if ("registerSpot" in action) {
|
|
827
|
-
return {
|
|
828
|
-
type: action.type,
|
|
829
|
-
registerSpot: {
|
|
830
|
-
tokens: action.registerSpot.tokens,
|
|
831
|
-
},
|
|
832
|
-
};
|
|
833
|
-
}
|
|
834
|
-
else if ("registerToken2" in action) {
|
|
835
|
-
const sortedAction = {
|
|
836
|
-
type: action.type,
|
|
837
|
-
registerToken2: {
|
|
838
|
-
spec: {
|
|
839
|
-
name: action.registerToken2.spec.name,
|
|
840
|
-
szDecimals: action.registerToken2.spec.szDecimals,
|
|
841
|
-
weiDecimals: action.registerToken2.spec.weiDecimals,
|
|
842
|
-
},
|
|
843
|
-
maxGas: action.registerToken2.maxGas,
|
|
844
|
-
fullName: action.registerToken2.fullName,
|
|
845
|
-
},
|
|
846
|
-
};
|
|
847
|
-
if (sortedAction.registerToken2.fullName === undefined) {
|
|
848
|
-
delete sortedAction.registerToken2.fullName;
|
|
849
|
-
}
|
|
850
|
-
return sortedAction;
|
|
851
|
-
}
|
|
852
|
-
else if ("setDeployerTradingFeeShare" in action) {
|
|
853
|
-
return {
|
|
854
|
-
type: action.type,
|
|
855
|
-
setDeployerTradingFeeShare: {
|
|
856
|
-
token: action.setDeployerTradingFeeShare.token,
|
|
857
|
-
share: action.setDeployerTradingFeeShare.share,
|
|
858
|
-
},
|
|
859
|
-
};
|
|
860
|
-
}
|
|
861
|
-
else { // "userGenesis" in action
|
|
862
|
-
const sortedAction = {
|
|
863
|
-
type: action.type,
|
|
864
|
-
userGenesis: {
|
|
865
|
-
token: action.userGenesis.token,
|
|
866
|
-
userAndWei: action.userGenesis.userAndWei,
|
|
867
|
-
existingTokenAndWei: action.userGenesis.existingTokenAndWei,
|
|
868
|
-
blacklistUsers: action.userGenesis.blacklistUsers,
|
|
869
|
-
},
|
|
870
|
-
};
|
|
871
|
-
if (sortedAction.userGenesis.blacklistUsers === undefined) {
|
|
872
|
-
delete sortedAction.userGenesis.blacklistUsers;
|
|
873
|
-
}
|
|
874
|
-
return sortedAction;
|
|
875
|
-
}
|
|
876
|
-
},
|
|
877
|
-
/** Sorts and formats a `spotSend` action. */
|
|
878
|
-
spotSend: (action) => {
|
|
879
|
-
return {
|
|
880
|
-
type: action.type,
|
|
881
|
-
signatureChainId: action.signatureChainId,
|
|
882
|
-
hyperliquidChain: action.hyperliquidChain,
|
|
883
|
-
destination: action.destination.toLowerCase(),
|
|
884
|
-
token: action.token,
|
|
885
|
-
amount: action.amount,
|
|
886
|
-
time: action.time,
|
|
887
|
-
};
|
|
888
|
-
},
|
|
889
|
-
/** Sorts and formats a `spotUser` action. */
|
|
890
|
-
spotUser: (action) => {
|
|
891
|
-
return {
|
|
892
|
-
type: action.type,
|
|
893
|
-
toggleSpotDusting: {
|
|
894
|
-
optOut: action.toggleSpotDusting.optOut,
|
|
895
|
-
},
|
|
896
|
-
};
|
|
897
|
-
},
|
|
898
|
-
/** Sorts and formats a `subAccountSpotTransfer` action. */
|
|
899
|
-
subAccountSpotTransfer: (action) => {
|
|
900
|
-
return {
|
|
901
|
-
type: action.type,
|
|
902
|
-
subAccountUser: action.subAccountUser.toLowerCase(),
|
|
903
|
-
isDeposit: action.isDeposit,
|
|
904
|
-
token: action.token,
|
|
905
|
-
amount: action.amount,
|
|
906
|
-
};
|
|
907
|
-
},
|
|
908
|
-
/** Sorts and formats a `subAccountTransfer` action. */
|
|
909
|
-
subAccountTransfer: (action) => {
|
|
910
|
-
return {
|
|
911
|
-
type: action.type,
|
|
912
|
-
subAccountUser: action.subAccountUser.toLowerCase(),
|
|
913
|
-
isDeposit: action.isDeposit,
|
|
914
|
-
usd: action.usd,
|
|
915
|
-
};
|
|
916
|
-
},
|
|
917
|
-
/** Sorts and formats a `tokenDelegate` action. */
|
|
918
|
-
tokenDelegate: (action) => {
|
|
919
|
-
return {
|
|
920
|
-
type: action.type,
|
|
921
|
-
signatureChainId: action.signatureChainId,
|
|
922
|
-
hyperliquidChain: action.hyperliquidChain,
|
|
923
|
-
validator: action.validator.toLowerCase(),
|
|
924
|
-
wei: action.wei,
|
|
925
|
-
isUndelegate: action.isUndelegate,
|
|
926
|
-
nonce: action.nonce,
|
|
927
|
-
};
|
|
928
|
-
},
|
|
929
|
-
/** Sorts and formats a `twapCancel` action. */
|
|
930
|
-
twapCancel: (action) => {
|
|
931
|
-
return {
|
|
932
|
-
type: action.type,
|
|
933
|
-
a: action.a,
|
|
934
|
-
t: action.t,
|
|
935
|
-
};
|
|
936
|
-
},
|
|
937
|
-
/** Sorts and formats a `twapOrder` action. */
|
|
938
|
-
twapOrder: (action) => {
|
|
939
|
-
return {
|
|
940
|
-
type: action.type,
|
|
941
|
-
twap: {
|
|
942
|
-
a: action.twap.a,
|
|
943
|
-
b: action.twap.b,
|
|
944
|
-
s: formatDecimal(action.twap.s),
|
|
945
|
-
r: action.twap.r,
|
|
946
|
-
m: action.twap.m,
|
|
947
|
-
t: action.twap.t,
|
|
948
|
-
},
|
|
949
|
-
};
|
|
950
|
-
},
|
|
951
|
-
/** Sorts and formats an `updateIsolatedMargin` action. */
|
|
952
|
-
updateIsolatedMargin: (action) => {
|
|
953
|
-
return {
|
|
954
|
-
type: action.type,
|
|
955
|
-
asset: action.asset,
|
|
956
|
-
isBuy: action.isBuy,
|
|
957
|
-
ntli: action.ntli,
|
|
958
|
-
};
|
|
959
|
-
},
|
|
960
|
-
/** Sorts and formats an `updateLeverage` action. */
|
|
961
|
-
updateLeverage: (action) => {
|
|
962
|
-
return {
|
|
963
|
-
type: action.type,
|
|
964
|
-
asset: action.asset,
|
|
965
|
-
isCross: action.isCross,
|
|
966
|
-
leverage: action.leverage,
|
|
967
|
-
};
|
|
968
|
-
},
|
|
969
|
-
/** Sorts and formats an `usdClassTransfer` action. */
|
|
970
|
-
usdClassTransfer: (action) => {
|
|
971
|
-
return {
|
|
972
|
-
type: action.type,
|
|
973
|
-
signatureChainId: action.signatureChainId,
|
|
974
|
-
hyperliquidChain: action.hyperliquidChain,
|
|
975
|
-
amount: action.amount,
|
|
976
|
-
toPerp: action.toPerp,
|
|
977
|
-
nonce: action.nonce,
|
|
978
|
-
};
|
|
979
|
-
},
|
|
980
|
-
/** Sorts and formats an `usdSend` action. */
|
|
981
|
-
usdSend: (action) => {
|
|
982
|
-
return {
|
|
983
|
-
type: action.type,
|
|
984
|
-
signatureChainId: action.signatureChainId,
|
|
985
|
-
hyperliquidChain: action.hyperliquidChain,
|
|
986
|
-
destination: action.destination.toLowerCase(),
|
|
987
|
-
amount: action.amount,
|
|
988
|
-
time: action.time,
|
|
989
|
-
};
|
|
990
|
-
},
|
|
991
|
-
/** Sorts and formats a `vaultDistribute` action. */
|
|
992
|
-
vaultDistribute: (action) => {
|
|
993
|
-
return {
|
|
994
|
-
type: action.type,
|
|
995
|
-
vaultAddress: action.vaultAddress,
|
|
996
|
-
usd: action.usd,
|
|
997
|
-
};
|
|
998
|
-
},
|
|
999
|
-
/** Sorts and formats a `vaultModify` action. */
|
|
1000
|
-
vaultModify: (action) => {
|
|
1001
|
-
return {
|
|
1002
|
-
type: action.type,
|
|
1003
|
-
vaultAddress: action.vaultAddress,
|
|
1004
|
-
allowDeposits: action.allowDeposits,
|
|
1005
|
-
alwaysCloseOnWithdraw: action.alwaysCloseOnWithdraw,
|
|
1006
|
-
};
|
|
1007
|
-
},
|
|
1008
|
-
/** Sorts and formats a `vaultTransfer` action. */
|
|
1009
|
-
vaultTransfer: (action) => {
|
|
1010
|
-
return {
|
|
1011
|
-
type: action.type,
|
|
1012
|
-
vaultAddress: action.vaultAddress,
|
|
1013
|
-
isDeposit: action.isDeposit,
|
|
1014
|
-
usd: action.usd,
|
|
1015
|
-
};
|
|
1016
|
-
},
|
|
1017
|
-
/** Sorts and formats a `withdraw3` action. */
|
|
1018
|
-
withdraw3: (action) => {
|
|
1019
|
-
return {
|
|
1020
|
-
type: action.type,
|
|
1021
|
-
signatureChainId: action.signatureChainId,
|
|
1022
|
-
hyperliquidChain: action.hyperliquidChain,
|
|
1023
|
-
destination: action.destination.toLowerCase(),
|
|
1024
|
-
amount: action.amount,
|
|
1025
|
-
time: action.time,
|
|
1026
|
-
};
|
|
1027
|
-
},
|
|
1028
|
-
};
|
|
1029
|
-
/** Removes trailing zeros from decimal string. */
|
|
1030
|
-
function formatDecimal(numStr) {
|
|
1031
|
-
if (!numStr.includes("."))
|
|
1032
|
-
return numStr;
|
|
1033
|
-
const [intPart, fracPart] = numStr.split(".");
|
|
1034
|
-
const newFrac = fracPart.replace(/0+$/, "");
|
|
1035
|
-
return newFrac ? `${intPart}.${newFrac}` : intPart;
|
|
1036
|
-
}
|
|
1037
|
-
/** EIP-712 type definitions for user-signed actions. */
|
|
1038
|
-
exports.userSignedActionEip712Types = {
|
|
1039
|
-
approveAgent: {
|
|
1040
|
-
"HyperliquidTransaction:ApproveAgent": [
|
|
1041
|
-
{ name: "hyperliquidChain", type: "string" },
|
|
1042
|
-
{ name: "agentAddress", type: "address" },
|
|
1043
|
-
{ name: "agentName", type: "string" },
|
|
1044
|
-
{ name: "nonce", type: "uint64" },
|
|
1045
|
-
],
|
|
1046
|
-
},
|
|
1047
|
-
approveBuilderFee: {
|
|
1048
|
-
"HyperliquidTransaction:ApproveBuilderFee": [
|
|
1049
|
-
{ name: "hyperliquidChain", type: "string" },
|
|
1050
|
-
{ name: "maxFeeRate", type: "string" },
|
|
1051
|
-
{ name: "builder", type: "address" },
|
|
1052
|
-
{ name: "nonce", type: "uint64" },
|
|
1053
|
-
],
|
|
1054
|
-
},
|
|
1055
|
-
cDeposit: {
|
|
1056
|
-
"HyperliquidTransaction:CDeposit": [
|
|
1057
|
-
{ name: "hyperliquidChain", type: "string" },
|
|
1058
|
-
{ name: "wei", type: "uint64" },
|
|
1059
|
-
{ name: "nonce", type: "uint64" },
|
|
1060
|
-
],
|
|
1061
|
-
},
|
|
1062
|
-
convertToMultiSigUser: {
|
|
1063
|
-
"HyperliquidTransaction:ConvertToMultiSigUser": [
|
|
1064
|
-
{ name: "hyperliquidChain", type: "string" },
|
|
1065
|
-
{ name: "signers", type: "string" },
|
|
1066
|
-
{ name: "nonce", type: "uint64" },
|
|
1067
|
-
],
|
|
1068
|
-
},
|
|
1069
|
-
cWithdraw: {
|
|
1070
|
-
"HyperliquidTransaction:CWithdraw": [
|
|
1071
|
-
{ name: "hyperliquidChain", type: "string" },
|
|
1072
|
-
{ name: "wei", type: "uint64" },
|
|
1073
|
-
{ name: "nonce", type: "uint64" },
|
|
1074
|
-
],
|
|
1075
|
-
},
|
|
1076
|
-
PerpDexClassTransfer: {
|
|
1077
|
-
"HyperliquidTransaction:PerpDexClassTransfer": [
|
|
1078
|
-
{ name: "hyperliquidChain", type: "string" },
|
|
1079
|
-
{ name: "dex", type: "string" },
|
|
1080
|
-
{ name: "token", type: "string" },
|
|
1081
|
-
{ name: "amount", type: "string" },
|
|
1082
|
-
{ name: "toPerp", type: "bool" },
|
|
1083
|
-
{ name: "nonce", type: "uint64" },
|
|
1084
|
-
],
|
|
1085
|
-
},
|
|
1086
|
-
spotSend: {
|
|
1087
|
-
"HyperliquidTransaction:SpotSend": [
|
|
1088
|
-
{ name: "hyperliquidChain", type: "string" },
|
|
1089
|
-
{ name: "destination", type: "string" },
|
|
1090
|
-
{ name: "token", type: "string" },
|
|
1091
|
-
{ name: "amount", type: "string" },
|
|
1092
|
-
{ name: "time", type: "uint64" },
|
|
1093
|
-
],
|
|
1094
|
-
},
|
|
1095
|
-
tokenDelegate: {
|
|
1096
|
-
"HyperliquidTransaction:TokenDelegate": [
|
|
1097
|
-
{ name: "hyperliquidChain", type: "string" },
|
|
1098
|
-
{ name: "validator", type: "address" },
|
|
1099
|
-
{ name: "wei", type: "uint64" },
|
|
1100
|
-
{ name: "isUndelegate", type: "bool" },
|
|
1101
|
-
{ name: "nonce", type: "uint64" },
|
|
1102
|
-
],
|
|
1103
|
-
},
|
|
1104
|
-
usdClassTransfer: {
|
|
1105
|
-
"HyperliquidTransaction:UsdClassTransfer": [
|
|
1106
|
-
{ name: "hyperliquidChain", type: "string" },
|
|
1107
|
-
{ name: "amount", type: "string" },
|
|
1108
|
-
{ name: "toPerp", type: "bool" },
|
|
1109
|
-
{ name: "nonce", type: "uint64" },
|
|
1110
|
-
],
|
|
1111
|
-
},
|
|
1112
|
-
usdSend: {
|
|
1113
|
-
"HyperliquidTransaction:UsdSend": [
|
|
1114
|
-
{ name: "hyperliquidChain", type: "string" },
|
|
1115
|
-
{ name: "destination", type: "string" },
|
|
1116
|
-
{ name: "amount", type: "string" },
|
|
1117
|
-
{ name: "time", type: "uint64" },
|
|
1118
|
-
],
|
|
1119
|
-
},
|
|
1120
|
-
withdraw3: {
|
|
1121
|
-
"HyperliquidTransaction:Withdraw": [
|
|
1122
|
-
{ name: "hyperliquidChain", type: "string" },
|
|
1123
|
-
{ name: "destination", type: "string" },
|
|
1124
|
-
{ name: "amount", type: "string" },
|
|
1125
|
-
{ name: "time", type: "uint64" },
|
|
1126
|
-
],
|
|
1127
|
-
},
|
|
1128
|
-
};
|
|
1129
|
-
});
|