@orderly.network/hooks 0.0.8 → 0.0.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orderly.network/hooks",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -21,7 +21,7 @@
21
21
  "rxjs": "^7.8.1",
22
22
  "tsup": "^7.1.0",
23
23
  "typescript": "^5.1.6",
24
- "tsconfig": "0.0.5"
24
+ "tsconfig": "0.0.6"
25
25
  },
26
26
  "dependencies": {
27
27
  "formik": "^2.4.3",
@@ -29,11 +29,11 @@
29
29
  "rxjs-hooks": "0.8.0-alpha.0",
30
30
  "swr": "^2.2.0",
31
31
  "use-constant": "^1.1.1",
32
- "@orderly.network/core": "0.0.7",
33
- "@orderly.network/futures": "0.0.8",
34
- "@orderly.network/types": "0.0.7",
32
+ "@orderly.network/core": "0.0.8",
35
33
  "@orderly.network/utils": "0.0.2",
36
- "@orderly.network/net": "1.0.5"
34
+ "@orderly.network/futures": "0.0.9",
35
+ "@orderly.network/net": "1.0.6",
36
+ "@orderly.network/types": "0.0.8"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "rxjs": "^7.8.1"
package/dist/index.d.mts DELETED
@@ -1,271 +0,0 @@
1
- import useSWR, { SWRConfiguration, SWRResponse } from 'swr';
2
- export { SWRConfiguration, default as useSWR } from 'swr';
3
- import { SWRMutationConfiguration } from 'swr/mutation';
4
- import { Account, AccountState, ConfigStore, OrderlyKeyStore, WalletAdapter, WSMessage } from '@orderly.network/core';
5
- import { SystemStateEnum, ExchangeStatusEnum, OrderEntity, API, OrderSide } from '@orderly.network/types';
6
- import { WebSocketClient, WS } from '@orderly.network/net';
7
- export { useEventCallback, useObservable } from 'rxjs-hooks';
8
- export { default as useConstant } from 'use-constant';
9
- import * as react from 'react';
10
- import { FC, PropsWithChildren } from 'react';
11
- import { FormikErrors, FormikState } from 'formik';
12
- import * as swr__internal from 'swr/_internal';
13
- import * as swr_subscription from 'swr/subscription';
14
-
15
- type useQueryOptions<T> = SWRConfiguration & {
16
- formatter?: (data: any) => T;
17
- };
18
-
19
- /**
20
- * useQuery
21
- * @description for public api
22
- * @param query
23
- * @param options
24
- */
25
- declare const useQuery: <T>(query: Parameters<typeof useSWR>["0"], options?: useQueryOptions<T> | undefined) => SWRResponse<T, any, any>;
26
-
27
- declare const useMutation: <T, E>(url: string, options?: SWRMutationConfiguration<T, E> | undefined) => {
28
- mutation: (data: any) => Promise<any>;
29
- data: any;
30
- error: E | undefined;
31
- reset: () => void;
32
- isMutating: boolean;
33
- };
34
-
35
- /**
36
- * usePrivateQuery
37
- * @description for private api
38
- * @param query
39
- * @param options
40
- */
41
- declare const usePrivateQuery: <T>(query: string, options?: useQueryOptions<T> | undefined) => SWRResponse<T, any, any>;
42
-
43
- declare const useTradingView: () => {};
44
-
45
- declare const usePrivateObserve: <T>() => {
46
- data: T | undefined;
47
- };
48
-
49
- declare const useTopicObserve: <T>(topic: string) => {
50
- data: T | undefined;
51
- };
52
-
53
- declare const useAccount: () => {
54
- account: Account;
55
- state: AccountState;
56
- login: (address: string) => void;
57
- };
58
-
59
- declare const useAppState: () => {
60
- systemState: SystemStateEnum;
61
- exchangeState: ExchangeStatusEnum;
62
- };
63
-
64
- declare const useWebSocketClient: () => WebSocketClient;
65
-
66
- declare const DataSourceProvider: FC<PropsWithChildren>;
67
-
68
- declare const useWS: () => WS;
69
-
70
- interface OrderlyAppConfig {
71
- logoUrl: string;
72
- theme: any;
73
- }
74
- interface OrderlyContextState extends OrderlyAppConfig {
75
- fetcher?: (url: string, init: RequestInit) => Promise<any>;
76
- apiBaseUrl: string;
77
- configStore: ConfigStore;
78
- keyStore: OrderlyKeyStore;
79
- walletAdapter: WalletAdapter;
80
- networkId: string;
81
- }
82
- declare const OrderlyContext: react.Context<OrderlyContextState>;
83
- declare const OrderlyProvider: react.Provider<OrderlyContextState>;
84
-
85
- type OrderBookItem = number[];
86
- type OrderbookData = {
87
- asks: OrderBookItem[];
88
- bids: OrderBookItem[];
89
- };
90
- type OrderbookOptions = {
91
- level?: number;
92
- };
93
- /**
94
- * @name useOrderbook
95
- * @description React hook that returns the current orderbook for a given market
96
- */
97
- declare const useOrderbook: (symbol: string, initial?: OrderbookData, options?: OrderbookOptions) => ({
98
- markPrice: number;
99
- middlePrice: any;
100
- asks: OrderBookItem[];
101
- bids: OrderBookItem[];
102
- onDepthChange?: undefined;
103
- depth?: undefined;
104
- } | {
105
- onDepthChange: (depth: number) => void;
106
- depth: number;
107
- })[];
108
-
109
- type OrderEntityKey = keyof OrderEntity & string;
110
-
111
- interface OrderEntryReturn {
112
- onSubmit: (values?: OrderEntity) => Promise<any>;
113
- validateForm: (values?: any) => Promise<FormikErrors<OrderEntity>>;
114
- resetForm: (nextState?: Partial<FormikState<OrderEntity>>) => void;
115
- setValue: (field: OrderEntityKey, value: any) => void;
116
- maxQty: number;
117
- freeCollateral: number;
118
- values: OrderEntity;
119
- markPrice: number;
120
- errors: Partial<Record<keyof OrderEntity, string>>;
121
- symbolConfig: API.SymbolExt;
122
- submitCount: number;
123
- isSubmitting: boolean;
124
- onFocus?: (field: keyof OrderEntity) => void;
125
- onBlur?: (field: keyof OrderEntity) => void;
126
- }
127
- type UseOrderEntryOptions = {
128
- commify?: boolean;
129
- validate?: (data: OrderEntity) => {
130
- [P in keyof OrderEntity]?: string;
131
- } | null | undefined;
132
- };
133
- /**
134
- * 创建订单
135
- * @param symbol
136
- * @returns
137
- */
138
- declare const useOrderEntry: (symbol: string, initialValue?: Partial<OrderEntity>, options?: UseOrderEntryOptions) => OrderEntryReturn;
139
-
140
- interface MarketInfo {
141
- }
142
- declare const useFetures: () => {
143
- data: MarketInfo[] | undefined;
144
- sortBy: (key: string) => void;
145
- filterBy: (key: string) => void;
146
- isLoading: boolean;
147
- error: any;
148
- };
149
-
150
- declare const useSymbolsInfo: () => any;
151
-
152
- declare const useAccountInfo: () => swr__internal.SWRResponse<API.AccountInfo, any, any>;
153
-
154
- declare const useTokenInfo: () => any;
155
-
156
- declare const useMarketsStream: () => {
157
- data: WSMessage.Ticker[] | null;
158
- };
159
-
160
- declare const useMarkPricesStream: () => swr_subscription.SWRSubscriptionResponse<any, any>;
161
-
162
- declare const useTickerStream: (symbol: string) => any;
163
-
164
- declare const useFundingRate$1: (symbol: string) => {
165
- countDown: string;
166
- symbol?: string | undefined;
167
- est_funding_rate?: number | undefined;
168
- est_funding_rate_timestamp?: number | undefined;
169
- last_funding_rate?: number | undefined;
170
- last_funding_rate_timestamp?: number | undefined;
171
- next_funding_time?: number | undefined;
172
- sum_unitary_funding?: number | undefined;
173
- };
174
-
175
- declare const usePositionStream: (symbol?: string, options?: SWRConfiguration) => any[];
176
-
177
- declare enum OrderStatus {
178
- FILLED = "FILLED",
179
- PARTIAL_FILLED = "PARTIAL_FILLED",
180
- CANCELED = "CANCELED",
181
- NEW = "NEW",
182
- COMPLETED = "COMPLETED"
183
- }
184
- declare const useOrderStream: ({ status, symbol, }?: {
185
- symbol?: string | undefined;
186
- status?: OrderStatus | undefined;
187
- }) => (any[] | {
188
- cancelAllOrders: () => void;
189
- updateOrder: (id: string, data: any) => void;
190
- cancelOrder: (id: string) => void;
191
- } | null)[];
192
-
193
- type CollateralOutputs = {
194
- totalCollateral: number;
195
- freeCollateral: number;
196
- totalValue: number;
197
- };
198
- /**
199
- * 用户保证金
200
- * @returns
201
- */
202
- declare const useCollateral: (dp?: number) => CollateralOutputs;
203
-
204
- declare const useMaxQty: (symbol: string, side: OrderSide, reduceOnly?: boolean) => number;
205
-
206
- interface Info {
207
- symbol: string;
208
- quote_min: number;
209
- quote_max: number;
210
- quote_tick: number;
211
- base_min: number;
212
- base_max: number;
213
- base_tick: number;
214
- min_notional: number;
215
- price_range: number;
216
- created_time: number;
217
- updated_time: number;
218
- }
219
- /**
220
- * useInfo
221
- * @returns
222
- */
223
- declare const useInfo: () => swr__internal.SWRResponse<Info[], any, any>;
224
-
225
- interface Token {
226
- token: string;
227
- token_account_id: string;
228
- decimals: number;
229
- minimum_increment: number;
230
- }
231
- /**
232
- * useToken
233
- * @description get token info
234
- */
235
- declare const useToken: () => swr__internal.SWRResponse<Token[], any, any>;
236
-
237
- interface FundingRate {
238
- symbol: string;
239
- est_funding_rate: number;
240
- est_funding_rate_timestamp: number;
241
- last_funding_rate: number;
242
- last_funding_rate_timestamp: number;
243
- next_funding_time: number;
244
- sum_unitary_funding: number;
245
- }
246
- /**
247
- * FundingRate
248
- * @param symbol
249
- */
250
- declare const useFundingRateBySymbol: (symbol: string) => swr__internal.SWRResponse<FundingRate, any, any>;
251
-
252
- /**
253
- * FundingRate
254
- * @param symbol
255
- */
256
- declare const useFundingRate: (symbol?: string) => swr__internal.SWRResponse<FundingRate, any, any>;
257
-
258
- declare const index_useFundingRate: typeof useFundingRate;
259
- declare const index_useFundingRateBySymbol: typeof useFundingRateBySymbol;
260
- declare const index_useInfo: typeof useInfo;
261
- declare const index_useToken: typeof useToken;
262
- declare namespace index {
263
- export {
264
- index_useFundingRate as useFundingRate,
265
- index_useFundingRateBySymbol as useFundingRateBySymbol,
266
- index_useInfo as useInfo,
267
- index_useToken as useToken,
268
- };
269
- }
270
-
271
- export { DataSourceProvider, OrderStatus, OrderlyAppConfig, OrderlyContext, OrderlyContextState, OrderlyProvider, index as apis, useAccount, useAccountInfo, useAppState, useCollateral, useFetures, useFundingRate$1 as useFundingRate, useMarkPricesStream, useMarketsStream, useMaxQty, useMutation, useOrderEntry, useOrderStream, useOrderbook, usePositionStream, usePrivateObserve, usePrivateQuery, useQuery, useSymbolsInfo, useTickerStream, useTokenInfo, useTopicObserve, useTradingView, useWS, useWebSocketClient };
package/dist/index.d.ts DELETED
@@ -1,271 +0,0 @@
1
- import useSWR, { SWRConfiguration, SWRResponse } from 'swr';
2
- export { SWRConfiguration, default as useSWR } from 'swr';
3
- import { SWRMutationConfiguration } from 'swr/mutation';
4
- import { Account, AccountState, ConfigStore, OrderlyKeyStore, WalletAdapter, WSMessage } from '@orderly.network/core';
5
- import { SystemStateEnum, ExchangeStatusEnum, OrderEntity, API, OrderSide } from '@orderly.network/types';
6
- import { WebSocketClient, WS } from '@orderly.network/net';
7
- export { useEventCallback, useObservable } from 'rxjs-hooks';
8
- export { default as useConstant } from 'use-constant';
9
- import * as react from 'react';
10
- import { FC, PropsWithChildren } from 'react';
11
- import { FormikErrors, FormikState } from 'formik';
12
- import * as swr__internal from 'swr/_internal';
13
- import * as swr_subscription from 'swr/subscription';
14
-
15
- type useQueryOptions<T> = SWRConfiguration & {
16
- formatter?: (data: any) => T;
17
- };
18
-
19
- /**
20
- * useQuery
21
- * @description for public api
22
- * @param query
23
- * @param options
24
- */
25
- declare const useQuery: <T>(query: Parameters<typeof useSWR>["0"], options?: useQueryOptions<T> | undefined) => SWRResponse<T, any, any>;
26
-
27
- declare const useMutation: <T, E>(url: string, options?: SWRMutationConfiguration<T, E> | undefined) => {
28
- mutation: (data: any) => Promise<any>;
29
- data: any;
30
- error: E | undefined;
31
- reset: () => void;
32
- isMutating: boolean;
33
- };
34
-
35
- /**
36
- * usePrivateQuery
37
- * @description for private api
38
- * @param query
39
- * @param options
40
- */
41
- declare const usePrivateQuery: <T>(query: string, options?: useQueryOptions<T> | undefined) => SWRResponse<T, any, any>;
42
-
43
- declare const useTradingView: () => {};
44
-
45
- declare const usePrivateObserve: <T>() => {
46
- data: T | undefined;
47
- };
48
-
49
- declare const useTopicObserve: <T>(topic: string) => {
50
- data: T | undefined;
51
- };
52
-
53
- declare const useAccount: () => {
54
- account: Account;
55
- state: AccountState;
56
- login: (address: string) => void;
57
- };
58
-
59
- declare const useAppState: () => {
60
- systemState: SystemStateEnum;
61
- exchangeState: ExchangeStatusEnum;
62
- };
63
-
64
- declare const useWebSocketClient: () => WebSocketClient;
65
-
66
- declare const DataSourceProvider: FC<PropsWithChildren>;
67
-
68
- declare const useWS: () => WS;
69
-
70
- interface OrderlyAppConfig {
71
- logoUrl: string;
72
- theme: any;
73
- }
74
- interface OrderlyContextState extends OrderlyAppConfig {
75
- fetcher?: (url: string, init: RequestInit) => Promise<any>;
76
- apiBaseUrl: string;
77
- configStore: ConfigStore;
78
- keyStore: OrderlyKeyStore;
79
- walletAdapter: WalletAdapter;
80
- networkId: string;
81
- }
82
- declare const OrderlyContext: react.Context<OrderlyContextState>;
83
- declare const OrderlyProvider: react.Provider<OrderlyContextState>;
84
-
85
- type OrderBookItem = number[];
86
- type OrderbookData = {
87
- asks: OrderBookItem[];
88
- bids: OrderBookItem[];
89
- };
90
- type OrderbookOptions = {
91
- level?: number;
92
- };
93
- /**
94
- * @name useOrderbook
95
- * @description React hook that returns the current orderbook for a given market
96
- */
97
- declare const useOrderbook: (symbol: string, initial?: OrderbookData, options?: OrderbookOptions) => ({
98
- markPrice: number;
99
- middlePrice: any;
100
- asks: OrderBookItem[];
101
- bids: OrderBookItem[];
102
- onDepthChange?: undefined;
103
- depth?: undefined;
104
- } | {
105
- onDepthChange: (depth: number) => void;
106
- depth: number;
107
- })[];
108
-
109
- type OrderEntityKey = keyof OrderEntity & string;
110
-
111
- interface OrderEntryReturn {
112
- onSubmit: (values?: OrderEntity) => Promise<any>;
113
- validateForm: (values?: any) => Promise<FormikErrors<OrderEntity>>;
114
- resetForm: (nextState?: Partial<FormikState<OrderEntity>>) => void;
115
- setValue: (field: OrderEntityKey, value: any) => void;
116
- maxQty: number;
117
- freeCollateral: number;
118
- values: OrderEntity;
119
- markPrice: number;
120
- errors: Partial<Record<keyof OrderEntity, string>>;
121
- symbolConfig: API.SymbolExt;
122
- submitCount: number;
123
- isSubmitting: boolean;
124
- onFocus?: (field: keyof OrderEntity) => void;
125
- onBlur?: (field: keyof OrderEntity) => void;
126
- }
127
- type UseOrderEntryOptions = {
128
- commify?: boolean;
129
- validate?: (data: OrderEntity) => {
130
- [P in keyof OrderEntity]?: string;
131
- } | null | undefined;
132
- };
133
- /**
134
- * 创建订单
135
- * @param symbol
136
- * @returns
137
- */
138
- declare const useOrderEntry: (symbol: string, initialValue?: Partial<OrderEntity>, options?: UseOrderEntryOptions) => OrderEntryReturn;
139
-
140
- interface MarketInfo {
141
- }
142
- declare const useFetures: () => {
143
- data: MarketInfo[] | undefined;
144
- sortBy: (key: string) => void;
145
- filterBy: (key: string) => void;
146
- isLoading: boolean;
147
- error: any;
148
- };
149
-
150
- declare const useSymbolsInfo: () => any;
151
-
152
- declare const useAccountInfo: () => swr__internal.SWRResponse<API.AccountInfo, any, any>;
153
-
154
- declare const useTokenInfo: () => any;
155
-
156
- declare const useMarketsStream: () => {
157
- data: WSMessage.Ticker[] | null;
158
- };
159
-
160
- declare const useMarkPricesStream: () => swr_subscription.SWRSubscriptionResponse<any, any>;
161
-
162
- declare const useTickerStream: (symbol: string) => any;
163
-
164
- declare const useFundingRate$1: (symbol: string) => {
165
- countDown: string;
166
- symbol?: string | undefined;
167
- est_funding_rate?: number | undefined;
168
- est_funding_rate_timestamp?: number | undefined;
169
- last_funding_rate?: number | undefined;
170
- last_funding_rate_timestamp?: number | undefined;
171
- next_funding_time?: number | undefined;
172
- sum_unitary_funding?: number | undefined;
173
- };
174
-
175
- declare const usePositionStream: (symbol?: string, options?: SWRConfiguration) => any[];
176
-
177
- declare enum OrderStatus {
178
- FILLED = "FILLED",
179
- PARTIAL_FILLED = "PARTIAL_FILLED",
180
- CANCELED = "CANCELED",
181
- NEW = "NEW",
182
- COMPLETED = "COMPLETED"
183
- }
184
- declare const useOrderStream: ({ status, symbol, }?: {
185
- symbol?: string | undefined;
186
- status?: OrderStatus | undefined;
187
- }) => (any[] | {
188
- cancelAllOrders: () => void;
189
- updateOrder: (id: string, data: any) => void;
190
- cancelOrder: (id: string) => void;
191
- } | null)[];
192
-
193
- type CollateralOutputs = {
194
- totalCollateral: number;
195
- freeCollateral: number;
196
- totalValue: number;
197
- };
198
- /**
199
- * 用户保证金
200
- * @returns
201
- */
202
- declare const useCollateral: (dp?: number) => CollateralOutputs;
203
-
204
- declare const useMaxQty: (symbol: string, side: OrderSide, reduceOnly?: boolean) => number;
205
-
206
- interface Info {
207
- symbol: string;
208
- quote_min: number;
209
- quote_max: number;
210
- quote_tick: number;
211
- base_min: number;
212
- base_max: number;
213
- base_tick: number;
214
- min_notional: number;
215
- price_range: number;
216
- created_time: number;
217
- updated_time: number;
218
- }
219
- /**
220
- * useInfo
221
- * @returns
222
- */
223
- declare const useInfo: () => swr__internal.SWRResponse<Info[], any, any>;
224
-
225
- interface Token {
226
- token: string;
227
- token_account_id: string;
228
- decimals: number;
229
- minimum_increment: number;
230
- }
231
- /**
232
- * useToken
233
- * @description get token info
234
- */
235
- declare const useToken: () => swr__internal.SWRResponse<Token[], any, any>;
236
-
237
- interface FundingRate {
238
- symbol: string;
239
- est_funding_rate: number;
240
- est_funding_rate_timestamp: number;
241
- last_funding_rate: number;
242
- last_funding_rate_timestamp: number;
243
- next_funding_time: number;
244
- sum_unitary_funding: number;
245
- }
246
- /**
247
- * FundingRate
248
- * @param symbol
249
- */
250
- declare const useFundingRateBySymbol: (symbol: string) => swr__internal.SWRResponse<FundingRate, any, any>;
251
-
252
- /**
253
- * FundingRate
254
- * @param symbol
255
- */
256
- declare const useFundingRate: (symbol?: string) => swr__internal.SWRResponse<FundingRate, any, any>;
257
-
258
- declare const index_useFundingRate: typeof useFundingRate;
259
- declare const index_useFundingRateBySymbol: typeof useFundingRateBySymbol;
260
- declare const index_useInfo: typeof useInfo;
261
- declare const index_useToken: typeof useToken;
262
- declare namespace index {
263
- export {
264
- index_useFundingRate as useFundingRate,
265
- index_useFundingRateBySymbol as useFundingRateBySymbol,
266
- index_useInfo as useInfo,
267
- index_useToken as useToken,
268
- };
269
- }
270
-
271
- export { DataSourceProvider, OrderStatus, OrderlyAppConfig, OrderlyContext, OrderlyContextState, OrderlyProvider, index as apis, useAccount, useAccountInfo, useAppState, useCollateral, useFetures, useFundingRate$1 as useFundingRate, useMarkPricesStream, useMarketsStream, useMaxQty, useMutation, useOrderEntry, useOrderStream, useOrderbook, usePositionStream, usePrivateObserve, usePrivateQuery, useQuery, useSymbolsInfo, useTickerStream, useTokenInfo, useTopicObserve, useTradingView, useWS, useWebSocketClient };