@nktkas/hyperliquid
Version:
Hyperliquid API SDK for all major JS runtimes, written in TypeScript.
39 lines (38 loc) • 1.22 kB
TypeScript
/**
* Identity-formation utilities for WebSocket request matching.
* @module
*/
/// <amd-module name="file:///home/runner/work/hyperliquid/hyperliquid/src/transport/websocket/_id.ts" />
/**
* Builds a stable string identifier from an arbitrary value: payloads with
* the same logical content produce the same id.
*
* Sorts object keys recursively and lowercases hex addresses.
*
* @example
* ```ts ignore
* requestToId({ user: "0xAbC123", type: "userFills" });
* // => '{"type":"userFills","user":"0xabc123"}'
* ```
*/
export declare function requestToId(value: unknown): string;
/**
* Counts the leaf values in `value`; a higher count means a more specific payload.
*
* @example
* ```ts ignore
* specificity({ type: "candle", coin: "ETH", interval: "1m" });
* // => 3
* ```
*/
export declare function specificity(value: unknown): number;
/**
* Returns true if every field of `subset` is present in `superset` with an equal value.
*
* @example
* ```ts ignore
* isSubset({ coin: "BTC" }, { coin: "BTC", nSigFigs: null }); // => true
* isSubset({ coin: "BTC", nSigFigs: 5 }, { coin: "BTC" }); // => false
* ```
*/
export declare function isSubset(subset: unknown, superset: unknown): boolean;