@orderly.network/hooks 1.0.28-alpha.2 → 1.0.28-alpha.20
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 +85 -35
- package/dist/index.d.ts +85 -35
- package/dist/index.js +569 -273
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +570 -276
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
package/dist/index.d.mts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import useSWR, { SWRConfiguration, SWRResponse } from 'swr';
|
|
2
2
|
export { SWRConfig, SWRConfiguration, default as useSWR } from 'swr';
|
|
3
|
-
import * as swr__internal from 'swr/_internal';
|
|
4
3
|
import { SWRMutationConfiguration, SWRMutationResponse } from 'swr/mutation';
|
|
5
4
|
import * as swr_infinite from 'swr/infinite';
|
|
6
5
|
import { SWRInfiniteKeyLoader, SWRInfiniteConfiguration } from 'swr/infinite';
|
|
6
|
+
import * as swr__internal from 'swr/_internal';
|
|
7
7
|
import * as _orderly_network_core from '@orderly.network/core';
|
|
8
8
|
import { AccountState, Account, EventEmitter, ConfigKey, ConfigStore, OrderlyKeyStore, getWalletAdapterFunc, IContract } from '@orderly.network/core';
|
|
9
9
|
export { default as useConstant } from 'use-constant';
|
|
10
10
|
import { WS } from '@orderly.network/net';
|
|
11
11
|
import * as react from 'react';
|
|
12
12
|
import { PropsWithChildren } from 'react';
|
|
13
|
+
import * as _orderly_network_types from '@orderly.network/types';
|
|
13
14
|
import { NetworkId, OrderSide, OrderEntity, API, WSMessage, OrderStatus } from '@orderly.network/types';
|
|
14
15
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
15
16
|
import * as swr_subscription from 'swr/subscription';
|
|
@@ -23,9 +24,9 @@ declare global {
|
|
|
23
24
|
};
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
|
-
declare const _default: "1.0.28-alpha.
|
|
27
|
+
declare const _default: "1.0.28-alpha.20";
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
type useQueryOptions<T> = SWRConfiguration & {
|
|
29
30
|
formatter?: (data: any) => T;
|
|
30
31
|
};
|
|
31
32
|
|
|
@@ -43,13 +44,13 @@ declare const useQuery: <T>(query: Parameters<typeof useSWR>["0"], options?: use
|
|
|
43
44
|
* @param query
|
|
44
45
|
* @param options
|
|
45
46
|
*/
|
|
46
|
-
declare const useLazyQuery: <T, R = any>(query: Parameters<typeof useSWR>["0"], options?: (SWRMutationConfiguration<any, any
|
|
47
|
+
declare const useLazyQuery: <T, R = any>(query: Parameters<typeof useSWR>["0"], options?: (SWRMutationConfiguration<any, any> & {
|
|
47
48
|
formatter?: ((data: any) => R) | undefined;
|
|
48
49
|
init?: RequestInit | undefined;
|
|
49
50
|
}) | undefined) => SWRMutationResponse;
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
declare const useMutation: <T, E>(url: string, method?: HTTP_METHOD, options?: SWRMutationConfiguration<T, E
|
|
52
|
+
type HTTP_METHOD = "POST" | "PUT" | "DELETE";
|
|
53
|
+
declare const useMutation: <T, E>(url: string, method?: HTTP_METHOD, options?: SWRMutationConfiguration<T, E> | undefined) => readonly [(data: any, params?: any, options?: any) => Promise<any>, {
|
|
53
54
|
readonly data: any;
|
|
54
55
|
readonly error: E | undefined;
|
|
55
56
|
readonly reset: () => void;
|
|
@@ -96,7 +97,7 @@ declare function useLocalStorage<T>(key: string, initialValue: T): [any, (value:
|
|
|
96
97
|
|
|
97
98
|
declare const useWS: () => WS;
|
|
98
99
|
|
|
99
|
-
declare const useConfig: <T>(key?: ConfigKey
|
|
100
|
+
declare const useConfig: <T>(key?: ConfigKey, defaultValue?: T | undefined) => ConfigStore | T;
|
|
100
101
|
|
|
101
102
|
interface OrderlyConfigContextState {
|
|
102
103
|
fetcher?: (url: string, init: RequestInit) => Promise<any>;
|
|
@@ -116,7 +117,7 @@ interface OrderlyConfigContextState {
|
|
|
116
117
|
declare const OrderlyContext: react.Context<OrderlyConfigContextState>;
|
|
117
118
|
declare const OrderlyProvider: react.Provider<OrderlyConfigContextState>;
|
|
118
119
|
|
|
119
|
-
|
|
120
|
+
type RequireAtLeastOne<T, R extends keyof T = keyof T> = Omit<T, R> & {
|
|
120
121
|
[K in R]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<R, K>>>;
|
|
121
122
|
}[R];
|
|
122
123
|
interface ConfigProviderProps {
|
|
@@ -130,8 +131,8 @@ interface ConfigProviderProps {
|
|
|
130
131
|
}
|
|
131
132
|
declare const OrderlyConfigProvider: (props: PropsWithChildren<RequireAtLeastOne<ConfigProviderProps, "brokerId" | "configStore">>) => react_jsx_runtime.JSX.Element | null;
|
|
132
133
|
|
|
133
|
-
|
|
134
|
-
id:
|
|
134
|
+
type ConnectedChain = {
|
|
135
|
+
id: number;
|
|
135
136
|
};
|
|
136
137
|
interface WalletConnectorContextState {
|
|
137
138
|
connect: () => Promise<any[]>;
|
|
@@ -146,19 +147,19 @@ interface WalletConnectorContextState {
|
|
|
146
147
|
declare const WalletConnectorContext: react.Context<WalletConnectorContextState>;
|
|
147
148
|
declare const useWalletConnector: () => WalletConnectorContextState;
|
|
148
149
|
|
|
149
|
-
|
|
150
|
-
|
|
150
|
+
type OrderBookItem = number[];
|
|
151
|
+
type OrderbookData = {
|
|
151
152
|
asks: OrderBookItem[];
|
|
152
153
|
bids: OrderBookItem[];
|
|
153
154
|
};
|
|
154
|
-
|
|
155
|
+
type OrderbookOptions = {
|
|
155
156
|
level?: number;
|
|
156
157
|
};
|
|
157
158
|
/**
|
|
158
159
|
* @name useOrderbookStream
|
|
159
160
|
* @description React hook that returns the current orderbook for a given market
|
|
160
161
|
*/
|
|
161
|
-
declare const useOrderbookStream: (symbol: string, initial?: OrderbookData, options?: OrderbookOptions
|
|
162
|
+
declare const useOrderbookStream: (symbol: string, initial?: OrderbookData, options?: OrderbookOptions) => ({
|
|
162
163
|
asks: OrderBookItem[];
|
|
163
164
|
bids: OrderBookItem[];
|
|
164
165
|
markPrice: any;
|
|
@@ -180,7 +181,7 @@ declare const useOrderbookStream: (symbol: string, initial?: OrderbookData, opti
|
|
|
180
181
|
middlePrice?: undefined;
|
|
181
182
|
})[];
|
|
182
183
|
|
|
183
|
-
|
|
184
|
+
type UseOrderEntryOptions = {
|
|
184
185
|
commify?: boolean;
|
|
185
186
|
validate?: (data: OrderEntity) => {
|
|
186
187
|
[P in keyof OrderEntity]?: string;
|
|
@@ -191,7 +192,7 @@ declare type UseOrderEntryOptions = {
|
|
|
191
192
|
* @param symbol
|
|
192
193
|
* @returns
|
|
193
194
|
*/
|
|
194
|
-
declare const useOrderEntry: (symbol: string, side: OrderSide, reduceOnly?: boolean, options?: UseOrderEntryOptions
|
|
195
|
+
declare const useOrderEntry: (symbol: string, side: OrderSide, reduceOnly?: boolean, options?: UseOrderEntryOptions) => {
|
|
195
196
|
maxQty: number;
|
|
196
197
|
freeCollateral: number;
|
|
197
198
|
markPrice: any;
|
|
@@ -212,6 +213,37 @@ declare const useMarketsStream: () => {
|
|
|
212
213
|
data: WSMessage.Ticker[] | null;
|
|
213
214
|
};
|
|
214
215
|
|
|
216
|
+
declare enum MarketsType {
|
|
217
|
+
FAVORITES = 0,
|
|
218
|
+
RECENT = 1,
|
|
219
|
+
ALL = 2
|
|
220
|
+
}
|
|
221
|
+
interface FavoriteTab {
|
|
222
|
+
name: string;
|
|
223
|
+
id: number;
|
|
224
|
+
}
|
|
225
|
+
interface Recent {
|
|
226
|
+
name: string;
|
|
227
|
+
}
|
|
228
|
+
declare const useMarkets: (type: MarketsType) => readonly [_orderly_network_types.WSMessage.Ticker[], {
|
|
229
|
+
readonly favoriteTabs: FavoriteTab[];
|
|
230
|
+
readonly favorites: {
|
|
231
|
+
tabs: FavoriteTab[];
|
|
232
|
+
name: string;
|
|
233
|
+
}[];
|
|
234
|
+
readonly recent: Recent[];
|
|
235
|
+
readonly addToHistory: (symbol: API.MarketInfoExt) => void;
|
|
236
|
+
readonly updateFavoriteTabs: (tab: FavoriteTab | FavoriteTab[], operator?: {
|
|
237
|
+
add?: boolean;
|
|
238
|
+
update?: boolean;
|
|
239
|
+
delete?: boolean;
|
|
240
|
+
}) => void;
|
|
241
|
+
readonly updateSymbolFavoriteState: (symbol: API.MarketInfoExt, tab: FavoriteTab | FavoriteTab[], del?: boolean) => void;
|
|
242
|
+
readonly pinToTop: (symbol: API.MarketInfoExt) => void;
|
|
243
|
+
readonly getLastSelFavTab: () => FavoriteTab;
|
|
244
|
+
readonly updateSelectedFavoriteTab: (tab: FavoriteTab) => void;
|
|
245
|
+
}];
|
|
246
|
+
|
|
215
247
|
declare const useMarkPricesStream: () => swr_subscription.SWRSubscriptionResponse<any, any>;
|
|
216
248
|
|
|
217
249
|
declare const useMarkPrice: (symbol: string) => swr_subscription.SWRSubscriptionResponse<any, any>;
|
|
@@ -233,7 +265,10 @@ declare const useFundingRate: (symbol: string) => {
|
|
|
233
265
|
sum_unitary_funding?: number | undefined;
|
|
234
266
|
};
|
|
235
267
|
|
|
236
|
-
|
|
268
|
+
type PriceMode = "markPrice" | "lastPrice";
|
|
269
|
+
declare const usePositionStream: (symbol?: string, options?: SWRConfiguration & {
|
|
270
|
+
calcMode?: PriceMode;
|
|
271
|
+
}) => readonly [{
|
|
237
272
|
readonly rows: API.PositionExt[] | null;
|
|
238
273
|
readonly aggregated: any;
|
|
239
274
|
readonly totalCollateral: Decimal;
|
|
@@ -242,11 +277,10 @@ declare const usePositionStream: (symbol?: string | undefined, options?: Partial
|
|
|
242
277
|
}, any, {
|
|
243
278
|
readonly loading: false;
|
|
244
279
|
readonly error: any;
|
|
245
|
-
readonly
|
|
246
|
-
readonly refresh: () => void;
|
|
280
|
+
readonly refresh: swr__internal.KeyedMutator<API.PositionInfo>;
|
|
247
281
|
}];
|
|
248
282
|
|
|
249
|
-
|
|
283
|
+
type Params = {
|
|
250
284
|
symbol?: string;
|
|
251
285
|
status?: OrderStatus;
|
|
252
286
|
size?: number;
|
|
@@ -255,10 +289,11 @@ declare type Params = {
|
|
|
255
289
|
declare const useOrderStream: (params: Params) => readonly [any[] | null, {
|
|
256
290
|
readonly total: any;
|
|
257
291
|
readonly isLoading: boolean;
|
|
292
|
+
readonly refresh: swr__internal.KeyedMutator<any[]>;
|
|
258
293
|
readonly loadMore: () => void;
|
|
259
294
|
readonly cancelAllOrders: () => void;
|
|
260
295
|
readonly updateOrder: (orderId: string, order: OrderEntity) => Promise<any>;
|
|
261
|
-
readonly cancelOrder: (orderId:
|
|
296
|
+
readonly cancelOrder: (orderId: number, symbol?: string) => Promise<any>;
|
|
262
297
|
readonly errors: {
|
|
263
298
|
readonly cancelOrder: unknown;
|
|
264
299
|
readonly updateOrder: unknown;
|
|
@@ -277,37 +312,39 @@ declare const useMarketTradeStream: (symbol: string, options?: MarketTradeStream
|
|
|
277
312
|
isLoading: boolean;
|
|
278
313
|
};
|
|
279
314
|
|
|
280
|
-
|
|
315
|
+
type CollateralOutputs = {
|
|
281
316
|
totalCollateral: number;
|
|
282
317
|
freeCollateral: number;
|
|
283
318
|
totalValue: number;
|
|
284
319
|
availableBalance: number;
|
|
285
320
|
unsettledPnL: number;
|
|
286
321
|
};
|
|
287
|
-
|
|
322
|
+
type Options = {
|
|
288
323
|
dp: number;
|
|
289
324
|
};
|
|
290
325
|
declare const useCollateral: (options?: Options) => CollateralOutputs;
|
|
291
326
|
|
|
292
327
|
declare const useMaxQty: (symbol: string, side: OrderSide, reduceOnly?: boolean) => number;
|
|
293
328
|
|
|
294
|
-
|
|
329
|
+
type MarginRatioReturn = {
|
|
295
330
|
marginRatio: number;
|
|
296
331
|
currentLeverage: number;
|
|
332
|
+
mmr: number | null;
|
|
297
333
|
};
|
|
334
|
+
declare const useMarginRatio: () => MarginRatioReturn;
|
|
298
335
|
|
|
299
|
-
|
|
336
|
+
type inputOptions = {
|
|
300
337
|
filter?: (item: API.Chain) => boolean;
|
|
301
338
|
pick?: "dexs" | "network_infos" | "token_infos";
|
|
302
339
|
crossEnabled?: boolean;
|
|
303
340
|
/** if true, use wooSwap api, else use orderly api only */
|
|
304
341
|
wooSwapEnabled?: boolean;
|
|
305
342
|
};
|
|
306
|
-
declare const useChains: (networkId?: NetworkId
|
|
343
|
+
declare const useChains: (networkId?: NetworkId, options?: inputOptions & SWRConfiguration) => readonly [API.Chain[] | {
|
|
307
344
|
testnet: API.Chain[];
|
|
308
345
|
mainnet: API.Chain[];
|
|
309
346
|
}, {
|
|
310
|
-
readonly findByChainId: (chainId: number, field?: string
|
|
347
|
+
readonly findByChainId: (chainId: number, field?: string) => (API.Chain & {
|
|
311
348
|
nativeToken?: API.TokenInfo | undefined;
|
|
312
349
|
}) | (<K extends never>(prop: K) => ((API.Chain & {
|
|
313
350
|
nativeToken?: API.TokenInfo | undefined;
|
|
@@ -333,7 +370,7 @@ declare const useWithdraw: () => {
|
|
|
333
370
|
unsettledPnL: number;
|
|
334
371
|
};
|
|
335
372
|
|
|
336
|
-
|
|
373
|
+
type useDepositOptions = {
|
|
337
374
|
address?: string;
|
|
338
375
|
decimals?: number;
|
|
339
376
|
crossChainRouteAddress?: string;
|
|
@@ -341,12 +378,14 @@ declare type useDepositOptions = {
|
|
|
341
378
|
networkId?: NetworkId;
|
|
342
379
|
srcChainId?: number;
|
|
343
380
|
srcToken?: string;
|
|
381
|
+
quantity?: string;
|
|
344
382
|
/**
|
|
345
383
|
* @hidden
|
|
346
384
|
*/
|
|
347
385
|
wooSwapEnabled?: boolean;
|
|
348
386
|
};
|
|
349
|
-
declare const useDeposit: (options?: useDepositOptions
|
|
387
|
+
declare const useDeposit: (options?: useDepositOptions) => {
|
|
388
|
+
/** orderly support chain dst */
|
|
350
389
|
dst: {
|
|
351
390
|
symbol: string;
|
|
352
391
|
address: string | undefined;
|
|
@@ -359,11 +398,18 @@ declare const useDeposit: (options?: useDepositOptions | undefined) => {
|
|
|
359
398
|
isNativeToken: boolean;
|
|
360
399
|
balanceRevalidating: boolean;
|
|
361
400
|
allowanceRevalidating: boolean;
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
401
|
+
/** input quantiy */
|
|
402
|
+
quantity: string;
|
|
403
|
+
/** orderly deposit fee, unit: wei */
|
|
404
|
+
depositFee: bigint;
|
|
405
|
+
/** enquiring depositFee status on chain */
|
|
406
|
+
depositFeeRevalidating: boolean;
|
|
407
|
+
approve: (amount?: string) => Promise<any>;
|
|
408
|
+
deposit: () => Promise<any>;
|
|
365
409
|
fetchBalances: (tokens: API.TokenInfo[]) => Promise<void>;
|
|
366
|
-
fetchBalance: (address: string, decimals?: number
|
|
410
|
+
fetchBalance: (address: string, decimals?: number) => Promise<string>;
|
|
411
|
+
/** set input quantity */
|
|
412
|
+
setQuantity: react.Dispatch<react.SetStateAction<string>>;
|
|
367
413
|
};
|
|
368
414
|
|
|
369
415
|
declare const useHoldingStream: () => {
|
|
@@ -380,7 +426,11 @@ declare const useSettleSubscription: (options?: {
|
|
|
380
426
|
onMessage?: ((data: any) => void) | undefined;
|
|
381
427
|
} | undefined) => swr_subscription.SWRSubscriptionResponse<any, any>;
|
|
382
428
|
|
|
383
|
-
|
|
429
|
+
type getKeyFunction = (index: number, prevData: any) => string | null;
|
|
430
|
+
|
|
431
|
+
declare const usePrivateDataObserver: (options: {
|
|
432
|
+
getKeysMap: (type: string) => Map<string, getKeyFunction>;
|
|
433
|
+
}) => void;
|
|
384
434
|
|
|
385
435
|
declare function useMediaQuery(query: string): boolean;
|
|
386
436
|
|
|
@@ -409,4 +459,4 @@ declare const useCrossSwap: () => any;
|
|
|
409
459
|
/** @hidden */
|
|
410
460
|
declare const useSwap: () => any;
|
|
411
461
|
|
|
412
|
-
export { ConfigProviderProps, OrderlyConfigContextState, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, WalletConnectorContext, useAccount, useAccountInfo, useAccountInstance, useBoolean, useChain, useChains, useCollateral, useConfig, useCrossSwap, useDeposit, useEventEmitter, useFundingRate, useHoldingStream, useIndexPrice, useLazyQuery, useLeverage, useLocalStorage, useMarginRatio, useMarkPrice, useMarkPricesStream, useMarketTradeStream, useMarketsStream, useMaxQty, useMediaQuery, useMutation, useOrderEntry, useOrderStream, useOrderbookStream, usePositionStream, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, useSessionStorage, useSettleSubscription, useSwap, useSymbolsInfo, useTickerStream, useWS, useWalletConnector, useWalletSubscription, useWithdraw, useWooCrossSwapQuery, useWooSwapQuery, _default as version };
|
|
462
|
+
export { ConfigProviderProps, MarketsType, OrderlyConfigContextState, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, WalletConnectorContext, useAccount, useAccountInfo, useAccountInstance, useBoolean, useChain, useChains, useCollateral, useConfig, useCrossSwap, useDeposit, useEventEmitter, useFundingRate, useHoldingStream, useIndexPrice, useLazyQuery, useLeverage, useLocalStorage, useMarginRatio, useMarkPrice, useMarkPricesStream, useMarketTradeStream, useMarkets, useMarketsStream, useMaxQty, useMediaQuery, useMutation, useOrderEntry, useOrderStream, useOrderbookStream, usePositionStream, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, useSessionStorage, useSettleSubscription, useSwap, useSymbolsInfo, useTickerStream, useWS, useWalletConnector, useWalletSubscription, useWithdraw, useWooCrossSwapQuery, useWooSwapQuery, _default as version };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import useSWR, { SWRConfiguration, SWRResponse } from 'swr';
|
|
2
2
|
export { SWRConfig, SWRConfiguration, default as useSWR } from 'swr';
|
|
3
|
-
import * as swr__internal from 'swr/_internal';
|
|
4
3
|
import { SWRMutationConfiguration, SWRMutationResponse } from 'swr/mutation';
|
|
5
4
|
import * as swr_infinite from 'swr/infinite';
|
|
6
5
|
import { SWRInfiniteKeyLoader, SWRInfiniteConfiguration } from 'swr/infinite';
|
|
6
|
+
import * as swr__internal from 'swr/_internal';
|
|
7
7
|
import * as _orderly_network_core from '@orderly.network/core';
|
|
8
8
|
import { AccountState, Account, EventEmitter, ConfigKey, ConfigStore, OrderlyKeyStore, getWalletAdapterFunc, IContract } from '@orderly.network/core';
|
|
9
9
|
export { default as useConstant } from 'use-constant';
|
|
10
10
|
import { WS } from '@orderly.network/net';
|
|
11
11
|
import * as react from 'react';
|
|
12
12
|
import { PropsWithChildren } from 'react';
|
|
13
|
+
import * as _orderly_network_types from '@orderly.network/types';
|
|
13
14
|
import { NetworkId, OrderSide, OrderEntity, API, WSMessage, OrderStatus } from '@orderly.network/types';
|
|
14
15
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
15
16
|
import * as swr_subscription from 'swr/subscription';
|
|
@@ -23,9 +24,9 @@ declare global {
|
|
|
23
24
|
};
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
|
-
declare const _default: "1.0.28-alpha.
|
|
27
|
+
declare const _default: "1.0.28-alpha.20";
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
type useQueryOptions<T> = SWRConfiguration & {
|
|
29
30
|
formatter?: (data: any) => T;
|
|
30
31
|
};
|
|
31
32
|
|
|
@@ -43,13 +44,13 @@ declare const useQuery: <T>(query: Parameters<typeof useSWR>["0"], options?: use
|
|
|
43
44
|
* @param query
|
|
44
45
|
* @param options
|
|
45
46
|
*/
|
|
46
|
-
declare const useLazyQuery: <T, R = any>(query: Parameters<typeof useSWR>["0"], options?: (SWRMutationConfiguration<any, any
|
|
47
|
+
declare const useLazyQuery: <T, R = any>(query: Parameters<typeof useSWR>["0"], options?: (SWRMutationConfiguration<any, any> & {
|
|
47
48
|
formatter?: ((data: any) => R) | undefined;
|
|
48
49
|
init?: RequestInit | undefined;
|
|
49
50
|
}) | undefined) => SWRMutationResponse;
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
declare const useMutation: <T, E>(url: string, method?: HTTP_METHOD, options?: SWRMutationConfiguration<T, E
|
|
52
|
+
type HTTP_METHOD = "POST" | "PUT" | "DELETE";
|
|
53
|
+
declare const useMutation: <T, E>(url: string, method?: HTTP_METHOD, options?: SWRMutationConfiguration<T, E> | undefined) => readonly [(data: any, params?: any, options?: any) => Promise<any>, {
|
|
53
54
|
readonly data: any;
|
|
54
55
|
readonly error: E | undefined;
|
|
55
56
|
readonly reset: () => void;
|
|
@@ -96,7 +97,7 @@ declare function useLocalStorage<T>(key: string, initialValue: T): [any, (value:
|
|
|
96
97
|
|
|
97
98
|
declare const useWS: () => WS;
|
|
98
99
|
|
|
99
|
-
declare const useConfig: <T>(key?: ConfigKey
|
|
100
|
+
declare const useConfig: <T>(key?: ConfigKey, defaultValue?: T | undefined) => ConfigStore | T;
|
|
100
101
|
|
|
101
102
|
interface OrderlyConfigContextState {
|
|
102
103
|
fetcher?: (url: string, init: RequestInit) => Promise<any>;
|
|
@@ -116,7 +117,7 @@ interface OrderlyConfigContextState {
|
|
|
116
117
|
declare const OrderlyContext: react.Context<OrderlyConfigContextState>;
|
|
117
118
|
declare const OrderlyProvider: react.Provider<OrderlyConfigContextState>;
|
|
118
119
|
|
|
119
|
-
|
|
120
|
+
type RequireAtLeastOne<T, R extends keyof T = keyof T> = Omit<T, R> & {
|
|
120
121
|
[K in R]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<R, K>>>;
|
|
121
122
|
}[R];
|
|
122
123
|
interface ConfigProviderProps {
|
|
@@ -130,8 +131,8 @@ interface ConfigProviderProps {
|
|
|
130
131
|
}
|
|
131
132
|
declare const OrderlyConfigProvider: (props: PropsWithChildren<RequireAtLeastOne<ConfigProviderProps, "brokerId" | "configStore">>) => react_jsx_runtime.JSX.Element | null;
|
|
132
133
|
|
|
133
|
-
|
|
134
|
-
id:
|
|
134
|
+
type ConnectedChain = {
|
|
135
|
+
id: number;
|
|
135
136
|
};
|
|
136
137
|
interface WalletConnectorContextState {
|
|
137
138
|
connect: () => Promise<any[]>;
|
|
@@ -146,19 +147,19 @@ interface WalletConnectorContextState {
|
|
|
146
147
|
declare const WalletConnectorContext: react.Context<WalletConnectorContextState>;
|
|
147
148
|
declare const useWalletConnector: () => WalletConnectorContextState;
|
|
148
149
|
|
|
149
|
-
|
|
150
|
-
|
|
150
|
+
type OrderBookItem = number[];
|
|
151
|
+
type OrderbookData = {
|
|
151
152
|
asks: OrderBookItem[];
|
|
152
153
|
bids: OrderBookItem[];
|
|
153
154
|
};
|
|
154
|
-
|
|
155
|
+
type OrderbookOptions = {
|
|
155
156
|
level?: number;
|
|
156
157
|
};
|
|
157
158
|
/**
|
|
158
159
|
* @name useOrderbookStream
|
|
159
160
|
* @description React hook that returns the current orderbook for a given market
|
|
160
161
|
*/
|
|
161
|
-
declare const useOrderbookStream: (symbol: string, initial?: OrderbookData, options?: OrderbookOptions
|
|
162
|
+
declare const useOrderbookStream: (symbol: string, initial?: OrderbookData, options?: OrderbookOptions) => ({
|
|
162
163
|
asks: OrderBookItem[];
|
|
163
164
|
bids: OrderBookItem[];
|
|
164
165
|
markPrice: any;
|
|
@@ -180,7 +181,7 @@ declare const useOrderbookStream: (symbol: string, initial?: OrderbookData, opti
|
|
|
180
181
|
middlePrice?: undefined;
|
|
181
182
|
})[];
|
|
182
183
|
|
|
183
|
-
|
|
184
|
+
type UseOrderEntryOptions = {
|
|
184
185
|
commify?: boolean;
|
|
185
186
|
validate?: (data: OrderEntity) => {
|
|
186
187
|
[P in keyof OrderEntity]?: string;
|
|
@@ -191,7 +192,7 @@ declare type UseOrderEntryOptions = {
|
|
|
191
192
|
* @param symbol
|
|
192
193
|
* @returns
|
|
193
194
|
*/
|
|
194
|
-
declare const useOrderEntry: (symbol: string, side: OrderSide, reduceOnly?: boolean, options?: UseOrderEntryOptions
|
|
195
|
+
declare const useOrderEntry: (symbol: string, side: OrderSide, reduceOnly?: boolean, options?: UseOrderEntryOptions) => {
|
|
195
196
|
maxQty: number;
|
|
196
197
|
freeCollateral: number;
|
|
197
198
|
markPrice: any;
|
|
@@ -212,6 +213,37 @@ declare const useMarketsStream: () => {
|
|
|
212
213
|
data: WSMessage.Ticker[] | null;
|
|
213
214
|
};
|
|
214
215
|
|
|
216
|
+
declare enum MarketsType {
|
|
217
|
+
FAVORITES = 0,
|
|
218
|
+
RECENT = 1,
|
|
219
|
+
ALL = 2
|
|
220
|
+
}
|
|
221
|
+
interface FavoriteTab {
|
|
222
|
+
name: string;
|
|
223
|
+
id: number;
|
|
224
|
+
}
|
|
225
|
+
interface Recent {
|
|
226
|
+
name: string;
|
|
227
|
+
}
|
|
228
|
+
declare const useMarkets: (type: MarketsType) => readonly [_orderly_network_types.WSMessage.Ticker[], {
|
|
229
|
+
readonly favoriteTabs: FavoriteTab[];
|
|
230
|
+
readonly favorites: {
|
|
231
|
+
tabs: FavoriteTab[];
|
|
232
|
+
name: string;
|
|
233
|
+
}[];
|
|
234
|
+
readonly recent: Recent[];
|
|
235
|
+
readonly addToHistory: (symbol: API.MarketInfoExt) => void;
|
|
236
|
+
readonly updateFavoriteTabs: (tab: FavoriteTab | FavoriteTab[], operator?: {
|
|
237
|
+
add?: boolean;
|
|
238
|
+
update?: boolean;
|
|
239
|
+
delete?: boolean;
|
|
240
|
+
}) => void;
|
|
241
|
+
readonly updateSymbolFavoriteState: (symbol: API.MarketInfoExt, tab: FavoriteTab | FavoriteTab[], del?: boolean) => void;
|
|
242
|
+
readonly pinToTop: (symbol: API.MarketInfoExt) => void;
|
|
243
|
+
readonly getLastSelFavTab: () => FavoriteTab;
|
|
244
|
+
readonly updateSelectedFavoriteTab: (tab: FavoriteTab) => void;
|
|
245
|
+
}];
|
|
246
|
+
|
|
215
247
|
declare const useMarkPricesStream: () => swr_subscription.SWRSubscriptionResponse<any, any>;
|
|
216
248
|
|
|
217
249
|
declare const useMarkPrice: (symbol: string) => swr_subscription.SWRSubscriptionResponse<any, any>;
|
|
@@ -233,7 +265,10 @@ declare const useFundingRate: (symbol: string) => {
|
|
|
233
265
|
sum_unitary_funding?: number | undefined;
|
|
234
266
|
};
|
|
235
267
|
|
|
236
|
-
|
|
268
|
+
type PriceMode = "markPrice" | "lastPrice";
|
|
269
|
+
declare const usePositionStream: (symbol?: string, options?: SWRConfiguration & {
|
|
270
|
+
calcMode?: PriceMode;
|
|
271
|
+
}) => readonly [{
|
|
237
272
|
readonly rows: API.PositionExt[] | null;
|
|
238
273
|
readonly aggregated: any;
|
|
239
274
|
readonly totalCollateral: Decimal;
|
|
@@ -242,11 +277,10 @@ declare const usePositionStream: (symbol?: string | undefined, options?: Partial
|
|
|
242
277
|
}, any, {
|
|
243
278
|
readonly loading: false;
|
|
244
279
|
readonly error: any;
|
|
245
|
-
readonly
|
|
246
|
-
readonly refresh: () => void;
|
|
280
|
+
readonly refresh: swr__internal.KeyedMutator<API.PositionInfo>;
|
|
247
281
|
}];
|
|
248
282
|
|
|
249
|
-
|
|
283
|
+
type Params = {
|
|
250
284
|
symbol?: string;
|
|
251
285
|
status?: OrderStatus;
|
|
252
286
|
size?: number;
|
|
@@ -255,10 +289,11 @@ declare type Params = {
|
|
|
255
289
|
declare const useOrderStream: (params: Params) => readonly [any[] | null, {
|
|
256
290
|
readonly total: any;
|
|
257
291
|
readonly isLoading: boolean;
|
|
292
|
+
readonly refresh: swr__internal.KeyedMutator<any[]>;
|
|
258
293
|
readonly loadMore: () => void;
|
|
259
294
|
readonly cancelAllOrders: () => void;
|
|
260
295
|
readonly updateOrder: (orderId: string, order: OrderEntity) => Promise<any>;
|
|
261
|
-
readonly cancelOrder: (orderId:
|
|
296
|
+
readonly cancelOrder: (orderId: number, symbol?: string) => Promise<any>;
|
|
262
297
|
readonly errors: {
|
|
263
298
|
readonly cancelOrder: unknown;
|
|
264
299
|
readonly updateOrder: unknown;
|
|
@@ -277,37 +312,39 @@ declare const useMarketTradeStream: (symbol: string, options?: MarketTradeStream
|
|
|
277
312
|
isLoading: boolean;
|
|
278
313
|
};
|
|
279
314
|
|
|
280
|
-
|
|
315
|
+
type CollateralOutputs = {
|
|
281
316
|
totalCollateral: number;
|
|
282
317
|
freeCollateral: number;
|
|
283
318
|
totalValue: number;
|
|
284
319
|
availableBalance: number;
|
|
285
320
|
unsettledPnL: number;
|
|
286
321
|
};
|
|
287
|
-
|
|
322
|
+
type Options = {
|
|
288
323
|
dp: number;
|
|
289
324
|
};
|
|
290
325
|
declare const useCollateral: (options?: Options) => CollateralOutputs;
|
|
291
326
|
|
|
292
327
|
declare const useMaxQty: (symbol: string, side: OrderSide, reduceOnly?: boolean) => number;
|
|
293
328
|
|
|
294
|
-
|
|
329
|
+
type MarginRatioReturn = {
|
|
295
330
|
marginRatio: number;
|
|
296
331
|
currentLeverage: number;
|
|
332
|
+
mmr: number | null;
|
|
297
333
|
};
|
|
334
|
+
declare const useMarginRatio: () => MarginRatioReturn;
|
|
298
335
|
|
|
299
|
-
|
|
336
|
+
type inputOptions = {
|
|
300
337
|
filter?: (item: API.Chain) => boolean;
|
|
301
338
|
pick?: "dexs" | "network_infos" | "token_infos";
|
|
302
339
|
crossEnabled?: boolean;
|
|
303
340
|
/** if true, use wooSwap api, else use orderly api only */
|
|
304
341
|
wooSwapEnabled?: boolean;
|
|
305
342
|
};
|
|
306
|
-
declare const useChains: (networkId?: NetworkId
|
|
343
|
+
declare const useChains: (networkId?: NetworkId, options?: inputOptions & SWRConfiguration) => readonly [API.Chain[] | {
|
|
307
344
|
testnet: API.Chain[];
|
|
308
345
|
mainnet: API.Chain[];
|
|
309
346
|
}, {
|
|
310
|
-
readonly findByChainId: (chainId: number, field?: string
|
|
347
|
+
readonly findByChainId: (chainId: number, field?: string) => (API.Chain & {
|
|
311
348
|
nativeToken?: API.TokenInfo | undefined;
|
|
312
349
|
}) | (<K extends never>(prop: K) => ((API.Chain & {
|
|
313
350
|
nativeToken?: API.TokenInfo | undefined;
|
|
@@ -333,7 +370,7 @@ declare const useWithdraw: () => {
|
|
|
333
370
|
unsettledPnL: number;
|
|
334
371
|
};
|
|
335
372
|
|
|
336
|
-
|
|
373
|
+
type useDepositOptions = {
|
|
337
374
|
address?: string;
|
|
338
375
|
decimals?: number;
|
|
339
376
|
crossChainRouteAddress?: string;
|
|
@@ -341,12 +378,14 @@ declare type useDepositOptions = {
|
|
|
341
378
|
networkId?: NetworkId;
|
|
342
379
|
srcChainId?: number;
|
|
343
380
|
srcToken?: string;
|
|
381
|
+
quantity?: string;
|
|
344
382
|
/**
|
|
345
383
|
* @hidden
|
|
346
384
|
*/
|
|
347
385
|
wooSwapEnabled?: boolean;
|
|
348
386
|
};
|
|
349
|
-
declare const useDeposit: (options?: useDepositOptions
|
|
387
|
+
declare const useDeposit: (options?: useDepositOptions) => {
|
|
388
|
+
/** orderly support chain dst */
|
|
350
389
|
dst: {
|
|
351
390
|
symbol: string;
|
|
352
391
|
address: string | undefined;
|
|
@@ -359,11 +398,18 @@ declare const useDeposit: (options?: useDepositOptions | undefined) => {
|
|
|
359
398
|
isNativeToken: boolean;
|
|
360
399
|
balanceRevalidating: boolean;
|
|
361
400
|
allowanceRevalidating: boolean;
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
401
|
+
/** input quantiy */
|
|
402
|
+
quantity: string;
|
|
403
|
+
/** orderly deposit fee, unit: wei */
|
|
404
|
+
depositFee: bigint;
|
|
405
|
+
/** enquiring depositFee status on chain */
|
|
406
|
+
depositFeeRevalidating: boolean;
|
|
407
|
+
approve: (amount?: string) => Promise<any>;
|
|
408
|
+
deposit: () => Promise<any>;
|
|
365
409
|
fetchBalances: (tokens: API.TokenInfo[]) => Promise<void>;
|
|
366
|
-
fetchBalance: (address: string, decimals?: number
|
|
410
|
+
fetchBalance: (address: string, decimals?: number) => Promise<string>;
|
|
411
|
+
/** set input quantity */
|
|
412
|
+
setQuantity: react.Dispatch<react.SetStateAction<string>>;
|
|
367
413
|
};
|
|
368
414
|
|
|
369
415
|
declare const useHoldingStream: () => {
|
|
@@ -380,7 +426,11 @@ declare const useSettleSubscription: (options?: {
|
|
|
380
426
|
onMessage?: ((data: any) => void) | undefined;
|
|
381
427
|
} | undefined) => swr_subscription.SWRSubscriptionResponse<any, any>;
|
|
382
428
|
|
|
383
|
-
|
|
429
|
+
type getKeyFunction = (index: number, prevData: any) => string | null;
|
|
430
|
+
|
|
431
|
+
declare const usePrivateDataObserver: (options: {
|
|
432
|
+
getKeysMap: (type: string) => Map<string, getKeyFunction>;
|
|
433
|
+
}) => void;
|
|
384
434
|
|
|
385
435
|
declare function useMediaQuery(query: string): boolean;
|
|
386
436
|
|
|
@@ -409,4 +459,4 @@ declare const useCrossSwap: () => any;
|
|
|
409
459
|
/** @hidden */
|
|
410
460
|
declare const useSwap: () => any;
|
|
411
461
|
|
|
412
|
-
export { ConfigProviderProps, OrderlyConfigContextState, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, WalletConnectorContext, useAccount, useAccountInfo, useAccountInstance, useBoolean, useChain, useChains, useCollateral, useConfig, useCrossSwap, useDeposit, useEventEmitter, useFundingRate, useHoldingStream, useIndexPrice, useLazyQuery, useLeverage, useLocalStorage, useMarginRatio, useMarkPrice, useMarkPricesStream, useMarketTradeStream, useMarketsStream, useMaxQty, useMediaQuery, useMutation, useOrderEntry, useOrderStream, useOrderbookStream, usePositionStream, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, useSessionStorage, useSettleSubscription, useSwap, useSymbolsInfo, useTickerStream, useWS, useWalletConnector, useWalletSubscription, useWithdraw, useWooCrossSwapQuery, useWooSwapQuery, _default as version };
|
|
462
|
+
export { ConfigProviderProps, MarketsType, OrderlyConfigContextState, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, WalletConnectorContext, useAccount, useAccountInfo, useAccountInstance, useBoolean, useChain, useChains, useCollateral, useConfig, useCrossSwap, useDeposit, useEventEmitter, useFundingRate, useHoldingStream, useIndexPrice, useLazyQuery, useLeverage, useLocalStorage, useMarginRatio, useMarkPrice, useMarkPricesStream, useMarketTradeStream, useMarkets, useMarketsStream, useMaxQty, useMediaQuery, useMutation, useOrderEntry, useOrderStream, useOrderbookStream, usePositionStream, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, useSessionStorage, useSettleSubscription, useSwap, useSymbolsInfo, useTickerStream, useWS, useWalletConnector, useWalletSubscription, useWithdraw, useWooCrossSwapQuery, useWooSwapQuery, _default as version };
|