UNPKG

@nktkas/hyperliquid

Version:

Hyperliquid API SDK for all major JS runtimes, written in TypeScript.

69 lines 3.08 kB
import * as v from "valibot"; // ============================================================ // API Schemas // ============================================================ import { Decimal, UnsignedInteger } from "../../_schemas.js"; /** * Request predicted funding rates. * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-predicted-funding-rates-for-different-venues */ export const PredictedFundingsRequest = /* @__PURE__ */ (() => { return v.pipe(v.object({ /** Type of request. */ type: v.pipe(v.literal("predictedFundings"), v.description("Type of request.")), }), v.description("Request predicted funding rates.")); })(); /** * Array of tuples of asset symbols and their predicted funding data. * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-predicted-funding-rates-for-different-venues */ export const PredictedFundingsResponse = /* @__PURE__ */ (() => { return v.pipe(v.array(v.tuple([ // Asset symbol v.string(), // Array of predicted funding data for each exchange v.array(v.tuple([ // Exchange symbol v.string(), // Predicted funding data (if available) v.nullable(v.object({ /** Predicted funding rate. */ fundingRate: v.pipe(Decimal, v.description("Predicted funding rate.")), /** Next funding time (ms since epoch). */ nextFundingTime: v.pipe(UnsignedInteger, v.description("Next funding time (ms since epoch).")), /** Funding interval in hours. */ fundingIntervalHours: v.pipe(v.optional(UnsignedInteger), v.description("Funding interval in hours.")), })), ])), ])), v.description("Array of tuples of asset symbols and their predicted funding data.")); })(); /** * Request predicted funding rates. * * @param config - General configuration for Info API requests. * @param signal - {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal | AbortSignal} to cancel the request. * * @returns Array of predicted funding rates. * * @throws {ValiError} When the request parameters fail validation (before sending). * @throws {TransportError} When the transport layer throws an error. * * @example * ```ts * import { HttpTransport } from "@nktkas/hyperliquid"; * import { predictedFundings } from "@nktkas/hyperliquid/api/info"; * * const transport = new HttpTransport(); // or `WebSocketTransport` * * const data = await predictedFundings({ transport }); * ``` * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-predicted-funding-rates-for-different-venues */ export function predictedFundings(config, signal) { const request = v.parse(PredictedFundingsRequest, { type: "predictedFundings", }); return config.transport.request("info", request, signal); } //# sourceMappingURL=predictedFundings.js.map