@orderly.network/hooks 1.0.2 → 1.0.4
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 +46 -27
- package/dist/index.d.ts +46 -27
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
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';
|
|
3
4
|
import { SWRMutationConfiguration, SWRMutationResponse } from 'swr/mutation';
|
|
4
5
|
import * as swr_infinite from 'swr/infinite';
|
|
5
6
|
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 } 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
|
-
import {
|
|
12
|
+
import react__default, { PropsWithChildren } from 'react';
|
|
13
13
|
import { NetworkId, OrderSide, OrderEntity, API, WSMessage, OrderStatus, WS_WalletStatusEnum } from '@orderly.network/types';
|
|
14
14
|
import * as swr_subscription from 'swr/subscription';
|
|
15
15
|
import { Decimal } from '@orderly.network/utils';
|
|
16
16
|
export * from 'use-debounce';
|
|
17
17
|
|
|
18
|
-
type useQueryOptions<T> = SWRConfiguration & {
|
|
18
|
+
declare type useQueryOptions<T> = SWRConfiguration & {
|
|
19
19
|
formatter?: (data: any) => T;
|
|
20
20
|
};
|
|
21
21
|
|
|
@@ -33,13 +33,13 @@ declare const useQuery: <T>(query: Parameters<typeof useSWR>["0"], options?: use
|
|
|
33
33
|
* @param query
|
|
34
34
|
* @param options
|
|
35
35
|
*/
|
|
36
|
-
declare const useLazyQuery: <T, R = any>(query: Parameters<typeof useSWR>["0"], options?: (SWRMutationConfiguration<any, any> & {
|
|
36
|
+
declare const useLazyQuery: <T, R = any>(query: Parameters<typeof useSWR>["0"], options?: (SWRMutationConfiguration<any, any, swr__internal.Key, any, any> & {
|
|
37
37
|
formatter?: ((data: any) => R) | undefined;
|
|
38
38
|
init?: RequestInit | undefined;
|
|
39
39
|
}) | undefined) => SWRMutationResponse;
|
|
40
40
|
|
|
41
|
-
type HTTP_METHOD = "POST" | "PUT" | "DELETE";
|
|
42
|
-
declare const useMutation: <T, E>(url: string, method?: HTTP_METHOD, options?: SWRMutationConfiguration<T, E> | undefined) => readonly [(data: any, params?: any) => Promise<any>, {
|
|
41
|
+
declare type HTTP_METHOD = "POST" | "PUT" | "DELETE";
|
|
42
|
+
declare const useMutation: <T, E>(url: string, method?: HTTP_METHOD, options?: SWRMutationConfiguration<T, E, swr__internal.Key, any, any> | undefined) => readonly [(data: any, params?: any) => Promise<any>, {
|
|
43
43
|
readonly data: any;
|
|
44
44
|
readonly error: E | undefined;
|
|
45
45
|
readonly reset: () => void;
|
|
@@ -86,7 +86,7 @@ declare function useLocalStorage<T>(key: string, initialValue: T): [any, (value:
|
|
|
86
86
|
|
|
87
87
|
declare const useWS: () => WS;
|
|
88
88
|
|
|
89
|
-
declare const useConfig: <T>(key?: ConfigKey, defaultValue?: T | undefined) => ConfigStore | T;
|
|
89
|
+
declare const useConfig: <T>(key?: ConfigKey | undefined, defaultValue?: T | undefined) => ConfigStore | T;
|
|
90
90
|
|
|
91
91
|
interface OrderlyConfigContextState {
|
|
92
92
|
fetcher?: (url: string, init: RequestInit) => Promise<any>;
|
|
@@ -99,7 +99,7 @@ interface OrderlyConfigContextState {
|
|
|
99
99
|
declare const OrderlyContext: react.Context<OrderlyConfigContextState>;
|
|
100
100
|
declare const OrderlyProvider: react.Provider<OrderlyConfigContextState>;
|
|
101
101
|
|
|
102
|
-
type RequireAtLeastOne<T, R extends keyof T = keyof T> = Omit<T, R> & {
|
|
102
|
+
declare type RequireAtLeastOne<T, R extends keyof T = keyof T> = Omit<T, R> & {
|
|
103
103
|
[K in R]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<R, K>>>;
|
|
104
104
|
}[R];
|
|
105
105
|
interface ConfigProviderProps {
|
|
@@ -109,21 +109,40 @@ interface ConfigProviderProps {
|
|
|
109
109
|
brokerId: string;
|
|
110
110
|
networkId: NetworkId;
|
|
111
111
|
}
|
|
112
|
-
declare const OrderlyConfigProvider:
|
|
112
|
+
declare const OrderlyConfigProvider: (props: PropsWithChildren<RequireAtLeastOne<ConfigProviderProps, "brokerId" | "configStore">>) => react__default.JSX.Element | null;
|
|
113
|
+
|
|
114
|
+
declare type ConnectedChain = {
|
|
115
|
+
id: string;
|
|
116
|
+
};
|
|
117
|
+
interface WalletConnectorContextState {
|
|
118
|
+
connect: () => Promise<any[]>;
|
|
119
|
+
disconnect: (options: any) => Promise<any[]>;
|
|
120
|
+
connecting: boolean;
|
|
121
|
+
setChain: (options: any) => Promise<any>;
|
|
122
|
+
chains: any[];
|
|
123
|
+
switchChain: (options: {
|
|
124
|
+
chainId: string;
|
|
125
|
+
}) => Promise<any>;
|
|
126
|
+
wallet: any;
|
|
127
|
+
connectedChain: ConnectedChain | null;
|
|
128
|
+
settingChain: boolean;
|
|
129
|
+
}
|
|
130
|
+
declare const WalletConnectorContext: react.Context<WalletConnectorContextState>;
|
|
131
|
+
declare const useWalletConnector: () => WalletConnectorContextState;
|
|
113
132
|
|
|
114
|
-
type OrderBookItem = number[];
|
|
115
|
-
type OrderbookData = {
|
|
133
|
+
declare type OrderBookItem = number[];
|
|
134
|
+
declare type OrderbookData = {
|
|
116
135
|
asks: OrderBookItem[];
|
|
117
136
|
bids: OrderBookItem[];
|
|
118
137
|
};
|
|
119
|
-
type OrderbookOptions = {
|
|
138
|
+
declare type OrderbookOptions = {
|
|
120
139
|
level?: number;
|
|
121
140
|
};
|
|
122
141
|
/**
|
|
123
142
|
* @name useOrderbookStream
|
|
124
143
|
* @description React hook that returns the current orderbook for a given market
|
|
125
144
|
*/
|
|
126
|
-
declare const useOrderbookStream: (symbol: string, initial?: OrderbookData, options?: OrderbookOptions) => ({
|
|
145
|
+
declare const useOrderbookStream: (symbol: string, initial?: OrderbookData, options?: OrderbookOptions | undefined) => ({
|
|
127
146
|
asks: OrderBookItem[];
|
|
128
147
|
bids: OrderBookItem[];
|
|
129
148
|
markPrice: any;
|
|
@@ -145,7 +164,7 @@ declare const useOrderbookStream: (symbol: string, initial?: OrderbookData, opti
|
|
|
145
164
|
middlePrice?: undefined;
|
|
146
165
|
})[];
|
|
147
166
|
|
|
148
|
-
type UseOrderEntryOptions = {
|
|
167
|
+
declare type UseOrderEntryOptions = {
|
|
149
168
|
commify?: boolean;
|
|
150
169
|
validate?: (data: OrderEntity) => {
|
|
151
170
|
[P in keyof OrderEntity]?: string;
|
|
@@ -156,7 +175,7 @@ type UseOrderEntryOptions = {
|
|
|
156
175
|
* @param symbol
|
|
157
176
|
* @returns
|
|
158
177
|
*/
|
|
159
|
-
declare const useOrderEntry: (symbol: string, side: OrderSide, reduceOnly?: boolean, options?: UseOrderEntryOptions) => {
|
|
178
|
+
declare const useOrderEntry: (symbol: string, side: OrderSide, reduceOnly?: boolean, options?: UseOrderEntryOptions | undefined) => {
|
|
160
179
|
maxQty: number;
|
|
161
180
|
freeCollateral: number;
|
|
162
181
|
markPrice: any;
|
|
@@ -200,7 +219,7 @@ declare const useFundingRate: (symbol: string) => {
|
|
|
200
219
|
sum_unitary_funding?: number | undefined;
|
|
201
220
|
};
|
|
202
221
|
|
|
203
|
-
declare const usePositionStream: (symbol?: string, options?:
|
|
222
|
+
declare const usePositionStream: (symbol?: string | undefined, options?: Partial<swr__internal.PublicConfiguration<any, any, swr__internal.BareFetcher<any>>> | undefined) => readonly [{
|
|
204
223
|
readonly rows: API.PositionExt[] | null;
|
|
205
224
|
readonly aggregated: any;
|
|
206
225
|
readonly totalCollateral: Decimal;
|
|
@@ -213,7 +232,7 @@ declare const usePositionStream: (symbol?: string, options?: SWRConfiguration) =
|
|
|
213
232
|
readonly refresh: () => void;
|
|
214
233
|
}];
|
|
215
234
|
|
|
216
|
-
type Params = {
|
|
235
|
+
declare type Params = {
|
|
217
236
|
symbol?: string;
|
|
218
237
|
status?: OrderStatus;
|
|
219
238
|
size?: number;
|
|
@@ -225,7 +244,7 @@ declare const useOrderStream: (params: Params) => readonly [any[] | null, {
|
|
|
225
244
|
readonly loadMore: () => void;
|
|
226
245
|
readonly cancelAllOrders: () => void;
|
|
227
246
|
readonly updateOrder: (orderId: string, order: OrderEntity) => Promise<any>;
|
|
228
|
-
readonly cancelOrder: (orderId: string, symbol?: string) => Promise<void>;
|
|
247
|
+
readonly cancelOrder: (orderId: string, symbol?: string | undefined) => Promise<void>;
|
|
229
248
|
}];
|
|
230
249
|
|
|
231
250
|
interface MarketTradeStreamOptions {
|
|
@@ -236,14 +255,14 @@ declare const useMarketTradeStream: (symbol: string, options?: MarketTradeStream
|
|
|
236
255
|
isLoading: boolean;
|
|
237
256
|
};
|
|
238
257
|
|
|
239
|
-
type CollateralOutputs = {
|
|
258
|
+
declare type CollateralOutputs = {
|
|
240
259
|
totalCollateral: number;
|
|
241
260
|
freeCollateral: number;
|
|
242
261
|
totalValue: number;
|
|
243
262
|
availableBalance: number;
|
|
244
263
|
unsettledPnL: number;
|
|
245
264
|
};
|
|
246
|
-
type Options = {
|
|
265
|
+
declare type Options = {
|
|
247
266
|
dp: number;
|
|
248
267
|
};
|
|
249
268
|
declare const useCollateral: (options?: Options) => CollateralOutputs;
|
|
@@ -255,18 +274,18 @@ declare const useMarginRatio: () => {
|
|
|
255
274
|
currentLeverage: number;
|
|
256
275
|
};
|
|
257
276
|
|
|
258
|
-
type inputOptions = {
|
|
277
|
+
declare type inputOptions = {
|
|
259
278
|
filter?: (item: API.Chain) => boolean;
|
|
260
279
|
pick?: "dexs" | "network_infos" | "token_infos";
|
|
261
280
|
crossEnabled?: boolean;
|
|
262
281
|
/** if true, use wooSwap api, else use orderly api only */
|
|
263
282
|
wooSwapEnabled?: boolean;
|
|
264
283
|
};
|
|
265
|
-
declare const useChains: (networkId?: NetworkId, options?: inputOptions & SWRConfiguration) => readonly [API.Chain[] | {
|
|
284
|
+
declare const useChains: (networkId?: NetworkId | undefined, options?: inputOptions & SWRConfiguration) => readonly [API.Chain[] | {
|
|
266
285
|
testnet: API.Chain[];
|
|
267
286
|
mainnet: API.Chain[];
|
|
268
287
|
}, {
|
|
269
|
-
readonly findByChainId: (chainId: number, field?: string) => (API.Chain & {
|
|
288
|
+
readonly findByChainId: (chainId: number, field?: string | undefined) => (API.Chain & {
|
|
270
289
|
nativeToken?: API.TokenInfo | undefined;
|
|
271
290
|
}) | undefined;
|
|
272
291
|
readonly error: any;
|
|
@@ -289,7 +308,7 @@ declare const useWithdraw: () => {
|
|
|
289
308
|
unsettledPnL: number;
|
|
290
309
|
};
|
|
291
310
|
|
|
292
|
-
type useDepositOptions = {
|
|
311
|
+
declare type useDepositOptions = {
|
|
293
312
|
address?: string;
|
|
294
313
|
decimals?: number;
|
|
295
314
|
crossChainRouteAddress?: string;
|
|
@@ -298,7 +317,7 @@ type useDepositOptions = {
|
|
|
298
317
|
srcChainId?: number;
|
|
299
318
|
srcToken?: string;
|
|
300
319
|
};
|
|
301
|
-
declare const useDeposit: (options?: useDepositOptions) => {
|
|
320
|
+
declare const useDeposit: (options?: useDepositOptions | undefined) => {
|
|
302
321
|
dst: {
|
|
303
322
|
symbol: string;
|
|
304
323
|
address: string | undefined;
|
|
@@ -314,7 +333,7 @@ declare const useDeposit: (options?: useDepositOptions) => {
|
|
|
314
333
|
approve: (amount: string | undefined) => Promise<any>;
|
|
315
334
|
deposit: (amount: string) => Promise<any>;
|
|
316
335
|
fetchBalances: (tokens: API.TokenInfo[]) => Promise<void>;
|
|
317
|
-
fetchBalance: (address: string, decimals?: number) => Promise<string>;
|
|
336
|
+
fetchBalance: (address: string, decimals?: number | undefined) => Promise<string>;
|
|
318
337
|
};
|
|
319
338
|
|
|
320
339
|
declare const useHoldingStream: () => {
|
|
@@ -410,4 +429,4 @@ declare const useSwap: () => {
|
|
|
410
429
|
status: WS_WalletStatusEnum;
|
|
411
430
|
};
|
|
412
431
|
|
|
413
|
-
export { ConfigProviderProps, OrderlyConfigContextState, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, useAccount, useAccountInfo, useAccountInstance, useBoolean, useChain, useChains, useCollateral, useConfig, useCrossSwap, useDeposit, useEventEmitter, useFundingRate, useHoldingStream, useIndexPrice, useLazyQuery, useLeverage, useLocalStorage, useMarginRatio, useMarkPrice, useMarkPricesStream, useMarketTradeStream, useMarketsStream, useMaxQty, useMutation, useOrderEntry, useOrderStream, useOrderbookStream, usePositionStream, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, useSessionStorage, useSettleSubscription, useSwap, useSymbolsInfo, useTickerStream, useWS, useWalletSubscription, useWithdraw, useWooCrossSwapQuery, useWooSwapQuery };
|
|
432
|
+
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, useMutation, useOrderEntry, useOrderStream, useOrderbookStream, usePositionStream, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, useSessionStorage, useSettleSubscription, useSwap, useSymbolsInfo, useTickerStream, useWS, useWalletConnector, useWalletSubscription, useWithdraw, useWooCrossSwapQuery, useWooSwapQuery };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
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';
|
|
3
4
|
import { SWRMutationConfiguration, SWRMutationResponse } from 'swr/mutation';
|
|
4
5
|
import * as swr_infinite from 'swr/infinite';
|
|
5
6
|
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 } 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
|
-
import {
|
|
12
|
+
import react__default, { PropsWithChildren } from 'react';
|
|
13
13
|
import { NetworkId, OrderSide, OrderEntity, API, WSMessage, OrderStatus, WS_WalletStatusEnum } from '@orderly.network/types';
|
|
14
14
|
import * as swr_subscription from 'swr/subscription';
|
|
15
15
|
import { Decimal } from '@orderly.network/utils';
|
|
16
16
|
export * from 'use-debounce';
|
|
17
17
|
|
|
18
|
-
type useQueryOptions<T> = SWRConfiguration & {
|
|
18
|
+
declare type useQueryOptions<T> = SWRConfiguration & {
|
|
19
19
|
formatter?: (data: any) => T;
|
|
20
20
|
};
|
|
21
21
|
|
|
@@ -33,13 +33,13 @@ declare const useQuery: <T>(query: Parameters<typeof useSWR>["0"], options?: use
|
|
|
33
33
|
* @param query
|
|
34
34
|
* @param options
|
|
35
35
|
*/
|
|
36
|
-
declare const useLazyQuery: <T, R = any>(query: Parameters<typeof useSWR>["0"], options?: (SWRMutationConfiguration<any, any> & {
|
|
36
|
+
declare const useLazyQuery: <T, R = any>(query: Parameters<typeof useSWR>["0"], options?: (SWRMutationConfiguration<any, any, swr__internal.Key, any, any> & {
|
|
37
37
|
formatter?: ((data: any) => R) | undefined;
|
|
38
38
|
init?: RequestInit | undefined;
|
|
39
39
|
}) | undefined) => SWRMutationResponse;
|
|
40
40
|
|
|
41
|
-
type HTTP_METHOD = "POST" | "PUT" | "DELETE";
|
|
42
|
-
declare const useMutation: <T, E>(url: string, method?: HTTP_METHOD, options?: SWRMutationConfiguration<T, E> | undefined) => readonly [(data: any, params?: any) => Promise<any>, {
|
|
41
|
+
declare type HTTP_METHOD = "POST" | "PUT" | "DELETE";
|
|
42
|
+
declare const useMutation: <T, E>(url: string, method?: HTTP_METHOD, options?: SWRMutationConfiguration<T, E, swr__internal.Key, any, any> | undefined) => readonly [(data: any, params?: any) => Promise<any>, {
|
|
43
43
|
readonly data: any;
|
|
44
44
|
readonly error: E | undefined;
|
|
45
45
|
readonly reset: () => void;
|
|
@@ -86,7 +86,7 @@ declare function useLocalStorage<T>(key: string, initialValue: T): [any, (value:
|
|
|
86
86
|
|
|
87
87
|
declare const useWS: () => WS;
|
|
88
88
|
|
|
89
|
-
declare const useConfig: <T>(key?: ConfigKey, defaultValue?: T | undefined) => ConfigStore | T;
|
|
89
|
+
declare const useConfig: <T>(key?: ConfigKey | undefined, defaultValue?: T | undefined) => ConfigStore | T;
|
|
90
90
|
|
|
91
91
|
interface OrderlyConfigContextState {
|
|
92
92
|
fetcher?: (url: string, init: RequestInit) => Promise<any>;
|
|
@@ -99,7 +99,7 @@ interface OrderlyConfigContextState {
|
|
|
99
99
|
declare const OrderlyContext: react.Context<OrderlyConfigContextState>;
|
|
100
100
|
declare const OrderlyProvider: react.Provider<OrderlyConfigContextState>;
|
|
101
101
|
|
|
102
|
-
type RequireAtLeastOne<T, R extends keyof T = keyof T> = Omit<T, R> & {
|
|
102
|
+
declare type RequireAtLeastOne<T, R extends keyof T = keyof T> = Omit<T, R> & {
|
|
103
103
|
[K in R]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<R, K>>>;
|
|
104
104
|
}[R];
|
|
105
105
|
interface ConfigProviderProps {
|
|
@@ -109,21 +109,40 @@ interface ConfigProviderProps {
|
|
|
109
109
|
brokerId: string;
|
|
110
110
|
networkId: NetworkId;
|
|
111
111
|
}
|
|
112
|
-
declare const OrderlyConfigProvider:
|
|
112
|
+
declare const OrderlyConfigProvider: (props: PropsWithChildren<RequireAtLeastOne<ConfigProviderProps, "brokerId" | "configStore">>) => react__default.JSX.Element | null;
|
|
113
|
+
|
|
114
|
+
declare type ConnectedChain = {
|
|
115
|
+
id: string;
|
|
116
|
+
};
|
|
117
|
+
interface WalletConnectorContextState {
|
|
118
|
+
connect: () => Promise<any[]>;
|
|
119
|
+
disconnect: (options: any) => Promise<any[]>;
|
|
120
|
+
connecting: boolean;
|
|
121
|
+
setChain: (options: any) => Promise<any>;
|
|
122
|
+
chains: any[];
|
|
123
|
+
switchChain: (options: {
|
|
124
|
+
chainId: string;
|
|
125
|
+
}) => Promise<any>;
|
|
126
|
+
wallet: any;
|
|
127
|
+
connectedChain: ConnectedChain | null;
|
|
128
|
+
settingChain: boolean;
|
|
129
|
+
}
|
|
130
|
+
declare const WalletConnectorContext: react.Context<WalletConnectorContextState>;
|
|
131
|
+
declare const useWalletConnector: () => WalletConnectorContextState;
|
|
113
132
|
|
|
114
|
-
type OrderBookItem = number[];
|
|
115
|
-
type OrderbookData = {
|
|
133
|
+
declare type OrderBookItem = number[];
|
|
134
|
+
declare type OrderbookData = {
|
|
116
135
|
asks: OrderBookItem[];
|
|
117
136
|
bids: OrderBookItem[];
|
|
118
137
|
};
|
|
119
|
-
type OrderbookOptions = {
|
|
138
|
+
declare type OrderbookOptions = {
|
|
120
139
|
level?: number;
|
|
121
140
|
};
|
|
122
141
|
/**
|
|
123
142
|
* @name useOrderbookStream
|
|
124
143
|
* @description React hook that returns the current orderbook for a given market
|
|
125
144
|
*/
|
|
126
|
-
declare const useOrderbookStream: (symbol: string, initial?: OrderbookData, options?: OrderbookOptions) => ({
|
|
145
|
+
declare const useOrderbookStream: (symbol: string, initial?: OrderbookData, options?: OrderbookOptions | undefined) => ({
|
|
127
146
|
asks: OrderBookItem[];
|
|
128
147
|
bids: OrderBookItem[];
|
|
129
148
|
markPrice: any;
|
|
@@ -145,7 +164,7 @@ declare const useOrderbookStream: (symbol: string, initial?: OrderbookData, opti
|
|
|
145
164
|
middlePrice?: undefined;
|
|
146
165
|
})[];
|
|
147
166
|
|
|
148
|
-
type UseOrderEntryOptions = {
|
|
167
|
+
declare type UseOrderEntryOptions = {
|
|
149
168
|
commify?: boolean;
|
|
150
169
|
validate?: (data: OrderEntity) => {
|
|
151
170
|
[P in keyof OrderEntity]?: string;
|
|
@@ -156,7 +175,7 @@ type UseOrderEntryOptions = {
|
|
|
156
175
|
* @param symbol
|
|
157
176
|
* @returns
|
|
158
177
|
*/
|
|
159
|
-
declare const useOrderEntry: (symbol: string, side: OrderSide, reduceOnly?: boolean, options?: UseOrderEntryOptions) => {
|
|
178
|
+
declare const useOrderEntry: (symbol: string, side: OrderSide, reduceOnly?: boolean, options?: UseOrderEntryOptions | undefined) => {
|
|
160
179
|
maxQty: number;
|
|
161
180
|
freeCollateral: number;
|
|
162
181
|
markPrice: any;
|
|
@@ -200,7 +219,7 @@ declare const useFundingRate: (symbol: string) => {
|
|
|
200
219
|
sum_unitary_funding?: number | undefined;
|
|
201
220
|
};
|
|
202
221
|
|
|
203
|
-
declare const usePositionStream: (symbol?: string, options?:
|
|
222
|
+
declare const usePositionStream: (symbol?: string | undefined, options?: Partial<swr__internal.PublicConfiguration<any, any, swr__internal.BareFetcher<any>>> | undefined) => readonly [{
|
|
204
223
|
readonly rows: API.PositionExt[] | null;
|
|
205
224
|
readonly aggregated: any;
|
|
206
225
|
readonly totalCollateral: Decimal;
|
|
@@ -213,7 +232,7 @@ declare const usePositionStream: (symbol?: string, options?: SWRConfiguration) =
|
|
|
213
232
|
readonly refresh: () => void;
|
|
214
233
|
}];
|
|
215
234
|
|
|
216
|
-
type Params = {
|
|
235
|
+
declare type Params = {
|
|
217
236
|
symbol?: string;
|
|
218
237
|
status?: OrderStatus;
|
|
219
238
|
size?: number;
|
|
@@ -225,7 +244,7 @@ declare const useOrderStream: (params: Params) => readonly [any[] | null, {
|
|
|
225
244
|
readonly loadMore: () => void;
|
|
226
245
|
readonly cancelAllOrders: () => void;
|
|
227
246
|
readonly updateOrder: (orderId: string, order: OrderEntity) => Promise<any>;
|
|
228
|
-
readonly cancelOrder: (orderId: string, symbol?: string) => Promise<void>;
|
|
247
|
+
readonly cancelOrder: (orderId: string, symbol?: string | undefined) => Promise<void>;
|
|
229
248
|
}];
|
|
230
249
|
|
|
231
250
|
interface MarketTradeStreamOptions {
|
|
@@ -236,14 +255,14 @@ declare const useMarketTradeStream: (symbol: string, options?: MarketTradeStream
|
|
|
236
255
|
isLoading: boolean;
|
|
237
256
|
};
|
|
238
257
|
|
|
239
|
-
type CollateralOutputs = {
|
|
258
|
+
declare type CollateralOutputs = {
|
|
240
259
|
totalCollateral: number;
|
|
241
260
|
freeCollateral: number;
|
|
242
261
|
totalValue: number;
|
|
243
262
|
availableBalance: number;
|
|
244
263
|
unsettledPnL: number;
|
|
245
264
|
};
|
|
246
|
-
type Options = {
|
|
265
|
+
declare type Options = {
|
|
247
266
|
dp: number;
|
|
248
267
|
};
|
|
249
268
|
declare const useCollateral: (options?: Options) => CollateralOutputs;
|
|
@@ -255,18 +274,18 @@ declare const useMarginRatio: () => {
|
|
|
255
274
|
currentLeverage: number;
|
|
256
275
|
};
|
|
257
276
|
|
|
258
|
-
type inputOptions = {
|
|
277
|
+
declare type inputOptions = {
|
|
259
278
|
filter?: (item: API.Chain) => boolean;
|
|
260
279
|
pick?: "dexs" | "network_infos" | "token_infos";
|
|
261
280
|
crossEnabled?: boolean;
|
|
262
281
|
/** if true, use wooSwap api, else use orderly api only */
|
|
263
282
|
wooSwapEnabled?: boolean;
|
|
264
283
|
};
|
|
265
|
-
declare const useChains: (networkId?: NetworkId, options?: inputOptions & SWRConfiguration) => readonly [API.Chain[] | {
|
|
284
|
+
declare const useChains: (networkId?: NetworkId | undefined, options?: inputOptions & SWRConfiguration) => readonly [API.Chain[] | {
|
|
266
285
|
testnet: API.Chain[];
|
|
267
286
|
mainnet: API.Chain[];
|
|
268
287
|
}, {
|
|
269
|
-
readonly findByChainId: (chainId: number, field?: string) => (API.Chain & {
|
|
288
|
+
readonly findByChainId: (chainId: number, field?: string | undefined) => (API.Chain & {
|
|
270
289
|
nativeToken?: API.TokenInfo | undefined;
|
|
271
290
|
}) | undefined;
|
|
272
291
|
readonly error: any;
|
|
@@ -289,7 +308,7 @@ declare const useWithdraw: () => {
|
|
|
289
308
|
unsettledPnL: number;
|
|
290
309
|
};
|
|
291
310
|
|
|
292
|
-
type useDepositOptions = {
|
|
311
|
+
declare type useDepositOptions = {
|
|
293
312
|
address?: string;
|
|
294
313
|
decimals?: number;
|
|
295
314
|
crossChainRouteAddress?: string;
|
|
@@ -298,7 +317,7 @@ type useDepositOptions = {
|
|
|
298
317
|
srcChainId?: number;
|
|
299
318
|
srcToken?: string;
|
|
300
319
|
};
|
|
301
|
-
declare const useDeposit: (options?: useDepositOptions) => {
|
|
320
|
+
declare const useDeposit: (options?: useDepositOptions | undefined) => {
|
|
302
321
|
dst: {
|
|
303
322
|
symbol: string;
|
|
304
323
|
address: string | undefined;
|
|
@@ -314,7 +333,7 @@ declare const useDeposit: (options?: useDepositOptions) => {
|
|
|
314
333
|
approve: (amount: string | undefined) => Promise<any>;
|
|
315
334
|
deposit: (amount: string) => Promise<any>;
|
|
316
335
|
fetchBalances: (tokens: API.TokenInfo[]) => Promise<void>;
|
|
317
|
-
fetchBalance: (address: string, decimals?: number) => Promise<string>;
|
|
336
|
+
fetchBalance: (address: string, decimals?: number | undefined) => Promise<string>;
|
|
318
337
|
};
|
|
319
338
|
|
|
320
339
|
declare const useHoldingStream: () => {
|
|
@@ -410,4 +429,4 @@ declare const useSwap: () => {
|
|
|
410
429
|
status: WS_WalletStatusEnum;
|
|
411
430
|
};
|
|
412
431
|
|
|
413
|
-
export { ConfigProviderProps, OrderlyConfigContextState, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, useAccount, useAccountInfo, useAccountInstance, useBoolean, useChain, useChains, useCollateral, useConfig, useCrossSwap, useDeposit, useEventEmitter, useFundingRate, useHoldingStream, useIndexPrice, useLazyQuery, useLeverage, useLocalStorage, useMarginRatio, useMarkPrice, useMarkPricesStream, useMarketTradeStream, useMarketsStream, useMaxQty, useMutation, useOrderEntry, useOrderStream, useOrderbookStream, usePositionStream, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, useSessionStorage, useSettleSubscription, useSwap, useSymbolsInfo, useTickerStream, useWS, useWalletSubscription, useWithdraw, useWooCrossSwapQuery, useWooSwapQuery };
|
|
432
|
+
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, useMutation, useOrderEntry, useOrderStream, useOrderbookStream, usePositionStream, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, useSessionStorage, useSettleSubscription, useSwap, useSymbolsInfo, useTickerStream, useWS, useWalletConnector, useWalletSubscription, useWithdraw, useWooCrossSwapQuery, useWooSwapQuery };
|
package/dist/index.js
CHANGED
|
@@ -486,6 +486,10 @@ var OrderlyConfigProvider = (props) => {
|
|
|
486
486
|
props.children
|
|
487
487
|
);
|
|
488
488
|
};
|
|
489
|
+
var WalletConnectorContext = React.createContext({});
|
|
490
|
+
var useWalletConnector = () => {
|
|
491
|
+
return React.useContext(WalletConnectorContext);
|
|
492
|
+
};
|
|
489
493
|
var useMarkPrice = (symbol) => {
|
|
490
494
|
const ws = useWS();
|
|
491
495
|
return useSWRSubscription__default.default(`${symbol}@markprice`, (key, { next }) => {
|
|
@@ -4168,6 +4172,7 @@ Object.defineProperty(exports, 'useConstant', {
|
|
|
4168
4172
|
exports.OrderlyConfigProvider = OrderlyConfigProvider;
|
|
4169
4173
|
exports.OrderlyContext = OrderlyContext;
|
|
4170
4174
|
exports.OrderlyProvider = OrderlyProvider;
|
|
4175
|
+
exports.WalletConnectorContext = WalletConnectorContext;
|
|
4171
4176
|
exports.useAccount = useAccount;
|
|
4172
4177
|
exports.useAccountInfo = useAccountInfo;
|
|
4173
4178
|
exports.useAccountInstance = useAccountInstance;
|
|
@@ -4207,6 +4212,7 @@ exports.useSwap = useSwap;
|
|
|
4207
4212
|
exports.useSymbolsInfo = useSymbolsInfo;
|
|
4208
4213
|
exports.useTickerStream = useTickerStream;
|
|
4209
4214
|
exports.useWS = useWS;
|
|
4215
|
+
exports.useWalletConnector = useWalletConnector;
|
|
4210
4216
|
exports.useWalletSubscription = useWalletSubscription;
|
|
4211
4217
|
exports.useWithdraw = useWithdraw;
|
|
4212
4218
|
exports.useWooCrossSwapQuery = useWooCrossSwapQuery;
|