@orderly.network/hooks 0.0.52 → 0.0.53

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.ts DELETED
@@ -1,367 +0,0 @@
1
- import useSWR, { SWRConfiguration, SWRResponse } from 'swr';
2
- export { SWRConfig, SWRConfiguration, default as useSWR } from 'swr';
3
- import { SWRMutationConfiguration } from 'swr/mutation';
4
- import * as _orderly_network_core from '@orderly.network/core';
5
- import { Account, AccountState, ConfigStore, OrderlyKeyStore, getWalletAdapterFunc, IContract, EventEmitter } from '@orderly.network/core';
6
- import * as react from 'react';
7
- import react__default, { FC, PropsWithChildren } from 'react';
8
- export { default as useConstant } from 'use-constant';
9
- import { WS } from '@orderly.network/net';
10
- import { OrderSide, OrderEntity, API, WSMessage } from '@orderly.network/types';
11
- import * as swr__internal from 'swr/_internal';
12
- import * as swr_subscription from 'swr/subscription';
13
-
14
- type useQueryOptions<T> = SWRConfiguration & {
15
- formatter?: (data: any) => T;
16
- };
17
-
18
- /**
19
- * useQuery
20
- * @description for public api
21
- * @param query
22
- * @param options
23
- */
24
- declare const useQuery: <T>(query: Parameters<typeof useSWR>["0"], options?: useQueryOptions<T> | undefined) => SWRResponse<T, any, any>;
25
-
26
- type HTTP_METHOD = "POST" | "PUT" | "DELETE";
27
- declare const useMutation: <T, E>(url: string, method?: HTTP_METHOD, options?: SWRMutationConfiguration<T, E> | undefined) => [any, any];
28
-
29
- /**
30
- * usePrivateQuery
31
- * @description for private api
32
- * @param query
33
- * @param options
34
- */
35
- declare const usePrivateQuery: <T>(query: string, options?: useQueryOptions<T> | undefined) => SWRResponse<T, any, any>;
36
-
37
- declare const useTradingView: () => {};
38
-
39
- declare const usePrivateObserve: <T>() => {
40
- data: T | undefined;
41
- };
42
-
43
- declare const useTopicObserve: <T>(topic: string) => {
44
- data: T | undefined;
45
- };
46
-
47
- declare const useAccount: () => {
48
- account: Account;
49
- state: AccountState;
50
- login: (address: string) => void;
51
- createOrderlyKey: (remember: boolean) => Promise<string>;
52
- createAccount: () => Promise<string>;
53
- disconnect: () => Promise<void>;
54
- connect: () => Promise<any>;
55
- setChain: (chainId: number) => Promise<any>;
56
- };
57
-
58
- declare const useAccountInstance: () => Account;
59
-
60
- interface OrderlyAppConfig {
61
- logoUrl: string;
62
- theme: any;
63
- }
64
- type AppStateErrors = {
65
- ChainNetworkNotSupport: boolean;
66
- IpNotSupport: boolean;
67
- NetworkError: boolean;
68
- };
69
- interface OrderlyContextState extends OrderlyAppConfig {
70
- fetcher?: (url: string, init: RequestInit) => Promise<any>;
71
- apiBaseUrl: string;
72
- klineDataUrl: string;
73
- configStore: ConfigStore;
74
- keyStore: OrderlyKeyStore;
75
- getWalletAdapter: getWalletAdapterFunc;
76
- contractManager: IContract;
77
- networkId: string;
78
- brokerId: string;
79
- onWalletConnect?: () => Promise<any>;
80
- onWalletDisconnect?: () => Promise<any>;
81
- onSetChain?: (chainId: number) => Promise<any>;
82
- ready: boolean;
83
- onAppTestChange?: (name: string) => void;
84
- errors: AppStateErrors;
85
- }
86
- declare const OrderlyContext: react.Context<OrderlyContextState>;
87
- declare const OrderlyProvider: react.Provider<OrderlyContextState>;
88
-
89
- declare const useAppState: () => {
90
- errors: AppStateErrors;
91
- ready: boolean;
92
- };
93
-
94
- declare const usePreLoadData: (onSuccess: (name: string) => void) => void;
95
-
96
- declare const useEventEmitter: (channel?: string) => EventEmitter<string | symbol, any>;
97
-
98
- declare function useSessionStorage<T>(key: string, initialValue: T): [T, (data: any) => void];
99
-
100
- declare function useLocalStorage<T>(key: string, initialValue: T): [T, any];
101
-
102
- type useRunOnceProps = {
103
- fn: () => any;
104
- sessionKey?: string;
105
- };
106
- declare const useRunOnce: react__default.FC<useRunOnceProps>;
107
-
108
- declare const DataSourceProvider: FC<PropsWithChildren>;
109
-
110
- declare const useWS: () => WS;
111
-
112
- declare const useConfig: () => _orderly_network_core.ConfigStore;
113
-
114
- type OrderBookItem = number[];
115
- type OrderbookData = {
116
- asks: OrderBookItem[];
117
- bids: OrderBookItem[];
118
- };
119
- type OrderbookOptions = {
120
- level?: number;
121
- };
122
- /**
123
- * @name useOrderbookStream
124
- * @description React hook that returns the current orderbook for a given market
125
- */
126
- declare const useOrderbookStream: (symbol: string, initial?: OrderbookData, options?: OrderbookOptions) => ({
127
- asks: OrderBookItem[];
128
- bids: OrderBookItem[];
129
- markPrice: any;
130
- middlePrice: any[];
131
- onDepthChange?: undefined;
132
- depth?: undefined;
133
- allDepths?: undefined;
134
- isLoading?: undefined;
135
- onItemClick?: undefined;
136
- } | {
137
- onDepthChange: (depth: number) => void;
138
- depth: number | undefined;
139
- allDepths: any[];
140
- isLoading: boolean;
141
- onItemClick: (item: OrderBookItem) => void;
142
- asks?: undefined;
143
- bids?: undefined;
144
- markPrice?: undefined;
145
- middlePrice?: undefined;
146
- })[];
147
-
148
- interface OrderEntryReturn {
149
- onSubmit: (values: OrderEntity) => Promise<any>;
150
- maxQty: number;
151
- freeCollateral: number;
152
- markPrice: number;
153
- symbolConfig: API.SymbolExt;
154
- helper: {
155
- calculate: (values: any, field: string, value: any) => any;
156
- validator: (values: any) => any;
157
- };
158
- }
159
- type UseOrderEntryOptions = {
160
- commify?: boolean;
161
- validate?: (data: OrderEntity) => {
162
- [P in keyof OrderEntity]?: string;
163
- } | null | undefined;
164
- };
165
- /**
166
- * 创建订单
167
- * @param symbol
168
- * @returns
169
- */
170
- declare const useOrderEntry: (symbol: string, side: OrderSide, reduceOnly?: boolean, options?: UseOrderEntryOptions) => OrderEntryReturn;
171
-
172
- interface MarketInfo {
173
- }
174
- declare const useFetures: () => {
175
- data: MarketInfo[] | undefined;
176
- sortBy: (key: string) => void;
177
- filterBy: (key: string) => void;
178
- isLoading: boolean;
179
- error: any;
180
- };
181
-
182
- declare const useSymbolsInfo: () => any;
183
-
184
- declare const useAccountInfo: () => swr__internal.SWRResponse<API.AccountInfo, any, any>;
185
-
186
- declare const useTokenInfo: () => any;
187
-
188
- declare const useMarketsStream: () => {
189
- data: WSMessage.Ticker[] | null;
190
- };
191
-
192
- declare const useMarkPricesStream: () => swr_subscription.SWRSubscriptionResponse<any, any>;
193
-
194
- declare const useMarkPrice: (symbol: string) => swr_subscription.SWRSubscriptionResponse<any, any>;
195
-
196
- declare const useLeverage: () => ({
197
- update: (data: any) => any;
198
- } | undefined)[];
199
-
200
- declare const useTickerStream: (symbol: string) => any;
201
-
202
- declare const useFundingRate: (symbol: string) => {
203
- est_funding_rate: string;
204
- countDown: string;
205
- symbol?: string | undefined;
206
- est_funding_rate_timestamp?: number | undefined;
207
- last_funding_rate?: number | undefined;
208
- last_funding_rate_timestamp?: number | undefined;
209
- next_funding_time?: number | undefined;
210
- sum_unitary_funding?: number | undefined;
211
- };
212
-
213
- declare const usePositionStream: (symbol?: string, options?: SWRConfiguration) => any[];
214
-
215
- declare enum OrderStatus {
216
- FILLED = "FILLED",
217
- PARTIAL_FILLED = "PARTIAL_FILLED",
218
- CANCELED = "CANCELED",
219
- NEW = "NEW",
220
- COMPLETED = "COMPLETED"
221
- }
222
- declare const useOrderStream: ({ status, symbol, side, size, }?: {
223
- symbol?: string | undefined;
224
- status?: OrderStatus | undefined;
225
- size?: number | undefined;
226
- side?: OrderSide | undefined;
227
- }) => (any[] | {
228
- cancelAllOrders: () => void;
229
- updateOrder: (orderId: string, order: OrderEntity) => any;
230
- cancelOrder: (orderId: string, symbol?: string) => any;
231
- } | null)[];
232
-
233
- interface MarketTradeStreamOptions {
234
- limit?: number;
235
- }
236
- declare const useMarketTradeStream: (symbol: string, options?: MarketTradeStreamOptions) => {
237
- data: API.Trade[];
238
- isLoading: boolean;
239
- };
240
-
241
- type CollateralOutputs = {
242
- totalCollateral: number;
243
- freeCollateral: number;
244
- totalValue: number;
245
- availableBalance: number;
246
- unsettledPnL: number;
247
- };
248
- /**
249
- * 用户保证金
250
- * @returns
251
- */
252
- type Options = {
253
- dp: number;
254
- };
255
- declare const useCollateral: (options?: Options) => CollateralOutputs;
256
-
257
- declare const useMaxQty: (symbol: string, side: OrderSide, reduceOnly?: boolean) => number;
258
-
259
- declare const useMarginRatio: () => {
260
- marginRatio: number;
261
- currentLeverage: number;
262
- };
263
-
264
- type inputOptions = {
265
- filter?: (item: API.Chain) => boolean;
266
- pick?: "dexs" | "network_infos" | "token_infos";
267
- };
268
- declare const useChains: (networkId?: "testnet" | "mainnet", options?: inputOptions & SWRConfiguration) => any[];
269
-
270
- declare const useChain: (token: string) => {
271
- chains: API.Chain | null;
272
- isLoading: boolean;
273
- };
274
-
275
- declare const useWithdraw: () => {
276
- withdraw: (inputs: {
277
- chainId: number;
278
- token: string;
279
- amount: number;
280
- }) => Promise<any>;
281
- isLoading: boolean;
282
- maxAmount: number;
283
- availableBalance: number;
284
- unsettledPnL: number;
285
- };
286
-
287
- declare const useDeposit: () => {
288
- balance: string;
289
- allowance: string;
290
- approve: (amount: string | undefined) => Promise<any>;
291
- deposit: (amount: string) => Promise<any>;
292
- };
293
-
294
- declare const useHoldingStream: () => {
295
- data: API.Holding[] | undefined;
296
- usdc: API.Holding | undefined;
297
- isLoading: boolean;
298
- };
299
-
300
- declare const useWalletSubscription: (options?: {
301
- onMessage?: ((data: any) => void) | undefined;
302
- } | undefined) => swr_subscription.SWRSubscriptionResponse<any, any>;
303
-
304
- declare const useBalance: () => any;
305
-
306
- declare const usePrivateDataObserver: () => void;
307
-
308
- declare const useExecutionReport: () => any;
309
-
310
- interface Info {
311
- symbol: string;
312
- quote_min: number;
313
- quote_max: number;
314
- quote_tick: number;
315
- base_min: number;
316
- base_max: number;
317
- base_tick: number;
318
- min_notional: number;
319
- price_range: number;
320
- created_time: number;
321
- updated_time: number;
322
- }
323
- /**
324
- * useInfo
325
- * @returns
326
- */
327
- declare const useInfo: () => swr__internal.SWRResponse<Info[], any, any>;
328
-
329
- interface Token {
330
- token: string;
331
- token_account_id: string;
332
- decimals: number;
333
- minimum_increment: number;
334
- }
335
- /**
336
- * useToken
337
- * @description get token info
338
- */
339
- declare const useToken: () => swr__internal.SWRResponse<Token[], any, any>;
340
-
341
- interface FundingRate {
342
- symbol: string;
343
- est_funding_rate: number;
344
- est_funding_rate_timestamp: number;
345
- last_funding_rate: number;
346
- last_funding_rate_timestamp: number;
347
- next_funding_time: number;
348
- sum_unitary_funding: number;
349
- }
350
- /**
351
- * FundingRate
352
- * @param symbol
353
- */
354
- declare const useFundingRateBySymbol: (symbol: string) => swr__internal.SWRResponse<FundingRate, any, any>;
355
-
356
- declare const index_useFundingRateBySymbol: typeof useFundingRateBySymbol;
357
- declare const index_useInfo: typeof useInfo;
358
- declare const index_useToken: typeof useToken;
359
- declare namespace index {
360
- export {
361
- index_useFundingRateBySymbol as useFundingRateBySymbol,
362
- index_useInfo as useInfo,
363
- index_useToken as useToken,
364
- };
365
- }
366
-
367
- export { AppStateErrors, DataSourceProvider, OrderStatus, OrderlyAppConfig, OrderlyContext, OrderlyContextState, OrderlyProvider, index as apis, useAccount, useAccountInfo, useAccountInstance, useAppState, useBalance, useChain, useChains, useCollateral, useConfig, useDeposit, useEventEmitter, useExecutionReport, useFetures, useFundingRate, useHoldingStream, useLeverage, useLocalStorage, useMarginRatio, useMarkPrice, useMarkPricesStream, useMarketTradeStream, useMarketsStream, useMaxQty, useMutation, useOrderEntry, useOrderStream, useOrderbookStream, usePositionStream, usePreLoadData, usePrivateDataObserver, usePrivateObserve, usePrivateQuery, useQuery, useRunOnce, useSessionStorage, useSymbolsInfo, useTickerStream, useTokenInfo, useTopicObserve, useTradingView, useWS, useWalletSubscription, useWithdraw };