@deeeed/hyperliquid-node20
Version:
Unofficial Hyperliquid API SDK for all major JS runtimes, written in TypeScript. Fork with Node.js 20.18.0+ compatibility.
1,352 lines (1,351 loc) • 53.1 kB
JavaScript
/**
* 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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Block details.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @see null
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Array of candlestick data points.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Account summary for perpetual trading.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Array of user's delegations to validators.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Array of user's staking updates.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Array of user's staking rewards.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Summary of a user's staking delegations.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 exchange status information.
* @param signal - An optional [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Exchange system status information.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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.exchangeStatus();
* ```
*/
exchangeStatus(signal) {
const request = {
type: "exchangeStatus",
};
return this.transport.request("info", request, signal);
}
/**
* Request user's extra agents.
* @param args - The parameters for the request.
* @param signal - An optional [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns User's extra agents.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @see null
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Array of open orders with additional frontend information.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Array of historical funding rate data for an asset.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Array of user's historical orders.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Boolean indicating user's VIP status.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @see null
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns L2 order book snapshot.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 leading vaults for a user.
* @param args - The parameters for the request.
* @param signal - An optional [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns
*
* @throws {TransportError} When the transport layer throws an error.
*
* @see null
* @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.leadingVaults({ user: "0x..." });
* ```
*/
leadingVaults(args, signal) {
const request = {
type: "leadingVaults",
...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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Legal verification status for a user.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @see null
* @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 liquidatable (unknown).
* @param signal - An optional [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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.liquidatable();
* ```
*/
liquidatable(signal) {
const request = {
type: "liquidatable",
};
return this.transport.request("info", request, signal);
}
/**
* Request margin table data.
* @param args - The parameters for the request.
* @param signal - An optional [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Margin requirements table with multiple tiers.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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.marginTable({ id: 1 });
* ```
*/
marginTable(args, signal) {
const request = {
type: "marginTable",
...args,
};
return this.transport.request("info", request, signal);
}
/**
* Request builder fee approval.
* @param args - The parameters for the request.
* @param signal - An optional [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Maximum builder fee approval.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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);
}
/**
* Request maximum market order notionals.
* @param signal - An optional [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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.maxMarketOrderNtls();
* ```
*/
maxMarketOrderNtls(signal) {
const request = {
type: "maxMarketOrderNtls",
};
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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Metadata and context for perpetual assets.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Array of open order.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Result of an order status lookup.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Status of the perpetual deploy auction.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Array of perpetual dexes (null is main dex).
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 signal - An optional [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Array of perpetuals at open interest caps.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 user portfolio.
* @param args - The parameters for the request.
* @param signal - An optional [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Portfolio metrics grouped by time periods.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Array of predicted funding rates.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Pre-transfer user existence check result.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @see null
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Referral information for a user.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Account summary for spot trading.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Deploy state for spot tokens.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Metadata for spot assets.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Metadata and context for spot assets.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Array of user sub-account or null if the user does not have any sub-accounts.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Details of a token.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Array of user's TWAP history.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @see null
* @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);
}
/**
* Request transaction details by transaction hash.
* @param args - The parameters for the request.
* @param signal - An optional [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Transaction details.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @see null
* @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;
}
/**
* Request user details by user's address.
* @param args - The parameters for the request.
* @param signal - An optional [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns User details.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @see null
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns User fees.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-a-users-fees
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Array of user's trade fill.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Array of user's trade fill.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Array of user's funding ledger update.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Array of user's non-funding ledger update.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns User's rate limits.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns User's role.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Multi-sig signers for a user or null if the user does not have any multi-sig signers.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @see null
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Array of user's twap slice fill.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Array of user's twap slice fill.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @see null
* @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 [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns Array of user's vault deposits.
*
* @throws {TransportError} When the transport layer throws an error.
*
* @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.userVaultEquities({ user: "0x..." });
* ```
*/
userVaultEquities(args, signal) {
const request = {
type: "userVaultEquities",
...args,
};
return this.transport.request("info", request, signal);
}
/**
* Request validator L1 votes.
* @param signal - An optional [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
* @returns
*
* @throws {TransportError} When the transport layer throws an error.
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-a-users-staking-summary
* @example
* ```ts