@nktkas/hyperliquid 0.25.3 → 0.25.5
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 +61 -27
- package/esm/bin/cli.js +87 -87
- package/esm/src/api/exchange/agentEnableDexAbstraction.d.ts +74 -0
- package/esm/src/api/exchange/agentEnableDexAbstraction.d.ts.map +1 -0
- package/esm/src/api/exchange/agentEnableDexAbstraction.js +58 -0
- package/esm/src/api/exchange/agentEnableDexAbstraction.js.map +1 -0
- package/esm/src/api/exchange/userDexAbstraction.d.ts +104 -0
- package/esm/src/api/exchange/userDexAbstraction.d.ts.map +1 -0
- package/esm/src/api/exchange/userDexAbstraction.js +79 -0
- package/esm/src/api/exchange/userDexAbstraction.js.map +1 -0
- package/esm/src/api/exchange/~client.d.ts +100 -40
- package/esm/src/api/exchange/~client.d.ts.map +1 -1
- package/esm/src/api/exchange/~client.js +51 -1
- package/esm/src/api/exchange/~client.js.map +1 -1
- package/esm/src/api/exchange/~mod.d.ts +2 -0
- package/esm/src/api/exchange/~mod.d.ts.map +1 -1
- package/esm/src/api/exchange/~mod.js +2 -0
- package/esm/src/api/exchange/~mod.js.map +1 -1
- package/esm/src/api/info/l2Book.d.ts +3 -3
- package/esm/src/api/info/l2Book.d.ts.map +1 -1
- package/esm/src/api/info/l2Book.js +2 -2
- package/esm/src/api/info/l2Book.js.map +1 -1
- package/esm/src/api/info/userDexAbstraction.d.ts +49 -0
- package/esm/src/api/info/userDexAbstraction.d.ts.map +1 -0
- package/esm/src/api/info/userDexAbstraction.js +52 -0
- package/esm/src/api/info/userDexAbstraction.js.map +1 -0
- package/esm/src/api/info/~client.d.ts +23 -1
- package/esm/src/api/info/~client.d.ts.map +1 -1
- package/esm/src/api/info/~client.js +23 -0
- package/esm/src/api/info/~client.js.map +1 -1
- package/esm/src/api/info/~mod.d.ts +1 -0
- package/esm/src/api/info/~mod.d.ts.map +1 -1
- package/esm/src/api/info/~mod.js +1 -0
- package/esm/src/api/info/~mod.js.map +1 -1
- package/esm/src/api/subscription/l2Book.d.ts +3 -0
- package/esm/src/api/subscription/l2Book.d.ts.map +1 -1
- package/esm/src/api/subscription/l2Book.js +10 -3
- package/esm/src/api/subscription/l2Book.js.map +1 -1
- package/esm/src/utils/{minimalEIP712Signer.d.ts → _minimalEIP712Signer.d.ts} +1 -1
- package/esm/src/utils/_minimalEIP712Signer.d.ts.map +1 -0
- package/esm/src/utils/{minimalEIP712Signer.js → _minimalEIP712Signer.js} +1 -1
- package/esm/src/utils/_minimalEIP712Signer.js.map +1 -0
- package/esm/src/utils/_symbolConverter.d.ts +77 -0
- package/esm/src/utils/_symbolConverter.d.ts.map +1 -0
- package/esm/src/utils/_symbolConverter.js +155 -0
- package/esm/src/utils/_symbolConverter.js.map +1 -0
- package/esm/src/utils/mod.d.ts +2 -0
- package/esm/src/utils/mod.d.ts.map +1 -0
- package/esm/src/utils/mod.js +2 -0
- package/esm/src/utils/mod.js.map +1 -0
- package/package.json +5 -1
- package/script/bin/cli.js +87 -87
- package/script/src/api/exchange/agentEnableDexAbstraction.d.ts +74 -0
- package/script/src/api/exchange/agentEnableDexAbstraction.d.ts.map +1 -0
- package/script/src/api/exchange/agentEnableDexAbstraction.js +95 -0
- package/script/src/api/exchange/agentEnableDexAbstraction.js.map +1 -0
- package/script/src/api/exchange/userDexAbstraction.d.ts +104 -0
- package/script/src/api/exchange/userDexAbstraction.d.ts.map +1 -0
- package/script/src/api/exchange/userDexAbstraction.js +116 -0
- package/script/src/api/exchange/userDexAbstraction.js.map +1 -0
- package/script/src/api/exchange/~client.d.ts +100 -40
- package/script/src/api/exchange/~client.d.ts.map +1 -1
- package/script/src/api/exchange/~client.js +53 -3
- package/script/src/api/exchange/~client.js.map +1 -1
- package/script/src/api/exchange/~mod.d.ts +2 -0
- package/script/src/api/exchange/~mod.d.ts.map +1 -1
- package/script/src/api/exchange/~mod.js +2 -0
- package/script/src/api/exchange/~mod.js.map +1 -1
- package/script/src/api/info/l2Book.d.ts +3 -3
- package/script/src/api/info/l2Book.d.ts.map +1 -1
- package/script/src/api/info/l2Book.js +2 -2
- package/script/src/api/info/l2Book.js.map +1 -1
- package/script/src/api/info/userDexAbstraction.d.ts +49 -0
- package/script/src/api/info/userDexAbstraction.d.ts.map +1 -0
- package/script/src/api/info/userDexAbstraction.js +89 -0
- package/script/src/api/info/userDexAbstraction.js.map +1 -0
- package/script/src/api/info/~client.d.ts +23 -1
- package/script/src/api/info/~client.d.ts.map +1 -1
- package/script/src/api/info/~client.js +23 -0
- package/script/src/api/info/~client.js.map +1 -1
- package/script/src/api/info/~mod.d.ts +1 -0
- package/script/src/api/info/~mod.d.ts.map +1 -1
- package/script/src/api/info/~mod.js +1 -0
- package/script/src/api/info/~mod.js.map +1 -1
- package/script/src/api/subscription/l2Book.d.ts +3 -0
- package/script/src/api/subscription/l2Book.d.ts.map +1 -1
- package/script/src/api/subscription/l2Book.js +9 -2
- package/script/src/api/subscription/l2Book.js.map +1 -1
- package/script/src/utils/{minimalEIP712Signer.d.ts → _minimalEIP712Signer.d.ts} +1 -1
- package/script/src/utils/_minimalEIP712Signer.d.ts.map +1 -0
- package/script/src/utils/{minimalEIP712Signer.js → _minimalEIP712Signer.js} +1 -1
- package/script/src/utils/_minimalEIP712Signer.js.map +1 -0
- package/script/src/utils/_symbolConverter.d.ts +77 -0
- package/script/src/utils/_symbolConverter.d.ts.map +1 -0
- package/script/src/utils/_symbolConverter.js +159 -0
- package/script/src/utils/_symbolConverter.js.map +1 -0
- package/script/src/utils/mod.d.ts +2 -0
- package/script/src/utils/mod.d.ts.map +1 -0
- package/script/src/utils/mod.js +18 -0
- package/script/src/utils/mod.js.map +1 -0
- package/src/bin/cli.ts +87 -87
- package/src/src/api/exchange/agentEnableDexAbstraction.ts +96 -0
- package/src/src/api/exchange/userDexAbstraction.ts +142 -0
- package/src/src/api/exchange/~client.ts +97 -41
- package/src/src/api/exchange/~mod.ts +2 -0
- package/src/src/api/info/l2Book.ts +20 -18
- package/src/src/api/info/userDexAbstraction.ts +79 -0
- package/src/src/api/info/~client.ts +25 -0
- package/src/src/api/info/~mod.ts +1 -0
- package/src/src/api/subscription/l2Book.ts +22 -3
- package/src/src/utils/_symbolConverter.ts +185 -0
- package/src/src/utils/mod.ts +1 -0
- package/esm/src/utils/minimalEIP712Signer.d.ts.map +0 -1
- package/esm/src/utils/minimalEIP712Signer.js.map +0 -1
- package/script/src/utils/minimalEIP712Signer.d.ts.map +0 -1
- package/script/src/utils/minimalEIP712Signer.js.map +0 -1
- /package/src/src/utils/{minimalEIP712Signer.ts → _minimalEIP712Signer.ts} +0 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { Address, type DeepImmutable, Hex, parser, UnsignedInteger } from "../_base.js";
|
|
2
|
+
import {
|
|
3
|
+
type ExchangeRequestConfig,
|
|
4
|
+
executeUserSignedAction,
|
|
5
|
+
type ExtractRequestAction,
|
|
6
|
+
type ExtractRequestOptions,
|
|
7
|
+
getNonce,
|
|
8
|
+
getSignatureChainId,
|
|
9
|
+
type MultiSignRequestConfig,
|
|
10
|
+
Signature,
|
|
11
|
+
} from "./_base.js";
|
|
12
|
+
import * as v from "valibot";
|
|
13
|
+
|
|
14
|
+
// -------------------- Schemas --------------------
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Enable/disable HIP-3 DEX abstraction.
|
|
18
|
+
* @see null
|
|
19
|
+
*/
|
|
20
|
+
export const UserDexAbstractionExchangeRequest = /* @__PURE__ */ (() => {
|
|
21
|
+
return v.pipe(
|
|
22
|
+
v.object({
|
|
23
|
+
/** Action to perform. */
|
|
24
|
+
action: v.pipe(
|
|
25
|
+
v.object({
|
|
26
|
+
/** Type of action. */
|
|
27
|
+
type: v.pipe(
|
|
28
|
+
v.literal("userDexAbstraction"),
|
|
29
|
+
v.description("Type of action."),
|
|
30
|
+
),
|
|
31
|
+
/** Chain ID used for signing. */
|
|
32
|
+
signatureChainId: v.pipe(
|
|
33
|
+
Hex,
|
|
34
|
+
v.description("Chain ID used for signing."),
|
|
35
|
+
),
|
|
36
|
+
/** HyperLiquid network. */
|
|
37
|
+
hyperliquidChain: v.pipe(
|
|
38
|
+
v.union([v.literal("Mainnet"), v.literal("Testnet")]),
|
|
39
|
+
v.description("HyperLiquid network."),
|
|
40
|
+
),
|
|
41
|
+
/** User address. */
|
|
42
|
+
user: v.pipe(
|
|
43
|
+
Address,
|
|
44
|
+
v.description("User address."),
|
|
45
|
+
),
|
|
46
|
+
/** Whether to enable or disable HIP-3 DEX abstraction. */
|
|
47
|
+
enabled: v.pipe(
|
|
48
|
+
v.boolean(),
|
|
49
|
+
v.description("Whether to enable or disable HIP-3 DEX abstraction."),
|
|
50
|
+
),
|
|
51
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
52
|
+
nonce: v.pipe(
|
|
53
|
+
UnsignedInteger,
|
|
54
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
55
|
+
),
|
|
56
|
+
}),
|
|
57
|
+
v.description("Action to perform."),
|
|
58
|
+
),
|
|
59
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
60
|
+
nonce: v.pipe(
|
|
61
|
+
UnsignedInteger,
|
|
62
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
63
|
+
),
|
|
64
|
+
/** Cryptographic signature. */
|
|
65
|
+
signature: v.pipe(
|
|
66
|
+
Signature,
|
|
67
|
+
v.description("Cryptographic signature."),
|
|
68
|
+
),
|
|
69
|
+
}),
|
|
70
|
+
v.description("Enable/disable HIP-3 DEX abstraction."),
|
|
71
|
+
);
|
|
72
|
+
})();
|
|
73
|
+
export type UserDexAbstractionExchangeRequest = v.InferOutput<typeof UserDexAbstractionExchangeRequest>;
|
|
74
|
+
|
|
75
|
+
import { SuccessResponse } from "./_base.js";
|
|
76
|
+
export { SuccessResponse };
|
|
77
|
+
|
|
78
|
+
// -------------------- Function --------------------
|
|
79
|
+
|
|
80
|
+
/** Action parameters for the {@linkcode userDexAbstraction} function. */
|
|
81
|
+
export type UserDexAbstractionExchangeParameters = ExtractRequestAction<
|
|
82
|
+
v.InferInput<typeof UserDexAbstractionExchangeRequest>
|
|
83
|
+
>;
|
|
84
|
+
/** Request options for the {@linkcode userDexAbstraction} function. */
|
|
85
|
+
export type UserDexAbstractionExchangeOptions = ExtractRequestOptions<
|
|
86
|
+
v.InferInput<typeof UserDexAbstractionExchangeRequest>
|
|
87
|
+
>;
|
|
88
|
+
|
|
89
|
+
/** EIP-712 types for the {@linkcode userDexAbstraction} function. */
|
|
90
|
+
export const UserDexAbstractionTypes = {
|
|
91
|
+
"HyperliquidTransaction:UserDexAbstraction": [
|
|
92
|
+
{ name: "hyperliquidChain", type: "string" },
|
|
93
|
+
{ name: "user", type: "address" },
|
|
94
|
+
{ name: "enabled", type: "bool" },
|
|
95
|
+
{ name: "nonce", type: "uint64" },
|
|
96
|
+
],
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Enable/disable HIP-3 DEX abstraction.
|
|
101
|
+
* @param config - General configuration for Exchange API requests.
|
|
102
|
+
* @param params - Parameters specific to the API request.
|
|
103
|
+
* @param opts - Request execution options.
|
|
104
|
+
* @returns Successful response without specific data.
|
|
105
|
+
*
|
|
106
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
107
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
108
|
+
*
|
|
109
|
+
* @see null
|
|
110
|
+
* @example
|
|
111
|
+
* ```ts
|
|
112
|
+
* import { HttpTransport } from "@nktkas/hyperliquid";
|
|
113
|
+
* import { userDexAbstraction } from "@nktkas/hyperliquid/api/exchange";
|
|
114
|
+
* import { privateKeyToAccount } from "npm:viem/accounts";
|
|
115
|
+
*
|
|
116
|
+
* const wallet = privateKeyToAccount("0x..."); // viem or ethers
|
|
117
|
+
* const transport = new HttpTransport(); // or `WebSocketTransport`
|
|
118
|
+
*
|
|
119
|
+
* await userDexAbstraction(
|
|
120
|
+
* { transport, wallet },
|
|
121
|
+
* { user: "0x...", enabled: true },
|
|
122
|
+
* );
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
export async function userDexAbstraction(
|
|
126
|
+
config: ExchangeRequestConfig | MultiSignRequestConfig,
|
|
127
|
+
params: DeepImmutable<UserDexAbstractionExchangeParameters>,
|
|
128
|
+
opts?: UserDexAbstractionExchangeOptions,
|
|
129
|
+
): Promise<SuccessResponse> {
|
|
130
|
+
const action = parser(UserDexAbstractionExchangeRequest.entries.action)({
|
|
131
|
+
type: "userDexAbstraction",
|
|
132
|
+
hyperliquidChain: config.transport.isTestnet ? "Testnet" : "Mainnet",
|
|
133
|
+
signatureChainId: await getSignatureChainId(config),
|
|
134
|
+
nonce: await getNonce(config),
|
|
135
|
+
...params,
|
|
136
|
+
});
|
|
137
|
+
return await executeUserSignedAction(
|
|
138
|
+
config,
|
|
139
|
+
{ action, types: UserDexAbstractionTypes },
|
|
140
|
+
opts?.signal,
|
|
141
|
+
);
|
|
142
|
+
}
|
|
@@ -2,8 +2,9 @@ import type { OmitFirst, OverloadedParameters } from "../_base.js";
|
|
|
2
2
|
import type { ExchangeRequestConfig, MaybePromise, MultiSignRequestConfig } from "./_base.js";
|
|
3
3
|
import type { IRequestTransport } from "../../transport/base.js";
|
|
4
4
|
import type { AbstractWallet } from "../../signing/mod.js";
|
|
5
|
-
import { PrivateKeyEIP712Signer } from "../../utils/
|
|
5
|
+
import { PrivateKeyEIP712Signer } from "../../utils/_minimalEIP712Signer.js";
|
|
6
6
|
|
|
7
|
+
import { agentEnableDexAbstraction } from "./agentEnableDexAbstraction.js";
|
|
7
8
|
import { approveAgent } from "./approveAgent.js";
|
|
8
9
|
import { approveBuilderFee } from "./approveBuilderFee.js";
|
|
9
10
|
import { batchModify } from "./batchModify.js";
|
|
@@ -42,51 +43,56 @@ import { updateIsolatedMargin } from "./updateIsolatedMargin.js";
|
|
|
42
43
|
import { updateLeverage } from "./updateLeverage.js";
|
|
43
44
|
import { usdClassTransfer } from "./usdClassTransfer.js";
|
|
44
45
|
import { usdSend } from "./usdSend.js";
|
|
46
|
+
import { userDexAbstraction } from "./userDexAbstraction.js";
|
|
45
47
|
import { vaultDistribute } from "./vaultDistribute.js";
|
|
46
48
|
import { vaultModify } from "./vaultModify.js";
|
|
47
49
|
import { vaultTransfer } from "./vaultTransfer.js";
|
|
48
50
|
import { withdraw3 } from "./withdraw3.js";
|
|
49
51
|
|
|
50
|
-
export type {
|
|
51
|
-
export type {
|
|
52
|
-
export type {
|
|
53
|
-
export type {
|
|
54
|
-
export type {
|
|
55
|
-
export type {
|
|
56
|
-
export type {
|
|
57
|
-
export type {
|
|
58
|
-
export type {
|
|
59
|
-
export type {
|
|
60
|
-
export type {
|
|
61
|
-
export type {
|
|
62
|
-
export type {
|
|
63
|
-
export type {
|
|
64
|
-
export type {
|
|
65
|
-
export type {
|
|
66
|
-
export type {
|
|
67
|
-
export type {
|
|
68
|
-
export type {
|
|
69
|
-
export type {
|
|
70
|
-
export type {
|
|
71
|
-
export type {
|
|
72
|
-
export type {
|
|
73
|
-
export type {
|
|
74
|
-
export type {
|
|
75
|
-
export type {
|
|
76
|
-
export type {
|
|
77
|
-
export type {
|
|
78
|
-
export type {
|
|
79
|
-
export type {
|
|
80
|
-
export type {
|
|
81
|
-
export type {
|
|
82
|
-
export type {
|
|
83
|
-
export type {
|
|
84
|
-
export type {
|
|
85
|
-
export type {
|
|
86
|
-
export type {
|
|
87
|
-
export type {
|
|
88
|
-
export type {
|
|
89
|
-
export type {
|
|
52
|
+
export type { AgentEnableDexAbstractionOptions } from "./agentEnableDexAbstraction.js";
|
|
53
|
+
export type { ApproveAgentOptions, ApproveAgentParameters } from "./approveAgent.js";
|
|
54
|
+
export type { ApproveBuilderFeeOptions, ApproveBuilderFeeParameters } from "./approveBuilderFee.js";
|
|
55
|
+
export type { BatchModifyOptions, BatchModifyParameters } from "./batchModify.js";
|
|
56
|
+
export type { CancelOptions, CancelParameters } from "./cancel.js";
|
|
57
|
+
export type { CancelByCloidOptions, CancelByCloidParameters } from "./cancelByCloid.js";
|
|
58
|
+
export type { CDepositOptions, CDepositParameters } from "./cDeposit.js";
|
|
59
|
+
export type { ClaimRewardsOptions } from "./claimRewards.js";
|
|
60
|
+
export type { ConvertToMultiSigUserOptions, ConvertToMultiSigUserParameters } from "./convertToMultiSigUser.js";
|
|
61
|
+
export type { CreateSubAccountOptions, CreateSubAccountParameters } from "./createSubAccount.js";
|
|
62
|
+
export type { CreateVaultOptions, CreateVaultParameters } from "./createVault.js";
|
|
63
|
+
export type { CSignerActionOptions, CSignerActionParameters } from "./cSignerAction.js";
|
|
64
|
+
export type { CValidatorActionOptions, CValidatorActionParameters } from "./cValidatorAction.js";
|
|
65
|
+
export type { CWithdrawOptions, CWithdrawParameters } from "./cWithdraw.js";
|
|
66
|
+
export type { EvmUserModifyOptions, EvmUserModifyParameters } from "./evmUserModify.js";
|
|
67
|
+
export type { ModifyOptions, ModifyParameters } from "./modify.js";
|
|
68
|
+
export type { MultiSigOptions, MultiSigParameters } from "./multiSig.js";
|
|
69
|
+
export type { OrderOptions, OrderParameters } from "./order.js";
|
|
70
|
+
export type { NoopOptions } from "./noop.js";
|
|
71
|
+
export type { PerpDeployOptions, PerpDeployParameters } from "./perpDeploy.js";
|
|
72
|
+
export type { RegisterReferrerOptions, RegisterReferrerParameters } from "./registerReferrer.js";
|
|
73
|
+
export type { ReserveRequestWeightOptions, ReserveRequestWeightParameters } from "./reserveRequestWeight.js";
|
|
74
|
+
export type { ScheduleCancelOptions, ScheduleCancelParameters } from "./scheduleCancel.js";
|
|
75
|
+
export type { SendAssetOptions, SendAssetParameters } from "./sendAsset.js";
|
|
76
|
+
export type { SetDisplayNameOptions, SetDisplayNameParameters } from "./setDisplayName.js";
|
|
77
|
+
export type { SetReferrerOptions, SetReferrerParameters } from "./setReferrer.js";
|
|
78
|
+
export type { SpotDeployOptions, SpotDeployParameters } from "./spotDeploy.js";
|
|
79
|
+
export type { SpotSendOptions, SpotSendParameters } from "./spotSend.js";
|
|
80
|
+
export type { SpotUserOptions, SpotUserParameters } from "./spotUser.js";
|
|
81
|
+
export type { SubAccountModifyOptions, SubAccountModifyParameters } from "./subAccountModify.js";
|
|
82
|
+
export type { SubAccountSpotTransferOptions, SubAccountSpotTransferParameters } from "./subAccountSpotTransfer.js";
|
|
83
|
+
export type { SubAccountTransferOptions, SubAccountTransferParameters } from "./subAccountTransfer.js";
|
|
84
|
+
export type { TokenDelegateOptions, TokenDelegateParameters } from "./tokenDelegate.js";
|
|
85
|
+
export type { TwapCancelOptions, TwapCancelParameters } from "./twapCancel.js";
|
|
86
|
+
export type { TwapOrderOptions, TwapOrderParameters } from "./twapOrder.js";
|
|
87
|
+
export type { UpdateIsolatedMarginOptions, UpdateIsolatedMarginParameters } from "./updateIsolatedMargin.js";
|
|
88
|
+
export type { UpdateLeverageOptions, UpdateLeverageParameters } from "./updateLeverage.js";
|
|
89
|
+
export type { UsdClassTransferOptions, UsdClassTransferParameters } from "./usdClassTransfer.js";
|
|
90
|
+
export type { UsdSendOptions, UsdSendParameters } from "./usdSend.js";
|
|
91
|
+
export type { UserDexAbstractionExchangeOptions, UserDexAbstractionExchangeParameters } from "./userDexAbstraction.js";
|
|
92
|
+
export type { VaultDistributeOptions, VaultDistributeParameters } from "./vaultDistribute.js";
|
|
93
|
+
export type { VaultModifyOptions, VaultModifyParameters } from "./vaultModify.js";
|
|
94
|
+
export type { VaultTransferOptions, VaultTransferParameters } from "./vaultTransfer.js";
|
|
95
|
+
export type { Withdraw3Options, Withdraw3Parameters } from "./withdraw3.js";
|
|
90
96
|
|
|
91
97
|
export type { CancelSuccessResponse } from "./cancel.js";
|
|
92
98
|
export type { CreateSubAccountResponse } from "./createSubAccount.js";
|
|
@@ -178,6 +184,31 @@ export class ExchangeClient<
|
|
|
178
184
|
this.nonceManager = args.nonceManager;
|
|
179
185
|
}
|
|
180
186
|
|
|
187
|
+
/**
|
|
188
|
+
* Enable HIP-3 DEX abstraction.
|
|
189
|
+
* @param params - Parameters specific to the API request.
|
|
190
|
+
* @param opts - Request execution options.
|
|
191
|
+
* @returns Successful response without specific data.
|
|
192
|
+
*
|
|
193
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
194
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
195
|
+
*
|
|
196
|
+
* @see null
|
|
197
|
+
* @example
|
|
198
|
+
* ```ts
|
|
199
|
+
* import * as hl from "@nktkas/hyperliquid";
|
|
200
|
+
*
|
|
201
|
+
* const pk = "0x..."; // viem, ethers or private key
|
|
202
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
203
|
+
*
|
|
204
|
+
* const client = new hl.ExchangeClient({ transport, wallet: pk });
|
|
205
|
+
* await client.agentEnableDexAbstraction();
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
agentEnableDexAbstraction(...args: OmitFirst<OverloadedParameters<typeof agentEnableDexAbstraction>>) {
|
|
209
|
+
return agentEnableDexAbstraction(this, ...args);
|
|
210
|
+
}
|
|
211
|
+
|
|
181
212
|
/**
|
|
182
213
|
* Approve an agent to sign on behalf of the master account.
|
|
183
214
|
* @param params - Parameters specific to the API request.
|
|
@@ -1315,6 +1346,31 @@ export class ExchangeClient<
|
|
|
1315
1346
|
return usdSend(this, ...args);
|
|
1316
1347
|
}
|
|
1317
1348
|
|
|
1349
|
+
/**
|
|
1350
|
+
* Enable/disable HIP-3 DEX abstraction.
|
|
1351
|
+
* @param params - Parameters specific to the API request.
|
|
1352
|
+
* @param opts - Request execution options.
|
|
1353
|
+
* @returns Successful response without specific data.
|
|
1354
|
+
*
|
|
1355
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
1356
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
1357
|
+
*
|
|
1358
|
+
* @see null
|
|
1359
|
+
* @example
|
|
1360
|
+
* ```ts
|
|
1361
|
+
* import * as hl from "@nktkas/hyperliquid";
|
|
1362
|
+
*
|
|
1363
|
+
* const pk = "0x..."; // viem, ethers or private key
|
|
1364
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1365
|
+
*
|
|
1366
|
+
* const client = new hl.ExchangeClient({ transport, wallet: pk });
|
|
1367
|
+
* await client.userDexAbstraction({ user: "0x...", enabled: true });
|
|
1368
|
+
* ```
|
|
1369
|
+
*/
|
|
1370
|
+
userDexAbstraction(...args: OmitFirst<OverloadedParameters<typeof userDexAbstraction>>) {
|
|
1371
|
+
return userDexAbstraction(this, ...args);
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1318
1374
|
/**
|
|
1319
1375
|
* Distribute funds from a vault between followers.
|
|
1320
1376
|
* @param params - Parameters specific to the API request.
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
export { parser, SchemaError } from "../_base.js";
|
|
41
41
|
export type { ExchangeRequestConfig } from "./_base.js";
|
|
42
42
|
|
|
43
|
+
export * from "./agentEnableDexAbstraction.js";
|
|
43
44
|
export * from "./approveAgent.js";
|
|
44
45
|
export * from "./approveBuilderFee.js";
|
|
45
46
|
export * from "./batchModify.js";
|
|
@@ -78,6 +79,7 @@ export * from "./updateIsolatedMargin.js";
|
|
|
78
79
|
export * from "./updateLeverage.js";
|
|
79
80
|
export * from "./usdClassTransfer.js";
|
|
80
81
|
export * from "./usdSend.js";
|
|
82
|
+
export * from "./userDexAbstraction.js";
|
|
81
83
|
export * from "./vaultDistribute.js";
|
|
82
84
|
export * from "./vaultModify.js";
|
|
83
85
|
export * from "./vaultTransfer.js";
|
|
@@ -55,24 +55,26 @@ export type L2BookRequest = v.InferOutput<typeof L2BookRequest>;
|
|
|
55
55
|
*/
|
|
56
56
|
export const L2BookResponse = /* @__PURE__ */ (() => {
|
|
57
57
|
return v.pipe(
|
|
58
|
-
v.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
v.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
58
|
+
v.nullable(
|
|
59
|
+
v.object({
|
|
60
|
+
/** Asset symbol. */
|
|
61
|
+
coin: v.pipe(
|
|
62
|
+
v.string(),
|
|
63
|
+
v.description("Asset symbol."),
|
|
64
|
+
),
|
|
65
|
+
/** Timestamp of the snapshot (in ms since epoch). */
|
|
66
|
+
time: v.pipe(
|
|
67
|
+
UnsignedInteger,
|
|
68
|
+
v.description("Timestamp of the snapshot (in ms since epoch)."),
|
|
69
|
+
),
|
|
70
|
+
/** Bid and ask levels (index 0 = bids, index 1 = asks). */
|
|
71
|
+
levels: v.pipe(
|
|
72
|
+
v.tuple([v.array(L2BookLevelSchema), v.array(L2BookLevelSchema)]),
|
|
73
|
+
v.description("Bid and ask levels (index 0 = bids, index 1 = asks)."),
|
|
74
|
+
),
|
|
75
|
+
}),
|
|
76
|
+
),
|
|
77
|
+
v.description("L2 order book snapshot or `null` if the market does not exist."),
|
|
76
78
|
);
|
|
77
79
|
})();
|
|
78
80
|
export type L2BookResponse = v.InferOutput<typeof L2BookResponse>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { Address, type DeepImmutable, parser } from "../_base.js";
|
|
3
|
+
import type { InfoRequestConfig } from "./_base.js";
|
|
4
|
+
|
|
5
|
+
// -------------------- Schemas --------------------
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Request user HIP-3 DEX abstraction state.
|
|
9
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-a-users-hip-3-dex-abstraction-state
|
|
10
|
+
*/
|
|
11
|
+
export const UserDexAbstractionInfoRequest = /* @__PURE__ */ (() => {
|
|
12
|
+
return v.pipe(
|
|
13
|
+
v.object({
|
|
14
|
+
/** Type of request. */
|
|
15
|
+
type: v.pipe(
|
|
16
|
+
v.literal("userDexAbstraction"),
|
|
17
|
+
v.description("Type of request."),
|
|
18
|
+
),
|
|
19
|
+
/** User address. */
|
|
20
|
+
user: v.pipe(
|
|
21
|
+
Address,
|
|
22
|
+
v.description("User address."),
|
|
23
|
+
),
|
|
24
|
+
}),
|
|
25
|
+
v.description("Request user referral."),
|
|
26
|
+
);
|
|
27
|
+
})();
|
|
28
|
+
export type UserDexAbstractionInfoRequest = v.InferOutput<typeof UserDexAbstractionInfoRequest>;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* User HIP-3 DEX abstraction state.
|
|
32
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-a-users-hip-3-dex-abstraction-state
|
|
33
|
+
*/
|
|
34
|
+
export const UserDexAbstractionInfoResponse = /* @__PURE__ */ (() => {
|
|
35
|
+
return v.pipe(
|
|
36
|
+
v.nullable(v.boolean()),
|
|
37
|
+
v.description("User HIP-3 DEX abstraction state."),
|
|
38
|
+
);
|
|
39
|
+
})();
|
|
40
|
+
export type UserDexAbstractionInfoResponse = v.InferOutput<typeof UserDexAbstractionInfoResponse>;
|
|
41
|
+
|
|
42
|
+
// -------------------- Function --------------------
|
|
43
|
+
|
|
44
|
+
/** Request parameters for the {@linkcode userDexAbstraction} function. */
|
|
45
|
+
export type UserDexAbstractionInfoParameters = Omit<v.InferInput<typeof UserDexAbstractionInfoRequest>, "type">;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Request user HIP-3 DEX abstraction state.
|
|
49
|
+
* @param config - General configuration for Info API requests.
|
|
50
|
+
* @param params - Parameters specific to the API request.
|
|
51
|
+
* @param signal - An [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) can be used to cancel the request by calling [`abort()`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort) on the corresponding [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
|
|
52
|
+
* @returns User HIP-3 DEX abstraction state.
|
|
53
|
+
*
|
|
54
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
55
|
+
*
|
|
56
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-a-users-hip-3-dex-abstraction-state
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* import { HttpTransport } from "@nktkas/hyperliquid";
|
|
60
|
+
* import { userDexAbstraction } from "@nktkas/hyperliquid/api/info";
|
|
61
|
+
*
|
|
62
|
+
* const transport = new HttpTransport(); // or `WebSocketTransport`
|
|
63
|
+
* const data = await userDexAbstraction(
|
|
64
|
+
* { transport },
|
|
65
|
+
* { user: "0x..." },
|
|
66
|
+
* );
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export function userDexAbstraction(
|
|
70
|
+
config: InfoRequestConfig,
|
|
71
|
+
params: DeepImmutable<UserDexAbstractionInfoParameters>,
|
|
72
|
+
signal?: AbortSignal,
|
|
73
|
+
): Promise<UserDexAbstractionInfoResponse> {
|
|
74
|
+
const request = parser(UserDexAbstractionInfoRequest)({
|
|
75
|
+
type: "userDexAbstraction",
|
|
76
|
+
...params,
|
|
77
|
+
});
|
|
78
|
+
return config.transport.request("info", request, signal);
|
|
79
|
+
}
|
|
@@ -49,6 +49,7 @@ import { tokenDetails } from "./tokenDetails.js";
|
|
|
49
49
|
import { twapHistory } from "./twapHistory.js";
|
|
50
50
|
import { txDetails } from "./txDetails.js";
|
|
51
51
|
import { userDetails } from "./userDetails.js";
|
|
52
|
+
import { userDexAbstraction } from "./userDexAbstraction.js";
|
|
52
53
|
import { userFees } from "./userFees.js";
|
|
53
54
|
import { userFills } from "./userFills.js";
|
|
54
55
|
import { userFillsByTime } from "./userFillsByTime.js";
|
|
@@ -113,6 +114,7 @@ export type { TokenDetailsParameters, TokenDetailsResponse } from "./tokenDetail
|
|
|
113
114
|
export type { TwapHistoryParameters, TwapHistoryResponse } from "./twapHistory.js";
|
|
114
115
|
export type { TxDetailsParameters, TxDetailsResponse } from "./txDetails.js";
|
|
115
116
|
export type { UserDetailsParameters, UserDetailsResponse } from "./userDetails.js";
|
|
117
|
+
export type { UserDexAbstractionInfoParameters, UserDexAbstractionInfoResponse } from "./userDexAbstraction.js";
|
|
116
118
|
export type { UserFeesParameters, UserFeesResponse } from "./userFees.js";
|
|
117
119
|
export type { UserFillsParameters, UserFillsResponse } from "./userFills.js";
|
|
118
120
|
export type { UserFillsByTimeParameters, UserFillsByTimeResponse } from "./userFillsByTime.js";
|
|
@@ -1261,6 +1263,29 @@ export class InfoClient<T extends IRequestTransport = IRequestTransport> impleme
|
|
|
1261
1263
|
return userDetails(this, ...args);
|
|
1262
1264
|
}
|
|
1263
1265
|
|
|
1266
|
+
/**
|
|
1267
|
+
* Request user HIP-3 DEX abstraction state.
|
|
1268
|
+
* @param params - Parameters specific to the API request.
|
|
1269
|
+
* @param signal - An [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) can be used to cancel the request by calling [`abort()`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort) on the corresponding [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
|
|
1270
|
+
* @returns User HIP-3 DEX abstraction state.
|
|
1271
|
+
*
|
|
1272
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
1273
|
+
*
|
|
1274
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-a-users-hip-3-dex-abstraction-state
|
|
1275
|
+
* @example
|
|
1276
|
+
* ```ts
|
|
1277
|
+
* import * as hl from "@nktkas/hyperliquid";
|
|
1278
|
+
*
|
|
1279
|
+
* const transport = new hl.HttpTransport(); // only `HttpTransport` supports this API
|
|
1280
|
+
*
|
|
1281
|
+
* const client = new hl.InfoClient({ transport });
|
|
1282
|
+
* const data = await client.userDexAbstraction({ user: "0x..." });
|
|
1283
|
+
* ```
|
|
1284
|
+
*/
|
|
1285
|
+
userDexAbstraction(...args: OmitFirst<OverloadedParameters<typeof userDexAbstraction>>) {
|
|
1286
|
+
return userDexAbstraction(this, ...args);
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1264
1289
|
/**
|
|
1265
1290
|
* Request user fees.
|
|
1266
1291
|
* @param params - Parameters specific to the API request.
|
package/src/src/api/info/~mod.ts
CHANGED
|
@@ -71,6 +71,7 @@ export * from "./tokenDetails.js";
|
|
|
71
71
|
export * from "./twapHistory.js";
|
|
72
72
|
export * from "./txDetails.js";
|
|
73
73
|
export * from "./userDetails.js";
|
|
74
|
+
export * from "./userDexAbstraction.js";
|
|
74
75
|
export * from "./userFees.js";
|
|
75
76
|
export * from "./userFills.js";
|
|
76
77
|
export * from "./userFillsByTime.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
import { type DeepImmutable, Integer, parser } from "../_base.js";
|
|
2
|
+
import { type DeepImmutable, Integer, parser, UnsignedInteger } from "../_base.js";
|
|
3
3
|
import type { SubscriptionRequestConfig } from "./_base.js";
|
|
4
4
|
import type { Subscription } from "../../transport/base.js";
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { L2BookLevelSchema } from "../_common_schemas.js";
|
|
7
7
|
|
|
8
8
|
// -------------------- Schemas --------------------
|
|
9
9
|
|
|
@@ -49,7 +49,26 @@ export type L2BookRequest = v.InferOutput<typeof L2BookRequest>;
|
|
|
49
49
|
|
|
50
50
|
/** Event of L2 order book snapshot. */
|
|
51
51
|
export const L2BookEvent = /* @__PURE__ */ (() => {
|
|
52
|
-
return
|
|
52
|
+
return v.pipe(
|
|
53
|
+
v.object({
|
|
54
|
+
/** Asset symbol. */
|
|
55
|
+
coin: v.pipe(
|
|
56
|
+
v.string(),
|
|
57
|
+
v.description("Asset symbol."),
|
|
58
|
+
),
|
|
59
|
+
/** Timestamp of the snapshot (in ms since epoch). */
|
|
60
|
+
time: v.pipe(
|
|
61
|
+
UnsignedInteger,
|
|
62
|
+
v.description("Timestamp of the snapshot (in ms since epoch)."),
|
|
63
|
+
),
|
|
64
|
+
/** Bid and ask levels (index 0 = bids, index 1 = asks). */
|
|
65
|
+
levels: v.pipe(
|
|
66
|
+
v.tuple([v.array(L2BookLevelSchema), v.array(L2BookLevelSchema)]),
|
|
67
|
+
v.description("Bid and ask levels (index 0 = bids, index 1 = asks)."),
|
|
68
|
+
),
|
|
69
|
+
}),
|
|
70
|
+
v.description("L2 order book snapshot."),
|
|
71
|
+
);
|
|
53
72
|
})();
|
|
54
73
|
export type L2BookEvent = v.InferOutput<typeof L2BookEvent>;
|
|
55
74
|
|