• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nktkas / hyperliquid / 17932585565

23 Sep 2025 12:11AM UTC coverage: 96.069% (+5.5%) from 90.582%
17932585565

push

github

nktkas
feat!: tree shaking support (~50% less size)

all API methods were moved to separate files and a new import point `/api` was added

breaking changes:
- import point `/schemas` replaced with `/api/[info,exchange,subscription]`
- standardization of typescript types to single pattern: [api name] + [Request,Response,Event,Parameters,Options,Types]
- private key directly supported only when creating a client instance

365 of 553 branches covered (66.0%)

Branch coverage included in aggregate %.

13134 of 13495 new or added lines in 148 files covered. (97.32%)

13173 of 13539 relevant lines covered (97.3%)

613.66 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.68
/src/api/exchange/subAccountModify.ts
1
import { Address, type DeepImmutable, parser, UnsignedInteger } from "../_common.ts";
328✔
2
import {
328✔
3
  type ExchangeRequestConfig,
4
  executeL1Action,
328✔
5
  type ExtractRequestAction,
6
  type ExtractRequestOptions,
7
  type MultiSignRequestConfig,
8
  Signature,
328✔
9
} from "./_common.ts";
328✔
10
import * as v from "valibot";
328✔
11

12
// -------------------- Schemas --------------------
13

14
/**
15
 * Modify a sub-account's.
16
 * @see null
17
 */
18
export const SubAccountModifyRequest = /* @__PURE__ */ (() => {
328✔
19
  return v.pipe(
555✔
20
    v.object({
555✔
21
      /** Action to perform. */
22
      action: v.pipe(
555✔
23
        v.object({
555✔
24
          /** Type of action. */
25
          type: v.pipe(
555✔
26
            v.literal("subAccountModify"),
555✔
27
            v.description("Type of action."),
555✔
28
          ),
29
          /** Sub-account address to modify. */
30
          subAccountUser: v.pipe(
555✔
31
            Address,
555✔
32
            v.description("Sub-account address to modify."),
555✔
33
          ),
34
          /** New sub-account name. */
35
          name: v.pipe(
555✔
36
            v.string(),
555✔
37
            v.minLength(1),
555✔
38
            v.description("New sub-account name."),
555✔
39
          ),
40
        }),
555✔
41
        v.description("Action to perform."),
555✔
42
      ),
43
      /** Unique request identifier (current timestamp in ms). */
44
      nonce: v.pipe(
555✔
45
        UnsignedInteger,
555✔
46
        v.description("Unique request identifier (current timestamp in ms)."),
555✔
47
      ),
48
      /** Cryptographic signature. */
49
      signature: v.pipe(
555✔
50
        Signature,
555✔
51
        v.description("Cryptographic signature."),
555✔
52
      ),
53
      /** Expiration time of the action. */
54
      expiresAfter: v.pipe(
555✔
55
        v.optional(UnsignedInteger),
555✔
56
        v.description("Expiration time of the action."),
555✔
57
      ),
58
    }),
555✔
59
    v.description("Modify a sub-account."),
555✔
60
  );
61
})();
328✔
62
export type SubAccountModifyRequest = v.InferOutput<typeof SubAccountModifyRequest>;
63

64
import { SuccessResponse } from "./_common.ts";
328✔
65
export { SuccessResponse };
328✔
66

67
// -------------------- Function --------------------
68

69
/** Action parameters for the {@linkcode subAccountModify} function. */
70
export type SubAccountModifyParameters = ExtractRequestAction<v.InferInput<typeof SubAccountModifyRequest>>;
71
/** Request options for the {@linkcode subAccountModify} function. */
72
export type SubAccountModifyOptions = ExtractRequestOptions<v.InferInput<typeof SubAccountModifyRequest>>;
73

74
/**
75
 * Modify a sub-account's.
76
 * @param config - General configuration for Exchange API requests.
77
 * @param params - Parameters specific to the API request.
78
 * @param opts - Request execution options.
79
 * @returns Successful response without specific data.
80
 *
81
 * @throws {ApiRequestError} When the API returns an unsuccessful response.
82
 * @throws {TransportError} When the transport layer throws an error.
83
 *
84
 * @see null
85
 * @example
86
 * ```ts
87
 * import { HttpTransport } from "@nktkas/hyperliquid";
88
 * import { subAccountModify } from "@nktkas/hyperliquid/api/exchange";
89
 * import { privateKeyToAccount } from "npm:viem/accounts";
90
 *
91
 * const wallet = privateKeyToAccount("0x..."); // viem or ethers
92
 * const transport = new HttpTransport(); // or `WebSocketTransport`
93
 *
94
 * await subAccountModify(
95
 *   { transport, wallet },
96
 *   { subAccountUser: "0x...", name: "..."  },
97
 * );
98
 * ```
99
 */
100
export async function subAccountModify(
328✔
101
  config: ExchangeRequestConfig | MultiSignRequestConfig,
328✔
102
  params: DeepImmutable<SubAccountModifyParameters>,
328✔
103
  opts?: SubAccountModifyOptions,
328✔
104
): Promise<SuccessResponse> {
105
  const action = parser(SubAccountModifyRequest.entries.action)({
331✔
106
    type: "subAccountModify",
331✔
107
    ...params,
331✔
108
  });
331✔
NEW
109
  const expiresAfter = typeof config.defaultExpiresAfter === "number"
×
NEW
110
    ? config.defaultExpiresAfter
×
NEW
111
    : await config.defaultExpiresAfter?.();
×
112
  return await executeL1Action(config, { action, expiresAfter }, opts?.signal);
993!
113
}
331✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc