@liberfi.io/ui-perpetuals 0.2.13 → 0.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +250 -30
- package/dist/index.d.ts +250 -30
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -7
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { PropsWithChildren, ReactElement } from 'react';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
5
5
|
import { UseQueryOptions, UseMutationOptions } from '@tanstack/react-query';
|
|
@@ -12,7 +12,7 @@ declare global {
|
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
declare const _default: "0.2.
|
|
15
|
+
declare const _default: "0.2.15";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Trading pair symbol format
|
|
@@ -105,6 +105,25 @@ interface Kline {
|
|
|
105
105
|
/** Kline end timestamp (milliseconds) */
|
|
106
106
|
closeTimestamp: number;
|
|
107
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Optional query window for {@link IPerpetualsClient.getKlines}.
|
|
110
|
+
*
|
|
111
|
+
* - `from` / `to` are millisecond epochs. When both are provided, providers
|
|
112
|
+
* return candles whose open timestamp falls inside `[from, to]`.
|
|
113
|
+
* - `limit` (when provided alongside a range) caps the response size on the
|
|
114
|
+
* client side; without `limit`, the provider returns whatever the backend
|
|
115
|
+
* allows for the given window.
|
|
116
|
+
*
|
|
117
|
+
* Required by chart UIs (e.g. TradingView) for backward history pagination.
|
|
118
|
+
*/
|
|
119
|
+
interface KlineQueryOptions {
|
|
120
|
+
/** Start of the window (ms epoch). */
|
|
121
|
+
from?: number;
|
|
122
|
+
/** End of the window (ms epoch, exclusive). */
|
|
123
|
+
to?: number;
|
|
124
|
+
/** Optional cap on the number of candles returned. */
|
|
125
|
+
limit?: number;
|
|
126
|
+
}
|
|
108
127
|
/**
|
|
109
128
|
* Order book price level
|
|
110
129
|
*/
|
|
@@ -129,6 +148,25 @@ interface OrderBook {
|
|
|
129
148
|
/** Timestamp (milliseconds) */
|
|
130
149
|
timestamp: number;
|
|
131
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* Venue-agnostic order-book aggregation hint passed to
|
|
153
|
+
* {@link IPerpetualsClient.getOrderBook} and
|
|
154
|
+
* {@link IPerpetualsClient.subscribeMarketData}.
|
|
155
|
+
*
|
|
156
|
+
* Currently mirrors Hyperliquid's `l2Book` parameters because that is the
|
|
157
|
+
* only implementation with server-side aggregation today. Other venues may
|
|
158
|
+
* add new optional fields here.
|
|
159
|
+
*
|
|
160
|
+
* - `nSigFigs`: number of significant figures (2..5) to round prices to.
|
|
161
|
+
* Omitted means full native precision.
|
|
162
|
+
* - `mantissa`: only valid when `nSigFigs === 5`. Allowed values: 1, 2, 5.
|
|
163
|
+
*
|
|
164
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint
|
|
165
|
+
*/
|
|
166
|
+
interface OrderBookAggregationOptions {
|
|
167
|
+
nSigFigs?: 2 | 3 | 4 | 5;
|
|
168
|
+
mantissa?: 1 | 2 | 5;
|
|
169
|
+
}
|
|
132
170
|
/**
|
|
133
171
|
* Trade record
|
|
134
172
|
*/
|
|
@@ -427,22 +465,36 @@ interface IPerpetualsClient {
|
|
|
427
465
|
*/
|
|
428
466
|
getMarkets(symbols?: string[]): Promise<MarketData[]>;
|
|
429
467
|
/**
|
|
430
|
-
* Get kline data
|
|
468
|
+
* Get kline data.
|
|
469
|
+
*
|
|
470
|
+
* Two call shapes are supported:
|
|
471
|
+
*
|
|
472
|
+
* - `getKlines(symbol, interval, limit)` — legacy form: returns the last
|
|
473
|
+
* `limit` candles ending at "now". Defaults to 100.
|
|
474
|
+
* - `getKlines(symbol, interval, { from, to, limit? })` — range form:
|
|
475
|
+
* returns candles whose open timestamp falls inside `[from, to]`
|
|
476
|
+
* (millisecond epochs). Required for TradingView-style backward
|
|
477
|
+
* history pagination.
|
|
478
|
+
*
|
|
431
479
|
* @param symbol Trading pair symbol, e.g. "BTC-USDC"
|
|
432
480
|
* @param interval Time interval, e.g. "1h"
|
|
433
|
-
* @param
|
|
434
|
-
*
|
|
481
|
+
* @param limitOrOptions Either a `limit` number (legacy) or a
|
|
482
|
+
* `{ from, to, limit? }` options object (range form).
|
|
483
|
+
* @returns Array of kline data, ascending by timestamp.
|
|
435
484
|
* @throws {Error} Network error or API error
|
|
436
485
|
*/
|
|
437
|
-
getKlines(symbol: string, interval: KlineInterval,
|
|
486
|
+
getKlines(symbol: string, interval: KlineInterval, limitOrOptions?: number | KlineQueryOptions): Promise<Kline[]>;
|
|
438
487
|
/**
|
|
439
488
|
* Get order book
|
|
440
489
|
* @param symbol Trading pair symbol, e.g. "BTC-USDC"
|
|
441
490
|
* @param maxLevel Maximum depth levels, default 10
|
|
491
|
+
* @param options Optional venue-specific aggregation params (e.g.
|
|
492
|
+
* Hyperliquid `nSigFigs` / `mantissa`). Implementations that don't
|
|
493
|
+
* support server-side aggregation may safely ignore them.
|
|
442
494
|
* @returns Order book data
|
|
443
495
|
* @throws {Error} Network error or API error
|
|
444
496
|
*/
|
|
445
|
-
getOrderBook(symbol: string, maxLevel?: number): Promise<OrderBook>;
|
|
497
|
+
getOrderBook(symbol: string, maxLevel?: number, options?: OrderBookAggregationOptions): Promise<OrderBook>;
|
|
446
498
|
/**
|
|
447
499
|
* Get recent trades
|
|
448
500
|
* @param symbol Trading pair symbol, e.g. "BTC-USDC"
|
|
@@ -500,9 +552,14 @@ interface IPerpetualsClient {
|
|
|
500
552
|
* @param type Subscription type: 'ticker' (price), 'trades' (trades), 'orderBook' (order book)
|
|
501
553
|
* @param symbol Coin symbol
|
|
502
554
|
* @param callback Data callback function
|
|
555
|
+
* @param options Optional subscription options. For `orderBook`, provide
|
|
556
|
+
* `aggregation` so the server pre-aggregates levels into the desired
|
|
557
|
+
* price buckets. Implementations may ignore unknown options.
|
|
503
558
|
* @returns Subscription ID (for unsubscribing)
|
|
504
559
|
*/
|
|
505
|
-
subscribeMarketData(type: "ticker" | "trades" | "orderBook", symbol: string, callback: (data: any) => void
|
|
560
|
+
subscribeMarketData(type: "ticker" | "trades" | "orderBook", symbol: string, callback: (data: any) => void, options?: {
|
|
561
|
+
aggregation?: OrderBookAggregationOptions;
|
|
562
|
+
}): string;
|
|
506
563
|
/**
|
|
507
564
|
* Subscribe to kline data
|
|
508
565
|
* @param symbol Coin symbol
|
|
@@ -526,6 +583,26 @@ interface IPerpetualsClient {
|
|
|
526
583
|
unsubscribe(subscriptionId: string): void;
|
|
527
584
|
}
|
|
528
585
|
|
|
586
|
+
/**
|
|
587
|
+
* Hyperliquid `l2Book` aggregation parameters.
|
|
588
|
+
*
|
|
589
|
+
* Sending these on the `subscribe` payload causes Hyperliquid to pre-aggregate
|
|
590
|
+
* raw price levels into discrete buckets server-side, so a single 20-level
|
|
591
|
+
* snapshot covers a much wider price range than at native tick resolution.
|
|
592
|
+
*
|
|
593
|
+
* - `nSigFigs`: number of significant figures (2..5) to round prices to.
|
|
594
|
+
* `undefined` (or `null`) means full native precision.
|
|
595
|
+
* - `mantissa`: only valid when `nSigFigs === 5`. Allowed values: 1, 2, 5.
|
|
596
|
+
* At BTC ~$80k with `nSigFigs=5`, mantissa controls the smallest digit:
|
|
597
|
+
* 1 → step $1, 2 → step $2, 5 → step $5.
|
|
598
|
+
*
|
|
599
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint
|
|
600
|
+
*/
|
|
601
|
+
interface OrderBookAggregation {
|
|
602
|
+
nSigFigs?: 2 | 3 | 4 | 5;
|
|
603
|
+
mantissa?: 1 | 2 | 5;
|
|
604
|
+
}
|
|
605
|
+
|
|
529
606
|
/**
|
|
530
607
|
* Hyperliquid 环境类型
|
|
531
608
|
*/
|
|
@@ -621,22 +698,34 @@ declare class HyperliquidPerpetualsClient implements IPerpetualsClient {
|
|
|
621
698
|
*/
|
|
622
699
|
getMarkets(symbols?: string[]): Promise<MarketData[]>;
|
|
623
700
|
/**
|
|
624
|
-
*
|
|
625
|
-
*
|
|
626
|
-
*
|
|
627
|
-
* @
|
|
628
|
-
*
|
|
629
|
-
*
|
|
701
|
+
* Fetch kline / candlestick data.
|
|
702
|
+
*
|
|
703
|
+
* Supports both shapes documented on
|
|
704
|
+
* {@link IPerpetualsClient.getKlines}:
|
|
705
|
+
*
|
|
706
|
+
* - `getKlines(symbol, interval, limit)` — last `limit` candles ending now.
|
|
707
|
+
* - `getKlines(symbol, interval, { from, to, limit? })` — explicit window
|
|
708
|
+
* for backward history pagination (TradingView pan).
|
|
709
|
+
*
|
|
710
|
+
* Maps to Hyperliquid's `candleSnapshot` which natively accepts
|
|
711
|
+
* `startTime` / `endTime` (ms epochs).
|
|
712
|
+
*
|
|
713
|
+
* @throws {HyperliquidApiError}
|
|
630
714
|
*/
|
|
631
|
-
getKlines(symbol: string, interval: KlineInterval,
|
|
715
|
+
getKlines(symbol: string, interval: KlineInterval, limitOrOptions?: number | KlineQueryOptions): Promise<Kline[]>;
|
|
632
716
|
/**
|
|
633
|
-
*
|
|
634
|
-
*
|
|
635
|
-
* @param
|
|
636
|
-
* @
|
|
717
|
+
* Get the order book.
|
|
718
|
+
*
|
|
719
|
+
* @param symbol Trading pair symbol (e.g. `BTC-USDC`)
|
|
720
|
+
* @param maxLevel Max number of levels to keep per side (post-slice)
|
|
721
|
+
* @param options Optional Hyperliquid `l2Book` aggregation params. When
|
|
722
|
+
* provided, Hyperliquid pre-aggregates raw levels into discrete buckets
|
|
723
|
+
* server-side, so a single 20-level snapshot covers a much wider price
|
|
724
|
+
* range than at native tick resolution. See {@link OrderBookAggregation}.
|
|
725
|
+
* @returns Order book data
|
|
637
726
|
* @throws {HyperliquidApiError} API 请求失败
|
|
638
727
|
*/
|
|
639
|
-
getOrderBook(symbol: string, maxLevel?: number): Promise<OrderBook>;
|
|
728
|
+
getOrderBook(symbol: string, maxLevel?: number, options?: OrderBookAggregation): Promise<OrderBook>;
|
|
640
729
|
/**
|
|
641
730
|
* 获取最近成交记录
|
|
642
731
|
* @param symbol 交易对符号
|
|
@@ -728,9 +817,15 @@ declare class HyperliquidPerpetualsClient implements IPerpetualsClient {
|
|
|
728
817
|
* @param type Subscription type: 'ticker' | 'trades' | 'orderBook'
|
|
729
818
|
* @param symbol Trading pair symbol (e.g., "BTC-USDC")
|
|
730
819
|
* @param callback Data callback function
|
|
820
|
+
* @param options Optional subscription options. For `orderBook`, provide
|
|
821
|
+
* `aggregation` (Hyperliquid `nSigFigs` / `mantissa`) so the server
|
|
822
|
+
* pre-aggregates levels into discrete price buckets — required to render
|
|
823
|
+
* wide-range books at coarse aggregation steps (e.g. $1000 buckets).
|
|
731
824
|
* @returns Subscription ID (for unsubscribing)
|
|
732
825
|
*/
|
|
733
|
-
subscribeMarketData(type: "ticker" | "trades" | "orderBook", symbol: string, callback: (data: any) => void
|
|
826
|
+
subscribeMarketData(type: "ticker" | "trades" | "orderBook", symbol: string, callback: (data: any) => void, options?: {
|
|
827
|
+
aggregation?: OrderBookAggregation;
|
|
828
|
+
}): string;
|
|
734
829
|
/**
|
|
735
830
|
* Subscribe to kline (candlestick) data
|
|
736
831
|
*
|
|
@@ -1093,8 +1188,11 @@ declare class LiberFiPerpetualsClient implements IPerpetualsClient {
|
|
|
1093
1188
|
getSupportedCoins(): Promise<string[]>;
|
|
1094
1189
|
getMarket(symbol: string): Promise<MarketData | null>;
|
|
1095
1190
|
getMarkets(symbols?: string[]): Promise<MarketData[]>;
|
|
1096
|
-
getKlines(symbol: string, interval: KlineInterval,
|
|
1097
|
-
getOrderBook(symbol: string, maxLevel?: number
|
|
1191
|
+
getKlines(symbol: string, interval: KlineInterval, limitOrOptions?: number | KlineQueryOptions): Promise<Kline[]>;
|
|
1192
|
+
getOrderBook(symbol: string, maxLevel?: number, options?: {
|
|
1193
|
+
nSigFigs?: number;
|
|
1194
|
+
mantissa?: number;
|
|
1195
|
+
}): Promise<OrderBook>;
|
|
1098
1196
|
getRecentTrades(symbol: string, limit?: number): Promise<Trade[]>;
|
|
1099
1197
|
getPositions(params?: GetPositionsParams): Promise<GetPositionsResult>;
|
|
1100
1198
|
getOpenOrders(params?: GetOpenOrdersParams): Promise<GetOpenOrdersResult>;
|
|
@@ -1103,7 +1201,12 @@ declare class LiberFiPerpetualsClient implements IPerpetualsClient {
|
|
|
1103
1201
|
cancelOrder(params: CancelOrderParams): Promise<CancelOrderResult>;
|
|
1104
1202
|
connectWebSocket(): Promise<void>;
|
|
1105
1203
|
disconnectWebSocket(): void;
|
|
1106
|
-
subscribeMarketData(type: "ticker" | "trades" | "orderBook", symbol: string, callback: (data: unknown) => void
|
|
1204
|
+
subscribeMarketData(type: "ticker" | "trades" | "orderBook", symbol: string, callback: (data: unknown) => void, options?: {
|
|
1205
|
+
aggregation?: {
|
|
1206
|
+
nSigFigs?: 2 | 3 | 4 | 5;
|
|
1207
|
+
mantissa?: 1 | 2 | 5;
|
|
1208
|
+
};
|
|
1209
|
+
}): string;
|
|
1107
1210
|
subscribeCandles(symbol: string, interval: KlineInterval, callback: (candle: Kline) => void): string;
|
|
1108
1211
|
subscribeUserData(type: "orders" | "positions" | "fills", userAddress: string, callback: (data: unknown) => void): string;
|
|
1109
1212
|
unsubscribe(subscriptionId: string): void;
|
|
@@ -1491,9 +1594,15 @@ declare function useKlinesQuery(params: UseKlinesQueryParams, options?: Omit<Use
|
|
|
1491
1594
|
interface UseOrderBookQueryParams {
|
|
1492
1595
|
symbol: string;
|
|
1493
1596
|
maxLevel?: number;
|
|
1597
|
+
/**
|
|
1598
|
+
* Optional venue aggregation params (e.g. Hyperliquid `nSigFigs` /
|
|
1599
|
+
* `mantissa`). When set, the request key includes these so different
|
|
1600
|
+
* aggregations cache independently.
|
|
1601
|
+
*/
|
|
1602
|
+
aggregation?: OrderBookAggregationOptions;
|
|
1494
1603
|
}
|
|
1495
1604
|
declare function orderBookQueryKey(params: UseOrderBookQueryParams): string[];
|
|
1496
|
-
declare function fetchOrderBook(client: IPerpetualsClient, { symbol, maxLevel }: UseOrderBookQueryParams): Promise<OrderBook>;
|
|
1605
|
+
declare function fetchOrderBook(client: IPerpetualsClient, { symbol, maxLevel, aggregation }: UseOrderBookQueryParams): Promise<OrderBook>;
|
|
1497
1606
|
declare function useOrderBookQuery(params: UseOrderBookQueryParams, options?: Omit<UseQueryOptions<OrderBook, Error, OrderBook, string[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<OrderBook, Error>;
|
|
1498
1607
|
|
|
1499
1608
|
interface UseRecentTradesQueryParams {
|
|
@@ -1538,6 +1647,24 @@ interface UseMarketDataSubscriptionParams {
|
|
|
1538
1647
|
type: MarketDataType;
|
|
1539
1648
|
symbol: string;
|
|
1540
1649
|
enabled?: boolean;
|
|
1650
|
+
/**
|
|
1651
|
+
* Optional venue aggregation hint (only meaningful when
|
|
1652
|
+
* `type === "orderBook"`). Changing it tears down and re-creates the
|
|
1653
|
+
* subscription so the upstream stream is re-keyed with the new
|
|
1654
|
+
* `nSigFigs` / `mantissa`.
|
|
1655
|
+
*/
|
|
1656
|
+
aggregation?: OrderBookAggregationOptions;
|
|
1657
|
+
/**
|
|
1658
|
+
* If set, coalesce upstream pushes into a single React `setData` call no
|
|
1659
|
+
* more than once every `throttleMs` milliseconds. The latest payload
|
|
1660
|
+
* always wins; intermediate pushes are dropped. Use this for high-rate
|
|
1661
|
+
* streams (e.g. orderBook on active markets) where the human eye can't
|
|
1662
|
+
* tell the difference between 30 Hz and 10 Hz but React reconciliation
|
|
1663
|
+
* cost scales linearly.
|
|
1664
|
+
*
|
|
1665
|
+
* Leave undefined to forward every push immediately (default).
|
|
1666
|
+
*/
|
|
1667
|
+
throttleMs?: number;
|
|
1541
1668
|
}
|
|
1542
1669
|
interface UseMarketDataSubscriptionResult<T> {
|
|
1543
1670
|
data: T | null;
|
|
@@ -1914,13 +2041,35 @@ type UseSearchCoinsScriptResult = {
|
|
|
1914
2041
|
};
|
|
1915
2042
|
declare function useSearchCoinsScript({ onSelectCoin, }?: UseSearchCoinsScriptParams): UseSearchCoinsScriptResult;
|
|
1916
2043
|
|
|
2044
|
+
/**
|
|
2045
|
+
* Default tick-aggregation steps offered to the user via the spread dropdown.
|
|
2046
|
+
*
|
|
2047
|
+
* Mirrors Axiom / Hyperliquid's perpetuals UI for major USD-quoted pairs
|
|
2048
|
+
* (BTC, ETH, SOL): users can collapse the book into 1, 2, 5, 10, 100, or
|
|
2049
|
+
* 1000-USD buckets to see liquidity at coarser granularities.
|
|
2050
|
+
*/
|
|
2051
|
+
declare const DEFAULT_ORDER_BOOK_PRECISION_OPTIONS: readonly [1, 2, 5, 10, 100, 1000];
|
|
1917
2052
|
type OrderBookWidgetProps = {
|
|
1918
2053
|
symbol: string;
|
|
2054
|
+
/**
|
|
2055
|
+
* How many price levels to fetch + render per side. Defaults to `40` so
|
|
2056
|
+
* that asks and bids always have enough rows to overflow their containers
|
|
2057
|
+
* and show their independent scroll bars.
|
|
2058
|
+
*/
|
|
1919
2059
|
maxLevel?: number;
|
|
2060
|
+
/**
|
|
2061
|
+
* Steps shown in the "Spread" dropdown. Defaults to
|
|
2062
|
+
* `[1, 2, 5, 10, 100, 1000]` (Axiom's BTC perpetuals options).
|
|
2063
|
+
*/
|
|
2064
|
+
precisionOptions?: readonly number[];
|
|
2065
|
+
/**
|
|
2066
|
+
* Initial selected step. Defaults to the first entry in `precisionOptions`.
|
|
2067
|
+
*/
|
|
2068
|
+
defaultPrecision?: number;
|
|
1920
2069
|
onPriceClick?: (price: number) => void;
|
|
1921
2070
|
className?: string;
|
|
1922
2071
|
};
|
|
1923
|
-
declare function OrderBookWidget({ symbol, maxLevel, onPriceClick, className, }: OrderBookWidgetProps): react_jsx_runtime.JSX.Element;
|
|
2072
|
+
declare function OrderBookWidget({ symbol, maxLevel, precisionOptions, defaultPrecision, onPriceClick, className, }: OrderBookWidgetProps): react_jsx_runtime.JSX.Element;
|
|
1924
2073
|
|
|
1925
2074
|
type PriceLevel = OrderBookLevel & {
|
|
1926
2075
|
total: number;
|
|
@@ -1929,12 +2078,48 @@ type PriceLevel = OrderBookLevel & {
|
|
|
1929
2078
|
type UseOrderBookScriptParams = {
|
|
1930
2079
|
symbol: string;
|
|
1931
2080
|
maxLevel?: number;
|
|
2081
|
+
/**
|
|
2082
|
+
* Initial price-bucket size. Defaults to `1` which matches major perpetual
|
|
2083
|
+
* pairs like BTC-USDC. Callers can change it dynamically via the returned
|
|
2084
|
+
* `setPrecision`.
|
|
2085
|
+
*/
|
|
1932
2086
|
precision?: number;
|
|
1933
2087
|
};
|
|
2088
|
+
/**
|
|
2089
|
+
* Map a desired bucket step (in quote currency, e.g. USD) to the closest
|
|
2090
|
+
* Hyperliquid `l2Book` aggregation params at the given reference price.
|
|
2091
|
+
*
|
|
2092
|
+
* Hyperliquid only emits 20 levels per side per snapshot. To make those 20
|
|
2093
|
+
* levels span a wide enough range (e.g. ±$20k for a $1000 step), we ask the
|
|
2094
|
+
* server to pre-aggregate via `nSigFigs` / `mantissa`. This function picks the
|
|
2095
|
+
* coarsest server step that is still ≤ the user's chosen step, so any
|
|
2096
|
+
* remaining mismatch is corrected by client-side `aggregateByPrecision`
|
|
2097
|
+
* (which is idempotent when the steps already match).
|
|
2098
|
+
*
|
|
2099
|
+
* Examples (BTC, price ≈ $80,740):
|
|
2100
|
+
* step $1 → { nSigFigs: 5 } (Hyperliquid step $1)
|
|
2101
|
+
* step $2 → { nSigFigs: 5, mantissa: 2 } (Hyperliquid step $2)
|
|
2102
|
+
* step $5 → { nSigFigs: 5, mantissa: 5 } (Hyperliquid step $5)
|
|
2103
|
+
* step $10 → { nSigFigs: 4 } (Hyperliquid step $10)
|
|
2104
|
+
* step $100 → { nSigFigs: 3 } (Hyperliquid step $100)
|
|
2105
|
+
* step $1000 → { nSigFigs: 2 } (Hyperliquid step $1000)
|
|
2106
|
+
*
|
|
2107
|
+
* Examples (ETH, price ≈ $4,000):
|
|
2108
|
+
* step $1 → { nSigFigs: 4 } (Hyperliquid step $1)
|
|
2109
|
+
* step $2 → { nSigFigs: 4 } + client agg (server $1, client → $2)
|
|
2110
|
+
* step $10 → { nSigFigs: 3 } (Hyperliquid step $10)
|
|
2111
|
+
*
|
|
2112
|
+
* @param price Reference price (mid / mark) used to compute the magnitude.
|
|
2113
|
+
* @param step Desired bucket size in the same quote currency as `price`.
|
|
2114
|
+
* @returns Aggregation hint, or empty object when inputs are invalid.
|
|
2115
|
+
*/
|
|
2116
|
+
declare function aggregationFromStep(price: number, step: number): OrderBookAggregationOptions;
|
|
1934
2117
|
type UseOrderBookScriptResult = {
|
|
1935
2118
|
bids: PriceLevel[];
|
|
1936
2119
|
asks: PriceLevel[];
|
|
2120
|
+
/** Raw `bestAsk - bestBid` after aggregation. */
|
|
1937
2121
|
spread: number;
|
|
2122
|
+
/** `spread / bestBid * 100`. */
|
|
1938
2123
|
spreadPercentage: number;
|
|
1939
2124
|
isLoading: boolean;
|
|
1940
2125
|
precision: number;
|
|
@@ -1945,11 +2130,46 @@ declare function useOrderBookScript({ symbol, maxLevel, precision: initialPrecis
|
|
|
1945
2130
|
type OrderBookUIProps = {
|
|
1946
2131
|
bids: PriceLevel[];
|
|
1947
2132
|
asks: PriceLevel[];
|
|
1948
|
-
|
|
2133
|
+
/** `(bestAsk - bestBid) / bestBid * 100`, rendered next to the precision dropdown. */
|
|
1949
2134
|
spreadPercentage: number;
|
|
2135
|
+
/** Currently selected aggregation step. */
|
|
2136
|
+
precision: number;
|
|
2137
|
+
/** Available steps shown in the dropdown. */
|
|
2138
|
+
precisionOptions: readonly number[];
|
|
2139
|
+
/** Notify parent when the user picks a new step. */
|
|
2140
|
+
onPrecisionChange: (precision: number) => void;
|
|
1950
2141
|
onPriceClick?: (price: number) => void;
|
|
1951
2142
|
};
|
|
1952
|
-
|
|
2143
|
+
/**
|
|
2144
|
+
* Order book layout (top to bottom):
|
|
2145
|
+
*
|
|
2146
|
+
* ┌─ Header (Price / Amount / Total) ────┐ fixed height
|
|
2147
|
+
* ├─ Asks scroll region ─────────────────┤ flex-1, independent scroll
|
|
2148
|
+
* │ highest ask │
|
|
2149
|
+
* │ ... │
|
|
2150
|
+
* │ best ask ◄── default visible │
|
|
2151
|
+
* ├─ Spread bar with precision dropdown ─┤ fixed height
|
|
2152
|
+
* ├─ Bids scroll region ─────────────────┤ flex-1, independent scroll
|
|
2153
|
+
* │ best bid ◄── default visible │
|
|
2154
|
+
* │ ... │
|
|
2155
|
+
* │ lowest bid │
|
|
2156
|
+
* └──────────────────────────────────────┘
|
|
2157
|
+
*
|
|
2158
|
+
* Both scroll regions consume any leftover container height equally; if the
|
|
2159
|
+
* widget is short, each side scrolls on its own without dragging the other.
|
|
2160
|
+
*
|
|
2161
|
+
* Asks come in sorted ascending (best ask = lowest price = `asks[0]`). To
|
|
2162
|
+
* pin the best ask flush against the spread bar we render asks reversed
|
|
2163
|
+
* (highest first → best last in DOM order) inside a normal column scroll
|
|
2164
|
+
* container, then default-scroll to the bottom on mount. We re-stick the
|
|
2165
|
+
* scroll position to the bottom whenever the user is already near it, so
|
|
2166
|
+
* websocket updates don't bounce the view off the best ask.
|
|
2167
|
+
*
|
|
2168
|
+
* Bids are sorted descending (`bids[0]` = best) and rendered top-down,
|
|
2169
|
+
* so the best bid sits at `scrollTop = 0` flush against the spread bar
|
|
2170
|
+
* by default.
|
|
2171
|
+
*/
|
|
2172
|
+
declare function OrderBookUI({ bids, asks, spreadPercentage, precision, precisionOptions, onPrecisionChange, onPriceClick, }: OrderBookUIProps): react_jsx_runtime.JSX.Element;
|
|
1953
2173
|
|
|
1954
2174
|
type TradesWidgetProps = {
|
|
1955
2175
|
symbol: string;
|
|
@@ -1963,7 +2183,7 @@ type TradesUIProps = {
|
|
|
1963
2183
|
trades: Trade[];
|
|
1964
2184
|
onTradeClick?: (trade: Trade) => void;
|
|
1965
2185
|
};
|
|
1966
|
-
declare function TradesUI({ trades, onTradeClick }: TradesUIProps):
|
|
2186
|
+
declare function TradesUI({ trades, onTradeClick, }: TradesUIProps): ReactElement;
|
|
1967
2187
|
|
|
1968
2188
|
type UseTradesScriptParams = {
|
|
1969
2189
|
symbol: string;
|
|
@@ -2402,4 +2622,4 @@ interface HyperliquidInitWidgetProps extends Pick<UseHyperliquidSetupOptions, "a
|
|
|
2402
2622
|
}
|
|
2403
2623
|
declare function HyperliquidInitWidget({ adapter, userAddress, steps, autoLoad, onComplete, onError, onDismiss, className, }: HyperliquidInitWidgetProps): react_jsx_runtime.JSX.Element;
|
|
2404
2624
|
|
|
2405
|
-
export { type Account, type ApproveBuilderFeeParams, type CancelOrderParams, type CancelOrderResult, type Coin, CoinInfoNotFoundUI, CoinInfoSkeletonsUI, CoinInfoUI, type CoinInfoUIProps, CoinInfoWidget, type CoinInfoWidgetProps, type DepositBreakdown, DepositConfirmUI, type DepositConfirmUIProps, type DepositErrorInfo, type DepositEvent, DepositFlowWidget, type DepositFlowWidgetProps, DepositFormUI, type DepositFormUIProps, type DepositPhase, type DepositQuoteRequest, type DepositQuoteResponse, type DepositSource, type DepositState, type DepositStatus, type DepositStatusResponse, type DepositStatusTransition, DepositStatusUI, type DepositStatusUIProps, type DepositSubmitRequest, type DepositSubmitResponse, type ExecuteDepositInput, type GetOpenOrdersParams, type GetOpenOrdersResult, type GetPositionsParams, type GetPositionsResult, type GetTradesParams, type GetTradesResult, HL_USDC_DECIMALS, type HyperliquidAccountState, HyperliquidApiError, type HyperliquidClientConfig, type HyperliquidEnvironment, HyperliquidInitUI, type HyperliquidInitUIProps, HyperliquidInitWidget, type HyperliquidInitWidgetProps, HyperliquidPerpetualsClient, type HyperliquidSetupActionResult, type IHyperliquidSetupAdapter, type IPerpDepositClient, type IPerpetualsClient, type Kline, type KlineInterval, LiberFiApiError, type LiberFiHttpMethod, type RequestOptions as LiberFiHttpRequestOptions, LiberFiHttpTransport, type LiberFiHttpTransportConfig, LiberFiPerpDepositClient, type LiberFiPerpDepositClientConfig, LiberFiPerpetualsClient, type LiberFiPerpetualsClientConfig, type MarketData, type MarketDataType, OpenOrdersEmpty, OpenOrdersSkeleton, OpenOrdersUI, type OpenOrdersUIProps, OpenOrdersWidget, type OpenOrdersWidgetProps, type Order, type OrderBook, type OrderBookLevel, OrderBookUI, type OrderBookUIProps, OrderBookWidget, type OrderBookWidgetProps, type OrderSide, type OrderStatus, type OrderType, PerpetualsContext, type PerpetualsContextValue, PerpetualsProvider, type PerpetualsProviderProps, type PlaceOrderFormData, PlaceOrderFormUI, type PlaceOrderFormUIProps, PlaceOrderFormWidget, type PlaceOrderFormWidgetProps, type PlaceOrderParams, type PlaceOrderResult, type Position, PositionsEmpty, PositionsSkeleton, PositionsUI, type PositionsUIProps, PositionsWidget, type PositionsWidgetProps, type PriceLevel, SearchCoinsUI, type SearchCoinsUIProps, SearchCoinsWidget, type SearchCoinsWidgetProps, type SetReferrerParams, type SetupAction, type SetupPhase, type SetupState, type SetupStep, type SetupStepId, type SignAndBroadcastSolanaTx, type SignTypedDataFn, type StepRecord, type StepStatus, type Symbol, TERMINAL_DEPOSIT_STATUSES, type TimeRange, type Trade, type TradeHistory, TradeHistoryEmpty, TradeHistorySkeleton, TradeHistoryUI, type TradeHistoryUIProps, TradeHistoryWidget, type TradeHistoryWidgetProps, type TradeSide, TradesUI, type TradesUIProps, TradesWidget, type TradesWidgetProps, type TradingProvider, type UpdateLeverageParams, type UseCancelOrderMutationParams, type UseCandlesSubscriptionParams, type UseCandlesSubscriptionResult, type UseCoinInfoReturnType, type UseCreateOrderMutationParams, type UseHyperliquidSetupOptions, type UseHyperliquidSetupResult, type UseKlinesQueryParams, type UseMarketDataSubscriptionParams, type UseMarketDataSubscriptionResult, type UseMarketQueryParams, type UseMarketsQueryParams, type UseOpenOrdersScriptParams, type UseOpenOrdersScriptResult, type UseOrderBookQueryParams, type UseOrderBookScriptParams, type UseOrderBookScriptResult, type UseOrdersQueryParams, type UsePerpDepositExecuteResult, type UsePerpDepositQuoteOptions, type UsePerpDepositStatusOptions, type UsePlaceOrderFormScriptParams, type UsePlaceOrderFormScriptResult, type UsePositionsQueryParams, type UsePositionsScriptParams, type UsePositionsScriptResult, type UseRecentTradesQueryParams, type UseSearchCoinsScriptParams, type UseSearchCoinsScriptResult, type UseTradeHistoryScriptParams, type UseTradeHistoryScriptResult, type UseTradesQueryParams, type UseTradesScriptParams, type UseTradesScriptResult, type UseUserDataSubscriptionParams, type UseUserDataSubscriptionResult, type UserDataType, cancelOrder, classifyStep, coinsQueryKey, createOrder, currentBreakdown as currentDepositBreakdown, currentStatus as currentDepositStatus, fetchCoins, fetchKlines, fetchMarket, fetchMarkets, fetchOrderBook, fetchOrders, fetchPerpDepositQuote, fetchPerpDepositStatus, fetchPositions, fetchRecentTrades, fetchTrades, hlUsdcRawToUsdc, initialDepositState, initialSetupState, isPolling as isDepositPolling, isTerminal as isDepositTerminal, isTerminalLifecycle as isTerminalDepositLifecycle, klinesQueryKey, lamportsToSol, marketQueryKey, marketsQueryKey, microUsdcToUsdc, nextRunnableStep, orderBookQueryKey, ordersQueryKey, perpDepositQuoteQueryKey, perpDepositStatusQueryKey, positionsQueryKey, recentTradesQueryKey, reduceDepositState, reduceSetupState, secondsUntil, shortAddress, solToLamports, tradesQueryKey, useCancelOrderMutation, useCandlesSubscription, useCoinInfo, useCoinsQuery, useCreateOrderMutation, useHyperliquidSetup, useKlinesQuery, useMarketDataSubscription, useMarketQuery, useMarketsQuery, useOpenOrdersScript, useOrderBookQuery, useOrderBookScript, useOrdersQuery, usePerpDepositClient, usePerpDepositClientMaybe, usePerpDepositExecute, usePerpDepositQuote, usePerpDepositStatus, usePerpetualsClient, usePlaceOrderFormScript, usePositionsQuery, usePositionsScript, useRecentTradesQuery, useSearchCoinsScript, useTradeHistoryScript, useTradesQuery, useTradesScript, useUserDataSubscription, _default as version };
|
|
2625
|
+
export { type Account, type ApproveBuilderFeeParams, type CancelOrderParams, type CancelOrderResult, type Coin, CoinInfoNotFoundUI, CoinInfoSkeletonsUI, CoinInfoUI, type CoinInfoUIProps, CoinInfoWidget, type CoinInfoWidgetProps, DEFAULT_ORDER_BOOK_PRECISION_OPTIONS, type DepositBreakdown, DepositConfirmUI, type DepositConfirmUIProps, type DepositErrorInfo, type DepositEvent, DepositFlowWidget, type DepositFlowWidgetProps, DepositFormUI, type DepositFormUIProps, type DepositPhase, type DepositQuoteRequest, type DepositQuoteResponse, type DepositSource, type DepositState, type DepositStatus, type DepositStatusResponse, type DepositStatusTransition, DepositStatusUI, type DepositStatusUIProps, type DepositSubmitRequest, type DepositSubmitResponse, type ExecuteDepositInput, type GetOpenOrdersParams, type GetOpenOrdersResult, type GetPositionsParams, type GetPositionsResult, type GetTradesParams, type GetTradesResult, HL_USDC_DECIMALS, type HyperliquidAccountState, HyperliquidApiError, type HyperliquidClientConfig, type HyperliquidEnvironment, HyperliquidInitUI, type HyperliquidInitUIProps, HyperliquidInitWidget, type HyperliquidInitWidgetProps, HyperliquidPerpetualsClient, type HyperliquidSetupActionResult, type IHyperliquidSetupAdapter, type IPerpDepositClient, type IPerpetualsClient, type Kline, type KlineInterval, type KlineQueryOptions, LiberFiApiError, type LiberFiHttpMethod, type RequestOptions as LiberFiHttpRequestOptions, LiberFiHttpTransport, type LiberFiHttpTransportConfig, LiberFiPerpDepositClient, type LiberFiPerpDepositClientConfig, LiberFiPerpetualsClient, type LiberFiPerpetualsClientConfig, type MarketData, type MarketDataType, OpenOrdersEmpty, OpenOrdersSkeleton, OpenOrdersUI, type OpenOrdersUIProps, OpenOrdersWidget, type OpenOrdersWidgetProps, type Order, type OrderBook, type OrderBookAggregationOptions, type OrderBookLevel, OrderBookUI, type OrderBookUIProps, OrderBookWidget, type OrderBookWidgetProps, type OrderSide, type OrderStatus, type OrderType, PerpetualsContext, type PerpetualsContextValue, PerpetualsProvider, type PerpetualsProviderProps, type PlaceOrderFormData, PlaceOrderFormUI, type PlaceOrderFormUIProps, PlaceOrderFormWidget, type PlaceOrderFormWidgetProps, type PlaceOrderParams, type PlaceOrderResult, type Position, PositionsEmpty, PositionsSkeleton, PositionsUI, type PositionsUIProps, PositionsWidget, type PositionsWidgetProps, type PriceLevel, SearchCoinsUI, type SearchCoinsUIProps, SearchCoinsWidget, type SearchCoinsWidgetProps, type SetReferrerParams, type SetupAction, type SetupPhase, type SetupState, type SetupStep, type SetupStepId, type SignAndBroadcastSolanaTx, type SignTypedDataFn, type StepRecord, type StepStatus, type Symbol, TERMINAL_DEPOSIT_STATUSES, type TimeRange, type Trade, type TradeHistory, TradeHistoryEmpty, TradeHistorySkeleton, TradeHistoryUI, type TradeHistoryUIProps, TradeHistoryWidget, type TradeHistoryWidgetProps, type TradeSide, TradesUI, type TradesUIProps, TradesWidget, type TradesWidgetProps, type TradingProvider, type UpdateLeverageParams, type UseCancelOrderMutationParams, type UseCandlesSubscriptionParams, type UseCandlesSubscriptionResult, type UseCoinInfoReturnType, type UseCreateOrderMutationParams, type UseHyperliquidSetupOptions, type UseHyperliquidSetupResult, type UseKlinesQueryParams, type UseMarketDataSubscriptionParams, type UseMarketDataSubscriptionResult, type UseMarketQueryParams, type UseMarketsQueryParams, type UseOpenOrdersScriptParams, type UseOpenOrdersScriptResult, type UseOrderBookQueryParams, type UseOrderBookScriptParams, type UseOrderBookScriptResult, type UseOrdersQueryParams, type UsePerpDepositExecuteResult, type UsePerpDepositQuoteOptions, type UsePerpDepositStatusOptions, type UsePlaceOrderFormScriptParams, type UsePlaceOrderFormScriptResult, type UsePositionsQueryParams, type UsePositionsScriptParams, type UsePositionsScriptResult, type UseRecentTradesQueryParams, type UseSearchCoinsScriptParams, type UseSearchCoinsScriptResult, type UseTradeHistoryScriptParams, type UseTradeHistoryScriptResult, type UseTradesQueryParams, type UseTradesScriptParams, type UseTradesScriptResult, type UseUserDataSubscriptionParams, type UseUserDataSubscriptionResult, type UserDataType, aggregationFromStep, cancelOrder, classifyStep, coinsQueryKey, createOrder, currentBreakdown as currentDepositBreakdown, currentStatus as currentDepositStatus, fetchCoins, fetchKlines, fetchMarket, fetchMarkets, fetchOrderBook, fetchOrders, fetchPerpDepositQuote, fetchPerpDepositStatus, fetchPositions, fetchRecentTrades, fetchTrades, hlUsdcRawToUsdc, initialDepositState, initialSetupState, isPolling as isDepositPolling, isTerminal as isDepositTerminal, isTerminalLifecycle as isTerminalDepositLifecycle, klinesQueryKey, lamportsToSol, marketQueryKey, marketsQueryKey, microUsdcToUsdc, nextRunnableStep, orderBookQueryKey, ordersQueryKey, perpDepositQuoteQueryKey, perpDepositStatusQueryKey, positionsQueryKey, recentTradesQueryKey, reduceDepositState, reduceSetupState, secondsUntil, shortAddress, solToLamports, tradesQueryKey, useCancelOrderMutation, useCandlesSubscription, useCoinInfo, useCoinsQuery, useCreateOrderMutation, useHyperliquidSetup, useKlinesQuery, useMarketDataSubscription, useMarketQuery, useMarketsQuery, useOpenOrdersScript, useOrderBookQuery, useOrderBookScript, useOrdersQuery, usePerpDepositClient, usePerpDepositClientMaybe, usePerpDepositExecute, usePerpDepositQuote, usePerpDepositStatus, usePerpetualsClient, usePlaceOrderFormScript, usePositionsQuery, usePositionsScript, useRecentTradesQuery, useSearchCoinsScript, useTradeHistoryScript, useTradesQuery, useTradesScript, useUserDataSubscription, _default as version };
|