@nktkas/hyperliquid
Version:
Hyperliquid API SDK for all major JS runtimes, written in TypeScript.
73 lines • 3.52 kB
JavaScript
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 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 PredictedFundingsResponse = /* @__PURE__ */ (() => {
return v.pipe(v.array(
/** Tuple of asset symbol and its predicted funding data. */
v.pipe(v.tuple([
/** Asset symbol. */
v.pipe(v.string(), v.description("Asset symbol.")),
/** Array of predicted funding data for each exchange. */
v.pipe(v.array(
/** Tuple of exchange symbol and predicted funding data. */
v.pipe(v.tuple([
/** Exchange symbol. */
v.pipe(v.string(), v.description("Exchange symbol.")),
/** Predicted funding data. */
v.pipe(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("Predicted funding data.")),
]), v.description("Tuple of exchange symbol and predicted funding data."))), v.description("Array of predicted funding data for each exchange.")),
]), v.description("Tuple of asset symbol and its predicted funding data."))), v.description("Array of predicted funding rates."));
})();
/**
* Request predicted funding rates.
*
* @param config - General configuration for Info API requests.
* @param signal - [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/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