@orderly.network/hooks 1.0.25-alpha.9 → 1.0.25

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 CHANGED
@@ -1,9 +1,9 @@
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, IContract } from '@orderly.network/core';
9
9
  export { default as useConstant } from 'use-constant';
@@ -23,9 +23,9 @@ declare global {
23
23
  };
24
24
  }
25
25
  }
26
- declare const _default: "1.0.25-alpha.9";
26
+ declare const _default: "1.0.25";
27
27
 
28
- type useQueryOptions<T> = SWRConfiguration & {
28
+ declare type useQueryOptions<T> = SWRConfiguration & {
29
29
  formatter?: (data: any) => T;
30
30
  };
31
31
 
@@ -43,13 +43,13 @@ declare const useQuery: <T>(query: Parameters<typeof useSWR>["0"], options?: use
43
43
  * @param query
44
44
  * @param options
45
45
  */
46
- declare const useLazyQuery: <T, R = any>(query: Parameters<typeof useSWR>["0"], options?: (SWRMutationConfiguration<any, any> & {
46
+ declare const useLazyQuery: <T, R = any>(query: Parameters<typeof useSWR>["0"], options?: (SWRMutationConfiguration<any, any, swr__internal.Key, any, any> & {
47
47
  formatter?: ((data: any) => R) | undefined;
48
48
  init?: RequestInit | undefined;
49
49
  }) | undefined) => SWRMutationResponse;
50
50
 
51
- type HTTP_METHOD = "POST" | "PUT" | "DELETE";
52
- declare const useMutation: <T, E>(url: string, method?: HTTP_METHOD, options?: SWRMutationConfiguration<T, E> | undefined) => readonly [(data: any, params?: any, options?: any) => Promise<any>, {
51
+ declare type HTTP_METHOD = "POST" | "PUT" | "DELETE";
52
+ 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, options?: any) => Promise<any>, {
53
53
  readonly data: any;
54
54
  readonly error: E | undefined;
55
55
  readonly reset: () => void;
@@ -96,7 +96,7 @@ declare function useLocalStorage<T>(key: string, initialValue: T): [any, (value:
96
96
 
97
97
  declare const useWS: () => WS;
98
98
 
99
- declare const useConfig: <T>(key?: ConfigKey, defaultValue?: T | undefined) => ConfigStore | T;
99
+ declare const useConfig: <T>(key?: ConfigKey | undefined, defaultValue?: T | undefined) => ConfigStore | T;
100
100
 
101
101
  interface OrderlyConfigContextState {
102
102
  fetcher?: (url: string, init: RequestInit) => Promise<any>;
@@ -116,7 +116,7 @@ interface OrderlyConfigContextState {
116
116
  declare const OrderlyContext: react.Context<OrderlyConfigContextState>;
117
117
  declare const OrderlyProvider: react.Provider<OrderlyConfigContextState>;
118
118
 
119
- type RequireAtLeastOne<T, R extends keyof T = keyof T> = Omit<T, R> & {
119
+ declare type RequireAtLeastOne<T, R extends keyof T = keyof T> = Omit<T, R> & {
120
120
  [K in R]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<R, K>>>;
121
121
  }[R];
122
122
  interface ConfigProviderProps {
@@ -130,7 +130,7 @@ interface ConfigProviderProps {
130
130
  }
131
131
  declare const OrderlyConfigProvider: (props: PropsWithChildren<RequireAtLeastOne<ConfigProviderProps, "brokerId" | "configStore">>) => react_jsx_runtime.JSX.Element | null;
132
132
 
133
- type ConnectedChain = {
133
+ declare type ConnectedChain = {
134
134
  id: string;
135
135
  };
136
136
  interface WalletConnectorContextState {
@@ -146,19 +146,19 @@ interface WalletConnectorContextState {
146
146
  declare const WalletConnectorContext: react.Context<WalletConnectorContextState>;
147
147
  declare const useWalletConnector: () => WalletConnectorContextState;
148
148
 
149
- type OrderBookItem = number[];
150
- type OrderbookData = {
149
+ declare type OrderBookItem = number[];
150
+ declare type OrderbookData = {
151
151
  asks: OrderBookItem[];
152
152
  bids: OrderBookItem[];
153
153
  };
154
- type OrderbookOptions = {
154
+ declare type OrderbookOptions = {
155
155
  level?: number;
156
156
  };
157
157
  /**
158
158
  * @name useOrderbookStream
159
159
  * @description React hook that returns the current orderbook for a given market
160
160
  */
161
- declare const useOrderbookStream: (symbol: string, initial?: OrderbookData, options?: OrderbookOptions) => ({
161
+ declare const useOrderbookStream: (symbol: string, initial?: OrderbookData, options?: OrderbookOptions | undefined) => ({
162
162
  asks: OrderBookItem[];
163
163
  bids: OrderBookItem[];
164
164
  markPrice: any;
@@ -180,7 +180,7 @@ declare const useOrderbookStream: (symbol: string, initial?: OrderbookData, opti
180
180
  middlePrice?: undefined;
181
181
  })[];
182
182
 
183
- type UseOrderEntryOptions = {
183
+ declare type UseOrderEntryOptions = {
184
184
  commify?: boolean;
185
185
  validate?: (data: OrderEntity) => {
186
186
  [P in keyof OrderEntity]?: string;
@@ -191,7 +191,7 @@ type UseOrderEntryOptions = {
191
191
  * @param symbol
192
192
  * @returns
193
193
  */
194
- declare const useOrderEntry: (symbol: string, side: OrderSide, reduceOnly?: boolean, options?: UseOrderEntryOptions) => {
194
+ declare const useOrderEntry: (symbol: string, side: OrderSide, reduceOnly?: boolean, options?: UseOrderEntryOptions | undefined) => {
195
195
  maxQty: number;
196
196
  freeCollateral: number;
197
197
  markPrice: any;
@@ -233,7 +233,7 @@ declare const useFundingRate: (symbol: string) => {
233
233
  sum_unitary_funding?: number | undefined;
234
234
  };
235
235
 
236
- declare const usePositionStream: (symbol?: string, options?: SWRConfiguration) => readonly [{
236
+ declare const usePositionStream: (symbol?: string | undefined, options?: Partial<swr__internal.PublicConfiguration<any, any, swr__internal.BareFetcher<any>>> | undefined) => readonly [{
237
237
  readonly rows: API.PositionExt[] | null;
238
238
  readonly aggregated: any;
239
239
  readonly totalCollateral: Decimal;
@@ -246,7 +246,7 @@ declare const usePositionStream: (symbol?: string, options?: SWRConfiguration) =
246
246
  readonly refresh: () => void;
247
247
  }];
248
248
 
249
- type Params = {
249
+ declare type Params = {
250
250
  symbol?: string;
251
251
  status?: OrderStatus;
252
252
  size?: number;
@@ -258,7 +258,7 @@ declare const useOrderStream: (params: Params) => readonly [any[] | null, {
258
258
  readonly loadMore: () => void;
259
259
  readonly cancelAllOrders: () => void;
260
260
  readonly updateOrder: (orderId: string, order: OrderEntity) => Promise<any>;
261
- readonly cancelOrder: (orderId: string, symbol?: string) => Promise<any>;
261
+ readonly cancelOrder: (orderId: string, symbol?: string | undefined) => Promise<any>;
262
262
  readonly errors: {
263
263
  readonly cancelOrder: unknown;
264
264
  readonly updateOrder: unknown;
@@ -277,14 +277,14 @@ declare const useMarketTradeStream: (symbol: string, options?: MarketTradeStream
277
277
  isLoading: boolean;
278
278
  };
279
279
 
280
- type CollateralOutputs = {
280
+ declare type CollateralOutputs = {
281
281
  totalCollateral: number;
282
282
  freeCollateral: number;
283
283
  totalValue: number;
284
284
  availableBalance: number;
285
285
  unsettledPnL: number;
286
286
  };
287
- type Options = {
287
+ declare type Options = {
288
288
  dp: number;
289
289
  };
290
290
  declare const useCollateral: (options?: Options) => CollateralOutputs;
@@ -296,18 +296,18 @@ declare const useMarginRatio: () => {
296
296
  currentLeverage: number;
297
297
  };
298
298
 
299
- type inputOptions = {
299
+ declare type inputOptions = {
300
300
  filter?: (item: API.Chain) => boolean;
301
301
  pick?: "dexs" | "network_infos" | "token_infos";
302
302
  crossEnabled?: boolean;
303
303
  /** if true, use wooSwap api, else use orderly api only */
304
304
  wooSwapEnabled?: boolean;
305
305
  };
306
- declare const useChains: (networkId?: NetworkId, options?: inputOptions & SWRConfiguration) => readonly [API.Chain[] | {
306
+ declare const useChains: (networkId?: NetworkId | undefined, options?: inputOptions & SWRConfiguration) => readonly [API.Chain[] | {
307
307
  testnet: API.Chain[];
308
308
  mainnet: API.Chain[];
309
309
  }, {
310
- readonly findByChainId: (chainId: number, field?: string) => (API.Chain & {
310
+ readonly findByChainId: (chainId: number, field?: string | undefined) => (API.Chain & {
311
311
  nativeToken?: API.TokenInfo | undefined;
312
312
  }) | (<K extends never>(prop: K) => ((API.Chain & {
313
313
  nativeToken?: API.TokenInfo | undefined;
@@ -332,7 +332,7 @@ declare const useWithdraw: () => {
332
332
  unsettledPnL: number;
333
333
  };
334
334
 
335
- type useDepositOptions = {
335
+ declare type useDepositOptions = {
336
336
  address?: string;
337
337
  decimals?: number;
338
338
  crossChainRouteAddress?: string;
@@ -345,7 +345,7 @@ type useDepositOptions = {
345
345
  */
346
346
  wooSwapEnabled?: boolean;
347
347
  };
348
- declare const useDeposit: (options?: useDepositOptions) => {
348
+ declare const useDeposit: (options?: useDepositOptions | undefined) => {
349
349
  dst: {
350
350
  symbol: string;
351
351
  address: string | undefined;
@@ -361,7 +361,7 @@ declare const useDeposit: (options?: useDepositOptions) => {
361
361
  approve: (amount: string | undefined) => Promise<any>;
362
362
  deposit: (amount: string) => Promise<any>;
363
363
  fetchBalances: (tokens: API.TokenInfo[]) => Promise<void>;
364
- fetchBalance: (address: string, decimals?: number) => Promise<string>;
364
+ fetchBalance: (address: string, decimals?: number | undefined) => Promise<string>;
365
365
  };
366
366
 
367
367
  declare const useHoldingStream: () => {
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
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, IContract } from '@orderly.network/core';
9
9
  export { default as useConstant } from 'use-constant';
@@ -23,9 +23,9 @@ declare global {
23
23
  };
24
24
  }
25
25
  }
26
- declare const _default: "1.0.25-alpha.9";
26
+ declare const _default: "1.0.25";
27
27
 
28
- type useQueryOptions<T> = SWRConfiguration & {
28
+ declare type useQueryOptions<T> = SWRConfiguration & {
29
29
  formatter?: (data: any) => T;
30
30
  };
31
31
 
@@ -43,13 +43,13 @@ declare const useQuery: <T>(query: Parameters<typeof useSWR>["0"], options?: use
43
43
  * @param query
44
44
  * @param options
45
45
  */
46
- declare const useLazyQuery: <T, R = any>(query: Parameters<typeof useSWR>["0"], options?: (SWRMutationConfiguration<any, any> & {
46
+ declare const useLazyQuery: <T, R = any>(query: Parameters<typeof useSWR>["0"], options?: (SWRMutationConfiguration<any, any, swr__internal.Key, any, any> & {
47
47
  formatter?: ((data: any) => R) | undefined;
48
48
  init?: RequestInit | undefined;
49
49
  }) | undefined) => SWRMutationResponse;
50
50
 
51
- type HTTP_METHOD = "POST" | "PUT" | "DELETE";
52
- declare const useMutation: <T, E>(url: string, method?: HTTP_METHOD, options?: SWRMutationConfiguration<T, E> | undefined) => readonly [(data: any, params?: any, options?: any) => Promise<any>, {
51
+ declare type HTTP_METHOD = "POST" | "PUT" | "DELETE";
52
+ 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, options?: any) => Promise<any>, {
53
53
  readonly data: any;
54
54
  readonly error: E | undefined;
55
55
  readonly reset: () => void;
@@ -96,7 +96,7 @@ declare function useLocalStorage<T>(key: string, initialValue: T): [any, (value:
96
96
 
97
97
  declare const useWS: () => WS;
98
98
 
99
- declare const useConfig: <T>(key?: ConfigKey, defaultValue?: T | undefined) => ConfigStore | T;
99
+ declare const useConfig: <T>(key?: ConfigKey | undefined, defaultValue?: T | undefined) => ConfigStore | T;
100
100
 
101
101
  interface OrderlyConfigContextState {
102
102
  fetcher?: (url: string, init: RequestInit) => Promise<any>;
@@ -116,7 +116,7 @@ interface OrderlyConfigContextState {
116
116
  declare const OrderlyContext: react.Context<OrderlyConfigContextState>;
117
117
  declare const OrderlyProvider: react.Provider<OrderlyConfigContextState>;
118
118
 
119
- type RequireAtLeastOne<T, R extends keyof T = keyof T> = Omit<T, R> & {
119
+ declare type RequireAtLeastOne<T, R extends keyof T = keyof T> = Omit<T, R> & {
120
120
  [K in R]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<R, K>>>;
121
121
  }[R];
122
122
  interface ConfigProviderProps {
@@ -130,7 +130,7 @@ interface ConfigProviderProps {
130
130
  }
131
131
  declare const OrderlyConfigProvider: (props: PropsWithChildren<RequireAtLeastOne<ConfigProviderProps, "brokerId" | "configStore">>) => react_jsx_runtime.JSX.Element | null;
132
132
 
133
- type ConnectedChain = {
133
+ declare type ConnectedChain = {
134
134
  id: string;
135
135
  };
136
136
  interface WalletConnectorContextState {
@@ -146,19 +146,19 @@ interface WalletConnectorContextState {
146
146
  declare const WalletConnectorContext: react.Context<WalletConnectorContextState>;
147
147
  declare const useWalletConnector: () => WalletConnectorContextState;
148
148
 
149
- type OrderBookItem = number[];
150
- type OrderbookData = {
149
+ declare type OrderBookItem = number[];
150
+ declare type OrderbookData = {
151
151
  asks: OrderBookItem[];
152
152
  bids: OrderBookItem[];
153
153
  };
154
- type OrderbookOptions = {
154
+ declare type OrderbookOptions = {
155
155
  level?: number;
156
156
  };
157
157
  /**
158
158
  * @name useOrderbookStream
159
159
  * @description React hook that returns the current orderbook for a given market
160
160
  */
161
- declare const useOrderbookStream: (symbol: string, initial?: OrderbookData, options?: OrderbookOptions) => ({
161
+ declare const useOrderbookStream: (symbol: string, initial?: OrderbookData, options?: OrderbookOptions | undefined) => ({
162
162
  asks: OrderBookItem[];
163
163
  bids: OrderBookItem[];
164
164
  markPrice: any;
@@ -180,7 +180,7 @@ declare const useOrderbookStream: (symbol: string, initial?: OrderbookData, opti
180
180
  middlePrice?: undefined;
181
181
  })[];
182
182
 
183
- type UseOrderEntryOptions = {
183
+ declare type UseOrderEntryOptions = {
184
184
  commify?: boolean;
185
185
  validate?: (data: OrderEntity) => {
186
186
  [P in keyof OrderEntity]?: string;
@@ -191,7 +191,7 @@ type UseOrderEntryOptions = {
191
191
  * @param symbol
192
192
  * @returns
193
193
  */
194
- declare const useOrderEntry: (symbol: string, side: OrderSide, reduceOnly?: boolean, options?: UseOrderEntryOptions) => {
194
+ declare const useOrderEntry: (symbol: string, side: OrderSide, reduceOnly?: boolean, options?: UseOrderEntryOptions | undefined) => {
195
195
  maxQty: number;
196
196
  freeCollateral: number;
197
197
  markPrice: any;
@@ -233,7 +233,7 @@ declare const useFundingRate: (symbol: string) => {
233
233
  sum_unitary_funding?: number | undefined;
234
234
  };
235
235
 
236
- declare const usePositionStream: (symbol?: string, options?: SWRConfiguration) => readonly [{
236
+ declare const usePositionStream: (symbol?: string | undefined, options?: Partial<swr__internal.PublicConfiguration<any, any, swr__internal.BareFetcher<any>>> | undefined) => readonly [{
237
237
  readonly rows: API.PositionExt[] | null;
238
238
  readonly aggregated: any;
239
239
  readonly totalCollateral: Decimal;
@@ -246,7 +246,7 @@ declare const usePositionStream: (symbol?: string, options?: SWRConfiguration) =
246
246
  readonly refresh: () => void;
247
247
  }];
248
248
 
249
- type Params = {
249
+ declare type Params = {
250
250
  symbol?: string;
251
251
  status?: OrderStatus;
252
252
  size?: number;
@@ -258,7 +258,7 @@ declare const useOrderStream: (params: Params) => readonly [any[] | null, {
258
258
  readonly loadMore: () => void;
259
259
  readonly cancelAllOrders: () => void;
260
260
  readonly updateOrder: (orderId: string, order: OrderEntity) => Promise<any>;
261
- readonly cancelOrder: (orderId: string, symbol?: string) => Promise<any>;
261
+ readonly cancelOrder: (orderId: string, symbol?: string | undefined) => Promise<any>;
262
262
  readonly errors: {
263
263
  readonly cancelOrder: unknown;
264
264
  readonly updateOrder: unknown;
@@ -277,14 +277,14 @@ declare const useMarketTradeStream: (symbol: string, options?: MarketTradeStream
277
277
  isLoading: boolean;
278
278
  };
279
279
 
280
- type CollateralOutputs = {
280
+ declare type CollateralOutputs = {
281
281
  totalCollateral: number;
282
282
  freeCollateral: number;
283
283
  totalValue: number;
284
284
  availableBalance: number;
285
285
  unsettledPnL: number;
286
286
  };
287
- type Options = {
287
+ declare type Options = {
288
288
  dp: number;
289
289
  };
290
290
  declare const useCollateral: (options?: Options) => CollateralOutputs;
@@ -296,18 +296,18 @@ declare const useMarginRatio: () => {
296
296
  currentLeverage: number;
297
297
  };
298
298
 
299
- type inputOptions = {
299
+ declare type inputOptions = {
300
300
  filter?: (item: API.Chain) => boolean;
301
301
  pick?: "dexs" | "network_infos" | "token_infos";
302
302
  crossEnabled?: boolean;
303
303
  /** if true, use wooSwap api, else use orderly api only */
304
304
  wooSwapEnabled?: boolean;
305
305
  };
306
- declare const useChains: (networkId?: NetworkId, options?: inputOptions & SWRConfiguration) => readonly [API.Chain[] | {
306
+ declare const useChains: (networkId?: NetworkId | undefined, options?: inputOptions & SWRConfiguration) => readonly [API.Chain[] | {
307
307
  testnet: API.Chain[];
308
308
  mainnet: API.Chain[];
309
309
  }, {
310
- readonly findByChainId: (chainId: number, field?: string) => (API.Chain & {
310
+ readonly findByChainId: (chainId: number, field?: string | undefined) => (API.Chain & {
311
311
  nativeToken?: API.TokenInfo | undefined;
312
312
  }) | (<K extends never>(prop: K) => ((API.Chain & {
313
313
  nativeToken?: API.TokenInfo | undefined;
@@ -332,7 +332,7 @@ declare const useWithdraw: () => {
332
332
  unsettledPnL: number;
333
333
  };
334
334
 
335
- type useDepositOptions = {
335
+ declare type useDepositOptions = {
336
336
  address?: string;
337
337
  decimals?: number;
338
338
  crossChainRouteAddress?: string;
@@ -345,7 +345,7 @@ type useDepositOptions = {
345
345
  */
346
346
  wooSwapEnabled?: boolean;
347
347
  };
348
- declare const useDeposit: (options?: useDepositOptions) => {
348
+ declare const useDeposit: (options?: useDepositOptions | undefined) => {
349
349
  dst: {
350
350
  symbol: string;
351
351
  address: string | undefined;
@@ -361,7 +361,7 @@ declare const useDeposit: (options?: useDepositOptions) => {
361
361
  approve: (amount: string | undefined) => Promise<any>;
362
362
  deposit: (amount: string) => Promise<any>;
363
363
  fetchBalances: (tokens: API.TokenInfo[]) => Promise<void>;
364
- fetchBalance: (address: string, decimals?: number) => Promise<string>;
364
+ fetchBalance: (address: string, decimals?: number | undefined) => Promise<string>;
365
365
  };
366
366
 
367
367
  declare const useHoldingStream: () => {
package/dist/index.js CHANGED
@@ -28,9 +28,9 @@ var useSWRSubscription__default = /*#__PURE__*/_interopDefault(useSWRSubscriptio
28
28
  // src/version.ts
29
29
  if (typeof window !== "undefined") {
30
30
  window.__ORDERLY_VERSION__ = window.__ORDERLY_VERSION__ || {};
31
- window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "1.0.25-alpha.9";
31
+ window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "1.0.25";
32
32
  }
33
- var version_default = "1.0.25-alpha.9";
33
+ var version_default = "1.0.25";
34
34
  var fetcher = (url, init = {}, queryOptions) => net.get(url, init, queryOptions?.formatter);
35
35
  var OrderlyContext = React.createContext({
36
36
  // configStore: new MemoryConfigStore(),