UNPKG

@nktkas/hyperliquid

Version:

Unofficial Hyperliquid API SDK for all major JS runtimes, written in TypeScript and provided with tests

1,202 lines (1,201 loc) 41.2 kB
/** * Info client for interacting with the Hyperliquid API. * @typeParam T The type of transport used to connect to the Hyperliquid API. */ export class InfoClient { transport; /** * Initialises a new instance. * @param args - The arguments for initialisation. * * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * ``` */ constructor(args) { this.transport = args.transport; } allMids(args_or_signal, maybeSignal) { const args = args_or_signal instanceof AbortSignal ? {} : args_or_signal; const signal = args_or_signal instanceof AbortSignal ? args_or_signal : maybeSignal; const request = { type: "allMids", ...args, }; return this.transport.request("info", request, signal); } /** * Block details by block height. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Block details response. * * @see null - no documentation * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.blockDetails({ height: 123 }); * ``` */ async blockDetails(args, signal) { const request = { type: "blockDetails", ...args, }; const { blockDetails } = await this.transport.request("explorer", request, signal); return blockDetails; } /** * Request candlestick snapshots. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Array of candlestick data points. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#candle-snapshot * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.candleSnapshot({ * coin: "ETH", * interval: "1h", * startTime: Date.now() - 1000 * 60 * 60 * 24 * }); * ``` */ candleSnapshot(args, signal) { const request = { type: "candleSnapshot", req: args, }; return this.transport.request("info", request, signal); } /** * Request clearinghouse state. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Account summary for perpetual trading. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-users-perpetuals-account-summary * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.clearinghouseState({ user: "0x..." }); * ``` */ clearinghouseState(args, signal) { const request = { type: "clearinghouseState", ...args, }; return this.transport.request("info", request, signal); } /** * Request user staking delegations. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Array of user's delegations to validators. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-a-users-staking-delegations * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.delegations({ user: "0x..." }); * ``` */ delegations(args, signal) { const request = { type: "delegations", ...args, }; return this.transport.request("info", request, signal); } /** * Request user staking history. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Array of user's staking updates. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-a-users-staking-history * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.delegatorHistory({ user: "0x..." }); * ``` */ delegatorHistory(args, signal) { const request = { type: "delegatorHistory", ...args, }; return this.transport.request("info", request, signal); } /** * Request user staking rewards. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Array of user's staking rewards. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-a-users-staking-rewards * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.delegatorRewards({ user: "0x..." }); * ``` */ delegatorRewards(args, signal) { const request = { type: "delegatorRewards", ...args, }; return this.transport.request("info", request, signal); } /** * Request user staking summary. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Summary of a user's staking delegations. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-a-users-staking-summary * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.delegatorSummary({ user: "0x..." }); * ``` */ delegatorSummary(args, signal) { const request = { type: "delegatorSummary", ...args, }; return this.transport.request("info", request, signal); } /** * Request user's extra agents. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns User's extra agents. * * @see null - no documentation * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.extraAgents({ user: "0x..." }); * ``` */ extraAgents(args, signal) { const request = { type: "extraAgents", ...args, }; return this.transport.request("info", request, signal); } /** * Request frontend open orders. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Array of open orders with additional frontend information. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-open-orders-with-additional-frontend-info * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.frontendOpenOrders({ user: "0x..." }); * ``` */ frontendOpenOrders(args, signal) { const request = { type: "frontendOpenOrders", ...args, }; return this.transport.request("info", request, signal); } /** * Request funding history. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Array of historical funding rate data for an asset. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-historical-funding-rates * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.fundingHistory({ * coin: "ETH", * startTime: Date.now() - 1000 * 60 * 60 * 24 * }); * ``` */ fundingHistory(args, signal) { const request = { type: "fundingHistory", ...args, }; return this.transport.request("info", request, signal); } /** * Request user's historical orders. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Array of user's historical orders. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-historical-orders * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.historicalOrders({ user: "0x..." }); * ``` */ historicalOrders(args, signal) { const request = { type: "historicalOrders", ...args, }; return this.transport.request("info", request, signal); } /** * Request to check if a user is a VIP. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Boolean indicating user's VIP status. * * @see null - no documentation * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.isVip({ user: "0x..." }); * ``` */ isVip(args, signal) { const request = { type: "isVip", ...args, }; return this.transport.request("info", request, signal); } /** * Request L2 order book. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns L2 order book snapshot. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#l2-book-snapshot * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.l2Book({ coin: "ETH", nSigFigs: 2 }); * ``` */ l2Book(args, signal) { const request = { type: "l2Book", ...args, }; return this.transport.request("info", request, signal); } /** * Request legal verification status of a user. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Legal verification status for a user. * * @see null - no documentation * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.legalCheck({ user: "0x..." }); * ``` */ legalCheck(args, signal) { const request = { type: "legalCheck", ...args, }; return this.transport.request("info", request, signal); } /** * Request builder fee approval. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Maximum builder fee approval. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#check-builder-fee-approval * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.maxBuilderFee({ user: "0x...", builder: "0x..." }); * ``` */ maxBuilderFee(args, signal) { const request = { type: "maxBuilderFee", ...args, }; return this.transport.request("info", request, signal); } meta(args_or_signal, maybeSignal) { const args = args_or_signal instanceof AbortSignal ? {} : args_or_signal; const signal = args_or_signal instanceof AbortSignal ? args_or_signal : maybeSignal; const request = { type: "meta", ...args, }; return this.transport.request("info", request, signal); } /** * Request metadata and asset contexts. * @param signal - An optional abort signal. * @returns Metadata and context information for each perpetual asset. * * @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 * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.metaAndAssetCtxs(); * ``` */ metaAndAssetCtxs(signal) { const request = { type: "metaAndAssetCtxs", }; return this.transport.request("info", request, signal); } /** * Request open orders. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Array of open order. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-open-orders * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.openOrders({ user: "0x..." }); * ``` */ openOrders(args, signal) { const request = { type: "openOrders", ...args, }; return this.transport.request("info", request, signal); } /** * Request order status. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Result of an order status lookup. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-order-status-by-oid-or-cloid * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.orderStatus({ user: "0x...", oid: 12345 }); * ``` */ orderStatus(args, signal) { const request = { type: "orderStatus", ...args, }; return this.transport.request("info", request, signal); } /** * Request for the status of the perpetual deploy auction. * @param signal - An optional abort signal. * @returns Status of the perpetual deploy auction. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-information-about-the-perp-deploy-auction * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.perpDeployAuctionStatus(); * ``` */ perpDeployAuctionStatus(signal) { const request = { type: "perpDeployAuctionStatus", }; return this.transport.request("info", request, signal); } /** * Request all perpetual dexs. * @param signal - An optional abort signal. * @returns Array of perpetual dexes. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-all-perpetual-dexs * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.perpDexs(); * ``` */ perpDexs(signal) { const request = { type: "perpDexs", }; return this.transport.request("info", request, signal); } /** * Request perpetuals at open interest cap. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Array of perpetuals at open interest caps. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#query-perps-at-open-interest-caps * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.perpsAtOpenInterestCap(); * ``` */ perpsAtOpenInterestCap(signal) { const request = { type: "perpsAtOpenInterestCap", }; return this.transport.request("info", request, signal); } /** * Request portfolio. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Portfolio of a user. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-a-users-portfolio * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.portfolio({ user: "0x..." }); * ``` */ portfolio(args, signal) { const request = { type: "portfolio", ...args, }; return this.transport.request("info", request, signal); } /** * Request predicted funding rates. * @param signal - An optional abort signal. * @returns 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 * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.predictedFundings(); * ``` */ predictedFundings(signal) { const request = { type: "predictedFundings", }; return this.transport.request("info", request, signal); } /** * Request user's existence check before transfer. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Pre-transfer user existence check result. * * @see null - no documentation * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.preTransferCheck({ user: "0x...", source: "0x..." }); * ``` */ preTransferCheck(args, signal) { const request = { type: "preTransferCheck", ...args, }; return this.transport.request("info", request, signal); } /** * Request user referral. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Referral information for a user. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-a-users-referral-information * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.referral({ user: "0x..." }); * ``` */ referral(args, signal) { const request = { type: "referral", ...args, }; return this.transport.request("info", request, signal); } /** * Request spot clearinghouse state. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Balances for spot tokens. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-a-users-token-balances * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.spotClearinghouseState({ user: "0x..." }); * ``` */ spotClearinghouseState(args, signal) { const request = { type: "spotClearinghouseState", ...args, }; return this.transport.request("info", request, signal); } /** * Request spot deploy state. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns The deploy state of a user. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-information-about-the-spot-deploy-auction * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.spotDeployState({ user: "0x..." }); * ``` */ spotDeployState(args, signal) { const request = { type: "spotDeployState", ...args, }; return this.transport.request("info", request, signal); } /** * Request spot trading metadata. * @param signal - An optional abort signal. * @returns Metadata for spot assets. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-spot-metadata * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.spotMeta(); * ``` */ spotMeta(signal) { const request = { type: "spotMeta", }; return this.transport.request("info", request, signal); } /** * Request spot metadata and asset contexts. * @param signal - An optional abort signal. * @returns Metadata and context information for each spot asset. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-spot-asset-contexts * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.spotMetaAndAssetCtxs(); * ``` */ spotMetaAndAssetCtxs(signal) { const request = { type: "spotMetaAndAssetCtxs", }; return this.transport.request("info", request, signal); } /** * Request user sub-accounts. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Array of user sub-account or null if the user does not have any sub-accounts. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-subaccounts * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.subAccounts({ user: "0x..." }); * ``` */ subAccounts(args, signal) { const request = { type: "subAccounts", ...args, }; return this.transport.request("info", request, signal); } /** * Request token details. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns The details of a token. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-information-about-a-token * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.tokenDetails({ tokenId: "0x..." }); * ``` */ tokenDetails(args, signal) { const request = { type: "tokenDetails", ...args, }; return this.transport.request("info", request, signal); } /** * Request twap history of a user. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns The twap history of a user. * * @see null - no documentation * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.twapHistory({ user: "0x..." }); * ``` */ twapHistory(args, signal) { const request = { type: "twapHistory", ...args, }; return this.transport.request("info", request, signal); } /** * Transaction details by transaction hash. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Transaction details response. * * @see null - no documentation * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.txDetails({ hash: "0x..." }); * ``` */ async txDetails(args, signal) { const request = { type: "txDetails", ...args, }; const { tx } = await this.transport.request("explorer", request, signal); return tx; } /** * User details by user's address. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns User details response. * * @see null - no documentation * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.userDetails({ user: "0x..." }); * ``` */ async userDetails(args, signal) { const request = { type: "userDetails", ...args, }; const { txs } = await this.transport.request("explorer", request, signal); return txs; } /** * Request user fees. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns User fees. * * @see null - no documentation * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.userFees({ user: "0x..." }); * ``` */ userFees(args, signal) { const request = { type: "userFees", ...args, }; return this.transport.request("info", request, signal); } /** * Request user fills. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Array of user's trade fill. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-fills * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.userFills({ user: "0x..." }); * ``` */ userFills(args, signal) { const request = { type: "userFills", ...args, }; return this.transport.request("info", request, signal); } /** * Request user fills by time. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Array of user's trade fill. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-fills-by-time * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.userFillsByTime({ * user: "0x...", * startTime: Date.now() - 1000 * 60 * 60 * 24 * }); * ``` */ userFillsByTime(args, signal) { const request = { type: "userFillsByTime", ...args, }; return this.transport.request("info", request, signal); } /** * Request user funding. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Array of user's funding ledger update. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-a-users-funding-history-or-non-funding-ledger-updates * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.userFunding({ * user: "0x...", * startTime: Date.now() - 1000 * 60 * 60 * 24 * }); * ``` */ userFunding(args, signal) { const request = { type: "userFunding", ...args, }; return this.transport.request("info", request, signal); } /** * Request user non-funding ledger updates. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Array of user's non-funding ledger update. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-a-users-funding-history-or-non-funding-ledger-updates * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.userNonFundingLedgerUpdates({ * user: "0x...", * startTime: Date.now() - 1000 * 60 * 60 * 24 * }); * ``` */ userNonFundingLedgerUpdates(args, signal) { const request = { type: "userNonFundingLedgerUpdates", ...args, }; return this.transport.request("info", request, signal); } /** * Request user rate limits. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns User's rate limits. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-user-rate-limits * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.userRateLimit({ user: "0x..." }); * ``` */ userRateLimit(args, signal) { const request = { type: "userRateLimit", ...args, }; return this.transport.request("info", request, signal); } /** * Request user role. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns User's role. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-a-users-role * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.userRole({ user: "0x..." }); * ``` */ userRole(args, signal) { const request = { type: "userRole", ...args, }; return this.transport.request("info", request, signal); } /** * Request multi-sig signers for a user. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Multi-sig signers for a user or null if the user does not have any multi-sig signers. * * @see null - no documentation * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.userToMultiSigSigners({ user: "0x..." }); * ``` */ userToMultiSigSigners(args, signal) { const request = { type: "userToMultiSigSigners", ...args, }; return this.transport.request("info", request, signal); } /** * Request user twap slice fills. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Array of user's twap slice fill. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-twap-slice-fills * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.userTwapSliceFills({ user: "0x..." }); * ``` */ userTwapSliceFills(args, signal) { const request = { type: "userTwapSliceFills", ...args, }; return this.transport.request("info", request, signal); } /** * Request user twap slice fills by time. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Array of user's twap slice fill. * * @see null - no documentation * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.userTwapSliceFillsByTime({ * user: "0x...", * startTime: Date.now() - 1000 * 60 * 60 * 24 * }); * ``` */ userTwapSliceFillsByTime(args, signal) { const request = { type: "userTwapSliceFillsByTime", ...args, }; return this.transport.request("info", request, signal); } /** * Request user vault deposits. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Array of user's vault deposits. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-vault-deposits * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.userVaultDeposits({ user: "0x..." }); * ``` */ userVaultEquities(args, signal) { const request = { type: "userVaultEquities", ...args, }; return this.transport.request("info", request, signal); } /** * Request validator summaries. * @param args - The parameters for the request. * @returns Array of validator summaries. * * @see null - no documentation * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.validatorSummaries(); * ``` */ validatorSummaries(signal) { const request = { type: "validatorSummaries", }; return this.transport.request("info", request, signal); } /** * Request details of a vault. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Details of a vault or null if the vault does not exist. * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-details-for-a-vault * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.vaultDetails({ vaultAddress: "0x..." }); * ``` */ vaultDetails(args, signal) { const request = { type: "vaultDetails", ...args, }; return this.transport.request("info", request, signal); } /** * Request a list of vaults less than 2 hours old. * @param args - The parameters for the request. * @param signal - An optional abort signal. * @returns Array of vault summaries. * * @see null - no documentation * @example * ```ts * import * as hl from "@nktkas/hyperliquid"; * * const transport = new hl.HttpTransport(); // or WebSocketTransport * const infoClient = new hl.InfoClient({ transport }); * * const data = await infoClient.vaultSummaries(); * ``` */ vaultSummaries(signal) { const request = { type: "vaultSummaries", }; return this.transport.request("info", request, signal); } async [Symbol.asyncDispose]() { await this.transport[Symbol.asyncDispose]?.(); } }