@liberfi.io/ui-perpetuals 0.2.4 → 0.2.6
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 +70 -9
- package/dist/index.d.ts +70 -9
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -12,7 +12,7 @@ declare global {
|
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
declare const _default: "0.2.
|
|
15
|
+
declare const _default: "0.2.6";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Trading pair symbol format
|
|
@@ -566,6 +566,13 @@ declare class HyperliquidPerpetualsClient implements IPerpetualsClient {
|
|
|
566
566
|
private readonly timeout;
|
|
567
567
|
private readonly environment;
|
|
568
568
|
private wsManager;
|
|
569
|
+
/**
|
|
570
|
+
* Reference count of active WebSocket consumers. The connection is
|
|
571
|
+
* established on the first `connectWebSocket()` call and torn down
|
|
572
|
+
* only when the last consumer disconnects — see the matching comment
|
|
573
|
+
* on {@link LiberFiPerpetualsClient}.
|
|
574
|
+
*/
|
|
575
|
+
private wsRefCount;
|
|
569
576
|
/**
|
|
570
577
|
* 构造 Hyperliquid 客户端
|
|
571
578
|
*
|
|
@@ -709,7 +716,10 @@ declare class HyperliquidPerpetualsClient implements IPerpetualsClient {
|
|
|
709
716
|
/**
|
|
710
717
|
* Disconnect from WebSocket server
|
|
711
718
|
*
|
|
712
|
-
*
|
|
719
|
+
* Decrements the consumer ref count. The underlying socket is closed
|
|
720
|
+
* only when the last consumer disconnects, so concurrent widgets
|
|
721
|
+
* (order book, trades, ticker) can mount/unmount independently
|
|
722
|
+
* without stealing each other's stream.
|
|
713
723
|
*/
|
|
714
724
|
disconnectWebSocket(): void;
|
|
715
725
|
/**
|
|
@@ -1071,6 +1081,14 @@ declare class LiberFiPerpetualsClient implements IPerpetualsClient {
|
|
|
1071
1081
|
private readonly wsEndpoint;
|
|
1072
1082
|
private readonly signTypedData?;
|
|
1073
1083
|
private wsManager;
|
|
1084
|
+
/**
|
|
1085
|
+
* Reference count of active WebSocket consumers (one per React hook
|
|
1086
|
+
* instance). The underlying connection is opened lazily on the first
|
|
1087
|
+
* connect() call and torn down only when the last consumer leaves —
|
|
1088
|
+
* this prevents one widget's unmount from killing the live stream
|
|
1089
|
+
* other widgets (order book, trades, ticker) still depend on.
|
|
1090
|
+
*/
|
|
1091
|
+
private wsRefCount;
|
|
1074
1092
|
constructor(config: LiberFiPerpetualsClientConfig);
|
|
1075
1093
|
getSupportedCoins(): Promise<string[]>;
|
|
1076
1094
|
getMarket(symbol: string): Promise<MarketData | null>;
|
|
@@ -1956,9 +1974,16 @@ type PlaceOrderFormWidgetProps = {
|
|
|
1956
1974
|
maxLeverage?: number;
|
|
1957
1975
|
onSuccess?: () => void;
|
|
1958
1976
|
onError?: (error: Error) => void;
|
|
1977
|
+
/**
|
|
1978
|
+
* Optional callback fired when the user clicks "Add More Funds".
|
|
1979
|
+
* The host app typically opens its deposit dialog here. When omitted,
|
|
1980
|
+
* the button is hidden so the form doesn't expose a non-functional
|
|
1981
|
+
* control.
|
|
1982
|
+
*/
|
|
1983
|
+
onAddFunds?: () => void;
|
|
1959
1984
|
className?: string;
|
|
1960
1985
|
};
|
|
1961
|
-
declare function PlaceOrderFormWidget({ symbol, userAddress, maxLeverage, onSuccess, onError, className, }: PlaceOrderFormWidgetProps): react_jsx_runtime.JSX.Element;
|
|
1986
|
+
declare function PlaceOrderFormWidget({ symbol, userAddress, maxLeverage, onSuccess, onError, onAddFunds, className, }: PlaceOrderFormWidgetProps): react_jsx_runtime.JSX.Element;
|
|
1962
1987
|
|
|
1963
1988
|
type PlaceOrderFormData = {
|
|
1964
1989
|
price?: number;
|
|
@@ -2012,8 +2037,15 @@ type PlaceOrderFormUIProps = {
|
|
|
2012
2037
|
accountValue: number;
|
|
2013
2038
|
currentPosition?: number;
|
|
2014
2039
|
maxLeverage: number;
|
|
2040
|
+
/**
|
|
2041
|
+
* Optional callback fired when the user clicks the "Add More Funds"
|
|
2042
|
+
* button (typically wired by the host app to open a deposit dialog).
|
|
2043
|
+
* The button is hidden when this prop is omitted, so consumers that
|
|
2044
|
+
* don't support a deposit flow don't render a dead control.
|
|
2045
|
+
*/
|
|
2046
|
+
onAddFunds?: () => void;
|
|
2015
2047
|
};
|
|
2016
|
-
declare function PlaceOrderFormUI({ methods, side, orderType, onSideChange, onOrderTypeChange, onSubmit, isSubmitting, symbol, currentPrice, estimatedFee, liquidationPrice, availableMargin, accountValue, currentPosition, maxLeverage, }: PlaceOrderFormUIProps): react_jsx_runtime.JSX.Element;
|
|
2048
|
+
declare function PlaceOrderFormUI({ methods, side, orderType, onSideChange, onOrderTypeChange, onSubmit, isSubmitting, symbol, currentPrice, estimatedFee, liquidationPrice, availableMargin, accountValue, currentPosition, maxLeverage, onAddFunds, }: PlaceOrderFormUIProps): react_jsx_runtime.JSX.Element;
|
|
2017
2049
|
|
|
2018
2050
|
type PositionsWidgetProps = {
|
|
2019
2051
|
userAddress?: string;
|
|
@@ -2229,9 +2261,16 @@ interface DepositConfirmUIProps {
|
|
|
2229
2261
|
declare function DepositConfirmUI({ isOpen, quote, isExecuting, isExpired, onConfirm, onCancel, onExpire, error, }: DepositConfirmUIProps): react_jsx_runtime.JSX.Element;
|
|
2230
2262
|
|
|
2231
2263
|
/**
|
|
2232
|
-
*
|
|
2264
|
+
* Polished progress / result panel for the SOL → Hyperliquid USDC
|
|
2265
|
+
* deposit flow.
|
|
2233
2266
|
*
|
|
2234
|
-
*
|
|
2267
|
+
* Visual design intentionally mirrors the swap-style deposit form
|
|
2268
|
+
* modal (dark surface, 14 px radius, accent-color spinner / icons,
|
|
2269
|
+
* pill-style transaction links) so the in-flight, success and failure
|
|
2270
|
+
* states all feel like the same product surface rather than a generic
|
|
2271
|
+
* HeroUI dialog.
|
|
2272
|
+
*
|
|
2273
|
+
* Renders one of four visual states based on the FSM phase:
|
|
2235
2274
|
* - in-progress (broadcasting / submitted / tracking)
|
|
2236
2275
|
* - succeeded
|
|
2237
2276
|
* - refunded
|
|
@@ -2265,13 +2304,35 @@ declare function DepositStatusUI({ isOpen, phase, status, solanaExplorerUrl, hyp
|
|
|
2265
2304
|
* lamport / microUSDC value — so we never silently lose precision on
|
|
2266
2305
|
* deposits that exceed `Number.MAX_SAFE_INTEGER` lamports.
|
|
2267
2306
|
*/
|
|
2307
|
+
/**
|
|
2308
|
+
* Hyperliquid credits perp USDC at 8-decimal granularity (NOT the 6
|
|
2309
|
+
* decimals used by ERC-20 USDC on Arbitrum). Relay's `currencyOut.amount`
|
|
2310
|
+
* for a Hyperliquid bridge quote is therefore expressed in HL perp units
|
|
2311
|
+
* — divide by 1e8 to get the human-readable USDC amount.
|
|
2312
|
+
*/
|
|
2313
|
+
declare const HL_USDC_DECIMALS = 8;
|
|
2268
2314
|
/**
|
|
2269
2315
|
* Convert a lamport amount (string bigint) to a SOL-denominated string
|
|
2270
2316
|
* with `precision` decimals and trailing zeros stripped.
|
|
2271
2317
|
*/
|
|
2272
2318
|
declare function lamportsToSol(value: string, precision?: number): string;
|
|
2273
|
-
/**
|
|
2274
|
-
|
|
2319
|
+
/**
|
|
2320
|
+
* Convert a raw Hyperliquid USDC amount (8 decimals) to a USDC display
|
|
2321
|
+
* string with `precision` decimals and trailing zeros stripped.
|
|
2322
|
+
*
|
|
2323
|
+
* This is the unit returned by the perpetuals-server `/deposits/quote`
|
|
2324
|
+
* endpoint in `breakdown.expectedOutputUSDC` — it mirrors Hyperliquid's
|
|
2325
|
+
* internal perp-account precision, NOT the 6-decimal USDC token on
|
|
2326
|
+
* Arbitrum.
|
|
2327
|
+
*/
|
|
2328
|
+
declare function hlUsdcRawToUsdc(value: string | undefined, precision?: number): string;
|
|
2329
|
+
/**
|
|
2330
|
+
* @deprecated Use {@link hlUsdcRawToUsdc} instead. The previous name
|
|
2331
|
+
* implied a 6-decimal microUSDC unit, but the Hyperliquid bridge actually
|
|
2332
|
+
* returns amounts at 8-decimal precision. Kept as a thin alias to avoid
|
|
2333
|
+
* a hard break for downstream callers; remove after consumers migrate.
|
|
2334
|
+
*/
|
|
2335
|
+
declare const microUsdcToUsdc: typeof hlUsdcRawToUsdc;
|
|
2275
2336
|
/** Convert a SOL-denominated decimal string to a lamport `string` (bigint). */
|
|
2276
2337
|
declare function solToLamports(value: string): string;
|
|
2277
2338
|
/** Returns whole-second countdown until `expiresAtMs`. Negative -> 0. */
|
|
@@ -2334,4 +2395,4 @@ interface HyperliquidInitWidgetProps extends Pick<UseHyperliquidSetupOptions, "a
|
|
|
2334
2395
|
}
|
|
2335
2396
|
declare function HyperliquidInitWidget({ adapter, userAddress, steps, autoLoad, onComplete, onError, onDismiss, className, }: HyperliquidInitWidgetProps): react_jsx_runtime.JSX.Element;
|
|
2336
2397
|
|
|
2337
|
-
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, 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, 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, usePerpDepositExecute, usePerpDepositQuote, usePerpDepositStatus, usePerpetualsClient, usePlaceOrderFormScript, usePositionsQuery, usePositionsScript, useRecentTradesQuery, useSearchCoinsScript, useTradeHistoryScript, useTradesQuery, useTradesScript, useUserDataSubscription, _default as version };
|
|
2398
|
+
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, usePerpDepositExecute, usePerpDepositQuote, usePerpDepositStatus, usePerpetualsClient, usePlaceOrderFormScript, usePositionsQuery, usePositionsScript, useRecentTradesQuery, useSearchCoinsScript, useTradeHistoryScript, useTradesQuery, useTradesScript, useUserDataSubscription, _default as version };
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ declare global {
|
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
declare const _default: "0.2.
|
|
15
|
+
declare const _default: "0.2.6";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Trading pair symbol format
|
|
@@ -566,6 +566,13 @@ declare class HyperliquidPerpetualsClient implements IPerpetualsClient {
|
|
|
566
566
|
private readonly timeout;
|
|
567
567
|
private readonly environment;
|
|
568
568
|
private wsManager;
|
|
569
|
+
/**
|
|
570
|
+
* Reference count of active WebSocket consumers. The connection is
|
|
571
|
+
* established on the first `connectWebSocket()` call and torn down
|
|
572
|
+
* only when the last consumer disconnects — see the matching comment
|
|
573
|
+
* on {@link LiberFiPerpetualsClient}.
|
|
574
|
+
*/
|
|
575
|
+
private wsRefCount;
|
|
569
576
|
/**
|
|
570
577
|
* 构造 Hyperliquid 客户端
|
|
571
578
|
*
|
|
@@ -709,7 +716,10 @@ declare class HyperliquidPerpetualsClient implements IPerpetualsClient {
|
|
|
709
716
|
/**
|
|
710
717
|
* Disconnect from WebSocket server
|
|
711
718
|
*
|
|
712
|
-
*
|
|
719
|
+
* Decrements the consumer ref count. The underlying socket is closed
|
|
720
|
+
* only when the last consumer disconnects, so concurrent widgets
|
|
721
|
+
* (order book, trades, ticker) can mount/unmount independently
|
|
722
|
+
* without stealing each other's stream.
|
|
713
723
|
*/
|
|
714
724
|
disconnectWebSocket(): void;
|
|
715
725
|
/**
|
|
@@ -1071,6 +1081,14 @@ declare class LiberFiPerpetualsClient implements IPerpetualsClient {
|
|
|
1071
1081
|
private readonly wsEndpoint;
|
|
1072
1082
|
private readonly signTypedData?;
|
|
1073
1083
|
private wsManager;
|
|
1084
|
+
/**
|
|
1085
|
+
* Reference count of active WebSocket consumers (one per React hook
|
|
1086
|
+
* instance). The underlying connection is opened lazily on the first
|
|
1087
|
+
* connect() call and torn down only when the last consumer leaves —
|
|
1088
|
+
* this prevents one widget's unmount from killing the live stream
|
|
1089
|
+
* other widgets (order book, trades, ticker) still depend on.
|
|
1090
|
+
*/
|
|
1091
|
+
private wsRefCount;
|
|
1074
1092
|
constructor(config: LiberFiPerpetualsClientConfig);
|
|
1075
1093
|
getSupportedCoins(): Promise<string[]>;
|
|
1076
1094
|
getMarket(symbol: string): Promise<MarketData | null>;
|
|
@@ -1956,9 +1974,16 @@ type PlaceOrderFormWidgetProps = {
|
|
|
1956
1974
|
maxLeverage?: number;
|
|
1957
1975
|
onSuccess?: () => void;
|
|
1958
1976
|
onError?: (error: Error) => void;
|
|
1977
|
+
/**
|
|
1978
|
+
* Optional callback fired when the user clicks "Add More Funds".
|
|
1979
|
+
* The host app typically opens its deposit dialog here. When omitted,
|
|
1980
|
+
* the button is hidden so the form doesn't expose a non-functional
|
|
1981
|
+
* control.
|
|
1982
|
+
*/
|
|
1983
|
+
onAddFunds?: () => void;
|
|
1959
1984
|
className?: string;
|
|
1960
1985
|
};
|
|
1961
|
-
declare function PlaceOrderFormWidget({ symbol, userAddress, maxLeverage, onSuccess, onError, className, }: PlaceOrderFormWidgetProps): react_jsx_runtime.JSX.Element;
|
|
1986
|
+
declare function PlaceOrderFormWidget({ symbol, userAddress, maxLeverage, onSuccess, onError, onAddFunds, className, }: PlaceOrderFormWidgetProps): react_jsx_runtime.JSX.Element;
|
|
1962
1987
|
|
|
1963
1988
|
type PlaceOrderFormData = {
|
|
1964
1989
|
price?: number;
|
|
@@ -2012,8 +2037,15 @@ type PlaceOrderFormUIProps = {
|
|
|
2012
2037
|
accountValue: number;
|
|
2013
2038
|
currentPosition?: number;
|
|
2014
2039
|
maxLeverage: number;
|
|
2040
|
+
/**
|
|
2041
|
+
* Optional callback fired when the user clicks the "Add More Funds"
|
|
2042
|
+
* button (typically wired by the host app to open a deposit dialog).
|
|
2043
|
+
* The button is hidden when this prop is omitted, so consumers that
|
|
2044
|
+
* don't support a deposit flow don't render a dead control.
|
|
2045
|
+
*/
|
|
2046
|
+
onAddFunds?: () => void;
|
|
2015
2047
|
};
|
|
2016
|
-
declare function PlaceOrderFormUI({ methods, side, orderType, onSideChange, onOrderTypeChange, onSubmit, isSubmitting, symbol, currentPrice, estimatedFee, liquidationPrice, availableMargin, accountValue, currentPosition, maxLeverage, }: PlaceOrderFormUIProps): react_jsx_runtime.JSX.Element;
|
|
2048
|
+
declare function PlaceOrderFormUI({ methods, side, orderType, onSideChange, onOrderTypeChange, onSubmit, isSubmitting, symbol, currentPrice, estimatedFee, liquidationPrice, availableMargin, accountValue, currentPosition, maxLeverage, onAddFunds, }: PlaceOrderFormUIProps): react_jsx_runtime.JSX.Element;
|
|
2017
2049
|
|
|
2018
2050
|
type PositionsWidgetProps = {
|
|
2019
2051
|
userAddress?: string;
|
|
@@ -2229,9 +2261,16 @@ interface DepositConfirmUIProps {
|
|
|
2229
2261
|
declare function DepositConfirmUI({ isOpen, quote, isExecuting, isExpired, onConfirm, onCancel, onExpire, error, }: DepositConfirmUIProps): react_jsx_runtime.JSX.Element;
|
|
2230
2262
|
|
|
2231
2263
|
/**
|
|
2232
|
-
*
|
|
2264
|
+
* Polished progress / result panel for the SOL → Hyperliquid USDC
|
|
2265
|
+
* deposit flow.
|
|
2233
2266
|
*
|
|
2234
|
-
*
|
|
2267
|
+
* Visual design intentionally mirrors the swap-style deposit form
|
|
2268
|
+
* modal (dark surface, 14 px radius, accent-color spinner / icons,
|
|
2269
|
+
* pill-style transaction links) so the in-flight, success and failure
|
|
2270
|
+
* states all feel like the same product surface rather than a generic
|
|
2271
|
+
* HeroUI dialog.
|
|
2272
|
+
*
|
|
2273
|
+
* Renders one of four visual states based on the FSM phase:
|
|
2235
2274
|
* - in-progress (broadcasting / submitted / tracking)
|
|
2236
2275
|
* - succeeded
|
|
2237
2276
|
* - refunded
|
|
@@ -2265,13 +2304,35 @@ declare function DepositStatusUI({ isOpen, phase, status, solanaExplorerUrl, hyp
|
|
|
2265
2304
|
* lamport / microUSDC value — so we never silently lose precision on
|
|
2266
2305
|
* deposits that exceed `Number.MAX_SAFE_INTEGER` lamports.
|
|
2267
2306
|
*/
|
|
2307
|
+
/**
|
|
2308
|
+
* Hyperliquid credits perp USDC at 8-decimal granularity (NOT the 6
|
|
2309
|
+
* decimals used by ERC-20 USDC on Arbitrum). Relay's `currencyOut.amount`
|
|
2310
|
+
* for a Hyperliquid bridge quote is therefore expressed in HL perp units
|
|
2311
|
+
* — divide by 1e8 to get the human-readable USDC amount.
|
|
2312
|
+
*/
|
|
2313
|
+
declare const HL_USDC_DECIMALS = 8;
|
|
2268
2314
|
/**
|
|
2269
2315
|
* Convert a lamport amount (string bigint) to a SOL-denominated string
|
|
2270
2316
|
* with `precision` decimals and trailing zeros stripped.
|
|
2271
2317
|
*/
|
|
2272
2318
|
declare function lamportsToSol(value: string, precision?: number): string;
|
|
2273
|
-
/**
|
|
2274
|
-
|
|
2319
|
+
/**
|
|
2320
|
+
* Convert a raw Hyperliquid USDC amount (8 decimals) to a USDC display
|
|
2321
|
+
* string with `precision` decimals and trailing zeros stripped.
|
|
2322
|
+
*
|
|
2323
|
+
* This is the unit returned by the perpetuals-server `/deposits/quote`
|
|
2324
|
+
* endpoint in `breakdown.expectedOutputUSDC` — it mirrors Hyperliquid's
|
|
2325
|
+
* internal perp-account precision, NOT the 6-decimal USDC token on
|
|
2326
|
+
* Arbitrum.
|
|
2327
|
+
*/
|
|
2328
|
+
declare function hlUsdcRawToUsdc(value: string | undefined, precision?: number): string;
|
|
2329
|
+
/**
|
|
2330
|
+
* @deprecated Use {@link hlUsdcRawToUsdc} instead. The previous name
|
|
2331
|
+
* implied a 6-decimal microUSDC unit, but the Hyperliquid bridge actually
|
|
2332
|
+
* returns amounts at 8-decimal precision. Kept as a thin alias to avoid
|
|
2333
|
+
* a hard break for downstream callers; remove after consumers migrate.
|
|
2334
|
+
*/
|
|
2335
|
+
declare const microUsdcToUsdc: typeof hlUsdcRawToUsdc;
|
|
2275
2336
|
/** Convert a SOL-denominated decimal string to a lamport `string` (bigint). */
|
|
2276
2337
|
declare function solToLamports(value: string): string;
|
|
2277
2338
|
/** Returns whole-second countdown until `expiresAtMs`. Negative -> 0. */
|
|
@@ -2334,4 +2395,4 @@ interface HyperliquidInitWidgetProps extends Pick<UseHyperliquidSetupOptions, "a
|
|
|
2334
2395
|
}
|
|
2335
2396
|
declare function HyperliquidInitWidget({ adapter, userAddress, steps, autoLoad, onComplete, onError, onDismiss, className, }: HyperliquidInitWidgetProps): react_jsx_runtime.JSX.Element;
|
|
2336
2397
|
|
|
2337
|
-
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, 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, 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, usePerpDepositExecute, usePerpDepositQuote, usePerpDepositStatus, usePerpetualsClient, usePlaceOrderFormScript, usePositionsQuery, usePositionsScript, useRecentTradesQuery, useSearchCoinsScript, useTradeHistoryScript, useTradesQuery, useTradesScript, useUserDataSubscription, _default as version };
|
|
2398
|
+
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, usePerpDepositExecute, usePerpDepositQuote, usePerpDepositStatus, usePerpetualsClient, usePlaceOrderFormScript, usePositionsQuery, usePositionsScript, useRecentTradesQuery, useSearchCoinsScript, useTradeHistoryScript, useTradesQuery, useTradesScript, useUserDataSubscription, _default as version };
|