@cetusprotocol/aggregator-sdk 0.0.0-experimental-20240719182939

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.
Files changed (66) hide show
  1. package/.env.example +4 -0
  2. package/README.md +0 -0
  3. package/bun.lockb +0 -0
  4. package/dist/index.d.mts +267 -0
  5. package/dist/index.d.ts +267 -0
  6. package/dist/index.js +6824 -0
  7. package/dist/index.mjs +6745 -0
  8. package/dist/src/client.d.ts +88 -0
  9. package/dist/src/config.d.ts +26 -0
  10. package/dist/src/const.d.ts +75 -0
  11. package/dist/src/errors.d.ts +31 -0
  12. package/dist/src/index.d.ts +5 -0
  13. package/dist/src/math.d.ts +5 -0
  14. package/dist/src/test_data.test.d.ts +8 -0
  15. package/dist/src/transaction/aftermath.d.ts +24 -0
  16. package/dist/src/transaction/cetus.d.ts +39 -0
  17. package/dist/src/transaction/common.d.ts +12 -0
  18. package/dist/src/transaction/deepbook.d.ts +21 -0
  19. package/dist/src/transaction/flowx.d.ts +20 -0
  20. package/dist/src/transaction/index.d.ts +1 -0
  21. package/dist/src/transaction/kriya.d.ts +21 -0
  22. package/dist/src/transaction/router.d.ts +6 -0
  23. package/dist/src/transaction/swap.d.ts +5 -0
  24. package/dist/src/transaction/turbos.d.ts +22 -0
  25. package/dist/src/types/CoinAssist.d.ts +122 -0
  26. package/dist/src/types/sui.d.ts +112 -0
  27. package/dist/src/utils/account_cap.d.ts +7 -0
  28. package/dist/src/utils/coin.d.ts +4 -0
  29. package/dist/src/utils/coin.spec.d.ts +1 -0
  30. package/dist/src/utils/contracts.d.ts +16 -0
  31. package/dist/src/utils/index.d.ts +1 -0
  32. package/dist/src/utils/transaction.d.ts +3 -0
  33. package/dist/tests/router.test.d.ts +2 -0
  34. package/dist/tests/wallet.test.d.ts +1 -0
  35. package/jest.config.mjs +13 -0
  36. package/package.json +41 -0
  37. package/src/client.ts +393 -0
  38. package/src/config.ts +65 -0
  39. package/src/const.ts +126 -0
  40. package/src/errors.ts +44 -0
  41. package/src/index.ts +5 -0
  42. package/src/math.ts +37 -0
  43. package/src/test_data.test.ts +17 -0
  44. package/src/transaction/aftermath.ts +142 -0
  45. package/src/transaction/cetus.ts +281 -0
  46. package/src/transaction/common.ts +169 -0
  47. package/src/transaction/deepbook.ts +126 -0
  48. package/src/transaction/flowx.ts +97 -0
  49. package/src/transaction/index.ts +1 -0
  50. package/src/transaction/kriya.ts +77 -0
  51. package/src/transaction/router.ts +341 -0
  52. package/src/transaction/swap.ts +164 -0
  53. package/src/transaction/turbos.ts +114 -0
  54. package/src/types/CoinAssist.ts +217 -0
  55. package/src/types/sui.ts +148 -0
  56. package/src/utils/account_cap.ts +62 -0
  57. package/src/utils/coin.spec.ts +10 -0
  58. package/src/utils/coin.ts +61 -0
  59. package/src/utils/contracts.ts +136 -0
  60. package/src/utils/index.ts +1 -0
  61. package/src/utils/transaction.ts +20 -0
  62. package/tests/router.test.ts +255 -0
  63. package/tests/wallet.test.ts +21 -0
  64. package/tsconfig.json +22 -0
  65. package/tsup.config.ts +23 -0
  66. package/version.mjs +28 -0
