@kodiak-finance/orderly-hooks 2.7.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 +2427 -0
- package/dist/index.d.ts +2427 -0
- package/dist/index.js +17962 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +17763 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +98 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,2427 @@
|
|
|
1
|
+
import * as swr from 'swr';
|
|
2
|
+
import { SWRConfiguration, SWRHook, SWRResponse } from 'swr';
|
|
3
|
+
export { swr };
|
|
4
|
+
export { KeyedMutator, Middleware, SWRConfiguration, SWRHook, SWRResponse, unstable_serialize, default as useSWR, useSWRConfig } from 'swr';
|
|
5
|
+
import * as swr_mutation from 'swr/mutation';
|
|
6
|
+
import { SWRMutationConfiguration, SWRMutationResponse } from 'swr/mutation';
|
|
7
|
+
import * as swr_infinite from 'swr/infinite';
|
|
8
|
+
import { SWRInfiniteKeyLoader, SWRInfiniteConfiguration } from 'swr/infinite';
|
|
9
|
+
import * as react from 'react';
|
|
10
|
+
import react__default, { PropsWithChildren, FC, ReactNode } from 'react';
|
|
11
|
+
import * as _kodiak_finance_orderly_types from '@kodiak-finance/orderly-types';
|
|
12
|
+
import { NetworkId, TrackerEventName, API, Chain as Chain$1, OrderlyOrder, ChainNamespace, WSMessage, OrderType, OrderStatus, OrderSide, AlgoOrderRootType, OrderEntity, PositionType, AlgoOrderEntity, AssetHistoryStatusEnum, AlgoOrderType, RequireKeys } from '@kodiak-finance/orderly-types';
|
|
13
|
+
import * as _kodiak_finance_orderly_core from '@kodiak-finance/orderly-core';
|
|
14
|
+
import { AccountState, Account, EventEmitter, ConfigStore, ConfigKey, SimpleDI, OrderlyKeyStore, WalletAdapter, IContract, DefaultConfigStore } from '@kodiak-finance/orderly-core';
|
|
15
|
+
export { SubAccount, WalletAdapter } from '@kodiak-finance/orderly-core';
|
|
16
|
+
import * as lodash from 'lodash';
|
|
17
|
+
import * as amplitude from '@amplitude/analytics-browser';
|
|
18
|
+
export { default as useConstant } from 'use-constant';
|
|
19
|
+
import { WS } from '@kodiak-finance/orderly-net';
|
|
20
|
+
import { EIP1193Provider } from '@web3-onboard/common';
|
|
21
|
+
import { SolanaWalletProvider } from '@kodiak-finance/orderly-default-solana-adapter';
|
|
22
|
+
import * as swr_subscription from 'swr/subscription';
|
|
23
|
+
import * as _kodiak_finance_orderly_utils from '@kodiak-finance/orderly-utils';
|
|
24
|
+
import { Decimal } from '@kodiak-finance/orderly-utils';
|
|
25
|
+
export * from 'use-debounce';
|
|
26
|
+
import * as immer from 'immer';
|
|
27
|
+
import * as zustand from 'zustand';
|
|
28
|
+
|
|
29
|
+
declare global {
|
|
30
|
+
interface Window {
|
|
31
|
+
__ORDERLY_VERSION__?: {
|
|
32
|
+
[key: string]: string;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
declare const _default: "2.7.4";
|
|
37
|
+
|
|
38
|
+
declare const fetcher: (url: string, init: RequestInit | undefined, queryOptions: useQueryOptions<any>) => Promise<any>;
|
|
39
|
+
type useQueryOptions<T> = SWRConfiguration & {
|
|
40
|
+
formatter?: (data: any) => T;
|
|
41
|
+
};
|
|
42
|
+
declare const noCacheConfig: SWRConfiguration;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* useQuery
|
|
46
|
+
* @description for public api
|
|
47
|
+
* @param query
|
|
48
|
+
* @param options
|
|
49
|
+
*/
|
|
50
|
+
declare const useQuery: <T>(query: Parameters<SWRHook>[0], options?: useQueryOptions<T>) => SWRResponse<T>;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* useQuery
|
|
54
|
+
* @description for public api
|
|
55
|
+
* @param query
|
|
56
|
+
* @param options
|
|
57
|
+
*/
|
|
58
|
+
declare const useLazyQuery: <T, R = any>(query: Parameters<SWRHook>[0], options?: SWRMutationConfiguration<any, any> & {
|
|
59
|
+
formatter?: (data: any) => R;
|
|
60
|
+
init?: RequestInit;
|
|
61
|
+
}) => SWRMutationResponse;
|
|
62
|
+
|
|
63
|
+
type HTTP_METHOD$1 = "POST" | "PUT" | "DELETE" | "GET";
|
|
64
|
+
/**
|
|
65
|
+
* This hook is used to execute API requests for data mutation, such as POST, DELETE, PUT, etc.
|
|
66
|
+
*/
|
|
67
|
+
declare const useMutation: <T, E>(
|
|
68
|
+
/**
|
|
69
|
+
* The URL to send the request to. If the URL does not start with "http",
|
|
70
|
+
* it will be prefixed with the API base URL.
|
|
71
|
+
*/
|
|
72
|
+
url: string,
|
|
73
|
+
/**
|
|
74
|
+
* The HTTP method to use for the request. Defaults to "POST".
|
|
75
|
+
*/
|
|
76
|
+
method?: HTTP_METHOD$1,
|
|
77
|
+
/**
|
|
78
|
+
* The configuration object for the mutation.
|
|
79
|
+
* @see [useSWRMutation](https://swr.vercel.app/docs/mutation#api)
|
|
80
|
+
*
|
|
81
|
+
* @link https://swr.vercel.app/docs/mutation#api
|
|
82
|
+
*/
|
|
83
|
+
options?: SWRMutationConfiguration<T, E>) => readonly [(this: unknown, data: Record<string, any> | null, params?: Record<string, any> | undefined, options?: SWRMutationConfiguration<T, E> | undefined) => Promise<any>, {
|
|
84
|
+
readonly data: any;
|
|
85
|
+
readonly error: E | undefined;
|
|
86
|
+
readonly reset: () => void;
|
|
87
|
+
readonly isMutating: boolean;
|
|
88
|
+
}];
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* usePrivateQuery
|
|
92
|
+
* @description for private api
|
|
93
|
+
* @param query
|
|
94
|
+
* @param options
|
|
95
|
+
*/
|
|
96
|
+
declare const usePrivateQuery: <T>(query: Parameters<SWRHook>[0], options?: useQueryOptions<T>) => SWRResponse<T>;
|
|
97
|
+
|
|
98
|
+
declare const usePrivateInfiniteQuery: <T>(getKey: SWRInfiniteKeyLoader | null, options?: SWRInfiniteConfiguration & {
|
|
99
|
+
formatter?: (data: any) => any;
|
|
100
|
+
}) => swr_infinite.SWRInfiniteResponse<T, any>;
|
|
101
|
+
|
|
102
|
+
declare const useInfiniteQuery: <T>(getKey: SWRInfiniteKeyLoader, options?: SWRInfiniteConfiguration & {
|
|
103
|
+
formatter?: (data: any) => any;
|
|
104
|
+
}) => swr_infinite.SWRInfiniteResponse<T, any>;
|
|
105
|
+
|
|
106
|
+
declare const useBoolean: (initialValue?: boolean) => [boolean, {
|
|
107
|
+
setTrue: () => void;
|
|
108
|
+
setFalse: () => void;
|
|
109
|
+
toggle: () => void;
|
|
110
|
+
}];
|
|
111
|
+
|
|
112
|
+
type NotFunction<T> = T extends (...args: any[]) => any ? never : T;
|
|
113
|
+
declare const useUpdatedRef: <T>(val: NotFunction<T>) => react.MutableRefObject<T>;
|
|
114
|
+
|
|
115
|
+
type noop = (this: any, ...args: any[]) => any;
|
|
116
|
+
type PickFunction<T extends noop> = (this: ThisParameterType<T>, ...args: Parameters<T>) => ReturnType<T>;
|
|
117
|
+
declare const useMemoizedFn: <T extends noop>(fn?: T) => PickFunction<T>;
|
|
118
|
+
|
|
119
|
+
interface AudioPlayerOptions {
|
|
120
|
+
volume?: number;
|
|
121
|
+
loop?: boolean;
|
|
122
|
+
autoPlay?: boolean;
|
|
123
|
+
}
|
|
124
|
+
declare const useAudioPlayer: (src: string, options?: AudioPlayerOptions) => readonly [react__default.DetailedReactHTMLElement<{
|
|
125
|
+
controls: boolean;
|
|
126
|
+
ref: react__default.MutableRefObject<HTMLAudioElement | null>;
|
|
127
|
+
autoPlay: boolean | undefined;
|
|
128
|
+
src: string;
|
|
129
|
+
style: {
|
|
130
|
+
display: "none";
|
|
131
|
+
};
|
|
132
|
+
onPlay: () => void;
|
|
133
|
+
onPlaying: () => void;
|
|
134
|
+
onPause: () => void;
|
|
135
|
+
onEnded: () => void;
|
|
136
|
+
onError: () => void;
|
|
137
|
+
}, HTMLAudioElement>, react__default.MutableRefObject<HTMLAudioElement | null>, "error" | "paused" | "idle" | "play" | "playing" | "ended"];
|
|
138
|
+
|
|
139
|
+
declare const useCommission: (options?: {
|
|
140
|
+
size?: number;
|
|
141
|
+
}) => any[];
|
|
142
|
+
|
|
143
|
+
declare namespace RefferalAPI {
|
|
144
|
+
interface ReferralInfo {
|
|
145
|
+
referrer_info: Referrer;
|
|
146
|
+
referee_info: Referee;
|
|
147
|
+
}
|
|
148
|
+
type ReferralCode = {
|
|
149
|
+
code: string;
|
|
150
|
+
max_rebate_rate: number;
|
|
151
|
+
referee_rebate_rate: number;
|
|
152
|
+
referrer_rebate_rate: number;
|
|
153
|
+
total_invites: number;
|
|
154
|
+
total_traded: number;
|
|
155
|
+
};
|
|
156
|
+
type AutoGenerateCode = {
|
|
157
|
+
code: string;
|
|
158
|
+
requireVolume: number;
|
|
159
|
+
completedVolume: number;
|
|
160
|
+
};
|
|
161
|
+
type Referrer = {
|
|
162
|
+
total_invites: number;
|
|
163
|
+
total_traded: number;
|
|
164
|
+
total_referee_volume: number;
|
|
165
|
+
total_referee_fee: number;
|
|
166
|
+
referral_codes: ReferralCode[];
|
|
167
|
+
total_referrer_rebate: number;
|
|
168
|
+
"1d_invites": number;
|
|
169
|
+
"7d_invites": number;
|
|
170
|
+
"30d_invites": number;
|
|
171
|
+
"1d_traded": number;
|
|
172
|
+
"7d_traded": number;
|
|
173
|
+
"30d_traded": number;
|
|
174
|
+
"1d_referee_volume": number;
|
|
175
|
+
"7d_referee_volume": number;
|
|
176
|
+
"30d_referee_volume": number;
|
|
177
|
+
"1d_referee_fee": number;
|
|
178
|
+
"7d_referee_fee": number;
|
|
179
|
+
"30d_referee_fee": number;
|
|
180
|
+
"1d_referrer_rebate": number;
|
|
181
|
+
"7d_referrer_rebate": number;
|
|
182
|
+
"30d_referrer_rebate": number;
|
|
183
|
+
};
|
|
184
|
+
type Referee = {
|
|
185
|
+
referer_code?: string;
|
|
186
|
+
referee_rebate_rate?: number;
|
|
187
|
+
"1d_referee_rebate": number;
|
|
188
|
+
"7d_referee_rebate": number;
|
|
189
|
+
"30d_referee_rebate": number;
|
|
190
|
+
total_referee_rebate: number;
|
|
191
|
+
};
|
|
192
|
+
type RefereeInfoItem = {
|
|
193
|
+
account_id: string;
|
|
194
|
+
code_binding_time: number;
|
|
195
|
+
fee: number;
|
|
196
|
+
referral_code: string;
|
|
197
|
+
referral_rebate: number;
|
|
198
|
+
register_time: number;
|
|
199
|
+
trade_status: string;
|
|
200
|
+
user_address: string;
|
|
201
|
+
volume: number;
|
|
202
|
+
};
|
|
203
|
+
type UserVolStats = {
|
|
204
|
+
perp_volume_last_30_days: number;
|
|
205
|
+
perp_volume_last_7_days: number;
|
|
206
|
+
perp_volume_ltd: number;
|
|
207
|
+
perp_volume_ytd: number;
|
|
208
|
+
};
|
|
209
|
+
type Distribution = {
|
|
210
|
+
amount: number;
|
|
211
|
+
created_time: number;
|
|
212
|
+
id: number;
|
|
213
|
+
status: string;
|
|
214
|
+
token: string;
|
|
215
|
+
type: string;
|
|
216
|
+
updated_time: number;
|
|
217
|
+
};
|
|
218
|
+
type ReferralRebateSummary = {
|
|
219
|
+
daily_traded_referral: number;
|
|
220
|
+
referral_rebate: number;
|
|
221
|
+
volume: number;
|
|
222
|
+
fee: number;
|
|
223
|
+
date: string;
|
|
224
|
+
};
|
|
225
|
+
type RefereeRebateSummary = {
|
|
226
|
+
referee_rebate: number;
|
|
227
|
+
fee: number;
|
|
228
|
+
date: string;
|
|
229
|
+
};
|
|
230
|
+
type DayliVolume = {
|
|
231
|
+
date: string;
|
|
232
|
+
perp_volume: number;
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
declare const useDaily: (options?: {
|
|
237
|
+
startDate?: Date;
|
|
238
|
+
endDate?: Date;
|
|
239
|
+
}) => {
|
|
240
|
+
data?: RefferalAPI.DayliVolume[];
|
|
241
|
+
mutate: any;
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
type Params$4 = {
|
|
245
|
+
size?: number;
|
|
246
|
+
startDate?: string;
|
|
247
|
+
endDate?: string;
|
|
248
|
+
initialSize?: number;
|
|
249
|
+
};
|
|
250
|
+
declare const useDistribution: (params: Params$4) => any;
|
|
251
|
+
|
|
252
|
+
type Params$3 = {
|
|
253
|
+
size?: number;
|
|
254
|
+
startDate?: string;
|
|
255
|
+
endDate?: string;
|
|
256
|
+
initialSize?: number;
|
|
257
|
+
page?: number;
|
|
258
|
+
};
|
|
259
|
+
declare const useReferralRebateSummary: (params: Params$3) => readonly [RefferalAPI.ReferralRebateSummary[] | null, {
|
|
260
|
+
readonly total: number;
|
|
261
|
+
readonly isLoading: boolean;
|
|
262
|
+
readonly refresh: swr.KeyedMutator<any[]>;
|
|
263
|
+
readonly loadMore: () => void;
|
|
264
|
+
readonly meta: {
|
|
265
|
+
total: number;
|
|
266
|
+
records_per_page: number;
|
|
267
|
+
current_page: number;
|
|
268
|
+
} | undefined;
|
|
269
|
+
}];
|
|
270
|
+
|
|
271
|
+
type Params$2 = {
|
|
272
|
+
size?: number;
|
|
273
|
+
startDate?: string;
|
|
274
|
+
endDate?: string;
|
|
275
|
+
initialSize?: number;
|
|
276
|
+
};
|
|
277
|
+
declare const useRefereeHistory: (params: Params$2) => any[];
|
|
278
|
+
|
|
279
|
+
type Params$1 = {
|
|
280
|
+
size?: number;
|
|
281
|
+
/**
|
|
282
|
+
* @deprecated
|
|
283
|
+
* YYYY-MM-dd */
|
|
284
|
+
startDate?: string;
|
|
285
|
+
/**
|
|
286
|
+
* @deprecated
|
|
287
|
+
* YYYY-MM-dd */
|
|
288
|
+
endDate?: string;
|
|
289
|
+
/** default is 1 */
|
|
290
|
+
initialSize?: number;
|
|
291
|
+
sort?: "ascending_code_binding_time" | "descending_code_binding_time" | "ascending_referral_rebate" | "descending_referral_rebate" | "ascending_volume" | "descending_volume";
|
|
292
|
+
page?: number;
|
|
293
|
+
};
|
|
294
|
+
declare const useRefereeInfo: (params: Params$1) => readonly [RefferalAPI.RefereeInfoItem[] | null, {
|
|
295
|
+
readonly total: number;
|
|
296
|
+
readonly isLoading: boolean;
|
|
297
|
+
readonly refresh: swr.KeyedMutator<any[]>;
|
|
298
|
+
readonly loadMore: () => void;
|
|
299
|
+
readonly meta: {
|
|
300
|
+
total: number;
|
|
301
|
+
records_per_page: number;
|
|
302
|
+
current_page: number;
|
|
303
|
+
} | undefined;
|
|
304
|
+
}];
|
|
305
|
+
|
|
306
|
+
type Params = {
|
|
307
|
+
startDate?: Date;
|
|
308
|
+
endDate?: Date;
|
|
309
|
+
};
|
|
310
|
+
declare const useRefereeRebateSummary: (params: Params) => {
|
|
311
|
+
data?: RefferalAPI.RefereeRebateSummary[];
|
|
312
|
+
mutate: any;
|
|
313
|
+
isLoading: boolean;
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
type CheckReferralCodeReturns = {
|
|
317
|
+
isExist?: boolean;
|
|
318
|
+
error: any;
|
|
319
|
+
isLoading: boolean;
|
|
320
|
+
};
|
|
321
|
+
declare const useCheckReferralCode: (code?: string) => CheckReferralCodeReturns;
|
|
322
|
+
|
|
323
|
+
declare const useGetReferralCode: (accountId?: string) => {
|
|
324
|
+
referral_code?: string;
|
|
325
|
+
error: any;
|
|
326
|
+
isLoading: boolean;
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
declare const useReferralInfo: () => {
|
|
330
|
+
data?: RefferalAPI.ReferralInfo;
|
|
331
|
+
isTrader?: boolean;
|
|
332
|
+
isAffiliate?: boolean;
|
|
333
|
+
error: any;
|
|
334
|
+
isLoading: boolean;
|
|
335
|
+
getFirstRefCode: () => RefferalAPI.ReferralCode | undefined;
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
declare const useAccount: () => {
|
|
339
|
+
account: _kodiak_finance_orderly_core.Account;
|
|
340
|
+
state: AccountState;
|
|
341
|
+
isSubAccount: boolean;
|
|
342
|
+
isMainAccount: boolean;
|
|
343
|
+
subAccount: {
|
|
344
|
+
refresh: () => Promise<Record<string, _kodiak_finance_orderly_types.API.Holding[]>>;
|
|
345
|
+
create: (description?: string) => Promise<any>;
|
|
346
|
+
update: (value: {
|
|
347
|
+
subAccountId: string;
|
|
348
|
+
description?: string;
|
|
349
|
+
}) => Promise<any>;
|
|
350
|
+
};
|
|
351
|
+
switchAccount: (accountId: string) => Promise<void>;
|
|
352
|
+
createOrderlyKey: (remember: boolean) => Promise<any>;
|
|
353
|
+
createAccount: () => Promise<any>;
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
declare const useAccountInstance: () => Account;
|
|
357
|
+
|
|
358
|
+
declare const usePreLoadData: () => {
|
|
359
|
+
error: any;
|
|
360
|
+
done: boolean;
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
declare const useEventEmitter: () => EventEmitter<string | symbol, any>;
|
|
364
|
+
|
|
365
|
+
declare function useSessionStorage<T>(key: string, initialValue: T): [T, (data: any) => void];
|
|
366
|
+
|
|
367
|
+
declare function parseJSON<T>(value: string | null): T | undefined;
|
|
368
|
+
|
|
369
|
+
declare function useLocalStorage<T>(key: string, initialValue: T, options?: {
|
|
370
|
+
parseJSON: typeof parseJSON;
|
|
371
|
+
}): [any, (value: T) => void];
|
|
372
|
+
|
|
373
|
+
type CurrentChain = {
|
|
374
|
+
id: number;
|
|
375
|
+
info?: Chain;
|
|
376
|
+
};
|
|
377
|
+
declare const useNetworkInfo: (networkId: NetworkId) => (chainId: number) => CurrentChain;
|
|
378
|
+
|
|
379
|
+
declare const useFeeState: () => {
|
|
380
|
+
readonly takerFee: string;
|
|
381
|
+
readonly makerFee: string;
|
|
382
|
+
readonly refereeRebate: number | undefined;
|
|
383
|
+
readonly effectiveTakerFee: string;
|
|
384
|
+
readonly effectiveMakerFee: string;
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
declare const useTrack: () => {
|
|
388
|
+
track: lodash.DebouncedFunc<(eventName: TrackerEventName, params?: any) => void>;
|
|
389
|
+
tracking: (eventName: TrackerEventName, params?: any) => void;
|
|
390
|
+
setTrackUserId: (userId: string) => void;
|
|
391
|
+
setIdentify: (params: any) => void;
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
declare enum ENVType$1 {
|
|
395
|
+
prod = "prod",
|
|
396
|
+
staging = "staging",
|
|
397
|
+
qa = "qa",
|
|
398
|
+
dev = "dev"
|
|
399
|
+
}
|
|
400
|
+
declare class AmplitudeTracker {
|
|
401
|
+
static instanceName: string;
|
|
402
|
+
private _userId;
|
|
403
|
+
private _sdkInfoTag;
|
|
404
|
+
private _ee;
|
|
405
|
+
constructor(env: ENVType$1, amplitudeConfig: {
|
|
406
|
+
amplitudeId: string;
|
|
407
|
+
serverZone?: amplitude.Types.ServerZoneType;
|
|
408
|
+
} | undefined, sdkInfo: any);
|
|
409
|
+
setUserId(userId: string): void;
|
|
410
|
+
setSdkInfo(sdkInfo: any): void;
|
|
411
|
+
identify(properties: any): void;
|
|
412
|
+
track(eventName: TrackerEventName, properties?: any): void;
|
|
413
|
+
private _bindEvents;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
declare const useTrackingInstance: () => AmplitudeTracker;
|
|
417
|
+
|
|
418
|
+
declare const useWS: () => WS;
|
|
419
|
+
|
|
420
|
+
declare function useConfig(): ConfigStore;
|
|
421
|
+
declare function useConfig<T = string>(key: ConfigKey, defaultValue?: T): T;
|
|
422
|
+
|
|
423
|
+
declare const useKeyStore: () => _kodiak_finance_orderly_core.OrderlyKeyStore;
|
|
424
|
+
|
|
425
|
+
declare const useSimpleDI: <T>() => {
|
|
426
|
+
get: (name: string) => T;
|
|
427
|
+
register: typeof SimpleDI.register;
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
type Chain = API.Chain & {
|
|
431
|
+
nativeToken?: API.TokenInfo;
|
|
432
|
+
isTestnet?: boolean;
|
|
433
|
+
};
|
|
434
|
+
type Chains<T extends NetworkId | undefined = undefined, K extends keyof API.Chain | undefined = undefined> = T extends NetworkId ? K extends keyof API.Chain ? API.Chain[K][] : API.Chain[] : K extends keyof API.Chain ? {
|
|
435
|
+
testnet: API.Chain[K][];
|
|
436
|
+
mainnet: API.Chain[K][];
|
|
437
|
+
} : {
|
|
438
|
+
testnet: API.Chain[];
|
|
439
|
+
mainnet: API.Chain[];
|
|
440
|
+
};
|
|
441
|
+
type UseChainsOptions = {
|
|
442
|
+
filter?: (item: API.Chain) => boolean;
|
|
443
|
+
pick?: "dexs" | "network_infos" | "token_infos";
|
|
444
|
+
forceAPI?: boolean;
|
|
445
|
+
} & SWRConfiguration;
|
|
446
|
+
type UseChainsReturnObject = {
|
|
447
|
+
findByChainId: (chainId: number, field?: string) => Chain | undefined;
|
|
448
|
+
checkChainSupport: (chainId: number | string, networkId: NetworkId) => boolean;
|
|
449
|
+
error: any;
|
|
450
|
+
};
|
|
451
|
+
declare function useChains(networkId?: undefined, options?: undefined): [Chains<undefined, undefined>, UseChainsReturnObject];
|
|
452
|
+
declare function useChains<T extends NetworkId | undefined, K extends UseChainsOptions | undefined>(networkId?: T, options?: K): [
|
|
453
|
+
Chains<T, K extends UseChainsOptions ? K["pick"] extends keyof API.Chain ? K["pick"] : undefined : undefined>,
|
|
454
|
+
UseChainsReturnObject
|
|
455
|
+
];
|
|
456
|
+
|
|
457
|
+
type filteredChains$1 = {
|
|
458
|
+
mainnet?: Chain$1[];
|
|
459
|
+
testnet?: Chain$1[];
|
|
460
|
+
};
|
|
461
|
+
type chainFilterFunc = (config: ConfigStore) => filteredChains$1;
|
|
462
|
+
type chainFilter = filteredChains$1 | chainFilterFunc;
|
|
463
|
+
interface OrderlyConfigContextState {
|
|
464
|
+
fetcher?: (url: string, init: RequestInit) => Promise<any>;
|
|
465
|
+
configStore: ConfigStore;
|
|
466
|
+
keyStore: OrderlyKeyStore;
|
|
467
|
+
walletAdapters: WalletAdapter[];
|
|
468
|
+
networkId: NetworkId;
|
|
469
|
+
/**
|
|
470
|
+
* @hidden
|
|
471
|
+
*/
|
|
472
|
+
onlyTestnet?: boolean;
|
|
473
|
+
filteredChains?: filteredChains$1 | null;
|
|
474
|
+
customChains?: Chains<undefined, undefined>;
|
|
475
|
+
chainTransformer?: (params: {
|
|
476
|
+
chains: API.Chain[];
|
|
477
|
+
tokenChains: API.Chain[];
|
|
478
|
+
chainInfos: any[];
|
|
479
|
+
swapChains: any[];
|
|
480
|
+
mainnet: boolean;
|
|
481
|
+
}) => API.Chain[];
|
|
482
|
+
/** enable swap deposit, default is false */
|
|
483
|
+
enableSwapDeposit?: boolean;
|
|
484
|
+
/**
|
|
485
|
+
* Custom orderbook default tick sizes.
|
|
486
|
+
*/
|
|
487
|
+
defaultOrderbookTickSizes?: Record<PropertyKey, string>;
|
|
488
|
+
/**
|
|
489
|
+
* Custom orderbook default symbol depths.
|
|
490
|
+
*/
|
|
491
|
+
defaultOrderbookSymbolDepths?: Record<PropertyKey, number[]>;
|
|
492
|
+
dataAdapter?: {
|
|
493
|
+
/**
|
|
494
|
+
* Custom `/v1/public/futures` response data.
|
|
495
|
+
*/
|
|
496
|
+
symbolList?: (originalVal: API.MarketInfoExt[]) => any[];
|
|
497
|
+
/**
|
|
498
|
+
* custom `/v2/public/announcement` response data
|
|
499
|
+
*/
|
|
500
|
+
announcementList?: (data: any[] | ReadonlyArray<any>) => any[];
|
|
501
|
+
};
|
|
502
|
+
notification?: {
|
|
503
|
+
orderFilled?: {
|
|
504
|
+
/**
|
|
505
|
+
* Sound to play when an order is successful.
|
|
506
|
+
* @default undefined
|
|
507
|
+
*/
|
|
508
|
+
media?: string;
|
|
509
|
+
/**
|
|
510
|
+
* Whether to open the notification by default.
|
|
511
|
+
* @default false
|
|
512
|
+
*/
|
|
513
|
+
defaultOpen?: boolean;
|
|
514
|
+
};
|
|
515
|
+
};
|
|
516
|
+
amplitudeConfig?: {
|
|
517
|
+
amplitudeId: string;
|
|
518
|
+
serverZone?: "EU" | "US";
|
|
519
|
+
};
|
|
520
|
+
orderMetadata?: OrderMetadataConfig;
|
|
521
|
+
}
|
|
522
|
+
type OrderMetadata = {
|
|
523
|
+
order_tag?: string;
|
|
524
|
+
client_order_id?: string;
|
|
525
|
+
};
|
|
526
|
+
type OrderMetadataConfig = OrderMetadata | ((order: Partial<OrderlyOrder>) => OrderMetadata);
|
|
527
|
+
declare const OrderlyContext: react.Context<OrderlyConfigContextState>;
|
|
528
|
+
declare const useOrderlyContext: () => OrderlyConfigContextState;
|
|
529
|
+
declare const OrderlyProvider: react.Provider<OrderlyConfigContextState>;
|
|
530
|
+
|
|
531
|
+
declare const StatusProvider: React.FC<PropsWithChildren>;
|
|
532
|
+
|
|
533
|
+
declare enum WsNetworkStatus {
|
|
534
|
+
Connected = "connected",
|
|
535
|
+
Unstable = "unstable",
|
|
536
|
+
Disconnected = "disconnected"
|
|
537
|
+
}
|
|
538
|
+
declare function useWsStatus(): WsNetworkStatus;
|
|
539
|
+
|
|
540
|
+
type filteredChains = {
|
|
541
|
+
mainnet?: Chain$1[];
|
|
542
|
+
testnet?: Chain$1[];
|
|
543
|
+
};
|
|
544
|
+
type filterChainsFunc = (config: ConfigStore) => filteredChains;
|
|
545
|
+
type BaseConfigProviderProps = {
|
|
546
|
+
keyStore?: OrderlyKeyStore;
|
|
547
|
+
contracts?: IContract;
|
|
548
|
+
walletAdapters?: WalletAdapter[];
|
|
549
|
+
chainFilter?: filteredChains | filterChainsFunc;
|
|
550
|
+
/**
|
|
551
|
+
* Custom orderbook default tick sizes.
|
|
552
|
+
*/
|
|
553
|
+
orderbookDefaultTickSizes?: Record<string, string>;
|
|
554
|
+
/**
|
|
555
|
+
* Custom orderbook default symbol depths.
|
|
556
|
+
*/
|
|
557
|
+
orderbookDefaultSymbolDepths?: Record<PropertyKey, number[]>;
|
|
558
|
+
} & Pick<OrderlyConfigContextState, "enableSwapDeposit" | "customChains" | "chainTransformer" | "dataAdapter" | "notification" | "amplitudeConfig" | "orderMetadata">;
|
|
559
|
+
type ExclusiveConfigProviderProps = {
|
|
560
|
+
brokerId: string;
|
|
561
|
+
brokerName?: string;
|
|
562
|
+
networkId: NetworkId;
|
|
563
|
+
configStore?: never;
|
|
564
|
+
} | {
|
|
565
|
+
brokerId?: never;
|
|
566
|
+
brokerName?: never;
|
|
567
|
+
networkId?: never;
|
|
568
|
+
configStore: ConfigStore;
|
|
569
|
+
};
|
|
570
|
+
type ConfigProviderProps = BaseConfigProviderProps & ExclusiveConfigProviderProps;
|
|
571
|
+
declare const OrderlyConfigProvider: FC<PropsWithChildren<ConfigProviderProps>>;
|
|
572
|
+
|
|
573
|
+
declare class ExtendedConfigStore extends DefaultConfigStore {
|
|
574
|
+
constructor(init: Partial<Record<ConfigKey, any>>);
|
|
575
|
+
get<T>(key: ConfigKey): T;
|
|
576
|
+
set<T>(key: ConfigKey, value: T): void;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
type ConnectedChain = {
|
|
580
|
+
id: number | string;
|
|
581
|
+
namespace: ChainNamespace;
|
|
582
|
+
};
|
|
583
|
+
type WalletAccount = {
|
|
584
|
+
address: string;
|
|
585
|
+
};
|
|
586
|
+
interface WalletState {
|
|
587
|
+
label: string;
|
|
588
|
+
icon: string;
|
|
589
|
+
provider: EIP1193Provider | SolanaWalletProvider;
|
|
590
|
+
accounts: WalletAccount[];
|
|
591
|
+
chains: ConnectedChain[];
|
|
592
|
+
instance?: unknown;
|
|
593
|
+
additionalInfo?: Record<string, any>;
|
|
594
|
+
}
|
|
595
|
+
interface WalletConnectorContextState {
|
|
596
|
+
connect: (options?: any) => Promise<WalletState[]>;
|
|
597
|
+
disconnect: (options: any) => Promise<any[]>;
|
|
598
|
+
connecting: boolean;
|
|
599
|
+
setChain: (options: {
|
|
600
|
+
chainId: string | number;
|
|
601
|
+
}) => Promise<any>;
|
|
602
|
+
chains: any[];
|
|
603
|
+
wallet: WalletState | null;
|
|
604
|
+
connectedChain: ConnectedChain | null;
|
|
605
|
+
settingChain: boolean;
|
|
606
|
+
namespace: ChainNamespace | null;
|
|
607
|
+
}
|
|
608
|
+
declare const WalletConnectorContext: react.Context<WalletConnectorContextState>;
|
|
609
|
+
declare const useWalletConnector: () => WalletConnectorContextState;
|
|
610
|
+
|
|
611
|
+
type OrderBookItem = number[];
|
|
612
|
+
type OrderbookData = {
|
|
613
|
+
asks: OrderBookItem[];
|
|
614
|
+
bids: OrderBookItem[];
|
|
615
|
+
};
|
|
616
|
+
declare const getPriceKey: (rawPrice: number, depth: number, isAsks: boolean) => number;
|
|
617
|
+
/**
|
|
618
|
+
* Configuration for the Order Book
|
|
619
|
+
*/
|
|
620
|
+
type OrderbookOptions = {
|
|
621
|
+
/** Indicates the number of data entries to return for ask/bid, default is 10 */
|
|
622
|
+
level?: number;
|
|
623
|
+
/** Whether to fill in when the actual data entries are less than the level. If filled, it will add [nan, nan, nan, nan]. Default is true */
|
|
624
|
+
padding?: boolean;
|
|
625
|
+
};
|
|
626
|
+
declare const ORDERLY_ORDERBOOK_DEPTH_KEY = "orderly_orderbook_depth_key";
|
|
627
|
+
/**
|
|
628
|
+
* @description React hook that returns the current orderbook for a given market
|
|
629
|
+
*/
|
|
630
|
+
declare const useOrderbookStream: (symbol: string, initial?: OrderbookData, options?: OrderbookOptions) => ({
|
|
631
|
+
asks: OrderBookItem[];
|
|
632
|
+
bids: OrderBookItem[];
|
|
633
|
+
markPrice: number;
|
|
634
|
+
middlePrice: number[];
|
|
635
|
+
onDepthChange?: undefined;
|
|
636
|
+
depth?: undefined;
|
|
637
|
+
allDepths?: undefined;
|
|
638
|
+
isLoading?: undefined;
|
|
639
|
+
onItemClick?: undefined;
|
|
640
|
+
} | {
|
|
641
|
+
onDepthChange: (val: number) => void;
|
|
642
|
+
depth: number;
|
|
643
|
+
allDepths: number[];
|
|
644
|
+
isLoading: boolean;
|
|
645
|
+
onItemClick: (item: OrderBookItem) => void;
|
|
646
|
+
asks?: undefined;
|
|
647
|
+
bids?: undefined;
|
|
648
|
+
markPrice?: undefined;
|
|
649
|
+
middlePrice?: undefined;
|
|
650
|
+
})[];
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* Type alias for the return type of useSymbolsInfo hook
|
|
654
|
+
*/
|
|
655
|
+
type SymbolsInfo = ReturnType<typeof useSymbolsInfo>;
|
|
656
|
+
/**
|
|
657
|
+
* A hook that provides access to symbol information.
|
|
658
|
+
*
|
|
659
|
+
* @returns A getter object that provides access to symbol information.
|
|
660
|
+
* The getter allows accessing symbol data either by symbol name directly,
|
|
661
|
+
* or through a two-level access pattern (symbol and property).
|
|
662
|
+
*
|
|
663
|
+
* @example
|
|
664
|
+
* ```typescript
|
|
665
|
+
* const symbolsInfo = useSymbolsInfo();
|
|
666
|
+
*
|
|
667
|
+
* // Get all info for a symbol
|
|
668
|
+
* const ethInfo = symbolsInfo["PERP_ETH_USDC"]();
|
|
669
|
+
*
|
|
670
|
+
* // Get specific property for a symbol
|
|
671
|
+
* const baseDP = symbolsInfo["PERP_ETH_USDC"]('base_dp');
|
|
672
|
+
*
|
|
673
|
+
* // Get specific property for a symbol with default value
|
|
674
|
+
* const quoteDP = symbolsInfo["PERP_ETH_USDC"]('quote_dp', 2);
|
|
675
|
+
* ```
|
|
676
|
+
*/
|
|
677
|
+
declare const useSymbolsInfo: () => Record<string, <Key extends keyof _kodiak_finance_orderly_types.API.SymbolExt>(key: Key, defaultValue?: _kodiak_finance_orderly_types.API.SymbolExt[Key] | undefined) => _kodiak_finance_orderly_types.API.SymbolExt[Key]> & Record<string, () => _kodiak_finance_orderly_types.API.SymbolExt> & {
|
|
678
|
+
isNil: boolean;
|
|
679
|
+
};
|
|
680
|
+
declare const useSymbolsInfoStore: () => Record<string, _kodiak_finance_orderly_types.API.SymbolExt> | undefined;
|
|
681
|
+
|
|
682
|
+
declare const useSymbolInfo: (symbol?: string) => ((<Key extends keyof _kodiak_finance_orderly_types.API.SymbolExt>(key: Key, defaultValue?: _kodiak_finance_orderly_types.API.SymbolExt[Key] | undefined) => _kodiak_finance_orderly_types.API.SymbolExt[Key]) & (() => _kodiak_finance_orderly_types.API.SymbolExt)) | null;
|
|
683
|
+
|
|
684
|
+
declare const useAccountInfo: () => swr.SWRResponse<API.AccountInfo, any, any>;
|
|
685
|
+
|
|
686
|
+
declare const useMarketsStream: () => {
|
|
687
|
+
data: WSMessage.Ticker[] | null;
|
|
688
|
+
};
|
|
689
|
+
|
|
690
|
+
declare enum MarketsType$1 {
|
|
691
|
+
FAVORITES = 0,
|
|
692
|
+
RECENT = 1,
|
|
693
|
+
ALL = 2,
|
|
694
|
+
NEW_LISTING = 3
|
|
695
|
+
}
|
|
696
|
+
interface FavoriteTab$1 {
|
|
697
|
+
name: string;
|
|
698
|
+
id: number;
|
|
699
|
+
}
|
|
700
|
+
interface Favorite$1 {
|
|
701
|
+
name: string;
|
|
702
|
+
tabs: FavoriteTab$1[];
|
|
703
|
+
}
|
|
704
|
+
interface Recent$1 {
|
|
705
|
+
name: string;
|
|
706
|
+
}
|
|
707
|
+
interface TabSort$1 {
|
|
708
|
+
sortKey: string;
|
|
709
|
+
sortOrder: string;
|
|
710
|
+
}
|
|
711
|
+
/** @deprecated use useMarkets instead */
|
|
712
|
+
declare const useMarket: (type: MarketsType$1) => readonly [any[], {
|
|
713
|
+
readonly favoriteTabs: {
|
|
714
|
+
name: string;
|
|
715
|
+
id: number;
|
|
716
|
+
}[];
|
|
717
|
+
readonly favorites: Favorite$1[];
|
|
718
|
+
readonly recent: Recent$1[];
|
|
719
|
+
readonly tabSort: Record<string, TabSort$1>;
|
|
720
|
+
readonly addToHistory: (symbol: API.MarketInfoExt) => void;
|
|
721
|
+
readonly updateFavorites: (favorites: Favorite$1[]) => void;
|
|
722
|
+
readonly updateFavoriteTabs: (tab: FavoriteTab$1 | FavoriteTab$1[], operator?: {
|
|
723
|
+
add?: boolean;
|
|
724
|
+
update?: boolean;
|
|
725
|
+
delete?: boolean;
|
|
726
|
+
}) => void;
|
|
727
|
+
readonly updateSymbolFavoriteState: (symbol: API.MarketInfoExt, tab: FavoriteTab$1 | FavoriteTab$1[], remove?: boolean) => void;
|
|
728
|
+
readonly pinToTop: (symbol: API.MarketInfoExt) => void;
|
|
729
|
+
readonly getLastSelFavTab: () => FavoriteTab$1;
|
|
730
|
+
readonly updateSelectedFavoriteTab: (tab: FavoriteTab$1) => void;
|
|
731
|
+
readonly updateTabsSortState: (tabId: string, sortKey: string, sortOrder: "desc" | "asc") => void;
|
|
732
|
+
}];
|
|
733
|
+
|
|
734
|
+
declare enum MarketsType {
|
|
735
|
+
FAVORITES = 0,
|
|
736
|
+
RECENT = 1,
|
|
737
|
+
ALL = 2,
|
|
738
|
+
NEW_LISTING = 3
|
|
739
|
+
}
|
|
740
|
+
interface FavoriteTab {
|
|
741
|
+
name: string;
|
|
742
|
+
id: number;
|
|
743
|
+
}
|
|
744
|
+
interface Favorite {
|
|
745
|
+
name: string;
|
|
746
|
+
tabs: FavoriteTab[];
|
|
747
|
+
}
|
|
748
|
+
interface Recent {
|
|
749
|
+
name: string;
|
|
750
|
+
}
|
|
751
|
+
interface NewListing {
|
|
752
|
+
name: string;
|
|
753
|
+
}
|
|
754
|
+
type TabSort = Record<string, {
|
|
755
|
+
sortKey: string;
|
|
756
|
+
sortOrder: string;
|
|
757
|
+
}>;
|
|
758
|
+
type MarketsItem = {
|
|
759
|
+
symbol: string;
|
|
760
|
+
index_price: number;
|
|
761
|
+
mark_price: number;
|
|
762
|
+
sum_unitary_funding: number;
|
|
763
|
+
est_funding_rate: number;
|
|
764
|
+
last_funding_rate: number;
|
|
765
|
+
next_funding_time: number;
|
|
766
|
+
open_interest: number;
|
|
767
|
+
"24h_open": number;
|
|
768
|
+
"24h_close": number;
|
|
769
|
+
"24h_high": number;
|
|
770
|
+
"24h_low": number;
|
|
771
|
+
"24h_volume": number;
|
|
772
|
+
"24h_amount": number;
|
|
773
|
+
"24h_volumn": number;
|
|
774
|
+
change: number;
|
|
775
|
+
"8h_funding": number;
|
|
776
|
+
quote_dp: number;
|
|
777
|
+
created_time: number;
|
|
778
|
+
openInterest: number;
|
|
779
|
+
isFavorite: boolean;
|
|
780
|
+
leverage?: number;
|
|
781
|
+
};
|
|
782
|
+
type MarketsStore = ReturnType<typeof useMarketsStore>;
|
|
783
|
+
declare const MarketsStorageKey = "orderly_markets";
|
|
784
|
+
declare const useMarketsStore: () => {
|
|
785
|
+
favoriteTabs: FavoriteTab[];
|
|
786
|
+
favorites: {
|
|
787
|
+
tabs: FavoriteTab[];
|
|
788
|
+
name: string;
|
|
789
|
+
}[];
|
|
790
|
+
recent: Recent[];
|
|
791
|
+
newListing: NewListing[];
|
|
792
|
+
tabSort: TabSort;
|
|
793
|
+
selectedFavoriteTab: FavoriteTab;
|
|
794
|
+
updateFavorites: react.Dispatch<react.SetStateAction<{
|
|
795
|
+
tabs: FavoriteTab[];
|
|
796
|
+
name: string;
|
|
797
|
+
}[]>>;
|
|
798
|
+
updateFavoriteTabs: (tab: FavoriteTab | FavoriteTab[], operator?: {
|
|
799
|
+
add?: boolean;
|
|
800
|
+
update?: boolean;
|
|
801
|
+
delete?: boolean;
|
|
802
|
+
}) => void;
|
|
803
|
+
updateSymbolFavoriteState: (symbol: API.MarketInfoExt, tab: FavoriteTab | FavoriteTab[], remove?: boolean) => void;
|
|
804
|
+
pinToTop: (symbol: API.MarketInfoExt) => void;
|
|
805
|
+
addToHistory: (symbol: API.MarketInfoExt) => void;
|
|
806
|
+
updateSelectedFavoriteTab: (tab: FavoriteTab) => void;
|
|
807
|
+
updateTabsSortState: (tabId: string, sortKey: string, sortOrder: "desc" | "asc") => void;
|
|
808
|
+
};
|
|
809
|
+
/**
|
|
810
|
+
* Hook for accessing filtered market data based on type
|
|
811
|
+
* @param type - Type of markets to filter (defaults to ALL)
|
|
812
|
+
* @returns Tuple containing filtered markets array and markets store
|
|
813
|
+
*/
|
|
814
|
+
declare const useMarkets: (type?: MarketsType) => [MarketsItem[], MarketsStore];
|
|
815
|
+
|
|
816
|
+
declare const useMarkPricesStream: () => {
|
|
817
|
+
data: Record<string, number>;
|
|
818
|
+
};
|
|
819
|
+
|
|
820
|
+
declare const useIndexPricesStream: () => {
|
|
821
|
+
data: Record<string, number>;
|
|
822
|
+
getIndexPrice: (this: unknown, token: string) => number;
|
|
823
|
+
};
|
|
824
|
+
|
|
825
|
+
declare const useMarkPrice: (symbol: string) => {
|
|
826
|
+
data: number;
|
|
827
|
+
};
|
|
828
|
+
|
|
829
|
+
declare const useIndexPrice: (symbol: string) => swr_subscription.SWRSubscriptionResponse<any, any>;
|
|
830
|
+
|
|
831
|
+
/**
|
|
832
|
+
* A hook for managing leverage in trading.
|
|
833
|
+
*
|
|
834
|
+
* @remarks
|
|
835
|
+
* This hook provides functionality to get and update the user's leverage settings.
|
|
836
|
+
*
|
|
837
|
+
* It fetches the current leverage from client info and available leverage options from config.
|
|
838
|
+
*
|
|
839
|
+
* @returns A tuple containing:
|
|
840
|
+
* - The current maximum leverage value
|
|
841
|
+
* - An object with:
|
|
842
|
+
* - `update`: Function to update leverage
|
|
843
|
+
* - `isMutating`: Boolean indicating if an update is in progress
|
|
844
|
+
* - `config`: Array of available leverage options (e.g. [1, 2, 3, 4, 5, 10, 15, 20])
|
|
845
|
+
*
|
|
846
|
+
* @example
|
|
847
|
+
* ```typescript
|
|
848
|
+
* const [maxLeverage, { update, isMutating, config }] = useLeverage();
|
|
849
|
+
*
|
|
850
|
+
* // Get current max leverage
|
|
851
|
+
* console.log(maxLeverage);
|
|
852
|
+
*
|
|
853
|
+
* // Update leverage
|
|
854
|
+
* update({ leverage: 5 });
|
|
855
|
+
*
|
|
856
|
+
* // Available leverage options
|
|
857
|
+
* console.log(config); // e.g., [1, 2, 3, 4, 5, 10, 15, 20]
|
|
858
|
+
* ```
|
|
859
|
+
*/
|
|
860
|
+
declare const useLeverage: () => {
|
|
861
|
+
readonly update: (data: {
|
|
862
|
+
leverage: number;
|
|
863
|
+
}) => Promise<{
|
|
864
|
+
max_leverage: string | number;
|
|
865
|
+
} | undefined>;
|
|
866
|
+
readonly isLoading: boolean;
|
|
867
|
+
readonly leverageLevers: number[];
|
|
868
|
+
readonly curLeverage: number;
|
|
869
|
+
readonly maxLeverage: number;
|
|
870
|
+
};
|
|
871
|
+
|
|
872
|
+
declare const useOdosQuote: () => readonly [(this: unknown, data: Record<string, any> | null, params?: Record<string, any> | undefined, options?: swr_mutation.SWRMutationConfiguration<unknown, unknown> | undefined) => Promise<any>, {
|
|
873
|
+
readonly data: any;
|
|
874
|
+
readonly error: unknown;
|
|
875
|
+
readonly reset: () => void;
|
|
876
|
+
readonly isMutating: boolean;
|
|
877
|
+
}];
|
|
878
|
+
|
|
879
|
+
interface LTVOptions {
|
|
880
|
+
input?: number;
|
|
881
|
+
token?: string;
|
|
882
|
+
}
|
|
883
|
+
declare const useComputedLTV: (options?: LTVOptions) => number;
|
|
884
|
+
|
|
885
|
+
declare const useTickerStream: (symbol: string) => API.MarketInfo & {
|
|
886
|
+
change?: number;
|
|
887
|
+
"24h_change"?: number;
|
|
888
|
+
};
|
|
889
|
+
|
|
890
|
+
declare const useFundingRate: (symbol: string) => {
|
|
891
|
+
est_funding_rate: string | null | undefined;
|
|
892
|
+
countDown: string;
|
|
893
|
+
symbol?: string | undefined;
|
|
894
|
+
est_funding_rate_timestamp?: number | undefined;
|
|
895
|
+
last_funding_rate?: number | undefined;
|
|
896
|
+
last_funding_rate_timestamp?: number | undefined;
|
|
897
|
+
next_funding_time?: number | undefined;
|
|
898
|
+
sum_unitary_funding?: number | undefined;
|
|
899
|
+
};
|
|
900
|
+
|
|
901
|
+
declare const useFundingDetails: (symbol: string) => swr.SWRResponse<API.FundingDetails, any, any>;
|
|
902
|
+
|
|
903
|
+
type FundingRates = ReturnType<typeof useFundingRates>;
|
|
904
|
+
declare const useFundingRates: () => Record<string, <Key extends keyof API.FundingRate>(key: Key, defaultValue?: API.FundingRate[Key] | undefined) => API.FundingRate[Key]> & Record<string, () => API.FundingRate> & {
|
|
905
|
+
isNil: boolean;
|
|
906
|
+
};
|
|
907
|
+
declare const useFundingRatesStore: () => Record<string, API.FundingRate> | undefined;
|
|
908
|
+
|
|
909
|
+
type PeriodKey = "1d" | "3d" | "7d" | "14d" | "30d" | "90d";
|
|
910
|
+
declare const useFundingRateHistory: () => {
|
|
911
|
+
data: readonly any[];
|
|
912
|
+
isLoading: boolean;
|
|
913
|
+
getPositiveRates: (data: ReadonlyArray<API.FundingHistory> | API.FundingHistory[], period: PeriodKey) => Record<string, number>;
|
|
914
|
+
};
|
|
915
|
+
|
|
916
|
+
type PriceMode = "markPrice" | "lastPrice";
|
|
917
|
+
declare const usePositionStream: (
|
|
918
|
+
/**
|
|
919
|
+
* If symbol is passed, only the position of that symbol will be returned.
|
|
920
|
+
*/
|
|
921
|
+
symbol?: string, options?: SWRConfiguration & {
|
|
922
|
+
calcMode?: PriceMode;
|
|
923
|
+
/**
|
|
924
|
+
* If true, the pending order will be included in the result.
|
|
925
|
+
*/
|
|
926
|
+
includedPendingOrder?: boolean;
|
|
927
|
+
}) => readonly [{
|
|
928
|
+
readonly rows: API.PositionTPSLExt[];
|
|
929
|
+
readonly aggregated: Omit<API.PositionsTPSLExt, "rows">;
|
|
930
|
+
readonly totalCollateral: _kodiak_finance_orderly_utils.Decimal;
|
|
931
|
+
readonly totalValue: _kodiak_finance_orderly_utils.Decimal | null;
|
|
932
|
+
readonly totalUnrealizedROI: number;
|
|
933
|
+
}, Record<"unsettledPnL" | "margin_ratio" | "initial_margin_ratio" | "maintenance_margin_ratio" | "open_margin_ratio" | "current_margin_ratio_with_orders" | "initial_margin_ratio_with_orders" | "maintenance_margin_ratio_with_orders" | "total_collateral_value" | "free_collateral" | "total_pnl_24_h" | "unrealPnL" | "total_unreal_pnl" | "total_unreal_pnl_index" | "total_unsettled_pnl" | "notional" | "unrealPnlROI" | "unrealPnlROI_index", <Key extends "unsettledPnL" | "margin_ratio" | "initial_margin_ratio" | "maintenance_margin_ratio" | "open_margin_ratio" | "current_margin_ratio_with_orders" | "initial_margin_ratio_with_orders" | "maintenance_margin_ratio_with_orders" | "total_collateral_value" | "free_collateral" | "total_pnl_24_h" | "unrealPnL" | "total_unreal_pnl" | "total_unreal_pnl_index" | "total_unsettled_pnl" | "notional" | "unrealPnlROI" | "unrealPnlROI_index">(defaultValue?: Omit<API.PositionInfo, "rows">[Key] | undefined) => Omit<API.PositionInfo, "rows">[Key]> & {
|
|
934
|
+
isNil: boolean;
|
|
935
|
+
}, {
|
|
936
|
+
/**
|
|
937
|
+
* @deprecated use `isLoading` instead
|
|
938
|
+
*/
|
|
939
|
+
readonly loading: boolean;
|
|
940
|
+
readonly isLoading: boolean;
|
|
941
|
+
}];
|
|
942
|
+
|
|
943
|
+
declare const findTPSLFromOrder: (order: API.AlgoOrder) => {
|
|
944
|
+
tp_trigger_price?: number;
|
|
945
|
+
sl_trigger_price?: number;
|
|
946
|
+
};
|
|
947
|
+
declare const findTPSLOrderPriceFromOrder: (order: API.AlgoOrder) => {
|
|
948
|
+
tp_order_price: OrderType | number | undefined;
|
|
949
|
+
sl_order_price: OrderType | number | undefined;
|
|
950
|
+
};
|
|
951
|
+
declare const findPositionTPSLFromOrders: (orders: API.AlgoOrder[], symbol: string) => {
|
|
952
|
+
fullPositionOrder?: API.AlgoOrder;
|
|
953
|
+
partialPositionOrders?: API.AlgoOrder[];
|
|
954
|
+
};
|
|
955
|
+
|
|
956
|
+
type CombineOrderType = AlgoOrderRootType | "ALL";
|
|
957
|
+
declare const useOrderStream: (
|
|
958
|
+
/**
|
|
959
|
+
* Orders query params
|
|
960
|
+
*/
|
|
961
|
+
params: {
|
|
962
|
+
symbol?: string;
|
|
963
|
+
status?: OrderStatus;
|
|
964
|
+
page?: number;
|
|
965
|
+
size?: number;
|
|
966
|
+
side?: OrderSide;
|
|
967
|
+
sourceTypeAll?: boolean;
|
|
968
|
+
/**
|
|
969
|
+
* Include the order type
|
|
970
|
+
* @default ["ALL"]
|
|
971
|
+
*/
|
|
972
|
+
includes?: CombineOrderType[];
|
|
973
|
+
/**
|
|
974
|
+
* Exclude the order type
|
|
975
|
+
* @default []
|
|
976
|
+
*/
|
|
977
|
+
excludes?: CombineOrderType[];
|
|
978
|
+
dateRange?: {
|
|
979
|
+
from?: Date;
|
|
980
|
+
to?: Date;
|
|
981
|
+
};
|
|
982
|
+
}, options?: {
|
|
983
|
+
/**
|
|
984
|
+
* Keep the state update alive
|
|
985
|
+
*/
|
|
986
|
+
keeplive?: boolean;
|
|
987
|
+
/**
|
|
988
|
+
* Stop the state update when the component unmount
|
|
989
|
+
*/
|
|
990
|
+
stopOnUnmount?: boolean;
|
|
991
|
+
}) => readonly [any[] | null, {
|
|
992
|
+
readonly total: number;
|
|
993
|
+
readonly isLoading: boolean;
|
|
994
|
+
readonly refresh: () => void;
|
|
995
|
+
readonly loadMore: () => void;
|
|
996
|
+
readonly cancelAllOrders: () => Promise<[any, any, any]>;
|
|
997
|
+
readonly cancelAllTPSLOrders: () => Promise<any[]>;
|
|
998
|
+
readonly cancelAlgoOrdersByTypes: (types: AlgoOrderRootType[]) => Promise<any[]>;
|
|
999
|
+
readonly updateOrder: (orderId: string, order: OrderEntity) => Promise<any>;
|
|
1000
|
+
readonly cancelOrder: (orderId: number, symbol?: string) => Promise<any>;
|
|
1001
|
+
readonly updateAlgoOrder: (orderId: string, order: OrderEntity) => Promise<any>;
|
|
1002
|
+
readonly cancelAlgoOrder: (orderId: number, symbol?: string) => Promise<any>;
|
|
1003
|
+
readonly cancelTPSLChildOrder: (orderId: number, rootAlgoOrderId: number) => Promise<any>;
|
|
1004
|
+
readonly updateTPSLOrder: (orderId: number, childOrders: API.AlgoOrder["child_orders"]) => Promise<any>;
|
|
1005
|
+
readonly cancelPostionOrdersByTypes: (symbol: string, types: AlgoOrderRootType[]) => Promise<any>;
|
|
1006
|
+
readonly meta: any;
|
|
1007
|
+
readonly errors: {
|
|
1008
|
+
readonly cancelOrder: unknown;
|
|
1009
|
+
readonly updateOrder: unknown;
|
|
1010
|
+
readonly cancelAlgoOrder: unknown;
|
|
1011
|
+
readonly updateAlgoOrder: unknown;
|
|
1012
|
+
};
|
|
1013
|
+
readonly submitting: {
|
|
1014
|
+
readonly cancelOrder: boolean;
|
|
1015
|
+
readonly updateOrder: boolean;
|
|
1016
|
+
readonly cancelAlgoOrder: boolean;
|
|
1017
|
+
readonly updateAlglOrder: boolean;
|
|
1018
|
+
};
|
|
1019
|
+
}];
|
|
1020
|
+
|
|
1021
|
+
interface MarketTradeStreamOptions {
|
|
1022
|
+
limit?: number;
|
|
1023
|
+
}
|
|
1024
|
+
declare const useMarketTradeStream: (symbol: string, options?: MarketTradeStreamOptions) => {
|
|
1025
|
+
data: API.Trade[];
|
|
1026
|
+
isLoading: boolean;
|
|
1027
|
+
};
|
|
1028
|
+
|
|
1029
|
+
/**
|
|
1030
|
+
* The return type of useCollateral hook, containing account collateral information
|
|
1031
|
+
*/
|
|
1032
|
+
type CollateralOutputs = {
|
|
1033
|
+
/**
|
|
1034
|
+
* Total collateral value in the account
|
|
1035
|
+
*
|
|
1036
|
+
* This includes all assets that can be used as margin
|
|
1037
|
+
*/
|
|
1038
|
+
totalCollateral: number;
|
|
1039
|
+
/**
|
|
1040
|
+
* Available collateral that can be used for new positions
|
|
1041
|
+
*
|
|
1042
|
+
* Calculated as: totalCollateral - margin requirements
|
|
1043
|
+
*/
|
|
1044
|
+
freeCollateral: number;
|
|
1045
|
+
/**
|
|
1046
|
+
* Total portfolio value including all positions and collateral
|
|
1047
|
+
*
|
|
1048
|
+
* Can be null if data is not available
|
|
1049
|
+
*/
|
|
1050
|
+
totalValue: number | null;
|
|
1051
|
+
/**
|
|
1052
|
+
* Current available balance that can be withdrawn
|
|
1053
|
+
*
|
|
1054
|
+
* Excludes locked collateral and pending settlements
|
|
1055
|
+
*/
|
|
1056
|
+
availableBalance: number;
|
|
1057
|
+
/**
|
|
1058
|
+
* Unrealized profit and loss across all open positions
|
|
1059
|
+
*
|
|
1060
|
+
* Positive value indicates profit, negative indicates loss
|
|
1061
|
+
*/
|
|
1062
|
+
unsettledPnL: number;
|
|
1063
|
+
/**
|
|
1064
|
+
* List of holdings in the account
|
|
1065
|
+
*
|
|
1066
|
+
* Each holding represents a specific token and its quantity
|
|
1067
|
+
*/
|
|
1068
|
+
holding?: API.Holding[];
|
|
1069
|
+
/**
|
|
1070
|
+
* Detailed account information and settings
|
|
1071
|
+
*
|
|
1072
|
+
* Contains account configuration, limits and risk parameters
|
|
1073
|
+
*/
|
|
1074
|
+
accountInfo?: API.AccountInfo;
|
|
1075
|
+
};
|
|
1076
|
+
/**
|
|
1077
|
+
* Hook to get and calculate collateral-related data for an account
|
|
1078
|
+
* @example
|
|
1079
|
+
* ```typescript
|
|
1080
|
+
* const {
|
|
1081
|
+
* totalCollateral,
|
|
1082
|
+
* freeCollateral,
|
|
1083
|
+
* totalValue,
|
|
1084
|
+
* availableBalance,
|
|
1085
|
+
* unsettledPnL,
|
|
1086
|
+
* accountInfo,
|
|
1087
|
+
* } = useCollateral({ dp: 4 });
|
|
1088
|
+
* ```
|
|
1089
|
+
*/
|
|
1090
|
+
declare const useCollateral: (options?: {
|
|
1091
|
+
/**
|
|
1092
|
+
* Decimal precision for numerical values (default: 6)
|
|
1093
|
+
* */
|
|
1094
|
+
dp: number;
|
|
1095
|
+
}) => CollateralOutputs;
|
|
1096
|
+
|
|
1097
|
+
/**
|
|
1098
|
+
* A hook that calculates the maximum tradeable quantity for a given symbol and side
|
|
1099
|
+
* @returns Maximum tradeable quantity
|
|
1100
|
+
* @example
|
|
1101
|
+
* ```tsx
|
|
1102
|
+
* // Get max buy quantity for BTC
|
|
1103
|
+
* const maxBuyQty = useMaxQty("PERP_BTC_USDC", OrderSide.BUY);
|
|
1104
|
+
*
|
|
1105
|
+
* // Get max sell quantity with reduce only
|
|
1106
|
+
* const maxSellQty = useMaxQty("PERP_BTC_USDC", OrderSide.SELL, true);
|
|
1107
|
+
* ```
|
|
1108
|
+
*/
|
|
1109
|
+
declare const useMaxQty: (
|
|
1110
|
+
/**
|
|
1111
|
+
* Trading pair symbol (e.g. "PERP_BTC_USDC")
|
|
1112
|
+
* */
|
|
1113
|
+
symbol: string,
|
|
1114
|
+
/**
|
|
1115
|
+
* Order side ("BUY" or "SELL")
|
|
1116
|
+
* */
|
|
1117
|
+
side: OrderSide,
|
|
1118
|
+
/**
|
|
1119
|
+
* Executes buy or sell orders which only reduce a current position.
|
|
1120
|
+
*
|
|
1121
|
+
* If true, only allows orders that reduce current position
|
|
1122
|
+
* */
|
|
1123
|
+
reduceOnly?: boolean) => number;
|
|
1124
|
+
|
|
1125
|
+
/**
|
|
1126
|
+
* The return type of useMarginRatio hook
|
|
1127
|
+
*/
|
|
1128
|
+
type MarginRatioReturn = {
|
|
1129
|
+
/**
|
|
1130
|
+
* Current leverage of the account, null if trading is not enabled
|
|
1131
|
+
*/
|
|
1132
|
+
currentLeverage: number | null;
|
|
1133
|
+
/**
|
|
1134
|
+
* Current margin ratio of the account
|
|
1135
|
+
*/
|
|
1136
|
+
marginRatio: number;
|
|
1137
|
+
/**
|
|
1138
|
+
* Maintenance margin ratio (MMR) of the account, null if user has no positions
|
|
1139
|
+
*/
|
|
1140
|
+
mmr: number | null;
|
|
1141
|
+
};
|
|
1142
|
+
/**
|
|
1143
|
+
* Hook to calculate and monitor account's margin ratio, leverage, and maintenance margin ratio (MMR)
|
|
1144
|
+
* @example
|
|
1145
|
+
* ```typescript
|
|
1146
|
+
* const { marginRatio, currentLeverage, mmr } = useMarginRatio();
|
|
1147
|
+
* ```
|
|
1148
|
+
*/
|
|
1149
|
+
declare const useMarginRatio: () => MarginRatioReturn;
|
|
1150
|
+
|
|
1151
|
+
declare function useStorageChain(): {
|
|
1152
|
+
storageChain: any;
|
|
1153
|
+
setStorageChain: (chainId: number) => void;
|
|
1154
|
+
};
|
|
1155
|
+
|
|
1156
|
+
/**
|
|
1157
|
+
* @param token @deprecated, use useTokenInfo instead
|
|
1158
|
+
*/
|
|
1159
|
+
declare const useChain: (token: string) => {
|
|
1160
|
+
chains: API.Chain | null;
|
|
1161
|
+
isLoading: boolean;
|
|
1162
|
+
};
|
|
1163
|
+
|
|
1164
|
+
declare const useChainInfo: () => swr.SWRResponse<unknown, any, any>;
|
|
1165
|
+
|
|
1166
|
+
type UseWithdrawOptions = {
|
|
1167
|
+
srcChainId?: number;
|
|
1168
|
+
token?: string;
|
|
1169
|
+
/** orderly token decimals */
|
|
1170
|
+
decimals?: number;
|
|
1171
|
+
};
|
|
1172
|
+
declare const useWithdraw: (options: UseWithdrawOptions) => {
|
|
1173
|
+
dst: {
|
|
1174
|
+
symbol: string;
|
|
1175
|
+
decimals: number;
|
|
1176
|
+
address: string | undefined;
|
|
1177
|
+
chainId: number;
|
|
1178
|
+
network: string;
|
|
1179
|
+
};
|
|
1180
|
+
withdraw: (inputs: {
|
|
1181
|
+
chainId: number;
|
|
1182
|
+
token: string;
|
|
1183
|
+
amount: string;
|
|
1184
|
+
allowCrossChainWithdraw: boolean;
|
|
1185
|
+
}) => Promise<any>;
|
|
1186
|
+
maxAmount: number;
|
|
1187
|
+
unsettledPnL: number;
|
|
1188
|
+
availableBalance: number;
|
|
1189
|
+
/** @deprecated use maxAmount instead */
|
|
1190
|
+
availableWithdraw: number;
|
|
1191
|
+
};
|
|
1192
|
+
|
|
1193
|
+
type DepositOptions = {
|
|
1194
|
+
address?: string;
|
|
1195
|
+
decimals?: number;
|
|
1196
|
+
srcChainId?: number;
|
|
1197
|
+
/** input token */
|
|
1198
|
+
srcToken?: string;
|
|
1199
|
+
/** output token */
|
|
1200
|
+
dstToken?: string;
|
|
1201
|
+
swapEnable?: boolean;
|
|
1202
|
+
crossChainRouteAddress?: string;
|
|
1203
|
+
depositorAddress?: string;
|
|
1204
|
+
/** @deprecated unused, will be removed in the future */
|
|
1205
|
+
networkId?: NetworkId;
|
|
1206
|
+
};
|
|
1207
|
+
declare const useDeposit: (options: DepositOptions) => {
|
|
1208
|
+
/** orderly support chain dst */
|
|
1209
|
+
dst: {
|
|
1210
|
+
symbol: string;
|
|
1211
|
+
address: string | undefined;
|
|
1212
|
+
decimals: number | undefined;
|
|
1213
|
+
chainId: number;
|
|
1214
|
+
network: string;
|
|
1215
|
+
};
|
|
1216
|
+
balance: string;
|
|
1217
|
+
allowance: string;
|
|
1218
|
+
isNativeToken: boolean;
|
|
1219
|
+
balanceRevalidating: boolean;
|
|
1220
|
+
allowanceRevalidating: boolean;
|
|
1221
|
+
/** input quantiy */
|
|
1222
|
+
quantity: string;
|
|
1223
|
+
/** orderly deposit fee, unit: wei */
|
|
1224
|
+
depositFee: bigint;
|
|
1225
|
+
/** enquiring depositFee status on chain */
|
|
1226
|
+
depositFeeRevalidating: boolean;
|
|
1227
|
+
approve: (amount?: string) => Promise<void | undefined>;
|
|
1228
|
+
deposit: () => Promise<any>;
|
|
1229
|
+
fetchBalance: (address: string, decimals?: number) => Promise<string>;
|
|
1230
|
+
fetchBalances: (tokens: API.TokenInfo[]) => Promise<string[]>;
|
|
1231
|
+
/** set input quantity */
|
|
1232
|
+
setQuantity: react.Dispatch<react.SetStateAction<string>>;
|
|
1233
|
+
};
|
|
1234
|
+
|
|
1235
|
+
interface ConvertOptions {
|
|
1236
|
+
token?: string;
|
|
1237
|
+
}
|
|
1238
|
+
declare const useConvert: (options: ConvertOptions) => {
|
|
1239
|
+
maxAmount: number;
|
|
1240
|
+
convert: (inputs: {
|
|
1241
|
+
amount: number;
|
|
1242
|
+
slippage: number;
|
|
1243
|
+
}) => Promise<any>;
|
|
1244
|
+
};
|
|
1245
|
+
|
|
1246
|
+
type Receiver = {
|
|
1247
|
+
account_id: string;
|
|
1248
|
+
amount: number;
|
|
1249
|
+
};
|
|
1250
|
+
type TransferOptions = {
|
|
1251
|
+
/** if not provided, use current account id */
|
|
1252
|
+
fromAccountId?: string;
|
|
1253
|
+
token?: string;
|
|
1254
|
+
};
|
|
1255
|
+
declare const useTransfer: (options?: TransferOptions) => {
|
|
1256
|
+
submitting: boolean;
|
|
1257
|
+
transfer: (token: string, receivers: Receiver | Receiver[]) => Promise<any>;
|
|
1258
|
+
maxAmount: number;
|
|
1259
|
+
unsettledPnL: number;
|
|
1260
|
+
holding: _kodiak_finance_orderly_types.API.Holding[] | undefined;
|
|
1261
|
+
};
|
|
1262
|
+
|
|
1263
|
+
type InternalTransferInputs = {
|
|
1264
|
+
token: string;
|
|
1265
|
+
amount: string;
|
|
1266
|
+
receiver: string;
|
|
1267
|
+
/** orderly token decimals */
|
|
1268
|
+
decimals: number;
|
|
1269
|
+
};
|
|
1270
|
+
declare const useInternalTransfer: () => {
|
|
1271
|
+
submitting: boolean;
|
|
1272
|
+
transfer: (inputs: InternalTransferInputs) => Promise<any>;
|
|
1273
|
+
};
|
|
1274
|
+
|
|
1275
|
+
/**
|
|
1276
|
+
* The max withdrawal amount for the token
|
|
1277
|
+
* if token is not provided, return the max withdrawal amount for USDC
|
|
1278
|
+
*/
|
|
1279
|
+
declare const useMaxWithdrawal: (token: string) => number;
|
|
1280
|
+
|
|
1281
|
+
declare const useHoldingStream: () => {
|
|
1282
|
+
data: API.Holding[] | undefined;
|
|
1283
|
+
usdc: API.Holding | undefined;
|
|
1284
|
+
isLoading: boolean;
|
|
1285
|
+
};
|
|
1286
|
+
|
|
1287
|
+
declare const useWalletSubscription: (options?: {
|
|
1288
|
+
onMessage?: (data: any) => void;
|
|
1289
|
+
}) => swr_subscription.SWRSubscriptionResponse<any, any>;
|
|
1290
|
+
|
|
1291
|
+
declare const useBalanceSubscription: (options?: {
|
|
1292
|
+
onMessage?: (data: any) => void;
|
|
1293
|
+
}) => swr_subscription.SWRSubscriptionResponse<any, any>;
|
|
1294
|
+
|
|
1295
|
+
declare const useWalletTopic: (options: {
|
|
1296
|
+
onMessage: (data: any) => void;
|
|
1297
|
+
}) => void;
|
|
1298
|
+
|
|
1299
|
+
declare const useBalanceTopic: (options: {
|
|
1300
|
+
onMessage: (data: any) => void;
|
|
1301
|
+
}) => void;
|
|
1302
|
+
|
|
1303
|
+
declare const useSettleSubscription: (options?: {
|
|
1304
|
+
onMessage?: (data: any) => void;
|
|
1305
|
+
}) => swr_subscription.SWRSubscriptionResponse<any, any>;
|
|
1306
|
+
|
|
1307
|
+
type getKeyFunction = (index: number, prevData: any) => string | null;
|
|
1308
|
+
|
|
1309
|
+
declare const usePrivateDataObserver: (options: {
|
|
1310
|
+
getKeysMap: (type: string) => Map<string, getKeyFunction>;
|
|
1311
|
+
}) => void;
|
|
1312
|
+
|
|
1313
|
+
type PriceRange = {
|
|
1314
|
+
min: number;
|
|
1315
|
+
max: number;
|
|
1316
|
+
};
|
|
1317
|
+
/**
|
|
1318
|
+
* Get the price range for the specified symbol with an optional price
|
|
1319
|
+
*
|
|
1320
|
+
* @param symbol - The symbol to get the price range for
|
|
1321
|
+
* @param price - Optional parameter to set the price
|
|
1322
|
+
* @returns PriceRange | undefined - Returns the PriceRange representing the price range or undefined
|
|
1323
|
+
*/
|
|
1324
|
+
declare const useSymbolPriceRange: (symbol: string, side: "BUY" | "SELL", price?: number) => PriceRange | undefined;
|
|
1325
|
+
|
|
1326
|
+
type OrderValidationItem = {
|
|
1327
|
+
type: "required";
|
|
1328
|
+
message: string;
|
|
1329
|
+
value?: never;
|
|
1330
|
+
} | {
|
|
1331
|
+
type: "max" | "min";
|
|
1332
|
+
message: string;
|
|
1333
|
+
value: number | string;
|
|
1334
|
+
} | {
|
|
1335
|
+
type: "range";
|
|
1336
|
+
message: string;
|
|
1337
|
+
value?: never;
|
|
1338
|
+
min: number | string;
|
|
1339
|
+
max: number | string;
|
|
1340
|
+
} | {
|
|
1341
|
+
type: "priceErrorMin" | "priceErrorMax";
|
|
1342
|
+
message: string;
|
|
1343
|
+
value?: never;
|
|
1344
|
+
};
|
|
1345
|
+
type OrderValidationResult = {
|
|
1346
|
+
[P in keyof OrderlyOrder]?: OrderValidationItem;
|
|
1347
|
+
};
|
|
1348
|
+
type ValuesDepConfig = {
|
|
1349
|
+
symbol: API.SymbolExt;
|
|
1350
|
+
maxQty: number;
|
|
1351
|
+
markPrice: number;
|
|
1352
|
+
estSlippage?: number | null;
|
|
1353
|
+
/** [ask0, bid0] */
|
|
1354
|
+
askAndBid?: number[];
|
|
1355
|
+
};
|
|
1356
|
+
interface OrderCreator<T> {
|
|
1357
|
+
create: (values: T, configs: ValuesDepConfig) => T;
|
|
1358
|
+
validate: (values: T, configs: ValuesDepConfig) => Promise<{
|
|
1359
|
+
[P in keyof T]?: OrderValidationItem;
|
|
1360
|
+
}>;
|
|
1361
|
+
get type(): OrderType;
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
type TPSLComputedData = {
|
|
1365
|
+
/**
|
|
1366
|
+
* Computed take profit
|
|
1367
|
+
*/
|
|
1368
|
+
tp_pnl: number;
|
|
1369
|
+
tp_offset: number;
|
|
1370
|
+
tp_offset_percentage: number;
|
|
1371
|
+
/**
|
|
1372
|
+
* Computed stop loss
|
|
1373
|
+
*/
|
|
1374
|
+
sl_pnl: number;
|
|
1375
|
+
sl_offset: number;
|
|
1376
|
+
sl_offset_percentage: number;
|
|
1377
|
+
};
|
|
1378
|
+
type ComputedAlgoOrder = Partial<AlgoOrderEntity<AlgoOrderRootType.TP_SL> & TPSLComputedData>;
|
|
1379
|
+
type ValidateError = {
|
|
1380
|
+
[P in keyof ComputedAlgoOrder]?: OrderValidationItem;
|
|
1381
|
+
};
|
|
1382
|
+
/**
|
|
1383
|
+
* @hidden
|
|
1384
|
+
*/
|
|
1385
|
+
declare const useTaskProfitAndStopLossInternal: (position: Partial<API.PositionTPSLExt> & Pick<API.PositionTPSLExt, "symbol" | "average_open_price" | "position_qty">, options?: {
|
|
1386
|
+
defaultOrder?: API.AlgoOrder;
|
|
1387
|
+
/**
|
|
1388
|
+
* If the order is editing, set to true
|
|
1389
|
+
* if the isEditing is true, the defaultOrder must be provided
|
|
1390
|
+
* Conversely, even if defaultOrder is provided and isEditing is false, a new TPSL order is still created
|
|
1391
|
+
*/
|
|
1392
|
+
isEditing?: boolean;
|
|
1393
|
+
tpslEnable?: {
|
|
1394
|
+
tp_enable?: boolean;
|
|
1395
|
+
sl_enable?: boolean;
|
|
1396
|
+
};
|
|
1397
|
+
positionType?: PositionType;
|
|
1398
|
+
}) => [
|
|
1399
|
+
/**
|
|
1400
|
+
* return the computed & formatted order
|
|
1401
|
+
*/
|
|
1402
|
+
ComputedAlgoOrder, {
|
|
1403
|
+
/**
|
|
1404
|
+
* Update the take profit and stop loss order, this will merge the new data with the old one
|
|
1405
|
+
*/
|
|
1406
|
+
setValue: (key: string, value: number | string | boolean) => void;
|
|
1407
|
+
setValues: (values: Partial<ComputedAlgoOrder>) => void;
|
|
1408
|
+
/**
|
|
1409
|
+
* Submit the TP/SL order
|
|
1410
|
+
*/
|
|
1411
|
+
submit: (params?: {
|
|
1412
|
+
accountId?: string;
|
|
1413
|
+
}) => Promise<any>;
|
|
1414
|
+
deleteOrder: (orderId: number, symbol: string) => Promise<any>;
|
|
1415
|
+
errors: ValidateError | null;
|
|
1416
|
+
/**
|
|
1417
|
+
*
|
|
1418
|
+
*/
|
|
1419
|
+
validate: () => Promise<AlgoOrderEntity<AlgoOrderRootType.POSITIONAL_TP_SL | AlgoOrderRootType.TP_SL>>;
|
|
1420
|
+
metaState: {
|
|
1421
|
+
dirty: { [K in keyof OrderlyOrder]?: boolean; };
|
|
1422
|
+
submitted: boolean;
|
|
1423
|
+
validated: boolean;
|
|
1424
|
+
errors: ValidateError | null;
|
|
1425
|
+
};
|
|
1426
|
+
isCreateMutating: boolean;
|
|
1427
|
+
isUpdateMutating: boolean;
|
|
1428
|
+
}];
|
|
1429
|
+
|
|
1430
|
+
declare const useTPSLOrder: (
|
|
1431
|
+
/**
|
|
1432
|
+
* Position that needs to set take profit and stop loss
|
|
1433
|
+
*/
|
|
1434
|
+
position: Partial<API.PositionTPSLExt> & Pick<API.PositionTPSLExt, "symbol" | "average_open_price" | "position_qty">, options?: {
|
|
1435
|
+
/**
|
|
1436
|
+
* You can set the default value for the take profit and stop loss order,
|
|
1437
|
+
* it is usually used when editing order
|
|
1438
|
+
*/
|
|
1439
|
+
defaultOrder?: API.AlgoOrder;
|
|
1440
|
+
tpslEnable?: {
|
|
1441
|
+
tp_enable?: boolean;
|
|
1442
|
+
sl_enable?: boolean;
|
|
1443
|
+
};
|
|
1444
|
+
isEditing?: boolean;
|
|
1445
|
+
positionType?: PositionType;
|
|
1446
|
+
}) => ReturnType<typeof useTaskProfitAndStopLossInternal>;
|
|
1447
|
+
|
|
1448
|
+
/**
|
|
1449
|
+
* A custom hook that calculates the maximum allowed leverage for a given trading pair symbol.
|
|
1450
|
+
*
|
|
1451
|
+
* The final leverage is determined by taking the minimum value between the account's maximum
|
|
1452
|
+
* leverage and the symbol's maximum leverage.
|
|
1453
|
+
*
|
|
1454
|
+
* @param symbol - Trading pair symbol (e.g. "PERP_BTC_USDC")
|
|
1455
|
+
* @returns The maximum allowed leverage as a number, or "-" if the leverage cannot be determined
|
|
1456
|
+
*
|
|
1457
|
+
* @example
|
|
1458
|
+
* ```typescript
|
|
1459
|
+
* const leverage = useMaxLeverage("PERP_BTC_USDC");
|
|
1460
|
+
* console.log(`Maximum leverage for PERP_BTC_USDC: ${leverage}x`);
|
|
1461
|
+
* ```
|
|
1462
|
+
*/
|
|
1463
|
+
declare const useMaxLeverage: (symbol: string) => number;
|
|
1464
|
+
|
|
1465
|
+
/**
|
|
1466
|
+
* A custom hook that calculates the maximum allowed leverage for a given trading pair symbol.
|
|
1467
|
+
*
|
|
1468
|
+
* The final leverage is determined by taking the minimum value between the account's maximum
|
|
1469
|
+
* leverage and the symbol's maximum leverage.
|
|
1470
|
+
*
|
|
1471
|
+
* @param symbol - Trading pair symbol (e.g. "PERP_BTC_USDC")
|
|
1472
|
+
* @returns The maximum allowed leverage as a number, or "-" if the leverage cannot be determined
|
|
1473
|
+
*
|
|
1474
|
+
* @example
|
|
1475
|
+
* ```typescript
|
|
1476
|
+
* const leverage = useMaxSymbolLeverage("PERP_BTC_USDC");
|
|
1477
|
+
* console.log(`Maximum leverage for PERP_BTC_USDC: ${leverage}x`);
|
|
1478
|
+
* ```
|
|
1479
|
+
*/
|
|
1480
|
+
declare const useSymbolLeverage: (symbol?: string) => {
|
|
1481
|
+
maxLeverage: number;
|
|
1482
|
+
update: (this: unknown, data: Record<string, any> | null, params?: Record<string, any> | undefined, options?: swr_mutation.SWRMutationConfiguration<unknown, unknown> | undefined) => Promise<any>;
|
|
1483
|
+
isLoading: boolean;
|
|
1484
|
+
};
|
|
1485
|
+
|
|
1486
|
+
/**
|
|
1487
|
+
* A hook to fetch and subscribe to leverage for a given trading symbol.
|
|
1488
|
+
* It initially fetches the leverage data via a private query and then listens for real-time
|
|
1489
|
+
* updates through a WebSocket subscription to keep the leverage value current.
|
|
1490
|
+
*
|
|
1491
|
+
* @param symbol - The trading symbol (e.g. "PERP_BTC_USDC")
|
|
1492
|
+
* @returns The current leverage value associated with the symbol, or undefined if not available
|
|
1493
|
+
*
|
|
1494
|
+
* @example
|
|
1495
|
+
* ```typescript
|
|
1496
|
+
* const leverage = useLeverageBySymbol("PERP_BTC_USDC");
|
|
1497
|
+
* ```
|
|
1498
|
+
*/
|
|
1499
|
+
declare const useLeverageBySymbol: (symbol?: string) => number | undefined;
|
|
1500
|
+
|
|
1501
|
+
type AssetHistoryOptions = {
|
|
1502
|
+
/** token name you want to search */
|
|
1503
|
+
token?: string;
|
|
1504
|
+
/** DEPOSIT、WITHDRAW, all */
|
|
1505
|
+
side?: string;
|
|
1506
|
+
status?: AssetHistoryStatusEnum;
|
|
1507
|
+
/** start time in milliseconds */
|
|
1508
|
+
startTime?: number;
|
|
1509
|
+
/** end time in milliseconds */
|
|
1510
|
+
endTime?: number;
|
|
1511
|
+
page?: number;
|
|
1512
|
+
pageSize?: number;
|
|
1513
|
+
};
|
|
1514
|
+
/**
|
|
1515
|
+
* Get asset history, including token deposits/withdrawals.
|
|
1516
|
+
* https://orderly.network/docs/build-on-omnichain/evm-api/restful-api/private/get-asset-history#get-asset-history
|
|
1517
|
+
*/
|
|
1518
|
+
declare const useAssetsHistory: (options: AssetHistoryOptions, config?: {
|
|
1519
|
+
/**
|
|
1520
|
+
* should update when wallet changed, default is update
|
|
1521
|
+
*/
|
|
1522
|
+
shouldUpdateOnWalletChanged?: (data: any) => boolean;
|
|
1523
|
+
}) => readonly [readonly any[], {
|
|
1524
|
+
readonly meta: API.RecordsMeta | undefined;
|
|
1525
|
+
readonly isLoading: boolean;
|
|
1526
|
+
}];
|
|
1527
|
+
|
|
1528
|
+
type QueryParams = {
|
|
1529
|
+
startDate: string;
|
|
1530
|
+
endDate: string;
|
|
1531
|
+
page?: number;
|
|
1532
|
+
};
|
|
1533
|
+
/**
|
|
1534
|
+
* Fetch statistics data, only support weekly/monthly/quarterly for now
|
|
1535
|
+
*/
|
|
1536
|
+
declare const useStatisticsDaily: (params: QueryParams, options?: {
|
|
1537
|
+
ignoreAggregation?: boolean;
|
|
1538
|
+
}) => readonly [readonly any[], {
|
|
1539
|
+
readonly aggregateValue: {
|
|
1540
|
+
vol: null;
|
|
1541
|
+
pnl: null;
|
|
1542
|
+
roi: null;
|
|
1543
|
+
} | {
|
|
1544
|
+
vol: number;
|
|
1545
|
+
pnl: number;
|
|
1546
|
+
roi: number;
|
|
1547
|
+
};
|
|
1548
|
+
}];
|
|
1549
|
+
|
|
1550
|
+
type FundingSearchParams = {
|
|
1551
|
+
/**
|
|
1552
|
+
* Data range for the funding fee history
|
|
1553
|
+
* noted that the time stamp is a 13-digits timestamp
|
|
1554
|
+
* the first element is the start date and the second element is the end date
|
|
1555
|
+
* @default [Now subtract 3 months, Now]
|
|
1556
|
+
*/
|
|
1557
|
+
dataRange?: number[];
|
|
1558
|
+
symbol?: string;
|
|
1559
|
+
page?: number;
|
|
1560
|
+
pageSize?: number;
|
|
1561
|
+
};
|
|
1562
|
+
declare const useFundingFeeHistory: (params: FundingSearchParams, options?: SWRConfiguration) => readonly [(API.FundingFeeRow & {
|
|
1563
|
+
annual_rate: number;
|
|
1564
|
+
})[] | null, {
|
|
1565
|
+
readonly meta: API.RecordsMeta | undefined;
|
|
1566
|
+
readonly isLoading: boolean;
|
|
1567
|
+
readonly isValidating: boolean;
|
|
1568
|
+
}];
|
|
1569
|
+
|
|
1570
|
+
type DistributionSearchParams = {
|
|
1571
|
+
/**
|
|
1572
|
+
* Data range for the distribution history
|
|
1573
|
+
* noted that the time stamp is a 13-digits timestamp
|
|
1574
|
+
* the first element is the start date and the second element is the end date
|
|
1575
|
+
* @default [Now subtract 3 months, Now]
|
|
1576
|
+
*/
|
|
1577
|
+
dataRange?: number[];
|
|
1578
|
+
type?: string;
|
|
1579
|
+
page: number;
|
|
1580
|
+
pageSize: number;
|
|
1581
|
+
};
|
|
1582
|
+
declare const useDistributionHistory: (parmas: DistributionSearchParams) => readonly [(API.FundingFeeRow & {
|
|
1583
|
+
annual_rate: number;
|
|
1584
|
+
})[], {
|
|
1585
|
+
readonly meta: API.RecordsMeta | undefined;
|
|
1586
|
+
readonly isLoading: boolean;
|
|
1587
|
+
readonly isValidating: boolean;
|
|
1588
|
+
}];
|
|
1589
|
+
|
|
1590
|
+
interface TransferHistorySearchParams$1 {
|
|
1591
|
+
dataRange?: number[];
|
|
1592
|
+
page: number;
|
|
1593
|
+
size: number;
|
|
1594
|
+
fromId?: string;
|
|
1595
|
+
toId?: string;
|
|
1596
|
+
side: "IN" | "OUT";
|
|
1597
|
+
/**
|
|
1598
|
+
* If True, return only internal transfers between main account and sub-accounts.
|
|
1599
|
+
* If False, return only internal transfers between main account and other main accounts.
|
|
1600
|
+
* If empty, return all transfer history.
|
|
1601
|
+
* @default true
|
|
1602
|
+
*/
|
|
1603
|
+
main_sub_only?: boolean;
|
|
1604
|
+
}
|
|
1605
|
+
declare const useTransferHistory: (parmas: TransferHistorySearchParams$1) => readonly [API.TransferHistoryRow[], {
|
|
1606
|
+
readonly meta: API.RecordsMeta | undefined;
|
|
1607
|
+
readonly isLoading: boolean;
|
|
1608
|
+
readonly mutate: swr.KeyedMutator<API.TransferHistory>;
|
|
1609
|
+
}];
|
|
1610
|
+
|
|
1611
|
+
interface TransferHistorySearchParams {
|
|
1612
|
+
dataRange?: number[];
|
|
1613
|
+
page: number;
|
|
1614
|
+
size: number;
|
|
1615
|
+
}
|
|
1616
|
+
declare const useVaultsHistory: (parmas: TransferHistorySearchParams) => (API.StrategyVaultHistoryRow[] | {
|
|
1617
|
+
meta: API.RecordsMeta | undefined;
|
|
1618
|
+
isLoading: boolean;
|
|
1619
|
+
mutate: swr.KeyedMutator<API.StrategyVaultHistory>;
|
|
1620
|
+
})[];
|
|
1621
|
+
|
|
1622
|
+
/** 0 for nothing, 2 for maintenance */
|
|
1623
|
+
declare enum MaintenanceStatus {
|
|
1624
|
+
None = 0,
|
|
1625
|
+
Maintenance = 2
|
|
1626
|
+
}
|
|
1627
|
+
declare const useMaintenanceStatus: () => {
|
|
1628
|
+
status: number;
|
|
1629
|
+
brokerName: string;
|
|
1630
|
+
startTime: number | undefined;
|
|
1631
|
+
endTime: number | undefined;
|
|
1632
|
+
};
|
|
1633
|
+
|
|
1634
|
+
declare const useMarkPriceBySymbol: (symbol: string) => number;
|
|
1635
|
+
|
|
1636
|
+
type PositionActions = {
|
|
1637
|
+
setPositions: (key: string, positions: API.PositionsTPSLExt) => void;
|
|
1638
|
+
clearAll: () => void;
|
|
1639
|
+
closePosition: (symbol: string) => void;
|
|
1640
|
+
};
|
|
1641
|
+
declare const usePositionActions: () => PositionActions;
|
|
1642
|
+
|
|
1643
|
+
declare const useStorageLedgerAddress: () => {
|
|
1644
|
+
setLedgerAddress: (address: string) => void;
|
|
1645
|
+
ledgerWallet: any;
|
|
1646
|
+
};
|
|
1647
|
+
|
|
1648
|
+
/**
|
|
1649
|
+
* return all tokens info
|
|
1650
|
+
*/
|
|
1651
|
+
declare const useTokensInfo: () => API.Chain[];
|
|
1652
|
+
/**
|
|
1653
|
+
* return token info by specify token
|
|
1654
|
+
*/
|
|
1655
|
+
declare const useTokenInfo: (token: string) => API.Chain | undefined;
|
|
1656
|
+
|
|
1657
|
+
type Portfolio$1 = {
|
|
1658
|
+
holding?: API.Holding[];
|
|
1659
|
+
totalCollateral: Decimal;
|
|
1660
|
+
freeCollateral: Decimal;
|
|
1661
|
+
totalValue: Decimal | null;
|
|
1662
|
+
availableBalance: number;
|
|
1663
|
+
unsettledPnL: number;
|
|
1664
|
+
totalUnrealizedROI: number;
|
|
1665
|
+
};
|
|
1666
|
+
declare const usePortfolio: () => Portfolio$1;
|
|
1667
|
+
|
|
1668
|
+
type UseOrderEntryOptions = {
|
|
1669
|
+
commify?: boolean;
|
|
1670
|
+
watchOrderbook?: boolean;
|
|
1671
|
+
validate?: (data: OrderEntity) => {
|
|
1672
|
+
[P in keyof OrderEntity]?: string;
|
|
1673
|
+
} | null | undefined;
|
|
1674
|
+
};
|
|
1675
|
+
type UseOrderEntryMetaState = {
|
|
1676
|
+
errors: {
|
|
1677
|
+
[P in keyof OrderEntity]?: {
|
|
1678
|
+
type: string;
|
|
1679
|
+
message: string;
|
|
1680
|
+
};
|
|
1681
|
+
} | null | undefined;
|
|
1682
|
+
dirty: {
|
|
1683
|
+
[P in keyof OrderEntity]?: boolean;
|
|
1684
|
+
} | null | undefined;
|
|
1685
|
+
submitted: boolean;
|
|
1686
|
+
};
|
|
1687
|
+
type UseOrderEntryReturn = {
|
|
1688
|
+
maxQty: number;
|
|
1689
|
+
freeCollateral: number;
|
|
1690
|
+
markPrice: number;
|
|
1691
|
+
estLiqPrice?: number | null;
|
|
1692
|
+
estLeverage?: number | null;
|
|
1693
|
+
onSubmit: (order: OrderEntity) => Promise<any>;
|
|
1694
|
+
submit: () => Promise<OrderEntity>;
|
|
1695
|
+
submitting: boolean;
|
|
1696
|
+
formattedOrder: Partial<OrderEntity>;
|
|
1697
|
+
helper: {
|
|
1698
|
+
calculate: (values: Partial<OrderlyOrder>, field: keyof OrderEntity, value: any) => Partial<OrderEntity>;
|
|
1699
|
+
validator: (values: Partial<OrderEntity>) => any;
|
|
1700
|
+
};
|
|
1701
|
+
metaState: UseOrderEntryMetaState;
|
|
1702
|
+
symbolConfig: API.SymbolExt;
|
|
1703
|
+
};
|
|
1704
|
+
type OrderParams = Required<Pick<OrderEntity, "side" | "order_type" | "symbol">> & Partial<Omit<OrderEntity, "side" | "symbol" | "order_type">>;
|
|
1705
|
+
/**
|
|
1706
|
+
* Create Order
|
|
1707
|
+
* @example
|
|
1708
|
+
* ```tsx
|
|
1709
|
+
* import { useOrderEntry } from "@kodiak-finance/orderly-hooks";
|
|
1710
|
+
* import {OrderSide, OrderType} from '@kodiak-finance/orderly-types';
|
|
1711
|
+
*
|
|
1712
|
+
* const { formattedOrder, onSubmit, helper } = useOrderEntry({
|
|
1713
|
+
* symbol: "PERP_ETH_USDC",
|
|
1714
|
+
* side: OrderSide.BUY,
|
|
1715
|
+
* order_type: OrderType.LIMIT,
|
|
1716
|
+
* order_price: 10000,
|
|
1717
|
+
* order_quantity: 1,
|
|
1718
|
+
* },{
|
|
1719
|
+
* // **Note:** it's required
|
|
1720
|
+
* watchOrderbook: true,
|
|
1721
|
+
* });
|
|
1722
|
+
* ```
|
|
1723
|
+
*/
|
|
1724
|
+
declare function useOrderEntry$1(order: OrderParams, options?: UseOrderEntryOptions): UseOrderEntryReturn;
|
|
1725
|
+
/**
|
|
1726
|
+
* @deprecated
|
|
1727
|
+
*/
|
|
1728
|
+
declare function useOrderEntry$1(symbol: string, side: OrderSide, reduceOnly: boolean): UseOrderEntryReturn;
|
|
1729
|
+
|
|
1730
|
+
declare function useMediaQuery(query: string): boolean;
|
|
1731
|
+
|
|
1732
|
+
type posterDataSource = {
|
|
1733
|
+
/**
|
|
1734
|
+
* slogan of the poster
|
|
1735
|
+
*/
|
|
1736
|
+
message?: string;
|
|
1737
|
+
position: {
|
|
1738
|
+
symbol: string;
|
|
1739
|
+
side: "LONG" | "SHORT";
|
|
1740
|
+
/**
|
|
1741
|
+
* The leverage of the position
|
|
1742
|
+
*/
|
|
1743
|
+
leverage: number;
|
|
1744
|
+
/**
|
|
1745
|
+
* The unrealized PnL of the position
|
|
1746
|
+
*/
|
|
1747
|
+
pnl: number;
|
|
1748
|
+
/**
|
|
1749
|
+
* The return on investment of the position
|
|
1750
|
+
*/
|
|
1751
|
+
ROI: number;
|
|
1752
|
+
/**
|
|
1753
|
+
* The informations of the position, such as open price, opened at, mark price, quantity and custom message.
|
|
1754
|
+
*/
|
|
1755
|
+
informations: {
|
|
1756
|
+
title: string;
|
|
1757
|
+
value: string;
|
|
1758
|
+
}[];
|
|
1759
|
+
/**
|
|
1760
|
+
* The quote currency of the position
|
|
1761
|
+
*/
|
|
1762
|
+
currency: string;
|
|
1763
|
+
};
|
|
1764
|
+
/**
|
|
1765
|
+
* The domain of the application
|
|
1766
|
+
*/
|
|
1767
|
+
domain: string;
|
|
1768
|
+
/**
|
|
1769
|
+
* The update time of the position
|
|
1770
|
+
*/
|
|
1771
|
+
updateTime: string;
|
|
1772
|
+
referral?: {
|
|
1773
|
+
code: string;
|
|
1774
|
+
slogan: string;
|
|
1775
|
+
link: string;
|
|
1776
|
+
} | null;
|
|
1777
|
+
};
|
|
1778
|
+
type layoutInfo = {
|
|
1779
|
+
width?: number;
|
|
1780
|
+
height?: number;
|
|
1781
|
+
fontSize?: number;
|
|
1782
|
+
color?: string;
|
|
1783
|
+
textAlign?: CanvasTextAlign;
|
|
1784
|
+
textBaseline?: CanvasTextBaseline;
|
|
1785
|
+
position: Partial<{
|
|
1786
|
+
left: number;
|
|
1787
|
+
right: number;
|
|
1788
|
+
top: number;
|
|
1789
|
+
bottom: number;
|
|
1790
|
+
}>;
|
|
1791
|
+
};
|
|
1792
|
+
type PosterLayoutConfig = {
|
|
1793
|
+
message?: layoutInfo;
|
|
1794
|
+
domain?: layoutInfo;
|
|
1795
|
+
position?: layoutInfo;
|
|
1796
|
+
unrealizedPnl?: layoutInfo & {
|
|
1797
|
+
secondaryColor: string;
|
|
1798
|
+
secondaryFontSize: number;
|
|
1799
|
+
};
|
|
1800
|
+
informations?: layoutInfo & {
|
|
1801
|
+
labelColor?: string;
|
|
1802
|
+
};
|
|
1803
|
+
updateTime?: layoutInfo;
|
|
1804
|
+
};
|
|
1805
|
+
type DrawOptions = {
|
|
1806
|
+
/**
|
|
1807
|
+
* Color of common text
|
|
1808
|
+
*/
|
|
1809
|
+
color?: string;
|
|
1810
|
+
fontFamily?: string;
|
|
1811
|
+
/**
|
|
1812
|
+
* Lose color
|
|
1813
|
+
*/
|
|
1814
|
+
lossColor?: string;
|
|
1815
|
+
/**
|
|
1816
|
+
* Profit color
|
|
1817
|
+
*/
|
|
1818
|
+
profitColor?: string;
|
|
1819
|
+
/**
|
|
1820
|
+
* The brand color of the application
|
|
1821
|
+
*/
|
|
1822
|
+
brandColor?: string;
|
|
1823
|
+
backgroundColor?: string;
|
|
1824
|
+
backgroundImg?: string;
|
|
1825
|
+
data?: posterDataSource;
|
|
1826
|
+
layout?: PosterLayoutConfig;
|
|
1827
|
+
};
|
|
1828
|
+
|
|
1829
|
+
/**
|
|
1830
|
+
* Generates a poster image based on position information. You can set the size, background color, font color, font size, and content position of the poster.
|
|
1831
|
+
* @example
|
|
1832
|
+
* ```tsx
|
|
1833
|
+
* const { ref, toDataURL, toBlob, download, copy } = usePoster({
|
|
1834
|
+
* backgroundColor: "#0b8c70",
|
|
1835
|
+
* backgroundImg: "/images/poster_bg.png",
|
|
1836
|
+
* color: "rgba(255, 255, 255, 0.98)",
|
|
1837
|
+
* profitColor: "rgb(0,181,159)",
|
|
1838
|
+
* // ...
|
|
1839
|
+
* });
|
|
1840
|
+
* ```
|
|
1841
|
+
*/
|
|
1842
|
+
declare const usePoster: (
|
|
1843
|
+
/**
|
|
1844
|
+
* The options to draw the poster
|
|
1845
|
+
*/
|
|
1846
|
+
data: DrawOptions, options?: {
|
|
1847
|
+
/**
|
|
1848
|
+
* The ratio of the poster
|
|
1849
|
+
*/
|
|
1850
|
+
ratio?: number;
|
|
1851
|
+
}) => {
|
|
1852
|
+
readonly error: Error | null;
|
|
1853
|
+
/**
|
|
1854
|
+
* The ref to the canvas element, you should pass this ref to the canvas element
|
|
1855
|
+
*/
|
|
1856
|
+
readonly ref: (ref: HTMLCanvasElement | null) => void;
|
|
1857
|
+
/**
|
|
1858
|
+
* Converts the poster to a data URL
|
|
1859
|
+
*/
|
|
1860
|
+
readonly toDataURL: (type?: string, encoderOptions?: number) => string;
|
|
1861
|
+
/**
|
|
1862
|
+
* Converts the poster to a blob
|
|
1863
|
+
*/
|
|
1864
|
+
readonly toBlob: (type?: string, encoderOptions?: number) => Promise<Blob | null>;
|
|
1865
|
+
/**
|
|
1866
|
+
* Downloads the poster as an image
|
|
1867
|
+
*/
|
|
1868
|
+
readonly download: (filename: string, type?: string, encoderOptions?: number) => void;
|
|
1869
|
+
/**
|
|
1870
|
+
* Browser if supports copy image to clipboard
|
|
1871
|
+
*/
|
|
1872
|
+
readonly canCopy: boolean;
|
|
1873
|
+
readonly copy: () => Promise<void>;
|
|
1874
|
+
};
|
|
1875
|
+
|
|
1876
|
+
declare const DefaultLayoutConfig: PosterLayoutConfig;
|
|
1877
|
+
|
|
1878
|
+
type FullOrderState$1 = OrderlyOrder;
|
|
1879
|
+
|
|
1880
|
+
declare const cleanStringStyle: (str: string | number) => string;
|
|
1881
|
+
/**
|
|
1882
|
+
* format number
|
|
1883
|
+
* TODO: refactor this
|
|
1884
|
+
*/
|
|
1885
|
+
declare function formatNumber(qty?: string | number, dp?: number | string): string | undefined;
|
|
1886
|
+
declare function calculate(values: Partial<FullOrderState$1>, fieldName: keyof FullOrderState$1, value: any, markPrice: number, config: API.SymbolExt): Partial<FullOrderState$1>;
|
|
1887
|
+
|
|
1888
|
+
/**
|
|
1889
|
+
* get the min notional for the order
|
|
1890
|
+
*/
|
|
1891
|
+
declare function getMinNotional(props: {
|
|
1892
|
+
base_tick?: number;
|
|
1893
|
+
price?: string | number;
|
|
1894
|
+
qty?: string | number;
|
|
1895
|
+
min_notional?: number;
|
|
1896
|
+
quote_dp?: number;
|
|
1897
|
+
base_dp?: number;
|
|
1898
|
+
quote_tick?: number;
|
|
1899
|
+
}): string | undefined;
|
|
1900
|
+
/**
|
|
1901
|
+
* @deprecated please use getMinNotional instead, it will be removed in next major version
|
|
1902
|
+
*/
|
|
1903
|
+
declare function checkNotional(props: {
|
|
1904
|
+
base_tick: number;
|
|
1905
|
+
price?: string | number;
|
|
1906
|
+
qty?: string | number;
|
|
1907
|
+
min_notional?: number;
|
|
1908
|
+
quote_dp?: number;
|
|
1909
|
+
base_dp?: number;
|
|
1910
|
+
quote_tick?: number;
|
|
1911
|
+
}): string | undefined;
|
|
1912
|
+
|
|
1913
|
+
declare function getPositionBySymbol(symbol: string): void;
|
|
1914
|
+
|
|
1915
|
+
/**
|
|
1916
|
+
* TP/SL price -> pnl
|
|
1917
|
+
* @price trigger_price
|
|
1918
|
+
* @entryPrice calculate price, maybe markPrice/limitPrice/order.price
|
|
1919
|
+
*/
|
|
1920
|
+
declare function priceToPnl(inputs: {
|
|
1921
|
+
qty: number;
|
|
1922
|
+
price: number;
|
|
1923
|
+
entryPrice: number;
|
|
1924
|
+
orderSide: OrderSide;
|
|
1925
|
+
orderType: AlgoOrderType;
|
|
1926
|
+
}, options?: {
|
|
1927
|
+
symbol?: Pick<API.SymbolExt, "quote_dp">;
|
|
1928
|
+
}): number;
|
|
1929
|
+
declare function calcTPSL_ROI(inputs: {
|
|
1930
|
+
pnl: number | string;
|
|
1931
|
+
qty: number | string;
|
|
1932
|
+
price: number | string;
|
|
1933
|
+
}): string;
|
|
1934
|
+
|
|
1935
|
+
declare const index_calcTPSL_ROI: typeof calcTPSL_ROI;
|
|
1936
|
+
declare const index_cleanStringStyle: typeof cleanStringStyle;
|
|
1937
|
+
declare const index_fetcher: typeof fetcher;
|
|
1938
|
+
declare const index_findPositionTPSLFromOrders: typeof findPositionTPSLFromOrders;
|
|
1939
|
+
declare const index_findTPSLFromOrder: typeof findTPSLFromOrder;
|
|
1940
|
+
declare const index_findTPSLOrderPriceFromOrder: typeof findTPSLOrderPriceFromOrder;
|
|
1941
|
+
declare const index_formatNumber: typeof formatNumber;
|
|
1942
|
+
declare const index_getPositionBySymbol: typeof getPositionBySymbol;
|
|
1943
|
+
declare const index_noCacheConfig: typeof noCacheConfig;
|
|
1944
|
+
declare const index_priceToPnl: typeof priceToPnl;
|
|
1945
|
+
type index_useQueryOptions<T> = useQueryOptions<T>;
|
|
1946
|
+
declare namespace index {
|
|
1947
|
+
export { index_calcTPSL_ROI as calcTPSL_ROI, index_cleanStringStyle as cleanStringStyle, index_fetcher as fetcher, index_findPositionTPSLFromOrders as findPositionTPSLFromOrders, index_findTPSLFromOrder as findTPSLFromOrder, index_findTPSLOrderPriceFromOrder as findTPSLOrderPriceFromOrder, index_formatNumber as formatNumber, index_getPositionBySymbol as getPositionBySymbol, index_noCacheConfig as noCacheConfig, index_priceToPnl as priceToPnl, type index_useQueryOptions as useQueryOptions };
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
declare enum TWType {
|
|
1951
|
+
normal = "normal",
|
|
1952
|
+
mm = "mm"
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
type EpochInfoItem = {
|
|
1956
|
+
epoch_id: number;
|
|
1957
|
+
start_time: number;
|
|
1958
|
+
end_time: number;
|
|
1959
|
+
epoch_token: string;
|
|
1960
|
+
max_reward_amount: number;
|
|
1961
|
+
};
|
|
1962
|
+
type EpochInfoType = [
|
|
1963
|
+
data: EpochInfoItem[] | undefined,
|
|
1964
|
+
{
|
|
1965
|
+
isLoading: boolean;
|
|
1966
|
+
curEpochInfo: EpochInfoItem | undefined;
|
|
1967
|
+
isNotStared: boolean;
|
|
1968
|
+
refresh: () => void;
|
|
1969
|
+
}
|
|
1970
|
+
];
|
|
1971
|
+
declare const useEpochInfo: (type: TWType) => EpochInfoType;
|
|
1972
|
+
|
|
1973
|
+
type Brokers = {
|
|
1974
|
+
[key: string]: string;
|
|
1975
|
+
};
|
|
1976
|
+
/** get all brokers, will be callback a list */
|
|
1977
|
+
declare const useAllBrokers: () => readonly [Brokers | undefined];
|
|
1978
|
+
|
|
1979
|
+
type CurrentEpochEstimateRow = {
|
|
1980
|
+
broker_id: string;
|
|
1981
|
+
est_r_account: number;
|
|
1982
|
+
broker_name: string;
|
|
1983
|
+
};
|
|
1984
|
+
type CurrentEpochEstimate = {
|
|
1985
|
+
est_r_wallet: string;
|
|
1986
|
+
est_stake_boost?: number;
|
|
1987
|
+
est_avg_stake?: number;
|
|
1988
|
+
est_trading_volume: number;
|
|
1989
|
+
rows: CurrentEpochEstimateRow[];
|
|
1990
|
+
};
|
|
1991
|
+
declare const useCurEpochEstimate: (type: TWType) => readonly [CurrentEpochEstimate | undefined];
|
|
1992
|
+
|
|
1993
|
+
type AccountRewardsHistoryRow = {
|
|
1994
|
+
broker_id: string;
|
|
1995
|
+
wallet_epoch_avg_staked?: number;
|
|
1996
|
+
trader_score_major?: number;
|
|
1997
|
+
trader_score_alts?: number;
|
|
1998
|
+
epoch_token?: string;
|
|
1999
|
+
reward_status?: string;
|
|
2000
|
+
r_major?: number;
|
|
2001
|
+
r_alts?: number;
|
|
2002
|
+
r_account?: number;
|
|
2003
|
+
broker_name?: string;
|
|
2004
|
+
};
|
|
2005
|
+
type AccountRewardsHistory = {
|
|
2006
|
+
epoch_id: number;
|
|
2007
|
+
broker: AccountRewardsHistoryRow[];
|
|
2008
|
+
};
|
|
2009
|
+
declare const useAccountRewardsHistory: (address?: string) => {
|
|
2010
|
+
data: AccountRewardsHistory[] | undefined;
|
|
2011
|
+
};
|
|
2012
|
+
|
|
2013
|
+
declare enum DistributionId {
|
|
2014
|
+
order = 0,
|
|
2015
|
+
esORder = 1,
|
|
2016
|
+
mmOrder = 2,
|
|
2017
|
+
mmEsOrder = 3
|
|
2018
|
+
}
|
|
2019
|
+
declare const useGetClaimed: (id: DistributionId) => [number | undefined, {
|
|
2020
|
+
refresh: () => void;
|
|
2021
|
+
}];
|
|
2022
|
+
|
|
2023
|
+
type WalletRewardsItem = {
|
|
2024
|
+
epoch_id: number;
|
|
2025
|
+
wallet_epoch_avg_staked: number;
|
|
2026
|
+
epoch_token: string;
|
|
2027
|
+
max_reward_amount: number;
|
|
2028
|
+
reward_status: string;
|
|
2029
|
+
r_wallet: number;
|
|
2030
|
+
};
|
|
2031
|
+
type WalletRewards = {
|
|
2032
|
+
wallet_lifetime_trading_rewards_order: string;
|
|
2033
|
+
wallet_lifetime_trading_rewards_escrow: string;
|
|
2034
|
+
wallet_pending_trading_rewards_order: string;
|
|
2035
|
+
wallet_pending_trading_rewards_escrow: string;
|
|
2036
|
+
rows: WalletRewardsItem[];
|
|
2037
|
+
};
|
|
2038
|
+
type WalletRewardsHistoryReturns = [
|
|
2039
|
+
WalletRewards | undefined,
|
|
2040
|
+
{
|
|
2041
|
+
refresh: () => void;
|
|
2042
|
+
error?: any;
|
|
2043
|
+
}
|
|
2044
|
+
];
|
|
2045
|
+
declare const useWalletRewardsHistory: (type: TWType) => WalletRewardsHistoryReturns;
|
|
2046
|
+
|
|
2047
|
+
declare enum EpochStatus {
|
|
2048
|
+
active = "Active",
|
|
2049
|
+
paused = "Paused",
|
|
2050
|
+
ended = "Ended"
|
|
2051
|
+
}
|
|
2052
|
+
type StatusInfo = {
|
|
2053
|
+
epochStatus: EpochStatus;
|
|
2054
|
+
currentEpoch: number | undefined;
|
|
2055
|
+
lastCompletedEpoch: number | undefined;
|
|
2056
|
+
};
|
|
2057
|
+
declare function useTradingRewardsStatus(isMMRewards: boolean): {
|
|
2058
|
+
statusInfo: StatusInfo | undefined;
|
|
2059
|
+
};
|
|
2060
|
+
|
|
2061
|
+
declare enum ENVType {
|
|
2062
|
+
prod = "prod",
|
|
2063
|
+
staging = "staging",
|
|
2064
|
+
qa = "qa",
|
|
2065
|
+
dev = "dev"
|
|
2066
|
+
}
|
|
2067
|
+
/**
|
|
2068
|
+
* env is determined by networkId and env
|
|
2069
|
+
* | networkId | env | retrurn |
|
|
2070
|
+
* |-----------|---------|----------|
|
|
2071
|
+
* | mainnet | noset | prod |
|
|
2072
|
+
* | mainnet | prod | prod |
|
|
2073
|
+
* | mainnet | staging | prod |
|
|
2074
|
+
* | mainnet | qa | prod |
|
|
2075
|
+
* | mainnet | dev | prod |
|
|
2076
|
+
* | testnet | noset | staging |
|
|
2077
|
+
* | testnet | prod | staging |
|
|
2078
|
+
* | testnet | staging | staging |
|
|
2079
|
+
* | testnet | qa | qa |
|
|
2080
|
+
* | testnet | dev | dev |
|
|
2081
|
+
* if env is not set, return staging
|
|
2082
|
+
*
|
|
2083
|
+
* @returns {ENVType}
|
|
2084
|
+
*/
|
|
2085
|
+
declare const useGetEnv: () => ENVType;
|
|
2086
|
+
|
|
2087
|
+
type APIKeyItem = {
|
|
2088
|
+
orderly_key: string;
|
|
2089
|
+
key_status: string;
|
|
2090
|
+
ip_restriction_list: string[];
|
|
2091
|
+
ip_restricion_status: string;
|
|
2092
|
+
expiration: number;
|
|
2093
|
+
tag?: any;
|
|
2094
|
+
scope?: string;
|
|
2095
|
+
};
|
|
2096
|
+
declare enum ScopeType {
|
|
2097
|
+
trade = "trade",
|
|
2098
|
+
trading = "trading",
|
|
2099
|
+
tradeAndTrading = "trade,trading"
|
|
2100
|
+
}
|
|
2101
|
+
declare const useApiKeyManager: (queryParams?: {
|
|
2102
|
+
keyInfo?: {
|
|
2103
|
+
page?: number;
|
|
2104
|
+
size?: number;
|
|
2105
|
+
key_status?: string;
|
|
2106
|
+
};
|
|
2107
|
+
}) => readonly [APIKeyItem[] | undefined, {
|
|
2108
|
+
readonly refresh: swr.KeyedMutator<APIKeyItem[]>;
|
|
2109
|
+
readonly error: any;
|
|
2110
|
+
readonly isLoading: boolean;
|
|
2111
|
+
readonly generateOrderlyKey: (scope?: ScopeType) => Promise<{
|
|
2112
|
+
key: string;
|
|
2113
|
+
secretKey: string;
|
|
2114
|
+
}>;
|
|
2115
|
+
readonly setIPRestriction: (orderly_key: string, ip_restriction_list: string) => Promise<any>;
|
|
2116
|
+
readonly removeOrderlyKey: (orderly_key: string) => Promise<any>;
|
|
2117
|
+
readonly resetOrderlyKeyIPRestriction: (orderlyKey: string, mode: "ALLOW_ALL_IPS" | "DISALLOW_ALL_IPS") => Promise<any>;
|
|
2118
|
+
}];
|
|
2119
|
+
|
|
2120
|
+
type FullOrderState = OrderlyOrder;
|
|
2121
|
+
type OrderEntryStateEntity = RequireKeys<FullOrderState, "side" | "order_type" | "symbol">;
|
|
2122
|
+
type OrderEntryState = {
|
|
2123
|
+
entry: OrderEntryStateEntity;
|
|
2124
|
+
estLeverage: number | null;
|
|
2125
|
+
estLiquidationPrice: number | null;
|
|
2126
|
+
errors: Partial<Record<keyof FullOrderState, string>>;
|
|
2127
|
+
};
|
|
2128
|
+
type OrderEntryActions = {
|
|
2129
|
+
updateOrder: (order: Partial<FullOrderState>) => void;
|
|
2130
|
+
updateOrderByKey: <K extends keyof FullOrderState>(key: K, value: FullOrderState[K]) => void;
|
|
2131
|
+
restoreOrder: (order?: Partial<FullOrderState>) => void;
|
|
2132
|
+
updateOrderComputed: (data: {
|
|
2133
|
+
estLeverage: number | null;
|
|
2134
|
+
estLiquidationPrice: number | null;
|
|
2135
|
+
}) => void;
|
|
2136
|
+
resetOrder: (order?: Partial<FullOrderState>) => void;
|
|
2137
|
+
hasTP_SL: () => boolean;
|
|
2138
|
+
};
|
|
2139
|
+
declare const useOrderStore: zustand.UseBoundStore<Omit<zustand.StoreApi<OrderEntryState & {
|
|
2140
|
+
actions: OrderEntryActions;
|
|
2141
|
+
}>, "setState"> & {
|
|
2142
|
+
setState(nextStateOrUpdater: (OrderEntryState & {
|
|
2143
|
+
actions: OrderEntryActions;
|
|
2144
|
+
}) | Partial<OrderEntryState & {
|
|
2145
|
+
actions: OrderEntryActions;
|
|
2146
|
+
}> | ((state: immer.WritableDraft<OrderEntryState & {
|
|
2147
|
+
actions: OrderEntryActions;
|
|
2148
|
+
}>) => void), shouldReplace?: boolean | undefined): void;
|
|
2149
|
+
}>;
|
|
2150
|
+
|
|
2151
|
+
declare const useOrderEntryNextInternal: (symbol: string, options?: {
|
|
2152
|
+
/**
|
|
2153
|
+
* initial order state, default is buy limit order
|
|
2154
|
+
*
|
|
2155
|
+
*/
|
|
2156
|
+
initialOrder?: Omit<Partial<FullOrderState>, "symbol">;
|
|
2157
|
+
symbolInfo?: API.SymbolExt;
|
|
2158
|
+
}) => {
|
|
2159
|
+
readonly formattedOrder: Required<Pick<OrderlyOrder, "symbol" | "side" | "order_type">> & Partial<Omit<OrderlyOrder, "symbol" | "side" | "order_type">>;
|
|
2160
|
+
readonly setValue: (key: keyof FullOrderState, value: any, additional?: {
|
|
2161
|
+
markPrice: number;
|
|
2162
|
+
}) => Partial<OrderlyOrder> | undefined;
|
|
2163
|
+
readonly setValues: (values: Partial<FullOrderState>, additional?: {
|
|
2164
|
+
markPrice: number;
|
|
2165
|
+
}) => Partial<OrderlyOrder> | undefined;
|
|
2166
|
+
readonly submit: () => void;
|
|
2167
|
+
readonly reset: (order?: Partial<OrderlyOrder>) => void;
|
|
2168
|
+
readonly generateOrder: (creator: OrderCreator<any>, options: {
|
|
2169
|
+
maxQty: number;
|
|
2170
|
+
markPrice: number;
|
|
2171
|
+
estSlippage?: number | null;
|
|
2172
|
+
askAndBid?: number[];
|
|
2173
|
+
}) => any;
|
|
2174
|
+
readonly validate: (order: Partial<OrderlyOrder>, creator: OrderCreator<any>, options: {
|
|
2175
|
+
maxQty: number;
|
|
2176
|
+
markPrice: number;
|
|
2177
|
+
estSlippage?: number | null;
|
|
2178
|
+
askAndBid?: number[];
|
|
2179
|
+
}) => Promise<{
|
|
2180
|
+
[x: string]: OrderValidationItem | undefined;
|
|
2181
|
+
}>;
|
|
2182
|
+
readonly onMarkPriceChange: (markPrice: number, baseOn?: string[]) => void;
|
|
2183
|
+
};
|
|
2184
|
+
|
|
2185
|
+
type OrderEntryParameters = Parameters<typeof useOrderEntryNextInternal>;
|
|
2186
|
+
type Options$1 = Omit<OrderEntryParameters["1"], "symbolInfo">;
|
|
2187
|
+
type OrderEntryReturn = {
|
|
2188
|
+
submit: (options?: {
|
|
2189
|
+
resetOnSuccess?: boolean;
|
|
2190
|
+
}) => Promise<{
|
|
2191
|
+
success: boolean;
|
|
2192
|
+
data: Record<string, any>;
|
|
2193
|
+
timestamp: number;
|
|
2194
|
+
}>;
|
|
2195
|
+
reset: () => void;
|
|
2196
|
+
resetErrors: () => void;
|
|
2197
|
+
resetMetaState: () => void;
|
|
2198
|
+
formattedOrder: Partial<FullOrderState>;
|
|
2199
|
+
maxQty: number;
|
|
2200
|
+
/**
|
|
2201
|
+
* The estimated liquidation price.
|
|
2202
|
+
*/
|
|
2203
|
+
estLiqPrice: number | null;
|
|
2204
|
+
/**
|
|
2205
|
+
* The estimated leverage after order creation.
|
|
2206
|
+
*/
|
|
2207
|
+
estLeverage: number | null;
|
|
2208
|
+
estSlippage: number | null;
|
|
2209
|
+
helper: {
|
|
2210
|
+
/**
|
|
2211
|
+
* @deprecated Use `validate` instead.
|
|
2212
|
+
*/
|
|
2213
|
+
validator: () => Promise<OrderValidationResult | null>;
|
|
2214
|
+
/**
|
|
2215
|
+
* Function to validate the order.
|
|
2216
|
+
* @returns {Promise<OrderValidationResult | null>} The validation result.
|
|
2217
|
+
*/
|
|
2218
|
+
validate: () => Promise<OrderValidationResult | null>;
|
|
2219
|
+
};
|
|
2220
|
+
freeCollateral: number;
|
|
2221
|
+
/**
|
|
2222
|
+
* set a single value to the order data;
|
|
2223
|
+
* @param key
|
|
2224
|
+
* @param value
|
|
2225
|
+
* @returns
|
|
2226
|
+
*/
|
|
2227
|
+
setValue: (key: keyof FullOrderState, value: any, options?: {
|
|
2228
|
+
shouldUpdateLastChangedField?: boolean;
|
|
2229
|
+
}) => void;
|
|
2230
|
+
setValues: (values: Partial<FullOrderState>) => void;
|
|
2231
|
+
symbolInfo: API.SymbolExt;
|
|
2232
|
+
/**
|
|
2233
|
+
* Meta state including validation and submission status.
|
|
2234
|
+
*/
|
|
2235
|
+
metaState: {
|
|
2236
|
+
dirty: {
|
|
2237
|
+
[K in keyof OrderlyOrder]?: boolean;
|
|
2238
|
+
};
|
|
2239
|
+
submitted: boolean;
|
|
2240
|
+
validated: boolean;
|
|
2241
|
+
errors: OrderValidationResult | null;
|
|
2242
|
+
};
|
|
2243
|
+
/**
|
|
2244
|
+
* Indicates if a mutation (order creation) is in progress.
|
|
2245
|
+
*/
|
|
2246
|
+
isMutating: boolean;
|
|
2247
|
+
markPrice: number | undefined;
|
|
2248
|
+
};
|
|
2249
|
+
/**
|
|
2250
|
+
* Custom hook for managing order entry in the Orderly application.
|
|
2251
|
+
*
|
|
2252
|
+
* @param {string} symbol - The symbol for which the order is being created. This parameter is required.
|
|
2253
|
+
*
|
|
2254
|
+
* @param {Options} options - Additional options for configuring the order entry.
|
|
2255
|
+
*
|
|
2256
|
+
* @returns {OrderEntryReturn} An object containing various actions and state related to order entry.
|
|
2257
|
+
*
|
|
2258
|
+
* @throws {Error} Throws an error if the symbol is not provided or is not a string.
|
|
2259
|
+
*
|
|
2260
|
+
* @example
|
|
2261
|
+
* ```typescript
|
|
2262
|
+
* const {
|
|
2263
|
+
* submit,
|
|
2264
|
+
* formattedOrder, //
|
|
2265
|
+
* setValue,
|
|
2266
|
+
* setValues,
|
|
2267
|
+
* symbolInfo,
|
|
2268
|
+
* metaState,
|
|
2269
|
+
* isMutating,
|
|
2270
|
+
* // maxQty, freeCollateral ... same as v1
|
|
2271
|
+
* } = useOrderEntry('BTC_USDC_PERP', options);
|
|
2272
|
+
*
|
|
2273
|
+
* // update the order type
|
|
2274
|
+
* setValue('order_type', OrderType.LIMIT);
|
|
2275
|
+
* // update the order price
|
|
2276
|
+
* setValue('order_price', '70000');
|
|
2277
|
+
* // update the order quantity
|
|
2278
|
+
* setValue('order_quantity', 1);
|
|
2279
|
+
*
|
|
2280
|
+
* // how to set TP/SL
|
|
2281
|
+
* setValue('tp_trigger_price', '71000'); // directly set TP trigger price
|
|
2282
|
+
* // or set the tp pnl, the TP trigger price will be calculated based on the current order price
|
|
2283
|
+
* // setValue('tp_pnl', '300'); // you can also set tp_offset or tp_offset_percentage, same as the usage of useTPSL hook;
|
|
2284
|
+
* // SL is similar to TP setting
|
|
2285
|
+
* setValue('sl_price', '69000');
|
|
2286
|
+
*
|
|
2287
|
+
* // Submit the order data to the backend, and reset the hook state after the order is successfully created.
|
|
2288
|
+
* // Note: If the order data is invalid, an error will be thrown.
|
|
2289
|
+
* // If you want to retain the current order data after a successful order creation,
|
|
2290
|
+
* // you can pass {resetOnSuccess: false} to `submit` function to prevent the hook from automatically resetting the order status.
|
|
2291
|
+
* // Of course, you can also call `reset()` to manually reset the order status and use `resetMetaState()` to clear the error state.
|
|
2292
|
+
* await submit();
|
|
2293
|
+
* ```
|
|
2294
|
+
*/
|
|
2295
|
+
declare const useOrderEntry: (symbol: string, options?: Options$1) => OrderEntryReturn;
|
|
2296
|
+
|
|
2297
|
+
declare const useOrderEntity: (order: {
|
|
2298
|
+
symbol: string;
|
|
2299
|
+
order_type: OrderType;
|
|
2300
|
+
side: OrderSide;
|
|
2301
|
+
reduce_only?: boolean;
|
|
2302
|
+
[key: string]: any;
|
|
2303
|
+
}, options?: {
|
|
2304
|
+
maxQty?: number;
|
|
2305
|
+
}) => {
|
|
2306
|
+
errors: OrderValidationResult;
|
|
2307
|
+
markPrice: number;
|
|
2308
|
+
symbolsInfo: Record<string, <Key extends keyof _kodiak_finance_orderly_types.API.SymbolExt>(key: Key, defaultValue?: _kodiak_finance_orderly_types.API.SymbolExt[Key] | undefined) => _kodiak_finance_orderly_types.API.SymbolExt[Key]> & Record<string, () => _kodiak_finance_orderly_types.API.SymbolExt> & {
|
|
2309
|
+
isNil: boolean;
|
|
2310
|
+
};
|
|
2311
|
+
validate: (this: unknown) => Promise<OrderValidationResult | null>;
|
|
2312
|
+
clearErrors: () => void;
|
|
2313
|
+
};
|
|
2314
|
+
|
|
2315
|
+
type RestrictedInfoReturns = ReturnType<typeof useRestrictedInfo>;
|
|
2316
|
+
interface RestrictedInfoOptions {
|
|
2317
|
+
enableDefault?: boolean;
|
|
2318
|
+
customRestrictedIps?: string[];
|
|
2319
|
+
customRestrictedRegions?: string[];
|
|
2320
|
+
customUnblockRegions?: string[];
|
|
2321
|
+
content?: ReactNode | ((data: {
|
|
2322
|
+
ip: string;
|
|
2323
|
+
brokerName: string;
|
|
2324
|
+
}) => ReactNode);
|
|
2325
|
+
}
|
|
2326
|
+
declare const useRestrictedInfo: (options?: RestrictedInfoOptions) => {
|
|
2327
|
+
ip: string;
|
|
2328
|
+
invalidRegions: string[];
|
|
2329
|
+
restrictedOpen: boolean;
|
|
2330
|
+
content: ReactNode | ((data: {
|
|
2331
|
+
ip: string;
|
|
2332
|
+
brokerName: string;
|
|
2333
|
+
}) => ReactNode);
|
|
2334
|
+
canUnblock: boolean;
|
|
2335
|
+
accessRestricted: any;
|
|
2336
|
+
setAccessRestricted: (value: boolean | undefined) => void;
|
|
2337
|
+
};
|
|
2338
|
+
|
|
2339
|
+
type QueryOptions<T> = SWRConfiguration & {
|
|
2340
|
+
formatter?: (data: any) => T;
|
|
2341
|
+
accountId?: string;
|
|
2342
|
+
};
|
|
2343
|
+
declare function useSubAccountQuery<T>(query: Parameters<SWRHook>[0], options?: QueryOptions<T>): SWRResponse<T>;
|
|
2344
|
+
|
|
2345
|
+
type HTTP_METHOD = "POST" | "PUT" | "DELETE" | "GET";
|
|
2346
|
+
type SubAccountMutationOptions<T, E> = SWRMutationConfiguration<T, E> & {
|
|
2347
|
+
/** sub account id */
|
|
2348
|
+
accountId?: string;
|
|
2349
|
+
};
|
|
2350
|
+
/**
|
|
2351
|
+
* This hook is used to execute API requests for data mutation, such as POST, DELETE, PUT, etc.
|
|
2352
|
+
*/
|
|
2353
|
+
declare const useSubAccountMutation: <T, E>(
|
|
2354
|
+
/**
|
|
2355
|
+
* The URL to send the request to. If the URL does not start with "http",
|
|
2356
|
+
* it will be prefixed with the API base URL.
|
|
2357
|
+
*/
|
|
2358
|
+
url: string,
|
|
2359
|
+
/**
|
|
2360
|
+
* The HTTP method to use for the request. Defaults to "POST".
|
|
2361
|
+
*/
|
|
2362
|
+
method?: HTTP_METHOD,
|
|
2363
|
+
/**
|
|
2364
|
+
* The configuration object for the mutation.
|
|
2365
|
+
* @see [useSWRMutation](https://swr.vercel.app/docs/mutation#api)
|
|
2366
|
+
*
|
|
2367
|
+
* @link https://swr.vercel.app/docs/mutation#api
|
|
2368
|
+
*/
|
|
2369
|
+
options?: SubAccountMutationOptions<T, E>) => readonly [(this: unknown, data: Record<string, any> | null, params?: Record<string, any> | undefined, options?: SubAccountMutationOptions<T, E> | undefined) => Promise<any>, {
|
|
2370
|
+
readonly data: any;
|
|
2371
|
+
readonly error: any;
|
|
2372
|
+
readonly reset: () => void;
|
|
2373
|
+
readonly isMutating: boolean;
|
|
2374
|
+
}];
|
|
2375
|
+
|
|
2376
|
+
type Portfolio = {
|
|
2377
|
+
holding?: API.Holding[];
|
|
2378
|
+
totalCollateral: Decimal;
|
|
2379
|
+
freeCollateral: Decimal;
|
|
2380
|
+
totalValue: Decimal | null;
|
|
2381
|
+
availableBalance: number;
|
|
2382
|
+
unsettledPnL: number;
|
|
2383
|
+
totalUnrealizedROI: number;
|
|
2384
|
+
};
|
|
2385
|
+
|
|
2386
|
+
declare const useSubAccountDataObserver: (accountId?: string) => {
|
|
2387
|
+
portfolio: Portfolio | undefined;
|
|
2388
|
+
positions: API.PositionsTPSLExt;
|
|
2389
|
+
};
|
|
2390
|
+
|
|
2391
|
+
type Options = {
|
|
2392
|
+
accountId?: string;
|
|
2393
|
+
};
|
|
2394
|
+
declare const useSubAccountWS: (options: Options) => WS;
|
|
2395
|
+
|
|
2396
|
+
/**
|
|
2397
|
+
* The max withdrawal amount for the token
|
|
2398
|
+
* if token is not provided, return the max withdrawal amount for USDC
|
|
2399
|
+
*/
|
|
2400
|
+
declare function useSubAccountMaxWithdrawal(options: {
|
|
2401
|
+
token?: string;
|
|
2402
|
+
unsettledPnL?: number;
|
|
2403
|
+
freeCollateral: Decimal;
|
|
2404
|
+
holdings?: API.Holding[];
|
|
2405
|
+
}): number;
|
|
2406
|
+
|
|
2407
|
+
type PositionCloseOptions = {
|
|
2408
|
+
position: API.PositionExt;
|
|
2409
|
+
order: {
|
|
2410
|
+
type: OrderType;
|
|
2411
|
+
quantity: string;
|
|
2412
|
+
price: string;
|
|
2413
|
+
};
|
|
2414
|
+
};
|
|
2415
|
+
declare const usePositionClose: (options: PositionCloseOptions) => {
|
|
2416
|
+
submit: () => Promise<any>;
|
|
2417
|
+
isMutating: boolean;
|
|
2418
|
+
side: OrderSide;
|
|
2419
|
+
closeOrderData: Partial<OrderlyOrder>;
|
|
2420
|
+
errors: OrderValidationResult | null;
|
|
2421
|
+
calculate: typeof calculate;
|
|
2422
|
+
};
|
|
2423
|
+
|
|
2424
|
+
declare const useMarketList: () => API.MarketInfoExt[];
|
|
2425
|
+
declare const useMarketMap: () => Record<string, API.MarketInfoExt> | null;
|
|
2426
|
+
|
|
2427
|
+
export { type APIKeyItem, type AccountRewardsHistory, type AccountRewardsHistoryRow, type Brokers, type Chain, type Chains, type CheckReferralCodeReturns, type CollateralOutputs, type ComputedAlgoOrder, type ConfigProviderProps, type ConnectedChain, type CurrentEpochEstimate, DefaultLayoutConfig, DistributionId, type DrawOptions, ENVType, type EpochInfoItem, type EpochInfoType, EpochStatus, type ExclusiveConfigProviderProps, ExtendedConfigStore, type Favorite, type FavoriteTab, type FundingRates, MaintenanceStatus, type MarginRatioReturn, type MarketsItem, MarketsStorageKey, type MarketsStore, MarketsType, type NewListing, ORDERLY_ORDERBOOK_DEPTH_KEY, type OrderBookItem, type OrderEntryReturn, type OrderMetadata, type OrderMetadataConfig, type OrderParams, type OrderValidationItem, type OrderValidationResult, type OrderbookData, type OrderbookOptions, type OrderlyConfigContextState, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, type PosterLayoutConfig, type PriceMode, type Recent, RefferalAPI, type RestrictedInfoOptions, type RestrictedInfoReturns, ScopeType, type StatusInfo, StatusProvider, type SymbolsInfo, TWType, type UseChainsOptions, type UseChainsReturnObject, type UseOrderEntryMetaState, WalletConnectorContext, type WalletConnectorContextState, type WalletRewards, type WalletRewardsHistoryReturns, type WalletRewardsItem, type WalletState, WsNetworkStatus, type chainFilter, type chainFilterFunc, checkNotional, cleanStringStyle, fetcher, type filteredChains$1 as filteredChains, findPositionTPSLFromOrders, findTPSLFromOrder, findTPSLOrderPriceFromOrder, getMinNotional, getPriceKey, noCacheConfig, parseJSON, useAccount, useAccountInfo, useAccountInstance, useAccountRewardsHistory, useAllBrokers, useApiKeyManager, useAssetsHistory, useAudioPlayer, useBalanceSubscription, useBalanceTopic, useBoolean, useChain, useChainInfo, useChains, useCheckReferralCode, useCollateral, useCommission, useComputedLTV, useConfig, useConvert, useCurEpochEstimate, useDaily, useDeposit, useDistribution, useDistributionHistory, useEpochInfo, useEventEmitter, useFeeState, useFundingDetails, useFundingFeeHistory, useFundingRate, useFundingRateHistory, useFundingRates, useFundingRatesStore, useGetClaimed, useGetEnv, useGetReferralCode, useHoldingStream, useIndexPrice, useIndexPricesStream, useInfiniteQuery, useInternalTransfer, useKeyStore, useLazyQuery, useLeverage, useLeverageBySymbol, useLocalStorage, useMaintenanceStatus, useMarginRatio, useMarkPrice, useMarkPriceBySymbol, useMarkPricesStream, useMarket, useMarketList, useMarketMap, useMarketTradeStream, useMarkets, useMarketsStore, useMarketsStream, useMaxLeverage, useMaxQty, useMaxWithdrawal, useMediaQuery, useMemoizedFn, useMutation, useNetworkInfo, useOdosQuote, useOrderEntity, useOrderEntry, useOrderEntry$1 as useOrderEntry_deprecated, useOrderStore, useOrderStream, useOrderbookStream, useOrderlyContext, usePortfolio, usePositionActions, usePositionClose, usePositionStream, usePoster, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, type useQueryOptions, useRefereeHistory, useRefereeInfo, useRefereeRebateSummary, useReferralInfo, useReferralRebateSummary, useRestrictedInfo, useSessionStorage, useSettleSubscription, useSimpleDI, useStatisticsDaily, useStorageChain, useStorageLedgerAddress, useSubAccountDataObserver, useSubAccountMaxWithdrawal, useSubAccountMutation, useSubAccountQuery, useSubAccountWS, useSymbolInfo, useSymbolLeverage, useSymbolPriceRange, useSymbolsInfo, useSymbolsInfoStore, useTPSLOrder, useTickerStream, useTokenInfo, useTokensInfo, useTrack, useTrackingInstance, useTradingRewardsStatus, useTransfer, useTransferHistory, useUpdatedRef, useVaultsHistory, useWS, useWalletConnector, useWalletRewardsHistory, useWalletSubscription, useWalletTopic, useWithdraw, useWsStatus, index as utils, _default as version };
|