@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.
Files changed (117) hide show
  1. package/README.md +61 -27
  2. package/esm/bin/cli.js +87 -87
  3. package/esm/src/api/exchange/agentEnableDexAbstraction.d.ts +74 -0
  4. package/esm/src/api/exchange/agentEnableDexAbstraction.d.ts.map +1 -0
  5. package/esm/src/api/exchange/agentEnableDexAbstraction.js +58 -0
  6. package/esm/src/api/exchange/agentEnableDexAbstraction.js.map +1 -0
  7. package/esm/src/api/exchange/userDexAbstraction.d.ts +104 -0
  8. package/esm/src/api/exchange/userDexAbstraction.d.ts.map +1 -0
  9. package/esm/src/api/exchange/userDexAbstraction.js +79 -0
  10. package/esm/src/api/exchange/userDexAbstraction.js.map +1 -0
  11. package/esm/src/api/exchange/~client.d.ts +100 -40
  12. package/esm/src/api/exchange/~client.d.ts.map +1 -1
  13. package/esm/src/api/exchange/~client.js +51 -1
  14. package/esm/src/api/exchange/~client.js.map +1 -1
  15. package/esm/src/api/exchange/~mod.d.ts +2 -0
  16. package/esm/src/api/exchange/~mod.d.ts.map +1 -1
  17. package/esm/src/api/exchange/~mod.js +2 -0
  18. package/esm/src/api/exchange/~mod.js.map +1 -1
  19. package/esm/src/api/info/l2Book.d.ts +3 -3
  20. package/esm/src/api/info/l2Book.d.ts.map +1 -1
  21. package/esm/src/api/info/l2Book.js +2 -2
  22. package/esm/src/api/info/l2Book.js.map +1 -1
  23. package/esm/src/api/info/userDexAbstraction.d.ts +49 -0
  24. package/esm/src/api/info/userDexAbstraction.d.ts.map +1 -0
  25. package/esm/src/api/info/userDexAbstraction.js +52 -0
  26. package/esm/src/api/info/userDexAbstraction.js.map +1 -0
  27. package/esm/src/api/info/~client.d.ts +23 -1
  28. package/esm/src/api/info/~client.d.ts.map +1 -1
  29. package/esm/src/api/info/~client.js +23 -0
  30. package/esm/src/api/info/~client.js.map +1 -1
  31. package/esm/src/api/info/~mod.d.ts +1 -0
  32. package/esm/src/api/info/~mod.d.ts.map +1 -1
  33. package/esm/src/api/info/~mod.js +1 -0
  34. package/esm/src/api/info/~mod.js.map +1 -1
  35. package/esm/src/api/subscription/l2Book.d.ts +3 -0
  36. package/esm/src/api/subscription/l2Book.d.ts.map +1 -1
  37. package/esm/src/api/subscription/l2Book.js +10 -3
  38. package/esm/src/api/subscription/l2Book.js.map +1 -1
  39. package/esm/src/utils/{minimalEIP712Signer.d.ts → _minimalEIP712Signer.d.ts} +1 -1
  40. package/esm/src/utils/_minimalEIP712Signer.d.ts.map +1 -0
  41. package/esm/src/utils/{minimalEIP712Signer.js → _minimalEIP712Signer.js} +1 -1
  42. package/esm/src/utils/_minimalEIP712Signer.js.map +1 -0
  43. package/esm/src/utils/_symbolConverter.d.ts +77 -0
  44. package/esm/src/utils/_symbolConverter.d.ts.map +1 -0
  45. package/esm/src/utils/_symbolConverter.js +155 -0
  46. package/esm/src/utils/_symbolConverter.js.map +1 -0
  47. package/esm/src/utils/mod.d.ts +2 -0
  48. package/esm/src/utils/mod.d.ts.map +1 -0
  49. package/esm/src/utils/mod.js +2 -0
  50. package/esm/src/utils/mod.js.map +1 -0
  51. package/package.json +5 -1
  52. package/script/bin/cli.js +87 -87
  53. package/script/src/api/exchange/agentEnableDexAbstraction.d.ts +74 -0
  54. package/script/src/api/exchange/agentEnableDexAbstraction.d.ts.map +1 -0
  55. package/script/src/api/exchange/agentEnableDexAbstraction.js +95 -0
  56. package/script/src/api/exchange/agentEnableDexAbstraction.js.map +1 -0
  57. package/script/src/api/exchange/userDexAbstraction.d.ts +104 -0
  58. package/script/src/api/exchange/userDexAbstraction.d.ts.map +1 -0
  59. package/script/src/api/exchange/userDexAbstraction.js +116 -0
  60. package/script/src/api/exchange/userDexAbstraction.js.map +1 -0
  61. package/script/src/api/exchange/~client.d.ts +100 -40
  62. package/script/src/api/exchange/~client.d.ts.map +1 -1
  63. package/script/src/api/exchange/~client.js +53 -3
  64. package/script/src/api/exchange/~client.js.map +1 -1
  65. package/script/src/api/exchange/~mod.d.ts +2 -0
  66. package/script/src/api/exchange/~mod.d.ts.map +1 -1
  67. package/script/src/api/exchange/~mod.js +2 -0
  68. package/script/src/api/exchange/~mod.js.map +1 -1
  69. package/script/src/api/info/l2Book.d.ts +3 -3
  70. package/script/src/api/info/l2Book.d.ts.map +1 -1
  71. package/script/src/api/info/l2Book.js +2 -2
  72. package/script/src/api/info/l2Book.js.map +1 -1
  73. package/script/src/api/info/userDexAbstraction.d.ts +49 -0
  74. package/script/src/api/info/userDexAbstraction.d.ts.map +1 -0
  75. package/script/src/api/info/userDexAbstraction.js +89 -0
  76. package/script/src/api/info/userDexAbstraction.js.map +1 -0
  77. package/script/src/api/info/~client.d.ts +23 -1
  78. package/script/src/api/info/~client.d.ts.map +1 -1
  79. package/script/src/api/info/~client.js +23 -0
  80. package/script/src/api/info/~client.js.map +1 -1
  81. package/script/src/api/info/~mod.d.ts +1 -0
  82. package/script/src/api/info/~mod.d.ts.map +1 -1
  83. package/script/src/api/info/~mod.js +1 -0
  84. package/script/src/api/info/~mod.js.map +1 -1
  85. package/script/src/api/subscription/l2Book.d.ts +3 -0
  86. package/script/src/api/subscription/l2Book.d.ts.map +1 -1
  87. package/script/src/api/subscription/l2Book.js +9 -2
  88. package/script/src/api/subscription/l2Book.js.map +1 -1
  89. package/script/src/utils/{minimalEIP712Signer.d.ts → _minimalEIP712Signer.d.ts} +1 -1
  90. package/script/src/utils/_minimalEIP712Signer.d.ts.map +1 -0
  91. package/script/src/utils/{minimalEIP712Signer.js → _minimalEIP712Signer.js} +1 -1
  92. package/script/src/utils/_minimalEIP712Signer.js.map +1 -0
  93. package/script/src/utils/_symbolConverter.d.ts +77 -0
  94. package/script/src/utils/_symbolConverter.d.ts.map +1 -0
  95. package/script/src/utils/_symbolConverter.js +159 -0
  96. package/script/src/utils/_symbolConverter.js.map +1 -0
  97. package/script/src/utils/mod.d.ts +2 -0
  98. package/script/src/utils/mod.d.ts.map +1 -0
  99. package/script/src/utils/mod.js +18 -0
  100. package/script/src/utils/mod.js.map +1 -0
  101. package/src/bin/cli.ts +87 -87
  102. package/src/src/api/exchange/agentEnableDexAbstraction.ts +96 -0
  103. package/src/src/api/exchange/userDexAbstraction.ts +142 -0
  104. package/src/src/api/exchange/~client.ts +97 -41
  105. package/src/src/api/exchange/~mod.ts +2 -0
  106. package/src/src/api/info/l2Book.ts +20 -18
  107. package/src/src/api/info/userDexAbstraction.ts +79 -0
  108. package/src/src/api/info/~client.ts +25 -0
  109. package/src/src/api/info/~mod.ts +1 -0
  110. package/src/src/api/subscription/l2Book.ts +22 -3
  111. package/src/src/utils/_symbolConverter.ts +185 -0
  112. package/src/src/utils/mod.ts +1 -0
  113. package/esm/src/utils/minimalEIP712Signer.d.ts.map +0 -1
  114. package/esm/src/utils/minimalEIP712Signer.js.map +0 -1
  115. package/script/src/utils/minimalEIP712Signer.d.ts.map +0 -1
  116. package/script/src/utils/minimalEIP712Signer.js.map +0 -1
  117. /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/minimalEIP712Signer.js";
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 { ApproveAgentParameters } from "./approveAgent.js";
51
- export type { ApproveBuilderFeeParameters } from "./approveBuilderFee.js";
52
- export type { BatchModifyParameters } from "./batchModify.js";
53
- export type { CancelParameters } from "./cancel.js";
54
- export type { CancelByCloidParameters } from "./cancelByCloid.js";
55
- export type { CDepositParameters } from "./cDeposit.js";
56
- export type { ConvertToMultiSigUserParameters } from "./convertToMultiSigUser.js";
57
- export type { CreateSubAccountParameters } from "./createSubAccount.js";
58
- export type { CreateVaultParameters } from "./createVault.js";
59
- export type { CSignerActionParameters } from "./cSignerAction.js";
60
- export type { CValidatorActionParameters } from "./cValidatorAction.js";
61
- export type { CWithdrawParameters } from "./cWithdraw.js";
62
- export type { EvmUserModifyParameters } from "./evmUserModify.js";
63
- export type { ModifyParameters } from "./modify.js";
64
- export type { MultiSigParameters } from "./multiSig.js";
65
- export type { OrderParameters } from "./order.js";
66
- export type { PerpDeployParameters } from "./perpDeploy.js";
67
- export type { RegisterReferrerParameters } from "./registerReferrer.js";
68
- export type { ReserveRequestWeightParameters } from "./reserveRequestWeight.js";
69
- export type { ScheduleCancelParameters } from "./scheduleCancel.js";
70
- export type { SendAssetParameters } from "./sendAsset.js";
71
- export type { SetDisplayNameParameters } from "./setDisplayName.js";
72
- export type { SetReferrerParameters } from "./setReferrer.js";
73
- export type { SpotDeployParameters } from "./spotDeploy.js";
74
- export type { SpotSendParameters } from "./spotSend.js";
75
- export type { SpotUserParameters } from "./spotUser.js";
76
- export type { SubAccountModifyParameters } from "./subAccountModify.js";
77
- export type { SubAccountSpotTransferParameters } from "./subAccountSpotTransfer.js";
78
- export type { SubAccountTransferParameters } from "./subAccountTransfer.js";
79
- export type { TokenDelegateParameters } from "./tokenDelegate.js";
80
- export type { TwapCancelParameters } from "./twapCancel.js";
81
- export type { TwapOrderParameters } from "./twapOrder.js";
82
- export type { UpdateIsolatedMarginParameters } from "./updateIsolatedMargin.js";
83
- export type { UpdateLeverageParameters } from "./updateLeverage.js";
84
- export type { UsdClassTransferParameters } from "./usdClassTransfer.js";
85
- export type { UsdSendParameters } from "./usdSend.js";
86
- export type { VaultDistributeParameters } from "./vaultDistribute.js";
87
- export type { VaultModifyParameters } from "./vaultModify.js";
88
- export type { VaultTransferParameters } from "./vaultTransfer.js";
89
- export type { Withdraw3Parameters } from "./withdraw3.js";
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.object({
59
- /** Asset symbol. */
60
- coin: v.pipe(
61
- v.string(),
62
- v.description("Asset symbol."),
63
- ),
64
- /** Timestamp of the snapshot (in ms since epoch). */
65
- time: v.pipe(
66
- UnsignedInteger,
67
- v.description("Timestamp of the snapshot (in ms since epoch)."),
68
- ),
69
- /** Bid and ask levels (index 0 = bids, index 1 = asks). */
70
- levels: v.pipe(
71
- v.tuple([v.array(L2BookLevelSchema), v.array(L2BookLevelSchema)]),
72
- v.description("Bid and ask levels (index 0 = bids, index 1 = asks)."),
73
- ),
74
- }),
75
- v.description("L2 order book snapshot."),
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.
@@ -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 { L2BookResponse } from "../info/l2Book.js";
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 L2BookResponse;
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