UNPKG

@nktkas/hyperliquid

Version:

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

51 lines (50 loc) 1.98 kB
import * as v from "valibot"; // ============================================================ // API Schemas // ============================================================ import { Address } from "../../_schemas.js"; /** * Request user staking rewards. * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-a-users-staking-rewards */ export const DelegatorRewardsRequest = /* @__PURE__ */ (()=>{ return v.object({ /** Type of request. */ type: v.literal("delegatorRewards"), /** User address. */ user: Address }); })(); // ============================================================ // Execution Logic // ============================================================ import { parse } from "../../../_base.js"; /** * Request user staking rewards. * * @param config General configuration for Info API requests. * @param params Parameters specific to the API request. * @param signal {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal | AbortSignal} to cancel the request. * @return Array of rewards received from staking activities. * * @throws {ValidationError} 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 { delegatorRewards } from "@nktkas/hyperliquid/api/info"; * * const transport = new HttpTransport(); // or `WebSocketTransport` * * const data = await delegatorRewards({ transport }, { * user: "0x...", * }); * ``` * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-a-users-staking-rewards */ export function delegatorRewards(config, params, signal) { const request = parse(DelegatorRewardsRequest, { type: "delegatorRewards", ...params }); return config.transport.request("info", request, signal); } //# sourceMappingURL=delegatorRewards.js.map