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

nktkas / hyperliquid / 19514753888

19 Nov 2025 08:02PM UTC coverage: 94.811% (+0.1%) from 94.685%
19514753888

push

github

nktkas
ci: remove environment for test job

364 of 583 branches covered (62.44%)

Branch coverage included in aggregate %.

12208 of 12677 relevant lines covered (96.3%)

964.38 hits per line

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

94.59
/src/api/info/metaAndAssetCtxs.ts
1
import * as v from "valibot";
357✔
2

3
// ============================================================
4
// API Schemas
5
// ============================================================
6

7
import { Decimal, UnsignedDecimal } from "../_base.ts";
357✔
8
import { MetaResponse } from "./meta.ts";
357✔
9

10
/**
11
 * Request metadata and asset contexts.
12
 * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-asset-contexts-includes-mark-price-current-funding-open-interest-etc
13
 */
14
export const MetaAndAssetCtxsRequest = /* @__PURE__ */ (() => {
357✔
15
  return v.pipe(
605✔
16
    v.object({
605✔
17
      /** Type of request. */
18
      type: v.pipe(
605✔
19
        v.literal("metaAndAssetCtxs"),
605✔
20
        v.description("Type of request."),
605✔
21
      ),
22
      /** DEX name (empty string for main dex). */
23
      dex: v.pipe(
605✔
24
        v.optional(v.string()),
605✔
25
        v.description("DEX name (empty string for main dex)."),
605✔
26
      ),
27
    }),
605✔
28
    v.description("Request metadata and asset contexts."),
605✔
29
  );
30
})();
357✔
31
export type MetaAndAssetCtxsRequest = v.InferOutput<typeof MetaAndAssetCtxsRequest>;
32

33
/**
34
 * Metadata and context for perpetual assets.
35
 * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-asset-contexts-includes-mark-price-current-funding-open-interest-etc
36
 */
37
export const MetaAndAssetCtxsResponse = /* @__PURE__ */ (() => {
357✔
38
  return v.pipe(
605✔
39
    v.tuple([
605✔
40
      MetaResponse,
605✔
41
      /** Array of contexts for each perpetual asset. */
42
      v.pipe(
605✔
43
        v.array(
605✔
44
          /** Context for a specific perpetual asset. */
45
          v.pipe(
605✔
46
            v.object({
605✔
47
              /** Previous day's closing price. */
48
              prevDayPx: v.pipe(
605✔
49
                UnsignedDecimal,
605✔
50
                v.description("Previous day's closing price."),
605✔
51
              ),
52
              /** Daily notional volume. */
53
              dayNtlVlm: v.pipe(
605✔
54
                UnsignedDecimal,
605✔
55
                v.description("Daily notional volume."),
605✔
56
              ),
57
              /** Mark price. */
58
              markPx: v.pipe(
605✔
59
                UnsignedDecimal,
605✔
60
                v.description("Mark price."),
605✔
61
              ),
62
              /** Mid price. */
63
              midPx: v.pipe(
605✔
64
                v.nullable(UnsignedDecimal),
605✔
65
                v.description("Mid price."),
605✔
66
              ),
67
              /** Funding rate. */
68
              funding: v.pipe(
605✔
69
                Decimal,
605✔
70
                v.description("Funding rate."),
605✔
71
              ),
72
              /** Total open interest. */
73
              openInterest: v.pipe(
605✔
74
                UnsignedDecimal,
605✔
75
                v.description("Total open interest."),
605✔
76
              ),
77
              /** Premium price. */
78
              premium: v.pipe(
605✔
79
                v.nullable(Decimal),
605✔
80
                v.description("Premium price."),
605✔
81
              ),
82
              /** Oracle price. */
83
              oraclePx: v.pipe(
605✔
84
                UnsignedDecimal,
605✔
85
                v.description("Oracle price."),
605✔
86
              ),
87
              /** Array of impact prices. */
88
              impactPxs: v.pipe(
605✔
89
                v.nullable(v.array(v.string())),
605✔
90
                v.description("Array of impact prices."),
605✔
91
              ),
92
              /** Daily volume in base currency. */
93
              dayBaseVlm: v.pipe(
605✔
94
                UnsignedDecimal,
605✔
95
                v.description("Daily volume in base currency."),
605✔
96
              ),
97
            }),
605✔
98
            v.description("Context for a specific perpetual asset."),
605✔
99
          ),
100
        ),
101
        v.description("Array of contexts for each perpetual asset."),
605✔
102
      ),
103
    ]),
605✔
104
    v.description("Metadata and context for perpetual assets."),
605✔
105
  );
106
})();
357✔
107
export type MetaAndAssetCtxsResponse = v.InferOutput<typeof MetaAndAssetCtxsResponse>;
108

109
// ============================================================
110
// Execution Logic
111
// ============================================================
112

113
import { type DeepImmutable, parser } from "../_base.ts";
357✔
114
import type { InfoRequestConfig } from "./_types.ts";
115

116
/** Request parameters for the {@linkcode metaAndAssetCtxs} function. */
117
export type MetaAndAssetCtxsParameters = Omit<v.InferInput<typeof MetaAndAssetCtxsRequest>, "type">;
118

119
/**
120
 * Request metadata and asset contexts.
121
 * @param config - General configuration for Info API requests.
122
 * @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).
123
 * @returns Metadata and context for perpetual assets.
124
 *
125
 * @throws {TransportError} When the transport layer throws an error.
126
 *
127
 * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-asset-contexts-includes-mark-price-current-funding-open-interest-etc
128
 * @example
129
 * ```ts
130
 * import { HttpTransport } from "@nktkas/hyperliquid";
131
 * import { metaAndAssetCtxs } from "@nktkas/hyperliquid/api/info";
132
 *
133
 * const transport = new HttpTransport(); // or `WebSocketTransport`
134
 * const data = await metaAndAssetCtxs({ transport });
135
 * ```
136
 */
137
export function metaAndAssetCtxs(
138
  config: InfoRequestConfig,
139
  params?: DeepImmutable<MetaAndAssetCtxsParameters>,
140
  signal?: AbortSignal,
141
): Promise<MetaAndAssetCtxsResponse>;
142
export function metaAndAssetCtxs(
143
  config: InfoRequestConfig,
144
  signal?: AbortSignal,
145
): Promise<MetaAndAssetCtxsResponse>;
146
export function metaAndAssetCtxs(
357✔
147
  config: InfoRequestConfig,
357✔
148
  paramsOrSignal?: DeepImmutable<MetaAndAssetCtxsParameters> | AbortSignal,
357✔
149
  maybeSignal?: AbortSignal,
357✔
150
): Promise<MetaAndAssetCtxsResponse> {
151
  const params = paramsOrSignal instanceof AbortSignal ? {} : paramsOrSignal;
×
152
  const signal = paramsOrSignal instanceof AbortSignal ? paramsOrSignal : maybeSignal;
×
153

154
  const request = parser(MetaAndAssetCtxsRequest)({
360✔
155
    type: "metaAndAssetCtxs",
360✔
156
    ...params,
360✔
157
  });
360✔
158
  return config.transport.request("info", request, signal);
360✔
159
}
360✔
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