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

nktkas / hyperliquid / 19405103680

16 Nov 2025 11:46AM UTC coverage: 94.726% (-0.6%) from 95.329%
19405103680

push

github

nktkas
test(info): adapt command execution for Deno and Node.js environments

368 of 581 branches covered (63.34%)

Branch coverage included in aggregate %.

11667 of 12124 relevant lines covered (96.23%)

951.31 hits per line

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

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

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

14
/**
15
 * Modify a vault's configuration.
16
 * @see null
17
 */
18
export const VaultModifyRequest = /* @__PURE__ */ (() => {
353✔
19
  return v.pipe(
598✔
20
    v.object({
598✔
21
      /** Action to perform. */
22
      action: v.pipe(
598✔
23
        v.object({
598✔
24
          /** Type of action. */
25
          type: v.pipe(
598✔
26
            v.literal("vaultModify"),
598✔
27
            v.description("Type of action."),
598✔
28
          ),
29
          /** Vault address. */
30
          vaultAddress: v.pipe(
598✔
31
            Address,
598✔
32
            v.description("Vault address."),
598✔
33
          ),
34
          /** Allow deposits from followers (default: null). */
35
          allowDeposits: v.pipe(
598✔
36
            v.optional(v.nullable(v.boolean()), null),
598✔
37
            v.description("Allow deposits from followers."),
598✔
38
          ),
39
          /** Always close positions on withdrawal (default: null). */
40
          alwaysCloseOnWithdraw: v.pipe(
598✔
41
            v.optional(v.nullable(v.boolean()), null),
598✔
42
            v.description("Always close positions on withdrawal."),
598✔
43
          ),
44
        }),
598✔
45
        v.description("Action to perform."),
598✔
46
      ),
47
      /** Unique request identifier (current timestamp in ms). */
48
      nonce: v.pipe(
598✔
49
        UnsignedInteger,
598✔
50
        v.description("Unique request identifier (current timestamp in ms)."),
598✔
51
      ),
52
      /** Cryptographic signature. */
53
      signature: v.pipe(
598✔
54
        Signature,
598✔
55
        v.description("Cryptographic signature."),
598✔
56
      ),
57
      /** Expiration time of the action. */
58
      expiresAfter: v.pipe(
598✔
59
        v.optional(UnsignedInteger),
598✔
60
        v.description("Expiration time of the action."),
598✔
61
      ),
62
    }),
598✔
63
    v.description("Modify a vault's configuration."),
598✔
64
  );
65
})();
353✔
66
export type VaultModifyRequest = v.InferOutput<typeof VaultModifyRequest>;
67

68
import { SuccessResponse } from "./_base/mod.ts";
353✔
69
export { SuccessResponse };
353✔
70

71
// -------------------- Function --------------------
72

73
/** Action parameters for the {@linkcode vaultModify} function. */
74
export type VaultModifyParameters = ExtractRequestAction<v.InferInput<typeof VaultModifyRequest>>;
75
/** Request options for the {@linkcode vaultModify} function. */
76
export type VaultModifyOptions = ExtractRequestOptions<v.InferInput<typeof VaultModifyRequest>>;
77

78
/**
79
 * Modify a vault's configuration.
80
 * @param config - General configuration for Exchange API requests.
81
 * @param params - Parameters specific to the API request.
82
 * @param opts - Request execution options.
83
 * @returns Successful response without specific data.
84
 *
85
 * @throws {ApiRequestError} When the API returns an unsuccessful response.
86
 * @throws {TransportError} When the transport layer throws an error.
87
 *
88
 * @see null
89
 * @example
90
 * ```ts
91
 * import { HttpTransport } from "@nktkas/hyperliquid";
92
 * import { vaultModify } from "@nktkas/hyperliquid/api/exchange";
93
 * import { privateKeyToAccount } from "npm:viem/accounts";
94
 *
95
 * const wallet = privateKeyToAccount("0x..."); // viem or ethers
96
 * const transport = new HttpTransport(); // or `WebSocketTransport`
97
 *
98
 * await vaultModify(
99
 *   { transport, wallet },
100
 *   {
101
 *     vaultAddress: "0x...",
102
 *     allowDeposits: true,
103
 *     alwaysCloseOnWithdraw: false,
104
 *   },
105
 * );
106
 * ```
107
 */
108
export async function vaultModify(
353✔
109
  config: ExchangeRequestConfig | MultiSignRequestConfig,
353✔
110
  params: DeepImmutable<VaultModifyParameters>,
353✔
111
  opts?: VaultModifyOptions,
353✔
112
): Promise<SuccessResponse> {
113
  const request = parser(VaultModifyRequest)({
356✔
114
    action: {
356✔
115
      type: "vaultModify",
356✔
116
      ...params,
356✔
117
    },
356✔
118
    nonce: 0, // Placeholder; actual nonce generated in `executeL1Action`
356✔
119
    signature: { // Placeholder; actual signature generated in `executeL1Action`
356✔
120
      r: "0x0000000000000000000000000000000000000000000000000000000000000000",
356✔
121
      s: "0x0000000000000000000000000000000000000000000000000000000000000000",
356✔
122
      v: 27,
356✔
123
    },
356✔
124
    expiresAfter: typeof config.defaultExpiresAfter === "number"
×
125
      ? config.defaultExpiresAfter
×
126
      : await config.defaultExpiresAfter?.(),
×
127
  });
356✔
128
  return await executeL1Action(config, request, opts?.signal);
×
129
}
356✔
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