package/.env.example ADDED
@@ -0,0 +1,4 @@
1
+ SUI_PRC=
2
+ SUI_WALLET_SECRET=
3
+ SUI_WALLET_MNEMONICS=
4
+ CETUS_AGGREGATOR=
package/README.md ADDED
File without changes
package/bun.lockb ADDED
Binary file
@@ -0,0 +1,267 @@
1
+ import * as _mysten_sui_client from '@mysten/sui/client';
2
+ import { SuiClient } from '@mysten/sui/client';
3
+ import Decimal from 'decimal.js';
4
+ import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
5
+ import { Signer } from '@mysten/sui/dist/cjs/cryptography';
6
+ import BN from 'bn.js';
7
+
8
+ type Package = {
9
+ packageName: string;
10
+ packageId: string;
11
+ publishedAt: string;
12
+ };
13
+ declare enum ENV {
14
+ MAINNET = 0,
15
+ TESTNET = 1
16
+ }
17
+ declare class AggregatorConfig {
18
+ private aggregatorUrl;
19
+ private fullNodeUrl;
20
+ private wallet;
21
+ private packages;
22
+ private env;
23
+ constructor(aggregatorUrl: string, fullNodeUrl: string, wallet: string, packages: Package[], env: ENV);
24
+ getAggregatorUrl(): string;
25
+ getFullNodeUrl(): string;
26
+ getWallet(): string;
27
+ getENV(): ENV;
28
+ getPackages(): Package[];
29
+ getPackage(packageName: string): Package | undefined;
30
+ addPackage(newPackage: Package): void;
31
+ removePackageById(packageId: string): void;
32
+ findPackageById(packageId: string): Package | undefined;
33
+ }
34
+
35
+ /**
36
+ * Represents a SUI address, which is a string.
37
+ */
38
+ type SuiAddress = string;
39
+ /**
40
+ * Represents a SUI object identifier, which is a string.
41
+ */
42
+ type SuiObjectIdType = string;
43
+ /**
44
+ * Represents a SUI struct tag.
45
+ */
46
+ type SuiStructTag = {
47
+ /**
48
+ * The full address of the struct.
49
+ */
50
+ full_address: string;
51
+ /**
52
+ * The source address of the struct.
53
+ */
54
+ source_address: string;
55
+ /**
56
+ * The address of the struct.
57
+ */
58
+ address: SuiAddress;
59
+ /**
60
+ * The module to which the struct belongs.
61
+ */
62
+ module: string;
63
+ /**
64
+ * The name of the struct.
65
+ */
66
+ name: string;
67
+ /**
68
+ * An array of type arguments (SUI addresses) for the struct.
69
+ */
70
+ type_arguments: SuiAddress[];
71
+ };
72
+ /**
73
+ * Represents a coin asset with address, object ID, and balance information.
74
+ */
75
+ type CoinAsset = {
76
+ /**
77
+ * The address type of the coin asset.
78
+ */
79
+ coinAddress: SuiAddress;
80
+ /**
81
+ * The object identifier of the coin asset.
82
+ */
83
+ coinObjectId: SuiObjectIdType;
84
+ /**
85
+ * The balance amount of the coin asset.
86
+ */
87
+ balance: bigint;
88
+ };
89
+
90
+ type ExtendedDetails = {
91
+ aftermathPoolFlatness?: number;
92
+ aftermathLpSupplyType?: string;
93
+ turbosFeeType?: string;
94
+ };
95
+ type Path = {
96
+ id: string;
97
+ a2b: boolean;
98
+ provider: string;
99
+ from: string;
100
+ target: string;
101
+ feeRate: number;
102
+ amountIn: number;
103
+ amountOut: number;
104
+ extendedDetails?: ExtendedDetails;
105
+ version?: string;
106
+ };
107
+ type Router = {
108
+ path: Path[];
109
+ amountIn: BN;
110
+ amountOut: BN;
111
+ initialPrice: Decimal;
112
+ };
113
+ type RouterData = {
114
+ amountIn: BN;
115
+ amountOut: BN;
116
+ routes: Router[];
117
+ insufficientLiquidity: boolean;
118
+ };
119
+ type AggregatorResponse = {
120
+ code: number;
121
+ msg: string;
122
+ data: RouterData;
123
+ };
124
+ type BuildRouterSwapParams = {
125
+ routers: Router[];
126
+ amountIn: BN;
127
+ amountOut: BN;
128
+ byAmountIn: boolean;
129
+ slippage: number;
130
+ fromCoinType: string;
131
+ targetCoinType: string;
132
+ partner?: string;
133
+ isMergeTragetCoin?: boolean;
134
+ refreshAllCoins?: boolean;
135
+ };
136
+ interface FindRouterParams {
137
+ from: string;
138
+ target: string;
139
+ amount: BN;
140
+ byAmountIn: boolean;
141
+ depth: number | null;
142
+ splitAlgorithm: string | null;
143
+ splitFactor: number | null;
144
+ splitCount: number | null;
145
+ providers: string[] | null;
146
+ }
147
+ interface SwapInPoolsParams {
148
+ from: string;
149
+ target: string;
150
+ amount: BN;
151
+ byAmountIn: boolean;
152
+ pools: string[];
153
+ }
154
+ interface SwapInPoolsResult {
155
+ isExceed: boolean;
156
+ routeData?: RouterData;
157
+ }
158
+ declare class AggregatorClient {
159
+ private config;
160
+ private wallet;
161
+ private client;
162
+ private allCoins;
163
+ constructor(config: AggregatorConfig);
164
+ getAllCoins(): Promise<CoinAsset[]>;
165
+ findRouter(fromRouterParams: FindRouterParams): Promise<RouterData | null>;
166
+ swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResult | null>;
167
+ routerSwap(params: BuildRouterSwapParams): Promise<Transaction>;
168
+ signAndExecuteTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
169
+ devInspectTransactionBlock(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.DevInspectResults>;
170
+ sendTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
171
+ }
172
+
173
+ declare function expectInputRouterSwap(client: SuiClient, params: BuildRouterSwapParams, txb: Transaction, fromCoin: TransactionObjectArgument, config: AggregatorConfig, partner?: string): Promise<TransactionObjectArgument[]>;
174
+ declare function expectOutputRouterSwap(params: BuildRouterSwapParams, txb: Transaction, fromCoin: TransactionObjectArgument, config: AggregatorConfig, partner?: string): Promise<TransactionObjectArgument[]>;
175
+
176
+ declare function isSortedSymbols(symbolX: string, symbolY: string): boolean;
177
+ declare function composeType(address: string, generics: SuiAddress[]): SuiAddress;
178
+ declare function composeType(address: string, struct: string, generics?: SuiAddress[]): SuiAddress;
179
+ declare function composeType(address: string, module: string, struct: string, generics?: SuiAddress[]): SuiAddress;
180
+ declare function extractAddressFromType(type: string): string;
181
+ declare function extractStructTagFromType(type: string): SuiStructTag;
182
+ declare function normalizeCoinType(coinType: string): string;
183
+ declare function fixSuiObjectId(value: string): string;
184
+ /**
185
+ * Recursively traverses the given data object and patches any string values that represent Sui object IDs.
186
+ *
187
+ * @param {any} data - The data object to be patched.
188
+ */
189
+ declare function patchFixSuiObjectId(data: any): void;
190
+ declare function createTarget(packageName: string, moduleName: string, functionName: string): `${string}::${string}::${string}`;
191
+
192
+ /**
193
+ * The address representing the clock in the system.
194
+ */
195
+ declare const CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
196
+ /**
197
+ * The address for CoinInfo module.
198
+ */
199
+ declare const CoinInfoAddress = "0x1::coin::CoinInfo";
200
+ /**
201
+ * The address for CoinStore module.
202
+ */
203
+ declare const CoinStoreAddress = "0x1::coin::CoinStore";
204
+ declare const SuiZeroCoinFn = "0x2::coin::zero";
205
+ declare const AGGREGATOR = "aggregator";
206
+ declare const CETUS_DEX = "CETUS";
207
+ declare const DEEPBOOK_DEX = "DEEPBOOK";
208
+ declare const KRIYA_DEX = "KRIYA";
209
+ declare const FLOWX_AMM = "FLOWX";
210
+ declare const TURBOS_DEX = "TURBOS";
211
+ declare const AFTERMATH_AMM = "AFTERMATH";
212
+ declare const INTEGRATE = "integrate";
213
+ declare const CETUS_MODULE = "cetus";
214
+ declare const DEEPBOOK_MODULE = "deepbook";
215
+ declare const KRIYA_MODULE = "kriya";
216
+ declare const UTILS_MODULE = "utils";
217
+ declare const POOL_MODULT = "pool";
218
+ declare const PAY_MODULE = "pay";
219
+ declare const FLOWX_AMM_MODULE = "flowx_amm";
220
+ declare const TURBOS_MODULE = "turbos";
221
+ declare const AFTERMATH_MODULE = "aftermath";
222
+ declare const DEEPBOOK_CUSTODIAN_V2_MODULE = "custodian_v2";
223
+ declare const DEEPBOOK_CLOB_V2_MODULE = "clob_v2";
224
+ declare const FlashSwapFunc = "flash_swap";
225
+ declare const FlashSwapWithPartnerFunc = "flash_swap_with_partner";
226
+ declare const RepayFalshSwapFunc = "repay_flash_swap";
227
+ declare const RepayFlashSwapWithPartnerFunc = "repay_flash_swap_with_partner";
228
+ declare const FlashSwapA2BFunc = "flash_swap_a2b";
229
+ declare const FlashSwapB2AFunc = "flash_swap_b2a";
230
+ declare const FlashSwapWithPartnerA2BFunc = "flash_swap_with_partner_a2b";
231
+ declare const FlashSwapWithPartnerB2AFunc = "flash_swap_with_partner_b2a";
232
+ declare const REPAY_FLASH_SWAP_A2B_FUNC = "repay_flash_swap_a2b";
233
+ declare const REPAY_FLASH_SWAP_B2A_FUNC = "repay_flash_swap_b2a";
234
+ declare const REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC = "repay_flash_swap_with_partner_a2b";
235
+ declare const REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC = "repay_flash_swap_with_partner_b2a";
236
+ declare const SWAP_A2B_FUNC = "swap_a2b";
237
+ declare const SWAP_B2A_FUNC = "swap_b2a";
238
+ declare const TRANSFER_OR_DESTORY_COIN_FUNC = "transfer_or_destroy_coin";
239
+ declare const CHECK_COINS_THRESHOLD_FUNC = "check_coins_threshold";
240
+ declare const JOIN_FUNC = "join_vec";
241
+ declare const TRANSFER_ACCOUNT_CAP = "transfer_account_cap";
242
+ declare const DEEPBOOK_PACKAGE_ID = "0x000000000000000000000000000000000000000000000000000000000000dee9";
243
+ declare const DEEPBOOK_PUBLISHED_AT = "0x000000000000000000000000000000000000000000000000000000000000dee9";
244
+ declare const CETUS_PUBLISHED_AT = "0x70968826ad1b4ba895753f634b0aea68d0672908ca1075a2abdf0fc9e0b2fc6a";
245
+ declare const MAINNET_CETUS_GLOBAL_CONFIG_ID = "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f";
246
+ declare const TESTNET_CETUS_GLOBAL_CONFIG_ID = "0x6f4149091a5aea0e818e7243a13adcfb403842d670b9a2089de058512620687a";
247
+ declare const ZERO: BN;
248
+ declare const ONE: BN;
249
+ declare const TWO: BN;
250
+ declare const U128: BN;
251
+ declare const U64_MAX_BN: BN;
252
+ declare const U64_MAX = "18446744073709551615";
253
+ declare const MAINNET_FLOWX_AMM_CONTAINER_ID = "0xb65dcbf63fd3ad5d0ebfbf334780dc9f785eff38a4459e37ab08fa79576ee511";
254
+ declare const TESTNET_FLOWX_AMM_CONTAINER_ID = "";
255
+ declare const TURBOS_VERSIONED = "0xf1cf0e81048df168ebeb1b8030fad24b3e0b53ae827c25053fff0779c1445b6f";
256
+ declare const MAINNET_AFTERMATH_REGISTRY_ID = "0xfcc774493db2c45c79f688f88d28023a3e7d98e4ee9f48bbf5c7990f651577ae";
257
+ declare const TESTNET_AFTERMATH_REGISTRY_ID = "";
258
+ declare const MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID = "0xf194d9b1bcad972e45a7dd67dd49b3ee1e3357a00a50850c52cd51bb450e13b4";
259
+ declare const TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID = "";
260
+ declare const MAINNET_AFTERMATH_TREASURY_ID = "0x28e499dff5e864a2eafe476269a4f5035f1c16f338da7be18b103499abf271ce";
261
+ declare const TESTNET_AFTERMATH_TREASURY_ID = "";
262
+ declare const MAINNET_AFTERMATH_INSURANCE_FUND_ID = "0xf0c40d67b078000e18032334c3325c47b9ec9f3d9ae4128be820d54663d14e3b";
263
+ declare const TESTNET_AFTERMATH_INSURANCE_FUND_ID = "";
264
+ declare const MAINNET_AFTERMATH_REFERRAL_VAULT_ID = "0x35d35b0e5b177593d8c3a801462485572fc30861e6ce96a55af6dc4730709278";
265
+ declare const TESTNET_AFTERMATH_REFERRAL_VAULT_ID = "";
266
+
267
+ export { AFTERMATH_AMM, AFTERMATH_MODULE, AGGREGATOR, AggregatorClient, AggregatorConfig, type AggregatorResponse, type BuildRouterSwapParams, CETUS_DEX, CETUS_MODULE, CETUS_PUBLISHED_AT, CHECK_COINS_THRESHOLD_FUNC, CLOCK_ADDRESS, CoinInfoAddress, CoinStoreAddress, DEEPBOOK_CLOB_V2_MODULE, DEEPBOOK_CUSTODIAN_V2_MODULE, DEEPBOOK_DEX, DEEPBOOK_MODULE, DEEPBOOK_PACKAGE_ID, DEEPBOOK_PUBLISHED_AT, ENV, type ExtendedDetails, FLOWX_AMM, FLOWX_AMM_MODULE, type FindRouterParams, FlashSwapA2BFunc, FlashSwapB2AFunc, FlashSwapFunc, FlashSwapWithPartnerA2BFunc, FlashSwapWithPartnerB2AFunc, FlashSwapWithPartnerFunc, INTEGRATE, JOIN_FUNC, KRIYA_DEX, KRIYA_MODULE, MAINNET_AFTERMATH_INSURANCE_FUND_ID, MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, MAINNET_AFTERMATH_REFERRAL_VAULT_ID, MAINNET_AFTERMATH_REGISTRY_ID, MAINNET_AFTERMATH_TREASURY_ID, MAINNET_CETUS_GLOBAL_CONFIG_ID, MAINNET_FLOWX_AMM_CONTAINER_ID, ONE, PAY_MODULE, POOL_MODULT, type Package, type Path, REPAY_FLASH_SWAP_A2B_FUNC, REPAY_FLASH_SWAP_B2A_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC, RepayFalshSwapFunc, RepayFlashSwapWithPartnerFunc, type Router, type RouterData, SWAP_A2B_FUNC, SWAP_B2A_FUNC, SuiZeroCoinFn, type SwapInPoolsParams, type SwapInPoolsResult, TESTNET_AFTERMATH_INSURANCE_FUND_ID, TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, TESTNET_AFTERMATH_REFERRAL_VAULT_ID, TESTNET_AFTERMATH_REGISTRY_ID, TESTNET_AFTERMATH_TREASURY_ID, TESTNET_CETUS_GLOBAL_CONFIG_ID, TESTNET_FLOWX_AMM_CONTAINER_ID, TRANSFER_ACCOUNT_CAP, TRANSFER_OR_DESTORY_COIN_FUNC, TURBOS_DEX, TURBOS_MODULE, TURBOS_VERSIONED, TWO, U128, U64_MAX, U64_MAX_BN, UTILS_MODULE, ZERO, composeType, createTarget, expectInputRouterSwap, expectOutputRouterSwap, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, isSortedSymbols, normalizeCoinType, patchFixSuiObjectId };
@@ -0,0 +1,267 @@
1
+ import * as _mysten_sui_client from '@mysten/sui/client';
2
+ import { SuiClient } from '@mysten/sui/client';
3
+ import Decimal from 'decimal.js';
4
+ import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
5
+ import { Signer } from '@mysten/sui/dist/cjs/cryptography';
6
+ import BN from 'bn.js';
7
+
8
+ type Package = {
9
+ packageName: string;
10
+ packageId: string;
11
+ publishedAt: string;
12
+ };
13
+ declare enum ENV {
14
+ MAINNET = 0,
15
+ TESTNET = 1
16
+ }
17
+ declare class AggregatorConfig {
18
+ private aggregatorUrl;
19
+ private fullNodeUrl;
20
+ private wallet;
21
+ private packages;
22
+ private env;
23
+ constructor(aggregatorUrl: string, fullNodeUrl: string, wallet: string, packages: Package[], env: ENV);
24
+ getAggregatorUrl(): string;
25
+ getFullNodeUrl(): string;
26
+ getWallet(): string;
27
+ getENV(): ENV;
28
+ getPackages(): Package[];
29
+ getPackage(packageName: string): Package | undefined;
30
+ addPackage(newPackage: Package): void;
31
+ removePackageById(packageId: string): void;
32
+ findPackageById(packageId: string): Package | undefined;
33
+ }
34
+
35
+ /**
36
+ * Represents a SUI address, which is a string.
37
+ */
38
+ type SuiAddress = string;
39
+ /**
40
+ * Represents a SUI object identifier, which is a string.
41
+ */
42
+ type SuiObjectIdType = string;
43
+ /**
44
+ * Represents a SUI struct tag.
45
+ */
46
+ type SuiStructTag = {
47
+ /**
48
+ * The full address of the struct.
49
+ */
50
+ full_address: string;
51
+ /**
52
+ * The source address of the struct.
53
+ */
54
+ source_address: string;
55
+ /**
56
+ * The address of the struct.
57
+ */
58
+ address: SuiAddress;
59
+ /**
60
+ * The module to which the struct belongs.
61
+ */
62
+ module: string;
63
+ /**
64
+ * The name of the struct.
65
+ */
66
+ name: string;
67
+ /**
68
+ * An array of type arguments (SUI addresses) for the struct.
69
+ */
70
+ type_arguments: SuiAddress[];
71
+ };
72
+ /**
73
+ * Represents a coin asset with address, object ID, and balance information.
74
+ */
75
+ type CoinAsset = {
76
+ /**
77
+ * The address type of the coin asset.
78
+ */
79
+ coinAddress: SuiAddress;
80
+ /**
81
+ * The object identifier of the coin asset.
82
+ */
83
+ coinObjectId: SuiObjectIdType;
84
+ /**
85
+ * The balance amount of the coin asset.
86
+ */
87
+ balance: bigint;
88
+ };
89
+
90
+ type ExtendedDetails = {
91
+ aftermathPoolFlatness?: number;
92
+ aftermathLpSupplyType?: string;
93
+ turbosFeeType?: string;
94
+ };
95
+ type Path = {
96
+ id: string;
97
+ a2b: boolean;
98
+ provider: string;
99
+ from: string;
100
+ target: string;
101
+ feeRate: number;
102
+ amountIn: number;
103
+ amountOut: number;
104
+ extendedDetails?: ExtendedDetails;
105
+ version?: string;
106
+ };
107
+ type Router = {
108
+ path: Path[];
109
+ amountIn: BN;
110
+ amountOut: BN;
111
+ initialPrice: Decimal;
112
+ };
113
+ type RouterData = {
114
+ amountIn: BN;
115
+ amountOut: BN;
116
+ routes: Router[];
117
+ insufficientLiquidity: boolean;
118
+ };
119
+ type AggregatorResponse = {
120
+ code: number;
121
+ msg: string;
122
+ data: RouterData;
123
+ };
124
+ type BuildRouterSwapParams = {
125
+ routers: Router[];
126
+ amountIn: BN;
127
+ amountOut: BN;
128
+ byAmountIn: boolean;
129
+ slippage: number;
130
+ fromCoinType: string;
131
+ targetCoinType: string;
132
+ partner?: string;
133
+ isMergeTragetCoin?: boolean;
134
+ refreshAllCoins?: boolean;
135
+ };
136
+ interface FindRouterParams {
137
+ from: string;
138
+ target: string;
139
+ amount: BN;
140
+ byAmountIn: boolean;
141
+ depth: number | null;
142
+ splitAlgorithm: string | null;
143
+ splitFactor: number | null;
144
+ splitCount: number | null;
145
+ providers: string[] | null;
146
+ }
147
+ interface SwapInPoolsParams {
148
+ from: string;
149
+ target: string;
150
+ amount: BN;
151
+ byAmountIn: boolean;
152
+ pools: string[];
153
+ }
154
+ interface SwapInPoolsResult {
155
+ isExceed: boolean;
156
+ routeData?: RouterData;
157
+ }
158
+ declare class AggregatorClient {
159
+ private config;
160
+ private wallet;
161
+ private client;
162
+ private allCoins;
163
+ constructor(config: AggregatorConfig);
164
+ getAllCoins(): Promise<CoinAsset[]>;
165
+ findRouter(fromRouterParams: FindRouterParams): Promise<RouterData | null>;
166
+ swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResult | null>;
167
+ routerSwap(params: BuildRouterSwapParams): Promise<Transaction>;
168
+ signAndExecuteTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
169
+ devInspectTransactionBlock(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.DevInspectResults>;
170
+ sendTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
171
+ }
172
+
173
+ declare function expectInputRouterSwap(client: SuiClient, params: BuildRouterSwapParams, txb: Transaction, fromCoin: TransactionObjectArgument, config: AggregatorConfig, partner?: string): Promise<TransactionObjectArgument[]>;
174
+ declare function expectOutputRouterSwap(params: BuildRouterSwapParams, txb: Transaction, fromCoin: TransactionObjectArgument, config: AggregatorConfig, partner?: string): Promise<TransactionObjectArgument[]>;
175
+
176
+ declare function isSortedSymbols(symbolX: string, symbolY: string): boolean;
177
+ declare function composeType(address: string, generics: SuiAddress[]): SuiAddress;
178
+ declare function composeType(address: string, struct: string, generics?: SuiAddress[]): SuiAddress;
179
+ declare function composeType(address: string, module: string, struct: string, generics?: SuiAddress[]): SuiAddress;
180
+ declare function extractAddressFromType(type: string): string;
181
+ declare function extractStructTagFromType(type: string): SuiStructTag;
182
+ declare function normalizeCoinType(coinType: string): string;
183
+ declare function fixSuiObjectId(value: string): string;
184
+ /**
185
+ * Recursively traverses the given data object and patches any string values that represent Sui object IDs.
186
+ *
187
+ * @param {any} data - The data object to be patched.
188
+ */
189
+ declare function patchFixSuiObjectId(data: any): void;
190
+ declare function createTarget(packageName: string, moduleName: string, functionName: string): `${string}::${string}::${string}`;
191
+
192
+ /**
193
+ * The address representing the clock in the system.
194
+ */
195
+ declare const CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
196
+ /**
197
+ * The address for CoinInfo module.
198
+ */
199
+ declare const CoinInfoAddress = "0x1::coin::CoinInfo";
200
+ /**
201
+ * The address for CoinStore module.
202
+ */
203
+ declare const CoinStoreAddress = "0x1::coin::CoinStore";
204
+ declare const SuiZeroCoinFn = "0x2::coin::zero";
205
+ declare const AGGREGATOR = "aggregator";
206
+ declare const CETUS_DEX = "CETUS";
207
+ declare const DEEPBOOK_DEX = "DEEPBOOK";
208
+ declare const KRIYA_DEX = "KRIYA";
209
+ declare const FLOWX_AMM = "FLOWX";
210
+ declare const TURBOS_DEX = "TURBOS";
211
+ declare const AFTERMATH_AMM = "AFTERMATH";
212
+ declare const INTEGRATE = "integrate";
213
+ declare const CETUS_MODULE = "cetus";
214
+ declare const DEEPBOOK_MODULE = "deepbook";
215
+ declare const KRIYA_MODULE = "kriya";
216
+ declare const UTILS_MODULE = "utils";
217
+ declare const POOL_MODULT = "pool";
218
+ declare const PAY_MODULE = "pay";
219
+ declare const FLOWX_AMM_MODULE = "flowx_amm";
220
+ declare const TURBOS_MODULE = "turbos";
221
+ declare const AFTERMATH_MODULE = "aftermath";
222
+ declare const DEEPBOOK_CUSTODIAN_V2_MODULE = "custodian_v2";
223
+ declare const DEEPBOOK_CLOB_V2_MODULE = "clob_v2";
224
+ declare const FlashSwapFunc = "flash_swap";
225
+ declare const FlashSwapWithPartnerFunc = "flash_swap_with_partner";
226
+ declare const RepayFalshSwapFunc = "repay_flash_swap";
227
+ declare const RepayFlashSwapWithPartnerFunc = "repay_flash_swap_with_partner";
228
+ declare const FlashSwapA2BFunc = "flash_swap_a2b";
229
+ declare const FlashSwapB2AFunc = "flash_swap_b2a";
230
+ declare const FlashSwapWithPartnerA2BFunc = "flash_swap_with_partner_a2b";
231
+ declare const FlashSwapWithPartnerB2AFunc = "flash_swap_with_partner_b2a";
232
+ declare const REPAY_FLASH_SWAP_A2B_FUNC = "repay_flash_swap_a2b";
233
+ declare const REPAY_FLASH_SWAP_B2A_FUNC = "repay_flash_swap_b2a";
234
+ declare const REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC = "repay_flash_swap_with_partner_a2b";
235
+ declare const REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC = "repay_flash_swap_with_partner_b2a";
236
+ declare const SWAP_A2B_FUNC = "swap_a2b";
237
+ declare const SWAP_B2A_FUNC = "swap_b2a";
238
+ declare const TRANSFER_OR_DESTORY_COIN_FUNC = "transfer_or_destroy_coin";
239
+ declare const CHECK_COINS_THRESHOLD_FUNC = "check_coins_threshold";
240
+ declare const JOIN_FUNC = "join_vec";
241
+ declare const TRANSFER_ACCOUNT_CAP = "transfer_account_cap";
242
+ declare const DEEPBOOK_PACKAGE_ID = "0x000000000000000000000000000000000000000000000000000000000000dee9";
243
+ declare const DEEPBOOK_PUBLISHED_AT = "0x000000000000000000000000000000000000000000000000000000000000dee9";
244
+ declare const CETUS_PUBLISHED_AT = "0x70968826ad1b4ba895753f634b0aea68d0672908ca1075a2abdf0fc9e0b2fc6a";
245
+ declare const MAINNET_CETUS_GLOBAL_CONFIG_ID = "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f";
246
+ declare const TESTNET_CETUS_GLOBAL_CONFIG_ID = "0x6f4149091a5aea0e818e7243a13adcfb403842d670b9a2089de058512620687a";
247
+ declare const ZERO: BN;
248
+ declare const ONE: BN;
249
+ declare const TWO: BN;
250
+ declare const U128: BN;
251
+ declare const U64_MAX_BN: BN;
252
+ declare const U64_MAX = "18446744073709551615";
253
+ declare const MAINNET_FLOWX_AMM_CONTAINER_ID = "0xb65dcbf63fd3ad5d0ebfbf334780dc9f785eff38a4459e37ab08fa79576ee511";
254
+ declare const TESTNET_FLOWX_AMM_CONTAINER_ID = "";
255
+ declare const TURBOS_VERSIONED = "0xf1cf0e81048df168ebeb1b8030fad24b3e0b53ae827c25053fff0779c1445b6f";
256
+ declare const MAINNET_AFTERMATH_REGISTRY_ID = "0xfcc774493db2c45c79f688f88d28023a3e7d98e4ee9f48bbf5c7990f651577ae";
257
+ declare const TESTNET_AFTERMATH_REGISTRY_ID = "";
258
+ declare const MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID = "0xf194d9b1bcad972e45a7dd67dd49b3ee1e3357a00a50850c52cd51bb450e13b4";
259
+ declare const TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID = "";
260
+ declare const MAINNET_AFTERMATH_TREASURY_ID = "0x28e499dff5e864a2eafe476269a4f5035f1c16f338da7be18b103499abf271ce";
261
+ declare const TESTNET_AFTERMATH_TREASURY_ID = "";
262
+ declare const MAINNET_AFTERMATH_INSURANCE_FUND_ID = "0xf0c40d67b078000e18032334c3325c47b9ec9f3d9ae4128be820d54663d14e3b";
263
+ declare const TESTNET_AFTERMATH_INSURANCE_FUND_ID = "";
264
+ declare const MAINNET_AFTERMATH_REFERRAL_VAULT_ID = "0x35d35b0e5b177593d8c3a801462485572fc30861e6ce96a55af6dc4730709278";
265
+ declare const TESTNET_AFTERMATH_REFERRAL_VAULT_ID = "";
266
+
267
+ export { AFTERMATH_AMM, AFTERMATH_MODULE, AGGREGATOR, AggregatorClient, AggregatorConfig, type AggregatorResponse, type BuildRouterSwapParams, CETUS_DEX, CETUS_MODULE, CETUS_PUBLISHED_AT, CHECK_COINS_THRESHOLD_FUNC, CLOCK_ADDRESS, CoinInfoAddress, CoinStoreAddress, DEEPBOOK_CLOB_V2_MODULE, DEEPBOOK_CUSTODIAN_V2_MODULE, DEEPBOOK_DEX, DEEPBOOK_MODULE, DEEPBOOK_PACKAGE_ID, DEEPBOOK_PUBLISHED_AT, ENV, type ExtendedDetails, FLOWX_AMM, FLOWX_AMM_MODULE, type FindRouterParams, FlashSwapA2BFunc, FlashSwapB2AFunc, FlashSwapFunc, FlashSwapWithPartnerA2BFunc, FlashSwapWithPartnerB2AFunc, FlashSwapWithPartnerFunc, INTEGRATE, JOIN_FUNC, KRIYA_DEX, KRIYA_MODULE, MAINNET_AFTERMATH_INSURANCE_FUND_ID, MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, MAINNET_AFTERMATH_REFERRAL_VAULT_ID, MAINNET_AFTERMATH_REGISTRY_ID, MAINNET_AFTERMATH_TREASURY_ID, MAINNET_CETUS_GLOBAL_CONFIG_ID, MAINNET_FLOWX_AMM_CONTAINER_ID, ONE, PAY_MODULE, POOL_MODULT, type Package, type Path, REPAY_FLASH_SWAP_A2B_FUNC, REPAY_FLASH_SWAP_B2A_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC, RepayFalshSwapFunc, RepayFlashSwapWithPartnerFunc, type Router, type RouterData, SWAP_A2B_FUNC, SWAP_B2A_FUNC, SuiZeroCoinFn, type SwapInPoolsParams, type SwapInPoolsResult, TESTNET_AFTERMATH_INSURANCE_FUND_ID, TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, TESTNET_AFTERMATH_REFERRAL_VAULT_ID, TESTNET_AFTERMATH_REGISTRY_ID, TESTNET_AFTERMATH_TREASURY_ID, TESTNET_CETUS_GLOBAL_CONFIG_ID, TESTNET_FLOWX_AMM_CONTAINER_ID, TRANSFER_ACCOUNT_CAP, TRANSFER_OR_DESTORY_COIN_FUNC, TURBOS_DEX, TURBOS_MODULE, TURBOS_VERSIONED, TWO, U128, U64_MAX, U64_MAX_BN, UTILS_MODULE, ZERO, composeType, createTarget, expectInputRouterSwap, expectOutputRouterSwap, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, isSortedSymbols, normalizeCoinType, patchFixSuiObjectId };