@nktkas/hyperliquid
Version:
Hyperliquid API SDK for all major JS runtimes, written in TypeScript.
63 lines • 2.87 kB
JavaScript
import * as v from "valibot";
// ============================================================
// API Schemas
// ============================================================
import { Address, UnsignedInteger } from "../../_schemas.js";
import { UserTwapSliceFillsResponse } from "./userTwapSliceFills.js";
/**
* Request user TWAP slice fills by time.
*/
export const UserTwapSliceFillsByTimeRequest = /* @__PURE__ */ (() => {
return v.pipe(v.object({
/** Type of request. */
type: v.pipe(v.literal("userTwapSliceFillsByTime"), v.description("Type of request.")),
/** User address. */
user: v.pipe(Address, v.description("User address.")),
/** Start time (in ms since epoch). */
startTime: v.pipe(UnsignedInteger, v.description("Start time (in ms since epoch).")),
/** End time (in ms since epoch). */
endTime: v.pipe(v.nullish(UnsignedInteger), v.description("End time (in ms since epoch).")),
/** If true, partial fills are aggregated when a crossing order fills multiple resting orders. */
aggregateByTime: v.pipe(v.optional(v.boolean()), v.description("If true, partial fills are aggregated when a crossing order fills multiple resting orders.")),
}), v.description("Request user TWAP slice fills by time."));
})();
/**
* Array of user's twap slice fill by time.
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-twap-slice-fills
*/
export const UserTwapSliceFillsByTimeResponse = /* @__PURE__ */ (() => {
return v.pipe(UserTwapSliceFillsResponse, v.description("Array of user's twap slice fill by time."));
})();
/**
* Request user TWAP slice fills by time.
*
* @param config - General configuration for Info API requests.
* @param params - Parameters specific to the API request.
* @param signal - [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) to cancel the request.
*
* @returns Array of user's twap slice fill by time.
*
* @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 { userTwapSliceFillsByTime } from "@nktkas/hyperliquid/api/info";
*
* const transport = new HttpTransport(); // or `WebSocketTransport`
*
* const data = await userTwapSliceFillsByTime(
* { transport },
* { user: "0x...", startTime: Date.now() - 1000 * 60 * 60 * 24 },
* );
* ```
*/
export function userTwapSliceFillsByTime(config, params, signal) {
const request = v.parse(UserTwapSliceFillsByTimeRequest, {
type: "userTwapSliceFillsByTime",
...params,
});
return config.transport.request("info", request, signal);
}
//# sourceMappingURL=userTwapSliceFillsByTime.js.map