@orderly.network/core 0.1.27 → 0.2.0
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 +243 -13
- package/dist/index.d.ts +243 -13
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import EventEmitter from 'eventemitter3';
|
|
2
2
|
export { default as EventEmitter } from 'eventemitter3';
|
|
3
|
-
import { API, AccountStatusEnum } from '@orderly.network/types';
|
|
3
|
+
import { definedTypes, API, AccountStatusEnum } from '@orderly.network/types';
|
|
4
4
|
import { parseUnits, TransactionResponse, ethers } from 'ethers';
|
|
5
5
|
|
|
6
6
|
interface OrderlyKeyPair {
|
|
@@ -70,12 +70,12 @@ declare class MockKeyStore implements OrderlyKeyStore {
|
|
|
70
70
|
cleanKey(key: string): void;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
type MessageFactor = {
|
|
74
74
|
url: string;
|
|
75
75
|
method: "GET" | "POST" | "PUT" | "DELETE";
|
|
76
76
|
data?: any;
|
|
77
77
|
};
|
|
78
|
-
|
|
78
|
+
type SignedMessagePayload = {
|
|
79
79
|
"orderly-key": string;
|
|
80
80
|
"orderly-timestamp": string;
|
|
81
81
|
"orderly-signature": string;
|
|
@@ -113,7 +113,7 @@ declare class BaseSigner implements Signer {
|
|
|
113
113
|
}>;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
type ConfigKey = "apiBaseUrl" | "klineDataUrl" | "privateWsUrl" | "publicWsUrl" | "operatorUrl" | "swapSupportApiUrl" | "domain" | "brokerId" | "networkId" | "env" | "PROD_URL" | "markets";
|
|
117
117
|
interface ConfigStore {
|
|
118
118
|
get<T>(key: ConfigKey): T;
|
|
119
119
|
getOr<T>(key: ConfigKey, defaultValue: T): T;
|
|
@@ -137,7 +137,7 @@ declare class BaseConfigStore extends MemoryConfigStore {
|
|
|
137
137
|
constructor(configMap: Record<string, any>);
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
type SignatureDomain = {
|
|
141
141
|
name: string;
|
|
142
142
|
version: string;
|
|
143
143
|
chainId: number;
|
|
@@ -177,14 +177,244 @@ declare namespace utils {
|
|
|
177
177
|
};
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
declare const getMockSigner: (secretKey?: string
|
|
180
|
+
declare const getMockSigner: (secretKey?: string) => BaseSigner;
|
|
181
181
|
declare const getDefaultSigner: () => BaseSigner;
|
|
182
|
+
/**
|
|
183
|
+
* generate `registerAccount` data and to be signed message structure
|
|
184
|
+
*/
|
|
185
|
+
declare function generateRegisterAccountMessage(inputs: {
|
|
186
|
+
chainId: number;
|
|
187
|
+
registrationNonce: number;
|
|
188
|
+
brokerId: string;
|
|
189
|
+
}): readonly [{
|
|
190
|
+
brokerId: string;
|
|
191
|
+
chainId: number;
|
|
192
|
+
timestamp: number;
|
|
193
|
+
registrationNonce: number;
|
|
194
|
+
}, {
|
|
195
|
+
domain: {
|
|
196
|
+
name: string;
|
|
197
|
+
version: string;
|
|
198
|
+
chainId: number;
|
|
199
|
+
verifyingContract: string;
|
|
200
|
+
};
|
|
201
|
+
message: {
|
|
202
|
+
brokerId: string;
|
|
203
|
+
chainId: number;
|
|
204
|
+
timestamp: number;
|
|
205
|
+
registrationNonce: number;
|
|
206
|
+
};
|
|
207
|
+
primaryType: string;
|
|
208
|
+
types: {
|
|
209
|
+
EIP712Domain: readonly [{
|
|
210
|
+
readonly name: "name";
|
|
211
|
+
readonly type: "string";
|
|
212
|
+
}, {
|
|
213
|
+
readonly name: "version";
|
|
214
|
+
readonly type: "string";
|
|
215
|
+
}, {
|
|
216
|
+
readonly name: "chainId";
|
|
217
|
+
readonly type: "uint256";
|
|
218
|
+
}, {
|
|
219
|
+
readonly name: "verifyingContract";
|
|
220
|
+
readonly type: "address";
|
|
221
|
+
}];
|
|
222
|
+
Registration: readonly [{
|
|
223
|
+
readonly name: "brokerId";
|
|
224
|
+
readonly type: "string";
|
|
225
|
+
}, {
|
|
226
|
+
readonly name: "chainId";
|
|
227
|
+
readonly type: "uint256";
|
|
228
|
+
}, {
|
|
229
|
+
readonly name: "timestamp";
|
|
230
|
+
readonly type: "uint64";
|
|
231
|
+
}, {
|
|
232
|
+
readonly name: "registrationNonce";
|
|
233
|
+
readonly type: "uint256";
|
|
234
|
+
}];
|
|
235
|
+
};
|
|
236
|
+
}];
|
|
237
|
+
/**
|
|
238
|
+
* generate `addOrderlyKey` data and to be signed message structure
|
|
239
|
+
*/
|
|
240
|
+
declare function generateAddOrderlyKeyMessage(inputs: {
|
|
241
|
+
publicKey: string;
|
|
242
|
+
chainId: number;
|
|
243
|
+
brokerId: string;
|
|
244
|
+
primaryType: keyof typeof definedTypes;
|
|
245
|
+
expiration?: number;
|
|
246
|
+
}): readonly [{
|
|
247
|
+
brokerId: string;
|
|
248
|
+
orderlyKey: string;
|
|
249
|
+
scope: string;
|
|
250
|
+
chainId: number;
|
|
251
|
+
timestamp: number;
|
|
252
|
+
expiration: number;
|
|
253
|
+
}, {
|
|
254
|
+
domain: {
|
|
255
|
+
name: string;
|
|
256
|
+
version: string;
|
|
257
|
+
chainId: number;
|
|
258
|
+
verifyingContract: string;
|
|
259
|
+
};
|
|
260
|
+
message: {
|
|
261
|
+
brokerId: string;
|
|
262
|
+
orderlyKey: string;
|
|
263
|
+
scope: string;
|
|
264
|
+
chainId: number;
|
|
265
|
+
timestamp: number;
|
|
266
|
+
expiration: number;
|
|
267
|
+
};
|
|
268
|
+
primaryType: "Registration" | "EIP712Domain" | "Withdraw" | "AddOrderlyKey" | "SettlePnl";
|
|
269
|
+
types: {
|
|
270
|
+
[x: string]: readonly [{
|
|
271
|
+
readonly name: "name";
|
|
272
|
+
readonly type: "string";
|
|
273
|
+
}, {
|
|
274
|
+
readonly name: "version";
|
|
275
|
+
readonly type: "string";
|
|
276
|
+
}, {
|
|
277
|
+
readonly name: "chainId";
|
|
278
|
+
readonly type: "uint256";
|
|
279
|
+
}, {
|
|
280
|
+
readonly name: "verifyingContract";
|
|
281
|
+
readonly type: "address";
|
|
282
|
+
}] | readonly [{
|
|
283
|
+
readonly name: "brokerId";
|
|
284
|
+
readonly type: "string";
|
|
285
|
+
}, {
|
|
286
|
+
readonly name: "chainId";
|
|
287
|
+
readonly type: "uint256";
|
|
288
|
+
}, {
|
|
289
|
+
readonly name: "timestamp";
|
|
290
|
+
readonly type: "uint64";
|
|
291
|
+
}, {
|
|
292
|
+
readonly name: "registrationNonce";
|
|
293
|
+
readonly type: "uint256";
|
|
294
|
+
}] | readonly [{
|
|
295
|
+
readonly name: "brokerId";
|
|
296
|
+
readonly type: "string";
|
|
297
|
+
}, {
|
|
298
|
+
readonly name: "chainId";
|
|
299
|
+
readonly type: "uint256";
|
|
300
|
+
}, {
|
|
301
|
+
readonly name: "receiver";
|
|
302
|
+
readonly type: "address";
|
|
303
|
+
}, {
|
|
304
|
+
readonly name: "token";
|
|
305
|
+
readonly type: "string";
|
|
306
|
+
}, {
|
|
307
|
+
readonly name: "amount";
|
|
308
|
+
readonly type: "uint256";
|
|
309
|
+
}, {
|
|
310
|
+
readonly name: "withdrawNonce";
|
|
311
|
+
readonly type: "uint64";
|
|
312
|
+
}, {
|
|
313
|
+
readonly name: "timestamp";
|
|
314
|
+
readonly type: "uint64";
|
|
315
|
+
}] | readonly [{
|
|
316
|
+
readonly name: "brokerId";
|
|
317
|
+
readonly type: "string";
|
|
318
|
+
}, {
|
|
319
|
+
readonly name: "chainId";
|
|
320
|
+
readonly type: "uint256";
|
|
321
|
+
}, {
|
|
322
|
+
readonly name: "orderlyKey";
|
|
323
|
+
readonly type: "string";
|
|
324
|
+
}, {
|
|
325
|
+
readonly name: "scope";
|
|
326
|
+
readonly type: "string";
|
|
327
|
+
}, {
|
|
328
|
+
readonly name: "timestamp";
|
|
329
|
+
readonly type: "uint64";
|
|
330
|
+
}, {
|
|
331
|
+
readonly name: "expiration";
|
|
332
|
+
readonly type: "uint64";
|
|
333
|
+
}] | readonly [{
|
|
334
|
+
readonly name: "brokerId";
|
|
335
|
+
readonly type: "string";
|
|
336
|
+
}, {
|
|
337
|
+
readonly name: "chainId";
|
|
338
|
+
readonly type: "uint256";
|
|
339
|
+
}, {
|
|
340
|
+
readonly name: "settleNonce";
|
|
341
|
+
readonly type: "uint64";
|
|
342
|
+
}, {
|
|
343
|
+
readonly name: "timestamp";
|
|
344
|
+
readonly type: "uint64";
|
|
345
|
+
}];
|
|
346
|
+
EIP712Domain: readonly [{
|
|
347
|
+
readonly name: "name";
|
|
348
|
+
readonly type: "string";
|
|
349
|
+
}, {
|
|
350
|
+
readonly name: "version";
|
|
351
|
+
readonly type: "string";
|
|
352
|
+
}, {
|
|
353
|
+
readonly name: "chainId";
|
|
354
|
+
readonly type: "uint256";
|
|
355
|
+
}, {
|
|
356
|
+
readonly name: "verifyingContract";
|
|
357
|
+
readonly type: "address";
|
|
358
|
+
}];
|
|
359
|
+
};
|
|
360
|
+
}];
|
|
361
|
+
/**
|
|
362
|
+
* generate `settle` data and to be signed message structure
|
|
363
|
+
*/
|
|
364
|
+
declare function generateSettleMessage(inputs: {
|
|
365
|
+
chainId: number;
|
|
366
|
+
brokerId: string;
|
|
367
|
+
settlePnlNonce: string;
|
|
368
|
+
domain: SignatureDomain;
|
|
369
|
+
}): readonly [{
|
|
370
|
+
brokerId: string;
|
|
371
|
+
chainId: number;
|
|
372
|
+
timestamp: number;
|
|
373
|
+
settleNonce: string;
|
|
374
|
+
}, {
|
|
375
|
+
domain: SignatureDomain;
|
|
376
|
+
message: {
|
|
377
|
+
brokerId: string;
|
|
378
|
+
chainId: number;
|
|
379
|
+
timestamp: number;
|
|
380
|
+
settleNonce: string;
|
|
381
|
+
};
|
|
382
|
+
primaryType: string;
|
|
383
|
+
types: {
|
|
384
|
+
EIP712Domain: readonly [{
|
|
385
|
+
readonly name: "name";
|
|
386
|
+
readonly type: "string";
|
|
387
|
+
}, {
|
|
388
|
+
readonly name: "version";
|
|
389
|
+
readonly type: "string";
|
|
390
|
+
}, {
|
|
391
|
+
readonly name: "chainId";
|
|
392
|
+
readonly type: "uint256";
|
|
393
|
+
}, {
|
|
394
|
+
readonly name: "verifyingContract";
|
|
395
|
+
readonly type: "address";
|
|
396
|
+
}];
|
|
397
|
+
SettlePnl: readonly [{
|
|
398
|
+
readonly name: "brokerId";
|
|
399
|
+
readonly type: "string";
|
|
400
|
+
}, {
|
|
401
|
+
readonly name: "chainId";
|
|
402
|
+
readonly type: "uint256";
|
|
403
|
+
}, {
|
|
404
|
+
readonly name: "settleNonce";
|
|
405
|
+
readonly type: "uint64";
|
|
406
|
+
}, {
|
|
407
|
+
readonly name: "timestamp";
|
|
408
|
+
readonly type: "uint64";
|
|
409
|
+
}];
|
|
410
|
+
};
|
|
411
|
+
}];
|
|
182
412
|
|
|
183
413
|
/**
|
|
184
414
|
* Orderly contracts information
|
|
185
415
|
* https://wootraders.atlassian.net/wiki/spaces/ORDER/pages/343441906/Orderly+V2+Contract+Information+Board
|
|
186
416
|
*/
|
|
187
|
-
|
|
417
|
+
type OrderlyContracts = {
|
|
188
418
|
usdcAddress: string;
|
|
189
419
|
usdcAbi: any;
|
|
190
420
|
erc20Abi: any;
|
|
@@ -378,14 +608,14 @@ interface IWalletAdapter {
|
|
|
378
608
|
on(eventName: any, listener: any): void;
|
|
379
609
|
off(eventName: any, listener: any): void;
|
|
380
610
|
}
|
|
381
|
-
|
|
611
|
+
type WalletAdapterOptions = {
|
|
382
612
|
provider: any;
|
|
383
613
|
address: string;
|
|
384
614
|
chain: {
|
|
385
615
|
id: number;
|
|
386
616
|
};
|
|
387
617
|
};
|
|
388
|
-
|
|
618
|
+
type getWalletAdapterFunc = (options: WalletAdapterOptions) => IWalletAdapter;
|
|
389
619
|
|
|
390
620
|
declare class Assets {
|
|
391
621
|
private readonly configStore;
|
|
@@ -395,7 +625,7 @@ declare class Assets {
|
|
|
395
625
|
withdraw(inputs: {
|
|
396
626
|
chainId: number;
|
|
397
627
|
token: string;
|
|
398
|
-
amount: number;
|
|
628
|
+
amount: string | number;
|
|
399
629
|
allowCrossChainWithdraw: boolean;
|
|
400
630
|
}): Promise<any>;
|
|
401
631
|
private _generateWithdrawMessage;
|
|
@@ -448,7 +678,7 @@ interface AccountState {
|
|
|
448
678
|
*/
|
|
449
679
|
declare class Account {
|
|
450
680
|
private readonly configStore;
|
|
451
|
-
|
|
681
|
+
readonly keyStore: OrderlyKeyStore;
|
|
452
682
|
private readonly getWalletAdapter;
|
|
453
683
|
static instanceName: string;
|
|
454
684
|
private _singer?;
|
|
@@ -491,7 +721,7 @@ declare class Account {
|
|
|
491
721
|
private _checkAccountExist;
|
|
492
722
|
createAccount(): Promise<any>;
|
|
493
723
|
signTypedData(toSignatureMessage: Record<string, any>): Promise<string>;
|
|
494
|
-
createOrderlyKey(expiration
|
|
724
|
+
createOrderlyKey(expiration?: number): Promise<any>;
|
|
495
725
|
settle(): Promise<any>;
|
|
496
726
|
disconnect(): Promise<void>;
|
|
497
727
|
private _checkOrderlyKeyState;
|
|
@@ -553,4 +783,4 @@ declare class EtherAdapter implements IWalletAdapter {
|
|
|
553
783
|
getContract(address: string, abi: any): ethers.Contract;
|
|
554
784
|
}
|
|
555
785
|
|
|
556
|
-
export { Account, AccountState, BaseConfigStore, BaseContract as BaseContractManager, BaseKeyStore, BaseOrderlyKeyPair, BaseSigner, ConfigKey, ConfigStore, DefaultConfigStore, EtherAdapter, IContract, LocalStorageStore, MemoryConfigStore, MessageFactor, MockKeyStore, OrderlyKeyPair, OrderlyKeyStore, SignedMessagePayload, Signer, SimpleDI, IWalletAdapter as WalletAdapter, WalletAdapterOptions, getDefaultSigner, getMockSigner, getWalletAdapterFunc, utils };
|
|
786
|
+
export { Account, AccountState, BaseConfigStore, BaseContract as BaseContractManager, BaseKeyStore, BaseOrderlyKeyPair, BaseSigner, ConfigKey, ConfigStore, DefaultConfigStore, EtherAdapter, IContract, LocalStorageStore, MemoryConfigStore, MessageFactor, MockKeyStore, OrderlyKeyPair, OrderlyKeyStore, SignedMessagePayload, Signer, SimpleDI, IWalletAdapter as WalletAdapter, WalletAdapterOptions, generateAddOrderlyKeyMessage, generateRegisterAccountMessage, generateSettleMessage, getDefaultSigner, getMockSigner, getWalletAdapterFunc, utils };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import EventEmitter from 'eventemitter3';
|
|
2
2
|
export { default as EventEmitter } from 'eventemitter3';
|
|
3
|
-
import { API, AccountStatusEnum } from '@orderly.network/types';
|
|
3
|
+
import { definedTypes, API, AccountStatusEnum } from '@orderly.network/types';
|
|
4
4
|
import { parseUnits, TransactionResponse, ethers } from 'ethers';
|
|
5
5
|
|
|
6
6
|
interface OrderlyKeyPair {
|
|
@@ -70,12 +70,12 @@ declare class MockKeyStore implements OrderlyKeyStore {
|
|
|
70
70
|
cleanKey(key: string): void;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
type MessageFactor = {
|
|
74
74
|
url: string;
|
|
75
75
|
method: "GET" | "POST" | "PUT" | "DELETE";
|
|
76
76
|
data?: any;
|
|
77
77
|
};
|
|
78
|
-
|
|
78
|
+
type SignedMessagePayload = {
|
|
79
79
|
"orderly-key": string;
|
|
80
80
|
"orderly-timestamp": string;
|
|
81
81
|
"orderly-signature": string;
|
|
@@ -113,7 +113,7 @@ declare class BaseSigner implements Signer {
|
|
|
113
113
|
}>;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
type ConfigKey = "apiBaseUrl" | "klineDataUrl" | "privateWsUrl" | "publicWsUrl" | "operatorUrl" | "swapSupportApiUrl" | "domain" | "brokerId" | "networkId" | "env" | "PROD_URL" | "markets";
|
|
117
117
|
interface ConfigStore {
|
|
118
118
|
get<T>(key: ConfigKey): T;
|
|
119
119
|
getOr<T>(key: ConfigKey, defaultValue: T): T;
|
|
@@ -137,7 +137,7 @@ declare class BaseConfigStore extends MemoryConfigStore {
|
|
|
137
137
|
constructor(configMap: Record<string, any>);
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
type SignatureDomain = {
|
|
141
141
|
name: string;
|
|
142
142
|
version: string;
|
|
143
143
|
chainId: number;
|
|
@@ -177,14 +177,244 @@ declare namespace utils {
|
|
|
177
177
|
};
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
declare const getMockSigner: (secretKey?: string
|
|
180
|
+
declare const getMockSigner: (secretKey?: string) => BaseSigner;
|
|
181
181
|
declare const getDefaultSigner: () => BaseSigner;
|
|
182
|
+
/**
|
|
183
|
+
* generate `registerAccount` data and to be signed message structure
|
|
184
|
+
*/
|
|
185
|
+
declare function generateRegisterAccountMessage(inputs: {
|
|
186
|
+
chainId: number;
|
|
187
|
+
registrationNonce: number;
|
|
188
|
+
brokerId: string;
|
|
189
|
+
}): readonly [{
|
|
190
|
+
brokerId: string;
|
|
191
|
+
chainId: number;
|
|
192
|
+
timestamp: number;
|
|
193
|
+
registrationNonce: number;
|
|
194
|
+
}, {
|
|
195
|
+
domain: {
|
|
196
|
+
name: string;
|
|
197
|
+
version: string;
|
|
198
|
+
chainId: number;
|
|
199
|
+
verifyingContract: string;
|
|
200
|
+
};
|
|
201
|
+
message: {
|
|
202
|
+
brokerId: string;
|
|
203
|
+
chainId: number;
|
|
204
|
+
timestamp: number;
|
|
205
|
+
registrationNonce: number;
|
|
206
|
+
};
|
|
207
|
+
primaryType: string;
|
|
208
|
+
types: {
|
|
209
|
+
EIP712Domain: readonly [{
|
|
210
|
+
readonly name: "name";
|
|
211
|
+
readonly type: "string";
|
|
212
|
+
}, {
|
|
213
|
+
readonly name: "version";
|
|
214
|
+
readonly type: "string";
|
|
215
|
+
}, {
|
|
216
|
+
readonly name: "chainId";
|
|
217
|
+
readonly type: "uint256";
|
|
218
|
+
}, {
|
|
219
|
+
readonly name: "verifyingContract";
|
|
220
|
+
readonly type: "address";
|
|
221
|
+
}];
|
|
222
|
+
Registration: readonly [{
|
|
223
|
+
readonly name: "brokerId";
|
|
224
|
+
readonly type: "string";
|
|
225
|
+
}, {
|
|
226
|
+
readonly name: "chainId";
|
|
227
|
+
readonly type: "uint256";
|
|
228
|
+
}, {
|
|
229
|
+
readonly name: "timestamp";
|
|
230
|
+
readonly type: "uint64";
|
|
231
|
+
}, {
|
|
232
|
+
readonly name: "registrationNonce";
|
|
233
|
+
readonly type: "uint256";
|
|
234
|
+
}];
|
|
235
|
+
};
|
|
236
|
+
}];
|
|
237
|
+
/**
|
|
238
|
+
* generate `addOrderlyKey` data and to be signed message structure
|
|
239
|
+
*/
|
|
240
|
+
declare function generateAddOrderlyKeyMessage(inputs: {
|
|
241
|
+
publicKey: string;
|
|
242
|
+
chainId: number;
|
|
243
|
+
brokerId: string;
|
|
244
|
+
primaryType: keyof typeof definedTypes;
|
|
245
|
+
expiration?: number;
|
|
246
|
+
}): readonly [{
|
|
247
|
+
brokerId: string;
|
|
248
|
+
orderlyKey: string;
|
|
249
|
+
scope: string;
|
|
250
|
+
chainId: number;
|
|
251
|
+
timestamp: number;
|
|
252
|
+
expiration: number;
|
|
253
|
+
}, {
|
|
254
|
+
domain: {
|
|
255
|
+
name: string;
|
|
256
|
+
version: string;
|
|
257
|
+
chainId: number;
|
|
258
|
+
verifyingContract: string;
|
|
259
|
+
};
|
|
260
|
+
message: {
|
|
261
|
+
brokerId: string;
|
|
262
|
+
orderlyKey: string;
|
|
263
|
+
scope: string;
|
|
264
|
+
chainId: number;
|
|
265
|
+
timestamp: number;
|
|
266
|
+
expiration: number;
|
|
267
|
+
};
|
|
268
|
+
primaryType: "Registration" | "EIP712Domain" | "Withdraw" | "AddOrderlyKey" | "SettlePnl";
|
|
269
|
+
types: {
|
|
270
|
+
[x: string]: readonly [{
|
|
271
|
+
readonly name: "name";
|
|
272
|
+
readonly type: "string";
|
|
273
|
+
}, {
|
|
274
|
+
readonly name: "version";
|
|
275
|
+
readonly type: "string";
|
|
276
|
+
}, {
|
|
277
|
+
readonly name: "chainId";
|
|
278
|
+
readonly type: "uint256";
|
|
279
|
+
}, {
|
|
280
|
+
readonly name: "verifyingContract";
|
|
281
|
+
readonly type: "address";
|
|
282
|
+
}] | readonly [{
|
|
283
|
+
readonly name: "brokerId";
|
|
284
|
+
readonly type: "string";
|
|
285
|
+
}, {
|
|
286
|
+
readonly name: "chainId";
|
|
287
|
+
readonly type: "uint256";
|
|
288
|
+
}, {
|
|
289
|
+
readonly name: "timestamp";
|
|
290
|
+
readonly type: "uint64";
|
|
291
|
+
}, {
|
|
292
|
+
readonly name: "registrationNonce";
|
|
293
|
+
readonly type: "uint256";
|
|
294
|
+
}] | readonly [{
|
|
295
|
+
readonly name: "brokerId";
|
|
296
|
+
readonly type: "string";
|
|
297
|
+
}, {
|
|
298
|
+
readonly name: "chainId";
|
|
299
|
+
readonly type: "uint256";
|
|
300
|
+
}, {
|
|
301
|
+
readonly name: "receiver";
|
|
302
|
+
readonly type: "address";
|
|
303
|
+
}, {
|
|
304
|
+
readonly name: "token";
|
|
305
|
+
readonly type: "string";
|
|
306
|
+
}, {
|
|
307
|
+
readonly name: "amount";
|
|
308
|
+
readonly type: "uint256";
|
|
309
|
+
}, {
|
|
310
|
+
readonly name: "withdrawNonce";
|
|
311
|
+
readonly type: "uint64";
|
|
312
|
+
}, {
|
|
313
|
+
readonly name: "timestamp";
|
|
314
|
+
readonly type: "uint64";
|
|
315
|
+
}] | readonly [{
|
|
316
|
+
readonly name: "brokerId";
|
|
317
|
+
readonly type: "string";
|
|
318
|
+
}, {
|
|
319
|
+
readonly name: "chainId";
|
|
320
|
+
readonly type: "uint256";
|
|
321
|
+
}, {
|
|
322
|
+
readonly name: "orderlyKey";
|
|
323
|
+
readonly type: "string";
|
|
324
|
+
}, {
|
|
325
|
+
readonly name: "scope";
|
|
326
|
+
readonly type: "string";
|
|
327
|
+
}, {
|
|
328
|
+
readonly name: "timestamp";
|
|
329
|
+
readonly type: "uint64";
|
|
330
|
+
}, {
|
|
331
|
+
readonly name: "expiration";
|
|
332
|
+
readonly type: "uint64";
|
|
333
|
+
}] | readonly [{
|
|
334
|
+
readonly name: "brokerId";
|
|
335
|
+
readonly type: "string";
|
|
336
|
+
}, {
|
|
337
|
+
readonly name: "chainId";
|
|
338
|
+
readonly type: "uint256";
|
|
339
|
+
}, {
|
|
340
|
+
readonly name: "settleNonce";
|
|
341
|
+
readonly type: "uint64";
|
|
342
|
+
}, {
|
|
343
|
+
readonly name: "timestamp";
|
|
344
|
+
readonly type: "uint64";
|
|
345
|
+
}];
|
|
346
|
+
EIP712Domain: readonly [{
|
|
347
|
+
readonly name: "name";
|
|
348
|
+
readonly type: "string";
|
|
349
|
+
}, {
|
|
350
|
+
readonly name: "version";
|
|
351
|
+
readonly type: "string";
|
|
352
|
+
}, {
|
|
353
|
+
readonly name: "chainId";
|
|
354
|
+
readonly type: "uint256";
|
|
355
|
+
}, {
|
|
356
|
+
readonly name: "verifyingContract";
|
|
357
|
+
readonly type: "address";
|
|
358
|
+
}];
|
|
359
|
+
};
|
|
360
|
+
}];
|
|
361
|
+
/**
|
|
362
|
+
* generate `settle` data and to be signed message structure
|
|
363
|
+
*/
|
|
364
|
+
declare function generateSettleMessage(inputs: {
|
|
365
|
+
chainId: number;
|
|
366
|
+
brokerId: string;
|
|
367
|
+
settlePnlNonce: string;
|
|
368
|
+
domain: SignatureDomain;
|
|
369
|
+
}): readonly [{
|
|
370
|
+
brokerId: string;
|
|
371
|
+
chainId: number;
|
|
372
|
+
timestamp: number;
|
|
373
|
+
settleNonce: string;
|
|
374
|
+
}, {
|
|
375
|
+
domain: SignatureDomain;
|
|
376
|
+
message: {
|
|
377
|
+
brokerId: string;
|
|
378
|
+
chainId: number;
|
|
379
|
+
timestamp: number;
|
|
380
|
+
settleNonce: string;
|
|
381
|
+
};
|
|
382
|
+
primaryType: string;
|
|
383
|
+
types: {
|
|
384
|
+
EIP712Domain: readonly [{
|
|
385
|
+
readonly name: "name";
|
|
386
|
+
readonly type: "string";
|
|
387
|
+
}, {
|
|
388
|
+
readonly name: "version";
|
|
389
|
+
readonly type: "string";
|
|
390
|
+
}, {
|
|
391
|
+
readonly name: "chainId";
|
|
392
|
+
readonly type: "uint256";
|
|
393
|
+
}, {
|
|
394
|
+
readonly name: "verifyingContract";
|
|
395
|
+
readonly type: "address";
|
|
396
|
+
}];
|
|
397
|
+
SettlePnl: readonly [{
|
|
398
|
+
readonly name: "brokerId";
|
|
399
|
+
readonly type: "string";
|
|
400
|
+
}, {
|
|
401
|
+
readonly name: "chainId";
|
|
402
|
+
readonly type: "uint256";
|
|
403
|
+
}, {
|
|
404
|
+
readonly name: "settleNonce";
|
|
405
|
+
readonly type: "uint64";
|
|
406
|
+
}, {
|
|
407
|
+
readonly name: "timestamp";
|
|
408
|
+
readonly type: "uint64";
|
|
409
|
+
}];
|
|
410
|
+
};
|
|
411
|
+
}];
|
|
182
412
|
|
|
183
413
|
/**
|
|
184
414
|
* Orderly contracts information
|
|
185
415
|
* https://wootraders.atlassian.net/wiki/spaces/ORDER/pages/343441906/Orderly+V2+Contract+Information+Board
|
|
186
416
|
*/
|
|
187
|
-
|
|
417
|
+
type OrderlyContracts = {
|
|
188
418
|
usdcAddress: string;
|
|
189
419
|
usdcAbi: any;
|
|
190
420
|
erc20Abi: any;
|
|
@@ -378,14 +608,14 @@ interface IWalletAdapter {
|
|
|
378
608
|
on(eventName: any, listener: any): void;
|
|
379
609
|
off(eventName: any, listener: any): void;
|
|
380
610
|
}
|
|
381
|
-
|
|
611
|
+
type WalletAdapterOptions = {
|
|
382
612
|
provider: any;
|
|
383
613
|
address: string;
|
|
384
614
|
chain: {
|
|
385
615
|
id: number;
|
|
386
616
|
};
|
|
387
617
|
};
|
|
388
|
-
|
|
618
|
+
type getWalletAdapterFunc = (options: WalletAdapterOptions) => IWalletAdapter;
|
|
389
619
|
|
|
390
620
|
declare class Assets {
|
|
391
621
|
private readonly configStore;
|
|
@@ -395,7 +625,7 @@ declare class Assets {
|
|
|
395
625
|
withdraw(inputs: {
|
|
396
626
|
chainId: number;
|
|
397
627
|
token: string;
|
|
398
|
-
amount: number;
|
|
628
|
+
amount: string | number;
|
|
399
629
|
allowCrossChainWithdraw: boolean;
|
|
400
630
|
}): Promise<any>;
|
|
401
631
|
private _generateWithdrawMessage;
|
|
@@ -448,7 +678,7 @@ interface AccountState {
|
|
|
448
678
|
*/
|
|
449
679
|
declare class Account {
|
|
450
680
|
private readonly configStore;
|
|
451
|
-
|
|
681
|
+
readonly keyStore: OrderlyKeyStore;
|
|
452
682
|
private readonly getWalletAdapter;
|
|
453
683
|
static instanceName: string;
|
|
454
684
|
private _singer?;
|
|
@@ -491,7 +721,7 @@ declare class Account {
|
|
|
491
721
|
private _checkAccountExist;
|
|
492
722
|
createAccount(): Promise<any>;
|
|
493
723
|
signTypedData(toSignatureMessage: Record<string, any>): Promise<string>;
|
|
494
|
-
createOrderlyKey(expiration
|
|
724
|
+
createOrderlyKey(expiration?: number): Promise<any>;
|
|
495
725
|
settle(): Promise<any>;
|
|
496
726
|
disconnect(): Promise<void>;
|
|
497
727
|
private _checkOrderlyKeyState;
|
|
@@ -553,4 +783,4 @@ declare class EtherAdapter implements IWalletAdapter {
|
|
|
553
783
|
getContract(address: string, abi: any): ethers.Contract;
|
|
554
784
|
}
|
|
555
785
|
|
|
556
|
-
export { Account, AccountState, BaseConfigStore, BaseContract as BaseContractManager, BaseKeyStore, BaseOrderlyKeyPair, BaseSigner, ConfigKey, ConfigStore, DefaultConfigStore, EtherAdapter, IContract, LocalStorageStore, MemoryConfigStore, MessageFactor, MockKeyStore, OrderlyKeyPair, OrderlyKeyStore, SignedMessagePayload, Signer, SimpleDI, IWalletAdapter as WalletAdapter, WalletAdapterOptions, getDefaultSigner, getMockSigner, getWalletAdapterFunc, utils };
|
|
786
|
+
export { Account, AccountState, BaseConfigStore, BaseContract as BaseContractManager, BaseKeyStore, BaseOrderlyKeyPair, BaseSigner, ConfigKey, ConfigStore, DefaultConfigStore, EtherAdapter, IContract, LocalStorageStore, MemoryConfigStore, MessageFactor, MockKeyStore, OrderlyKeyPair, OrderlyKeyStore, SignedMessagePayload, Signer, SimpleDI, IWalletAdapter as WalletAdapter, WalletAdapterOptions, generateAddOrderlyKeyMessage, generateRegisterAccountMessage, generateSettleMessage, getDefaultSigner, getMockSigner, getWalletAdapterFunc, utils };
|