@orderly.network/core 0.0.3
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 +323 -0
- package/dist/index.d.ts +323 -0
- package/dist/index.js +2333 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2294 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +45 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { BehaviorSubject } from 'rxjs';
|
|
2
|
+
|
|
3
|
+
interface OrderlyKeyPair {
|
|
4
|
+
getPublicKey(): Promise<string>;
|
|
5
|
+
secretKey: string;
|
|
6
|
+
sign: (data: Uint8Array) => Promise<Uint8Array>;
|
|
7
|
+
}
|
|
8
|
+
declare class BaseOrderlyKeyPair implements OrderlyKeyPair {
|
|
9
|
+
secretKey: string;
|
|
10
|
+
constructor(secretKey: string);
|
|
11
|
+
sign(message: Uint8Array): Promise<Uint8Array>;
|
|
12
|
+
getPublicKey(): Promise<string>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface KeyStore {
|
|
16
|
+
getOrderlyKey: () => OrderlyKeyPair;
|
|
17
|
+
generateKey: () => OrderlyKeyPair;
|
|
18
|
+
setKey: (orderlyKey: string, secretKey: string) => void;
|
|
19
|
+
}
|
|
20
|
+
declare class LocalStorageStore implements KeyStore {
|
|
21
|
+
private readonly networkId;
|
|
22
|
+
private readonly accountId;
|
|
23
|
+
constructor(networkId: string, accountId: string);
|
|
24
|
+
getOrderlyKey(): OrderlyKeyPair;
|
|
25
|
+
generateKey(): BaseOrderlyKeyPair;
|
|
26
|
+
setKey(orderlyKey: string, secretKey: string): void;
|
|
27
|
+
private get _keyPrefix();
|
|
28
|
+
}
|
|
29
|
+
declare class MockKeyStore implements KeyStore {
|
|
30
|
+
private readonly secretKey;
|
|
31
|
+
constructor(secretKey: string);
|
|
32
|
+
generateKey(): BaseOrderlyKeyPair;
|
|
33
|
+
getOrderlyKey(): BaseOrderlyKeyPair;
|
|
34
|
+
setKey(orderlyKey: string, secretKey: string): void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
type MessageFactor = {
|
|
38
|
+
url: string;
|
|
39
|
+
method: "GET" | "POST" | "PUT" | "DELETE";
|
|
40
|
+
data?: any;
|
|
41
|
+
};
|
|
42
|
+
type SignedMessagePayload = {
|
|
43
|
+
"orderly-key": string;
|
|
44
|
+
"orderly-timestamp": string;
|
|
45
|
+
"orderly-signature": string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* 签名
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* const signer = new BaseSigner(keyStore);
|
|
52
|
+
* const payload = await signer.sign({
|
|
53
|
+
* url: "https://api.orderly.io/get_account?address=0x1234567890&brokerId=woofi_dex",
|
|
54
|
+
* method: "GET",
|
|
55
|
+
* data: {
|
|
56
|
+
* address: "0x1234567890",
|
|
57
|
+
* brokerId: "woofi_dex",
|
|
58
|
+
* },
|
|
59
|
+
* });
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
interface Signer {
|
|
63
|
+
sign: (data: MessageFactor) => Promise<SignedMessagePayload>;
|
|
64
|
+
}
|
|
65
|
+
declare class BaseSigner implements Signer {
|
|
66
|
+
private readonly keyStore;
|
|
67
|
+
constructor(keyStore: KeyStore);
|
|
68
|
+
sign(message: MessageFactor): Promise<SignedMessagePayload>;
|
|
69
|
+
signText(text: string): Promise<{
|
|
70
|
+
signature: string;
|
|
71
|
+
publicKey: string;
|
|
72
|
+
}>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
interface ConfigStore {
|
|
76
|
+
get<T>(key: string): T;
|
|
77
|
+
set<T>(key: string, value: T): void;
|
|
78
|
+
clear(): void;
|
|
79
|
+
}
|
|
80
|
+
declare class MemoryConfigStore implements ConfigStore {
|
|
81
|
+
private map;
|
|
82
|
+
constructor();
|
|
83
|
+
private _restore;
|
|
84
|
+
get<T>(key: string): T;
|
|
85
|
+
set<T>(key: string, value: T): void;
|
|
86
|
+
clear(): void;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
declare const getMockSigner: (secretKey?: string) => BaseSigner;
|
|
90
|
+
declare const getDefaultSigner: () => BaseSigner;
|
|
91
|
+
|
|
92
|
+
declare class SimpleDI {
|
|
93
|
+
private static container;
|
|
94
|
+
private static getContainer;
|
|
95
|
+
static register(...serviceClasses: any[]): void;
|
|
96
|
+
static registerByName(name: string, serviceClass: any): void;
|
|
97
|
+
static get<T = any>(name: string): T;
|
|
98
|
+
static getAll(): {
|
|
99
|
+
[name: string]: any;
|
|
100
|
+
};
|
|
101
|
+
private constructor();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
interface WalletClient {
|
|
105
|
+
get address(): string;
|
|
106
|
+
getBalance: () => Promise<any>;
|
|
107
|
+
deposit: () => Promise<any>;
|
|
108
|
+
connect: () => Promise<any>;
|
|
109
|
+
}
|
|
110
|
+
declare abstract class BaseWalletClient implements WalletClient {
|
|
111
|
+
private readonly _address;
|
|
112
|
+
constructor(_address: string);
|
|
113
|
+
abstract getBalance(): Promise<any>;
|
|
114
|
+
abstract deposit(): Promise<any>;
|
|
115
|
+
abstract connect(): Promise<any>;
|
|
116
|
+
get address(): string;
|
|
117
|
+
}
|
|
118
|
+
declare class SimpleWallet extends BaseWalletClient {
|
|
119
|
+
getBalance(): Promise<any>;
|
|
120
|
+
deposit(): Promise<any>;
|
|
121
|
+
connect(): Promise<any>;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
type wallet_BaseWalletClient = BaseWalletClient;
|
|
125
|
+
declare const wallet_BaseWalletClient: typeof BaseWalletClient;
|
|
126
|
+
type wallet_SimpleWallet = SimpleWallet;
|
|
127
|
+
declare const wallet_SimpleWallet: typeof SimpleWallet;
|
|
128
|
+
type wallet_WalletClient = WalletClient;
|
|
129
|
+
declare namespace wallet {
|
|
130
|
+
export {
|
|
131
|
+
wallet_BaseWalletClient as BaseWalletClient,
|
|
132
|
+
wallet_SimpleWallet as SimpleWallet,
|
|
133
|
+
wallet_WalletClient as WalletClient,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
type AccountStatus = "NotConnected" | "Connected" | "NotSignedIn" | "SignedIn";
|
|
138
|
+
declare enum AccountStatusEnum {
|
|
139
|
+
NotConnected = 0,
|
|
140
|
+
Connected = 1,
|
|
141
|
+
NotSignedIn = 2,
|
|
142
|
+
SignedIn = 3,
|
|
143
|
+
EnableTrading = 4
|
|
144
|
+
}
|
|
145
|
+
interface AccountState {
|
|
146
|
+
status: AccountStatus;
|
|
147
|
+
accountId?: string;
|
|
148
|
+
userId?: string;
|
|
149
|
+
address?: string;
|
|
150
|
+
balance: string;
|
|
151
|
+
leverage: number;
|
|
152
|
+
positon?: string[];
|
|
153
|
+
orders?: string[];
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* 账户
|
|
157
|
+
* @example
|
|
158
|
+
* ```ts
|
|
159
|
+
* const account = new Account();
|
|
160
|
+
* account.login("0x1234567890");
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
declare class Account {
|
|
164
|
+
private readonly configStore;
|
|
165
|
+
private walletClient?;
|
|
166
|
+
private _state$;
|
|
167
|
+
constructor(configStore: ConfigStore, walletClient?: WalletClient | undefined);
|
|
168
|
+
/**
|
|
169
|
+
* 登录
|
|
170
|
+
* @param address 钱包地址
|
|
171
|
+
*/
|
|
172
|
+
login(address: string): void;
|
|
173
|
+
logout(): void;
|
|
174
|
+
/**
|
|
175
|
+
* 连接钱包先用第三方的React版本,不用自己实现
|
|
176
|
+
*/
|
|
177
|
+
/**
|
|
178
|
+
* 为账户设置钱包
|
|
179
|
+
*/
|
|
180
|
+
set wallet(wallet: WalletClient | string);
|
|
181
|
+
get state$(): BehaviorSubject<AccountState>;
|
|
182
|
+
get stateValue(): AccountState;
|
|
183
|
+
/**
|
|
184
|
+
* set user positions count
|
|
185
|
+
*/
|
|
186
|
+
set position(position: string[]);
|
|
187
|
+
set orders(orders: string[]);
|
|
188
|
+
private _checkAccount;
|
|
189
|
+
private _checkAccountExist;
|
|
190
|
+
private getAccountInfo;
|
|
191
|
+
private getBalance;
|
|
192
|
+
private _fetch;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
declare namespace API {
|
|
196
|
+
interface Token {
|
|
197
|
+
token: string;
|
|
198
|
+
token_hash: string;
|
|
199
|
+
decimals: number;
|
|
200
|
+
minimum_withdraw_amount: number;
|
|
201
|
+
chain_details: ChainDetail[];
|
|
202
|
+
}
|
|
203
|
+
interface ChainDetail {
|
|
204
|
+
chain_id: string;
|
|
205
|
+
contract_address: string;
|
|
206
|
+
decimals: number;
|
|
207
|
+
}
|
|
208
|
+
interface MarketInfo {
|
|
209
|
+
symbol: string;
|
|
210
|
+
index_price: number;
|
|
211
|
+
mark_price: number;
|
|
212
|
+
sum_unitary_funding: number;
|
|
213
|
+
est_funding_rate: number;
|
|
214
|
+
last_funding_rate: number;
|
|
215
|
+
next_funding_time: number;
|
|
216
|
+
open_interest: string;
|
|
217
|
+
"24h_open": number;
|
|
218
|
+
"24h_close": number;
|
|
219
|
+
"24h_high": number;
|
|
220
|
+
"24h_low": number;
|
|
221
|
+
"24h_volumn": number;
|
|
222
|
+
"24h_amount": number;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* v1/public/info
|
|
226
|
+
*/
|
|
227
|
+
interface Symbol {
|
|
228
|
+
symbol: string;
|
|
229
|
+
quote_min: number;
|
|
230
|
+
quote_max: number;
|
|
231
|
+
quote_tick: number;
|
|
232
|
+
base_min: number;
|
|
233
|
+
base_max: number;
|
|
234
|
+
base_tick: number;
|
|
235
|
+
min_notional: number;
|
|
236
|
+
price_range: number;
|
|
237
|
+
price_scope: number;
|
|
238
|
+
std_liquidation_fee: number;
|
|
239
|
+
liquidator_fee: number;
|
|
240
|
+
claim_insurance_fund_discount: number;
|
|
241
|
+
funding_period: number;
|
|
242
|
+
cap_funding: number;
|
|
243
|
+
floor_funding: number;
|
|
244
|
+
interest_rate: number;
|
|
245
|
+
created_time: number;
|
|
246
|
+
updated_time: number;
|
|
247
|
+
imr_factor: number;
|
|
248
|
+
base_mmr: number;
|
|
249
|
+
base_imr: number;
|
|
250
|
+
}
|
|
251
|
+
interface SymbolExt extends Symbol {
|
|
252
|
+
base: string;
|
|
253
|
+
quote: string;
|
|
254
|
+
type: string;
|
|
255
|
+
}
|
|
256
|
+
interface Order {
|
|
257
|
+
symbol: string;
|
|
258
|
+
status: string;
|
|
259
|
+
side: string;
|
|
260
|
+
order_id: number;
|
|
261
|
+
user_id: number;
|
|
262
|
+
price: number | null;
|
|
263
|
+
type: string;
|
|
264
|
+
quantity: number;
|
|
265
|
+
amount: null;
|
|
266
|
+
visible: number;
|
|
267
|
+
executed: number;
|
|
268
|
+
total_fee: number;
|
|
269
|
+
fee_asset: string;
|
|
270
|
+
client_order_id: null;
|
|
271
|
+
average_executed_price: number;
|
|
272
|
+
created_time: number;
|
|
273
|
+
updated_time: number;
|
|
274
|
+
reduce_only: boolean;
|
|
275
|
+
}
|
|
276
|
+
interface PositionInfo {
|
|
277
|
+
margin_ratio: number;
|
|
278
|
+
initial_margin_ratio: number;
|
|
279
|
+
maintenance_margin_ratio: number;
|
|
280
|
+
open_margin_ratio: number;
|
|
281
|
+
current_margin_ratio_with_orders: number;
|
|
282
|
+
initial_margin_ratio_with_orders: number;
|
|
283
|
+
maintenance_margin_ratio_with_orders: number;
|
|
284
|
+
total_collateral_value: number;
|
|
285
|
+
free_collateral: number;
|
|
286
|
+
rows: Position[];
|
|
287
|
+
total_pnl_24_h: number;
|
|
288
|
+
}
|
|
289
|
+
interface Position {
|
|
290
|
+
symbol: string;
|
|
291
|
+
position_qty: number;
|
|
292
|
+
cost_position: number;
|
|
293
|
+
last_sum_unitary_funding: number;
|
|
294
|
+
pending_long_qty: number;
|
|
295
|
+
pending_short_qty: number;
|
|
296
|
+
settle_price: number;
|
|
297
|
+
average_open_price: number;
|
|
298
|
+
unsettled_pnl: number;
|
|
299
|
+
mark_price: number;
|
|
300
|
+
est_liq_price: number;
|
|
301
|
+
timestamp: number;
|
|
302
|
+
mmr: number;
|
|
303
|
+
imr: number;
|
|
304
|
+
IMR_withdraw_orders: number;
|
|
305
|
+
MMR_with_orders: number;
|
|
306
|
+
pnl_24_h: number;
|
|
307
|
+
fee_24_h: number;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
declare namespace WSMessage {
|
|
311
|
+
interface Ticker {
|
|
312
|
+
symbol: string;
|
|
313
|
+
open: number;
|
|
314
|
+
close: number;
|
|
315
|
+
high: number;
|
|
316
|
+
low: number;
|
|
317
|
+
volume: number;
|
|
318
|
+
amount: number;
|
|
319
|
+
count: number;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export { API, Account, AccountState, AccountStatusEnum, BaseSigner, ConfigStore, KeyStore, LocalStorageStore, MemoryConfigStore, MessageFactor, MockKeyStore, SignedMessagePayload, Signer, SimpleDI, WSMessage, getDefaultSigner, getMockSigner, wallet };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { BehaviorSubject } from 'rxjs';
|
|
2
|
+
|
|
3
|
+
interface OrderlyKeyPair {
|
|
4
|
+
getPublicKey(): Promise<string>;
|
|
5
|
+
secretKey: string;
|
|
6
|
+
sign: (data: Uint8Array) => Promise<Uint8Array>;
|
|
7
|
+
}
|
|
8
|
+
declare class BaseOrderlyKeyPair implements OrderlyKeyPair {
|
|
9
|
+
secretKey: string;
|
|
10
|
+
constructor(secretKey: string);
|
|
11
|
+
sign(message: Uint8Array): Promise<Uint8Array>;
|
|
12
|
+
getPublicKey(): Promise<string>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface KeyStore {
|
|
16
|
+
getOrderlyKey: () => OrderlyKeyPair;
|
|
17
|
+
generateKey: () => OrderlyKeyPair;
|
|
18
|
+
setKey: (orderlyKey: string, secretKey: string) => void;
|
|
19
|
+
}
|
|
20
|
+
declare class LocalStorageStore implements KeyStore {
|
|
21
|
+
private readonly networkId;
|
|
22
|
+
private readonly accountId;
|
|
23
|
+
constructor(networkId: string, accountId: string);
|
|
24
|
+
getOrderlyKey(): OrderlyKeyPair;
|
|
25
|
+
generateKey(): BaseOrderlyKeyPair;
|
|
26
|
+
setKey(orderlyKey: string, secretKey: string): void;
|
|
27
|
+
private get _keyPrefix();
|
|
28
|
+
}
|
|
29
|
+
declare class MockKeyStore implements KeyStore {
|
|
30
|
+
private readonly secretKey;
|
|
31
|
+
constructor(secretKey: string);
|
|
32
|
+
generateKey(): BaseOrderlyKeyPair;
|
|
33
|
+
getOrderlyKey(): BaseOrderlyKeyPair;
|
|
34
|
+
setKey(orderlyKey: string, secretKey: string): void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
type MessageFactor = {
|
|
38
|
+
url: string;
|
|
39
|
+
method: "GET" | "POST" | "PUT" | "DELETE";
|
|
40
|
+
data?: any;
|
|
41
|
+
};
|
|
42
|
+
type SignedMessagePayload = {
|
|
43
|
+
"orderly-key": string;
|
|
44
|
+
"orderly-timestamp": string;
|
|
45
|
+
"orderly-signature": string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* 签名
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* const signer = new BaseSigner(keyStore);
|
|
52
|
+
* const payload = await signer.sign({
|
|
53
|
+
* url: "https://api.orderly.io/get_account?address=0x1234567890&brokerId=woofi_dex",
|
|
54
|
+
* method: "GET",
|
|
55
|
+
* data: {
|
|
56
|
+
* address: "0x1234567890",
|
|
57
|
+
* brokerId: "woofi_dex",
|
|
58
|
+
* },
|
|
59
|
+
* });
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
interface Signer {
|
|
63
|
+
sign: (data: MessageFactor) => Promise<SignedMessagePayload>;
|
|
64
|
+
}
|
|
65
|
+
declare class BaseSigner implements Signer {
|
|
66
|
+
private readonly keyStore;
|
|
67
|
+
constructor(keyStore: KeyStore);
|
|
68
|
+
sign(message: MessageFactor): Promise<SignedMessagePayload>;
|
|
69
|
+
signText(text: string): Promise<{
|
|
70
|
+
signature: string;
|
|
71
|
+
publicKey: string;
|
|
72
|
+
}>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
interface ConfigStore {
|
|
76
|
+
get<T>(key: string): T;
|
|
77
|
+
set<T>(key: string, value: T): void;
|
|
78
|
+
clear(): void;
|
|
79
|
+
}
|
|
80
|
+
declare class MemoryConfigStore implements ConfigStore {
|
|
81
|
+
private map;
|
|
82
|
+
constructor();
|
|
83
|
+
private _restore;
|
|
84
|
+
get<T>(key: string): T;
|
|
85
|
+
set<T>(key: string, value: T): void;
|
|
86
|
+
clear(): void;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
declare const getMockSigner: (secretKey?: string) => BaseSigner;
|
|
90
|
+
declare const getDefaultSigner: () => BaseSigner;
|
|
91
|
+
|
|
92
|
+
declare class SimpleDI {
|
|
93
|
+
private static container;
|
|
94
|
+
private static getContainer;
|
|
95
|
+
static register(...serviceClasses: any[]): void;
|
|
96
|
+
static registerByName(name: string, serviceClass: any): void;
|
|
97
|
+
static get<T = any>(name: string): T;
|
|
98
|
+
static getAll(): {
|
|
99
|
+
[name: string]: any;
|
|
100
|
+
};
|
|
101
|
+
private constructor();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
interface WalletClient {
|
|
105
|
+
get address(): string;
|
|
106
|
+
getBalance: () => Promise<any>;
|
|
107
|
+
deposit: () => Promise<any>;
|
|
108
|
+
connect: () => Promise<any>;
|
|
109
|
+
}
|
|
110
|
+
declare abstract class BaseWalletClient implements WalletClient {
|
|
111
|
+
private readonly _address;
|
|
112
|
+
constructor(_address: string);
|
|
113
|
+
abstract getBalance(): Promise<any>;
|
|
114
|
+
abstract deposit(): Promise<any>;
|
|
115
|
+
abstract connect(): Promise<any>;
|
|
116
|
+
get address(): string;
|
|
117
|
+
}
|
|
118
|
+
declare class SimpleWallet extends BaseWalletClient {
|
|
119
|
+
getBalance(): Promise<any>;
|
|
120
|
+
deposit(): Promise<any>;
|
|
121
|
+
connect(): Promise<any>;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
type wallet_BaseWalletClient = BaseWalletClient;
|
|
125
|
+
declare const wallet_BaseWalletClient: typeof BaseWalletClient;
|
|
126
|
+
type wallet_SimpleWallet = SimpleWallet;
|
|
127
|
+
declare const wallet_SimpleWallet: typeof SimpleWallet;
|
|
128
|
+
type wallet_WalletClient = WalletClient;
|
|
129
|
+
declare namespace wallet {
|
|
130
|
+
export {
|
|
131
|
+
wallet_BaseWalletClient as BaseWalletClient,
|
|
132
|
+
wallet_SimpleWallet as SimpleWallet,
|
|
133
|
+
wallet_WalletClient as WalletClient,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
type AccountStatus = "NotConnected" | "Connected" | "NotSignedIn" | "SignedIn";
|
|
138
|
+
declare enum AccountStatusEnum {
|
|
139
|
+
NotConnected = 0,
|
|
140
|
+
Connected = 1,
|
|
141
|
+
NotSignedIn = 2,
|
|
142
|
+
SignedIn = 3,
|
|
143
|
+
EnableTrading = 4
|
|
144
|
+
}
|
|
145
|
+
interface AccountState {
|
|
146
|
+
status: AccountStatus;
|
|
147
|
+
accountId?: string;
|
|
148
|
+
userId?: string;
|
|
149
|
+
address?: string;
|
|
150
|
+
balance: string;
|
|
151
|
+
leverage: number;
|
|
152
|
+
positon?: string[];
|
|
153
|
+
orders?: string[];
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* 账户
|
|
157
|
+
* @example
|
|
158
|
+
* ```ts
|
|
159
|
+
* const account = new Account();
|
|
160
|
+
* account.login("0x1234567890");
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
declare class Account {
|
|
164
|
+
private readonly configStore;
|
|
165
|
+
private walletClient?;
|
|
166
|
+
private _state$;
|
|
167
|
+
constructor(configStore: ConfigStore, walletClient?: WalletClient | undefined);
|
|
168
|
+
/**
|
|
169
|
+
* 登录
|
|
170
|
+
* @param address 钱包地址
|
|
171
|
+
*/
|
|
172
|
+
login(address: string): void;
|
|
173
|
+
logout(): void;
|
|
174
|
+
/**
|
|
175
|
+
* 连接钱包先用第三方的React版本,不用自己实现
|
|
176
|
+
*/
|
|
177
|
+
/**
|
|
178
|
+
* 为账户设置钱包
|
|
179
|
+
*/
|
|
180
|
+
set wallet(wallet: WalletClient | string);
|
|
181
|
+
get state$(): BehaviorSubject<AccountState>;
|
|
182
|
+
get stateValue(): AccountState;
|
|
183
|
+
/**
|
|
184
|
+
* set user positions count
|
|
185
|
+
*/
|
|
186
|
+
set position(position: string[]);
|
|
187
|
+
set orders(orders: string[]);
|
|
188
|
+
private _checkAccount;
|
|
189
|
+
private _checkAccountExist;
|
|
190
|
+
private getAccountInfo;
|
|
191
|
+
private getBalance;
|
|
192
|
+
private _fetch;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
declare namespace API {
|
|
196
|
+
interface Token {
|
|
197
|
+
token: string;
|
|
198
|
+
token_hash: string;
|
|
199
|
+
decimals: number;
|
|
200
|
+
minimum_withdraw_amount: number;
|
|
201
|
+
chain_details: ChainDetail[];
|
|
202
|
+
}
|
|
203
|
+
interface ChainDetail {
|
|
204
|
+
chain_id: string;
|
|
205
|
+
contract_address: string;
|
|
206
|
+
decimals: number;
|
|
207
|
+
}
|
|
208
|
+
interface MarketInfo {
|
|
209
|
+
symbol: string;
|
|
210
|
+
index_price: number;
|
|
211
|
+
mark_price: number;
|
|
212
|
+
sum_unitary_funding: number;
|
|
213
|
+
est_funding_rate: number;
|
|
214
|
+
last_funding_rate: number;
|
|
215
|
+
next_funding_time: number;
|
|
216
|
+
open_interest: string;
|
|
217
|
+
"24h_open": number;
|
|
218
|
+
"24h_close": number;
|
|
219
|
+
"24h_high": number;
|
|
220
|
+
"24h_low": number;
|
|
221
|
+
"24h_volumn": number;
|
|
222
|
+
"24h_amount": number;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* v1/public/info
|
|
226
|
+
*/
|
|
227
|
+
interface Symbol {
|
|
228
|
+
symbol: string;
|
|
229
|
+
quote_min: number;
|
|
230
|
+
quote_max: number;
|
|
231
|
+
quote_tick: number;
|
|
232
|
+
base_min: number;
|
|
233
|
+
base_max: number;
|
|
234
|
+
base_tick: number;
|
|
235
|
+
min_notional: number;
|
|
236
|
+
price_range: number;
|
|
237
|
+
price_scope: number;
|
|
238
|
+
std_liquidation_fee: number;
|
|
239
|
+
liquidator_fee: number;
|
|
240
|
+
claim_insurance_fund_discount: number;
|
|
241
|
+
funding_period: number;
|
|
242
|
+
cap_funding: number;
|
|
243
|
+
floor_funding: number;
|
|
244
|
+
interest_rate: number;
|
|
245
|
+
created_time: number;
|
|
246
|
+
updated_time: number;
|
|
247
|
+
imr_factor: number;
|
|
248
|
+
base_mmr: number;
|
|
249
|
+
base_imr: number;
|
|
250
|
+
}
|
|
251
|
+
interface SymbolExt extends Symbol {
|
|
252
|
+
base: string;
|
|
253
|
+
quote: string;
|
|
254
|
+
type: string;
|
|
255
|
+
}
|
|
256
|
+
interface Order {
|
|
257
|
+
symbol: string;
|
|
258
|
+
status: string;
|
|
259
|
+
side: string;
|
|
260
|
+
order_id: number;
|
|
261
|
+
user_id: number;
|
|
262
|
+
price: number | null;
|
|
263
|
+
type: string;
|
|
264
|
+
quantity: number;
|
|
265
|
+
amount: null;
|
|
266
|
+
visible: number;
|
|
267
|
+
executed: number;
|
|
268
|
+
total_fee: number;
|
|
269
|
+
fee_asset: string;
|
|
270
|
+
client_order_id: null;
|
|
271
|
+
average_executed_price: number;
|
|
272
|
+
created_time: number;
|
|
273
|
+
updated_time: number;
|
|
274
|
+
reduce_only: boolean;
|
|
275
|
+
}
|
|
276
|
+
interface PositionInfo {
|
|
277
|
+
margin_ratio: number;
|
|
278
|
+
initial_margin_ratio: number;
|
|
279
|
+
maintenance_margin_ratio: number;
|
|
280
|
+
open_margin_ratio: number;
|
|
281
|
+
current_margin_ratio_with_orders: number;
|
|
282
|
+
initial_margin_ratio_with_orders: number;
|
|
283
|
+
maintenance_margin_ratio_with_orders: number;
|
|
284
|
+
total_collateral_value: number;
|
|
285
|
+
free_collateral: number;
|
|
286
|
+
rows: Position[];
|
|
287
|
+
total_pnl_24_h: number;
|
|
288
|
+
}
|
|
289
|
+
interface Position {
|
|
290
|
+
symbol: string;
|
|
291
|
+
position_qty: number;
|
|
292
|
+
cost_position: number;
|
|
293
|
+
last_sum_unitary_funding: number;
|
|
294
|
+
pending_long_qty: number;
|
|
295
|
+
pending_short_qty: number;
|
|
296
|
+
settle_price: number;
|
|
297
|
+
average_open_price: number;
|
|
298
|
+
unsettled_pnl: number;
|
|
299
|
+
mark_price: number;
|
|
300
|
+
est_liq_price: number;
|
|
301
|
+
timestamp: number;
|
|
302
|
+
mmr: number;
|
|
303
|
+
imr: number;
|
|
304
|
+
IMR_withdraw_orders: number;
|
|
305
|
+
MMR_with_orders: number;
|
|
306
|
+
pnl_24_h: number;
|
|
307
|
+
fee_24_h: number;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
declare namespace WSMessage {
|
|
311
|
+
interface Ticker {
|
|
312
|
+
symbol: string;
|
|
313
|
+
open: number;
|
|
314
|
+
close: number;
|
|
315
|
+
high: number;
|
|
316
|
+
low: number;
|
|
317
|
+
volume: number;
|
|
318
|
+
amount: number;
|
|
319
|
+
count: number;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export { API, Account, AccountState, AccountStatusEnum, BaseSigner, ConfigStore, KeyStore, LocalStorageStore, MemoryConfigStore, MessageFactor, MockKeyStore, SignedMessagePayload, Signer, SimpleDI, WSMessage, getDefaultSigner, getMockSigner, wallet };
|