@orderly.network/core 2.6.0 → 2.6.1-alpha.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 +256 -93
- package/dist/index.d.ts +256 -93
- 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 +3 -3
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 { definedTypes,
|
|
3
|
+
import { definedTypes, ChainNamespace, API, AccountStatusEnum, NetworkId } from '@orderly.network/types';
|
|
4
4
|
import { BigNumberish } from 'ethers/src.ts/utils';
|
|
5
5
|
import { parseUnits, TransactionResponse, ethers } from 'ethers';
|
|
6
6
|
|
|
@@ -248,7 +248,7 @@ declare function generateAddOrderlyKeyMessage(inputs: {
|
|
|
248
248
|
timestamp: number;
|
|
249
249
|
expiration: number;
|
|
250
250
|
};
|
|
251
|
-
primaryType: "EIP712Domain" | "Registration" | "Withdraw" | "AddOrderlyKey" | "SettlePnl";
|
|
251
|
+
primaryType: "EIP712Domain" | "Registration" | "Withdraw" | "AddOrderlyKey" | "SettlePnl" | "DexRequest" | "InternalTransfer";
|
|
252
252
|
types: {
|
|
253
253
|
[x: string]: readonly [{
|
|
254
254
|
readonly name: "name";
|
|
@@ -325,6 +325,39 @@ declare function generateAddOrderlyKeyMessage(inputs: {
|
|
|
325
325
|
}, {
|
|
326
326
|
readonly name: "timestamp";
|
|
327
327
|
readonly type: "uint64";
|
|
328
|
+
}] | readonly [{
|
|
329
|
+
readonly name: "payloadType";
|
|
330
|
+
readonly type: "uint8";
|
|
331
|
+
}, {
|
|
332
|
+
readonly name: "nonce";
|
|
333
|
+
readonly type: "uint256";
|
|
334
|
+
}, {
|
|
335
|
+
readonly name: "receiver";
|
|
336
|
+
readonly type: "address";
|
|
337
|
+
}, {
|
|
338
|
+
readonly name: "amount";
|
|
339
|
+
readonly type: "uint256";
|
|
340
|
+
}, {
|
|
341
|
+
readonly name: "vaultId";
|
|
342
|
+
readonly type: "bytes32";
|
|
343
|
+
}, {
|
|
344
|
+
readonly name: "token";
|
|
345
|
+
readonly type: "string";
|
|
346
|
+
}, {
|
|
347
|
+
readonly name: "dexBrokerId";
|
|
348
|
+
readonly type: "string";
|
|
349
|
+
}] | readonly [{
|
|
350
|
+
readonly name: "receiver";
|
|
351
|
+
readonly type: "bytes32";
|
|
352
|
+
}, {
|
|
353
|
+
readonly name: "token";
|
|
354
|
+
readonly type: "string";
|
|
355
|
+
}, {
|
|
356
|
+
readonly name: "amount";
|
|
357
|
+
readonly type: "uint256";
|
|
358
|
+
}, {
|
|
359
|
+
readonly name: "transferNonce";
|
|
360
|
+
readonly type: "uint64";
|
|
328
361
|
}];
|
|
329
362
|
EIP712Domain: readonly [{
|
|
330
363
|
readonly name: "name";
|
|
@@ -392,6 +425,78 @@ declare function generateSettleMessage(inputs: {
|
|
|
392
425
|
}];
|
|
393
426
|
};
|
|
394
427
|
}];
|
|
428
|
+
/**
|
|
429
|
+
* generate `dexRequest` data and to be signed message structure
|
|
430
|
+
*/
|
|
431
|
+
declare function generateDexRequestMessage(inputs: {
|
|
432
|
+
chainId: number;
|
|
433
|
+
payloadType: number;
|
|
434
|
+
nonce: string;
|
|
435
|
+
receiver: string;
|
|
436
|
+
amount: string;
|
|
437
|
+
vaultId: string;
|
|
438
|
+
token: string;
|
|
439
|
+
dexBrokerId: string;
|
|
440
|
+
domain: SignatureDomain;
|
|
441
|
+
timestamp?: number;
|
|
442
|
+
}): readonly [{
|
|
443
|
+
payloadType: number;
|
|
444
|
+
nonce: string;
|
|
445
|
+
receiver: string;
|
|
446
|
+
amount: string;
|
|
447
|
+
vaultId: string;
|
|
448
|
+
token: string;
|
|
449
|
+
dexBrokerId: string;
|
|
450
|
+
}, {
|
|
451
|
+
domain: SignatureDomain;
|
|
452
|
+
message: {
|
|
453
|
+
payloadType: number;
|
|
454
|
+
nonce: string;
|
|
455
|
+
receiver: string;
|
|
456
|
+
amount: string;
|
|
457
|
+
vaultId: string;
|
|
458
|
+
token: string;
|
|
459
|
+
dexBrokerId: string;
|
|
460
|
+
};
|
|
461
|
+
primaryType: string;
|
|
462
|
+
types: {
|
|
463
|
+
EIP712Domain: readonly [{
|
|
464
|
+
readonly name: "name";
|
|
465
|
+
readonly type: "string";
|
|
466
|
+
}, {
|
|
467
|
+
readonly name: "version";
|
|
468
|
+
readonly type: "string";
|
|
469
|
+
}, {
|
|
470
|
+
readonly name: "chainId";
|
|
471
|
+
readonly type: "uint256";
|
|
472
|
+
}, {
|
|
473
|
+
readonly name: "verifyingContract";
|
|
474
|
+
readonly type: "address";
|
|
475
|
+
}];
|
|
476
|
+
DexRequest: readonly [{
|
|
477
|
+
readonly name: "payloadType";
|
|
478
|
+
readonly type: "uint8";
|
|
479
|
+
}, {
|
|
480
|
+
readonly name: "nonce";
|
|
481
|
+
readonly type: "uint256";
|
|
482
|
+
}, {
|
|
483
|
+
readonly name: "receiver";
|
|
484
|
+
readonly type: "address";
|
|
485
|
+
}, {
|
|
486
|
+
readonly name: "amount";
|
|
487
|
+
readonly type: "uint256";
|
|
488
|
+
}, {
|
|
489
|
+
readonly name: "vaultId";
|
|
490
|
+
readonly type: "bytes32";
|
|
491
|
+
}, {
|
|
492
|
+
readonly name: "token";
|
|
493
|
+
readonly type: "string";
|
|
494
|
+
}, {
|
|
495
|
+
readonly name: "dexBrokerId";
|
|
496
|
+
readonly type: "string";
|
|
497
|
+
}];
|
|
498
|
+
};
|
|
499
|
+
}];
|
|
395
500
|
|
|
396
501
|
type ConfigKey = "apiBaseUrl" | "klineDataUrl" | "privateWsUrl" | "publicWsUrl" | "operatorUrl" | "domain" | "brokerId" | "brokerName" | "networkId" | "env" | "chainNamespace" | "PROD_URL" | "orderly_markets" | "markets";
|
|
397
502
|
interface ConfigStore {
|
|
@@ -726,6 +831,120 @@ declare class SimpleDI {
|
|
|
726
831
|
private constructor();
|
|
727
832
|
}
|
|
728
833
|
|
|
834
|
+
type ChainType = "EVM" | "SOL";
|
|
835
|
+
interface Message {
|
|
836
|
+
message: {
|
|
837
|
+
chainType: ChainType;
|
|
838
|
+
[key: string]: any;
|
|
839
|
+
};
|
|
840
|
+
signatured: string;
|
|
841
|
+
}
|
|
842
|
+
type RegisterAccountInputs = {
|
|
843
|
+
brokerId: string;
|
|
844
|
+
registrationNonce: number;
|
|
845
|
+
timestamp: number;
|
|
846
|
+
};
|
|
847
|
+
type WithdrawInputs = {
|
|
848
|
+
brokerId: string;
|
|
849
|
+
receiver: string;
|
|
850
|
+
token: string;
|
|
851
|
+
amount: string;
|
|
852
|
+
nonce: number;
|
|
853
|
+
timestamp: number;
|
|
854
|
+
verifyContract?: string;
|
|
855
|
+
};
|
|
856
|
+
type InternalTransferInputs = {
|
|
857
|
+
receiver: string;
|
|
858
|
+
token: string;
|
|
859
|
+
amount: string;
|
|
860
|
+
nonce: number;
|
|
861
|
+
verifyContract?: string;
|
|
862
|
+
};
|
|
863
|
+
type SettleInputs = {
|
|
864
|
+
brokerId: string;
|
|
865
|
+
settlePnlNonce: string;
|
|
866
|
+
timestamp: number;
|
|
867
|
+
verifyContract?: string;
|
|
868
|
+
};
|
|
869
|
+
type AddOrderlyKeyInputs = {
|
|
870
|
+
publicKey: string;
|
|
871
|
+
brokerId: string;
|
|
872
|
+
expiration: number;
|
|
873
|
+
timestamp: number;
|
|
874
|
+
scope?: string;
|
|
875
|
+
tag?: string;
|
|
876
|
+
/** @since 2.3.0, when create orderly key for sub account, it's required */
|
|
877
|
+
subAccountId?: string;
|
|
878
|
+
};
|
|
879
|
+
type DexRequestInputs = {
|
|
880
|
+
payloadType: number;
|
|
881
|
+
nonce: string;
|
|
882
|
+
receiver: string;
|
|
883
|
+
amount: string;
|
|
884
|
+
vaultId: string;
|
|
885
|
+
token: string;
|
|
886
|
+
dexBrokerId: string;
|
|
887
|
+
timestamp: number;
|
|
888
|
+
domain: SignatureDomain;
|
|
889
|
+
};
|
|
890
|
+
interface WalletAdapter<Config = any> {
|
|
891
|
+
chainNamespace: ChainNamespace;
|
|
892
|
+
get chainId(): number;
|
|
893
|
+
get address(): string;
|
|
894
|
+
set chainId(chainId: number);
|
|
895
|
+
set address(addresses: string);
|
|
896
|
+
active(config: Config): void;
|
|
897
|
+
update(config: Config): void;
|
|
898
|
+
deactivate(): void;
|
|
899
|
+
generateSecretKey(): string;
|
|
900
|
+
/**
|
|
901
|
+
* business methods
|
|
902
|
+
*/
|
|
903
|
+
generateRegisterAccountMessage(inputs: RegisterAccountInputs): Promise<Message>;
|
|
904
|
+
generateWithdrawMessage(inputs: WithdrawInputs): Promise<Message & {
|
|
905
|
+
domain: SignatureDomain;
|
|
906
|
+
}>;
|
|
907
|
+
generateInternalTransferMessage(inputs: InternalTransferInputs): Promise<Message & {
|
|
908
|
+
domain: SignatureDomain;
|
|
909
|
+
}>;
|
|
910
|
+
generateSettleMessage(inputs: SettleInputs): Promise<Message & {
|
|
911
|
+
domain: SignatureDomain;
|
|
912
|
+
}>;
|
|
913
|
+
generateAddOrderlyKeyMessage(inputs: AddOrderlyKeyInputs): Promise<Message>;
|
|
914
|
+
generateDexRequestMessage(inputs: DexRequestInputs): Promise<Message & {
|
|
915
|
+
domain: SignatureDomain;
|
|
916
|
+
}>;
|
|
917
|
+
/**
|
|
918
|
+
* ===== general methods =====
|
|
919
|
+
*/
|
|
920
|
+
/**
|
|
921
|
+
* call contract
|
|
922
|
+
*/
|
|
923
|
+
call(address: string, method: string, params: any[], options?: {
|
|
924
|
+
abi: any;
|
|
925
|
+
}): Promise<any>;
|
|
926
|
+
/**
|
|
927
|
+
* send transaction
|
|
928
|
+
*/
|
|
929
|
+
sendTransaction(contractAddress: string, method: string, payload: {
|
|
930
|
+
from: string;
|
|
931
|
+
to?: string;
|
|
932
|
+
data: any[];
|
|
933
|
+
value?: bigint;
|
|
934
|
+
}, options: {
|
|
935
|
+
abi: any;
|
|
936
|
+
}): Promise<any>;
|
|
937
|
+
callOnChain(chain: API.NetworkInfos, address: string, method: string, params: any[], options: {
|
|
938
|
+
abi: any;
|
|
939
|
+
}): Promise<any>;
|
|
940
|
+
getBalance(): Promise<bigint>;
|
|
941
|
+
pollTransactionReceiptWithBackoff(txHash: string, baseInterval?: number, maxInterval?: number, maxRetries?: number): Promise<any>;
|
|
942
|
+
parseUnits: (amount: string, decimals: number) => string;
|
|
943
|
+
formatUnits: (amount: BigNumberish, decimals: number) => string;
|
|
944
|
+
on(eventName: string, listener: (...args: any[]) => void): void;
|
|
945
|
+
off(eventName: string, listener: (...args: any[]) => void): void;
|
|
946
|
+
}
|
|
947
|
+
|
|
729
948
|
declare class Assets {
|
|
730
949
|
private readonly configStore;
|
|
731
950
|
private readonly contractManger;
|
|
@@ -826,6 +1045,14 @@ declare class Assets {
|
|
|
826
1045
|
/** vault address */
|
|
827
1046
|
vaultAddress?: string;
|
|
828
1047
|
}): Promise<any>;
|
|
1048
|
+
internalTransfer(inputs: {
|
|
1049
|
+
token: string;
|
|
1050
|
+
amount: string;
|
|
1051
|
+
receiver: string;
|
|
1052
|
+
/** orderly token decimals */
|
|
1053
|
+
decimals: number;
|
|
1054
|
+
}): Promise<any>;
|
|
1055
|
+
private getTransferNonce;
|
|
829
1056
|
private _simpleFetch;
|
|
830
1057
|
get usdcAddress(): string;
|
|
831
1058
|
}
|
|
@@ -836,96 +1063,6 @@ type SubAccount = {
|
|
|
836
1063
|
holding: API.Holding[];
|
|
837
1064
|
};
|
|
838
1065
|
|
|
839
|
-
type ChainType = "EVM" | "SOL";
|
|
840
|
-
interface Message {
|
|
841
|
-
message: {
|
|
842
|
-
chainType: ChainType;
|
|
843
|
-
[key: string]: any;
|
|
844
|
-
};
|
|
845
|
-
signatured: string;
|
|
846
|
-
}
|
|
847
|
-
type RegisterAccountInputs = {
|
|
848
|
-
brokerId: string;
|
|
849
|
-
registrationNonce: number;
|
|
850
|
-
timestamp: number;
|
|
851
|
-
};
|
|
852
|
-
type WithdrawInputs = {
|
|
853
|
-
brokerId: string;
|
|
854
|
-
receiver: string;
|
|
855
|
-
token: string;
|
|
856
|
-
amount: string;
|
|
857
|
-
nonce: number;
|
|
858
|
-
timestamp: number;
|
|
859
|
-
verifyContract?: string;
|
|
860
|
-
};
|
|
861
|
-
type SettleInputs = {
|
|
862
|
-
brokerId: string;
|
|
863
|
-
settlePnlNonce: string;
|
|
864
|
-
timestamp: number;
|
|
865
|
-
verifyContract?: string;
|
|
866
|
-
};
|
|
867
|
-
type AddOrderlyKeyInputs = {
|
|
868
|
-
publicKey: string;
|
|
869
|
-
brokerId: string;
|
|
870
|
-
expiration: number;
|
|
871
|
-
timestamp: number;
|
|
872
|
-
scope?: string;
|
|
873
|
-
tag?: string;
|
|
874
|
-
/** @since 2.3.0, when create orderly key for sub account, it's required */
|
|
875
|
-
subAccountId?: string;
|
|
876
|
-
};
|
|
877
|
-
interface WalletAdapter<Config = any> {
|
|
878
|
-
chainNamespace: ChainNamespace;
|
|
879
|
-
get chainId(): number;
|
|
880
|
-
get address(): string;
|
|
881
|
-
set chainId(chainId: number);
|
|
882
|
-
set address(addresses: string);
|
|
883
|
-
active(config: Config): void;
|
|
884
|
-
update(config: Config): void;
|
|
885
|
-
deactivate(): void;
|
|
886
|
-
generateSecretKey(): string;
|
|
887
|
-
/**
|
|
888
|
-
* business methods
|
|
889
|
-
*/
|
|
890
|
-
generateRegisterAccountMessage(inputs: RegisterAccountInputs): Promise<Message>;
|
|
891
|
-
generateWithdrawMessage(inputs: WithdrawInputs): Promise<Message & {
|
|
892
|
-
domain: SignatureDomain;
|
|
893
|
-
}>;
|
|
894
|
-
generateSettleMessage(inputs: SettleInputs): Promise<Message & {
|
|
895
|
-
domain: SignatureDomain;
|
|
896
|
-
}>;
|
|
897
|
-
generateAddOrderlyKeyMessage(inputs: AddOrderlyKeyInputs): Promise<Message>;
|
|
898
|
-
/**
|
|
899
|
-
* ===== general methods =====
|
|
900
|
-
*/
|
|
901
|
-
/**
|
|
902
|
-
* call contract
|
|
903
|
-
*/
|
|
904
|
-
call(address: string, method: string, params: any[], options?: {
|
|
905
|
-
abi: any;
|
|
906
|
-
}): Promise<any>;
|
|
907
|
-
/**
|
|
908
|
-
* send transaction
|
|
909
|
-
*/
|
|
910
|
-
sendTransaction(contractAddress: string, method: string, payload: {
|
|
911
|
-
from: string;
|
|
912
|
-
to?: string;
|
|
913
|
-
data: any[];
|
|
914
|
-
value?: bigint;
|
|
915
|
-
}, options: {
|
|
916
|
-
abi: any;
|
|
917
|
-
}): Promise<any>;
|
|
918
|
-
callOnChain(chain: API.NetworkInfos, address: string, method: string, params: any[], options: {
|
|
919
|
-
abi: any;
|
|
920
|
-
}): Promise<any>;
|
|
921
|
-
getBalance(): Promise<bigint>;
|
|
922
|
-
pollTransactionReceiptWithBackoff(txHash: string, baseInterval?: number, maxInterval?: number, maxRetries?: number): Promise<any>;
|
|
923
|
-
parseUnits: (amount: string, decimals: number) => string;
|
|
924
|
-
formatUnits: (amount: BigNumberish, decimals: number) => string;
|
|
925
|
-
on(eventName: string, listener: (...args: any[]) => void): void;
|
|
926
|
-
off(eventName: string, listener: (...args: any[]) => void): void;
|
|
927
|
-
}
|
|
928
|
-
|
|
929
1066
|
interface AccountState {
|
|
930
1067
|
status: AccountStatusEnum;
|
|
931
1068
|
/**
|
|
@@ -1116,10 +1253,30 @@ declare class Account {
|
|
|
1116
1253
|
private _getAccountInfo;
|
|
1117
1254
|
private _getSettleNonce;
|
|
1118
1255
|
private _simpleFetch;
|
|
1256
|
+
private _getVaultOperationNonce;
|
|
1119
1257
|
getAdditionalInfo(): Record<string, any> | null;
|
|
1120
1258
|
get on(): <T extends string | symbol>(event: T, fn: (...args: any[]) => void, context?: any) => EventEmitter<string | symbol, any>;
|
|
1121
1259
|
get once(): <T extends string | symbol>(event: T, fn: (...args: any[]) => void, context?: any) => EventEmitter<string | symbol, any>;
|
|
1122
1260
|
get off(): <T extends string | symbol>(event: T, fn?: ((...args: any[]) => void) | undefined, context?: any, once?: boolean) => EventEmitter<string | symbol, any>;
|
|
1261
|
+
/**
|
|
1262
|
+
* Generate DexRequest message for DEX operations
|
|
1263
|
+
* @param inputs DexRequest parameters
|
|
1264
|
+
* @returns Signed message and domain
|
|
1265
|
+
*/
|
|
1266
|
+
generateDexRequest(inputs: {
|
|
1267
|
+
payloadType: number;
|
|
1268
|
+
amount: string;
|
|
1269
|
+
vaultId: string;
|
|
1270
|
+
token: string;
|
|
1271
|
+
domain: SignatureDomain;
|
|
1272
|
+
}): Promise<{
|
|
1273
|
+
message: {
|
|
1274
|
+
[key: string]: any;
|
|
1275
|
+
chainType: ChainType;
|
|
1276
|
+
};
|
|
1277
|
+
signatured: string;
|
|
1278
|
+
domain: SignatureDomain;
|
|
1279
|
+
}>;
|
|
1123
1280
|
/**
|
|
1124
1281
|
* Signs a GET MessageFactor payload with the current timestamp.
|
|
1125
1282
|
* @param url The URL for the GET request
|
|
@@ -1150,10 +1307,16 @@ declare abstract class BaseWalletAdapter<Config> implements WalletAdapter<Config
|
|
|
1150
1307
|
abstract generateWithdrawMessage(inputs: WithdrawInputs): Promise<Message & {
|
|
1151
1308
|
domain: SignatureDomain;
|
|
1152
1309
|
}>;
|
|
1310
|
+
abstract generateInternalTransferMessage(inputs: InternalTransferInputs): Promise<Message & {
|
|
1311
|
+
domain: SignatureDomain;
|
|
1312
|
+
}>;
|
|
1153
1313
|
abstract generateSettleMessage(inputs: SettleInputs): Promise<Message & {
|
|
1154
1314
|
domain: SignatureDomain;
|
|
1155
1315
|
}>;
|
|
1156
1316
|
abstract generateAddOrderlyKeyMessage(inputs: AddOrderlyKeyInputs): Promise<Message>;
|
|
1317
|
+
abstract generateDexRequestMessage(inputs: DexRequestInputs): Promise<Message & {
|
|
1318
|
+
domain: SignatureDomain;
|
|
1319
|
+
}>;
|
|
1157
1320
|
abstract getBalance(): Promise<bigint>;
|
|
1158
1321
|
abstract chainNamespace: ChainNamespace;
|
|
1159
1322
|
signMessageByOrderlyKey(payload: any): Promise<SignedMessagePayload>;
|
|
@@ -1270,4 +1433,4 @@ declare class EtherAdapter implements IWalletAdapter {
|
|
|
1270
1433
|
getContract(address: string, abi: any): ethers.Contract;
|
|
1271
1434
|
}
|
|
1272
1435
|
|
|
1273
|
-
export { API_URLS, Account, type AccountState, type AddOrderlyKeyInputs, BaseContract as BaseContractManager, BaseKeyStore, BaseOrderlyKeyPair, BaseSigner, BaseWalletAdapter, type ChainType, type ConfigKey, type ConfigStore, DefaultConfigStore, EVENT_NAMES, type Ed25519Keypair, EtherAdapter, type IContract, LocalStorageStore, type Message, type MessageFactor, MockKeyStore, type OrderlyKeyPair, type OrderlyKeyStore, type RegisterAccountInputs, type SettleInputs, type SignatureDomain, type SignedMessagePayload, type Signer, SimpleDI, type SubAccount, type URLS, type WalletAdapter, type WalletAdapterOptions, type WithdrawInputs, generateAddOrderlyKeyMessage, generateRegisterAccountMessage, generateSettleMessage, getDefaultSigner, getMockSigner, type getWalletAdapterFunc, utils };
|
|
1436
|
+
export { API_URLS, Account, type AccountState, type AddOrderlyKeyInputs, BaseContract as BaseContractManager, BaseKeyStore, BaseOrderlyKeyPair, BaseSigner, BaseWalletAdapter, type ChainType, type ConfigKey, type ConfigStore, DefaultConfigStore, type DexRequestInputs, EVENT_NAMES, type Ed25519Keypair, EtherAdapter, type IContract, type InternalTransferInputs, LocalStorageStore, type Message, type MessageFactor, MockKeyStore, type OrderlyKeyPair, type OrderlyKeyStore, type RegisterAccountInputs, type SettleInputs, type SignatureDomain, type SignedMessagePayload, type Signer, SimpleDI, type SubAccount, type URLS, type WalletAdapter, type WalletAdapterOptions, type WithdrawInputs, generateAddOrderlyKeyMessage, generateDexRequestMessage, generateRegisterAccountMessage, generateSettleMessage, getDefaultSigner, getMockSigner, type getWalletAdapterFunc, utils };
|