@cetusprotocol/aggregator-sdk 0.0.7 → 0.1.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.
Files changed (57) hide show
  1. package/dist/index.d.mts +98 -102
  2. package/dist/index.d.ts +98 -102
  3. package/dist/index.js +1228 -1556
  4. package/dist/index.mjs +1215 -1543
  5. package/dist/src/api.d.ts +53 -0
  6. package/dist/src/client.d.ts +38 -65
  7. package/dist/src/const.d.ts +0 -9
  8. package/dist/src/index.d.ts +9 -5
  9. package/dist/src/transaction/afsui.d.ts +10 -0
  10. package/dist/src/transaction/aftermath.d.ts +13 -24
  11. package/dist/src/transaction/cetus.d.ts +9 -33
  12. package/dist/src/transaction/deepbook_v2.d.ts +14 -0
  13. package/dist/src/transaction/flowx_v2.d.ts +7 -0
  14. package/dist/src/transaction/haedal.d.ts +6 -0
  15. package/dist/src/transaction/index.d.ts +6 -1
  16. package/dist/src/transaction/kriya_v2.d.ts +6 -0
  17. package/dist/src/transaction/kriya_v3.d.ts +7 -0
  18. package/dist/src/transaction/swap.d.ts +1 -2
  19. package/dist/src/transaction/turbos.d.ts +7 -22
  20. package/dist/src/transaction/volo.d.ts +8 -0
  21. package/dist/src/utils/coin.d.ts +9 -0
  22. package/dist/{src → tests}/test_data.test.d.ts +1 -0
  23. package/package.json +2 -2
  24. package/src/api.ts +144 -0
  25. package/src/client.ts +295 -239
  26. package/src/const.ts +0 -13
  27. package/src/index.ts +10 -5
  28. package/src/transaction/afsui.ts +60 -0
  29. package/src/transaction/aftermath.ts +71 -124
  30. package/src/transaction/cetus.ts +87 -258
  31. package/src/transaction/deepbook_v2.ts +122 -0
  32. package/src/transaction/flowx_v2.ts +42 -0
  33. package/src/transaction/haedal.ts +41 -0
  34. package/src/transaction/index.ts +17 -1
  35. package/src/transaction/kriya_v2.ts +38 -0
  36. package/src/transaction/kriya_v3.ts +46 -0
  37. package/src/transaction/swap.ts +17 -31
  38. package/src/transaction/turbos.ts +40 -99
  39. package/src/transaction/volo.ts +52 -0
  40. package/src/utils/coin.ts +91 -6
  41. package/src/utils/transaction.ts +1 -1
  42. package/tests/router.test.ts +127 -81
  43. package/{src → tests}/test_data.test.ts +2 -0
  44. package/dist/src/config.d.ts +0 -26
  45. package/dist/src/transaction/common.d.ts +0 -12
  46. package/dist/src/transaction/deepbook.d.ts +0 -21
  47. package/dist/src/transaction/flowx.d.ts +0 -20
  48. package/dist/src/transaction/kriya.d.ts +0 -21
  49. package/dist/src/transaction/router.d.ts +0 -6
  50. package/dist/src/utils/account_cap.d.ts +0 -7
  51. package/src/config.ts +0 -65
  52. package/src/transaction/common.ts +0 -174
  53. package/src/transaction/deepbook.ts +0 -126
  54. package/src/transaction/flowx.ts +0 -97
  55. package/src/transaction/kriya.ts +0 -77
  56. package/src/transaction/router.ts +0 -341
  57. package/src/utils/account_cap.ts +0 -62
package/dist/index.d.mts CHANGED
@@ -1,36 +1,9 @@
1
1
  import * as _mysten_sui_client from '@mysten/sui/client';
2
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';
3
+ import { TransactionObjectArgument, Transaction } from '@mysten/sui/transactions';
4
+ import { Signer } from '@mysten/sui/cryptography';
6
5
  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
- }
6
+ import Decimal from 'decimal.js';
34
7
 
35
8
  /**
36
9
  * Represents a SUI address, which is a string.
@@ -87,68 +60,33 @@ type CoinAsset = {
87
60
  balance: bigint;
88
61
  };
89
62
 
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 RouterError = {
114
- code: number;
115
- msg: string;
116
- };
117
- type RouterData = {
118
- amountIn: BN;
119
- amountOut: BN;
120
- routes: Router[];
121
- insufficientLiquidity: boolean;
122
- error?: RouterError;
123
- };
124
- type AggregatorResponse = {
125
- code: number;
126
- msg: string;
127
- data: RouterData;
128
- };
63
+ declare const CETUS = "CETUS";
64
+ declare const DEEPBOOKV2 = "DEEPBOOK";
65
+ declare const KRIYA = "KRIYA";
66
+ declare const FLOWXV2 = "FLOWX";
67
+ declare const KRIYAV3 = "KRIYAV3";
68
+ declare const TURBOS = "TURBOS";
69
+ declare const AFTERMATH = "AFTERMATH";
70
+ declare const HAEDAL = "HAEDAL";
71
+ declare const VOLO = "VOLO";
72
+ declare const AFSUI = "AFSUI";
129
73
  type BuildRouterSwapParams = {
130
74
  routers: Router[];
131
- amountIn: BN;
132
- amountOut: BN;
133
75
  byAmountIn: boolean;
76
+ inputCoin: TransactionObjectArgument;
134
77
  slippage: number;
135
- fromCoinType: string;
136
- targetCoinType: string;
78
+ txb: Transaction;
79
+ partner?: string;
80
+ };
81
+ type BuildFastRouterSwapParams = {
82
+ routers: Router[];
83
+ byAmountIn: boolean;
84
+ slippage: number;
85
+ txb: Transaction;
137
86
  partner?: string;
138
87
  isMergeTragetCoin?: boolean;
139
88
  refreshAllCoins?: boolean;
140
89
  };
141
- interface FindRouterParams {
142
- from: string;
143
- target: string;
144
- amount: BN;
145
- byAmountIn: boolean;
146
- depth: number | null;
147
- splitAlgorithm: string | null;
148
- splitFactor: number | null;
149
- splitCount: number | null;
150
- providers: string[] | null;
151
- }
152
90
  interface SwapInPoolsParams {
153
91
  from: string;
154
92
  target: string;
@@ -161,23 +99,33 @@ interface SwapInPoolsResult {
161
99
  routeData?: RouterData;
162
100
  }
163
101
  declare class AggregatorClient {
164
- private config;
165
- private wallet;
166
- private client;
102
+ endpoint: string;
103
+ signer: string;
104
+ client: SuiClient;
105
+ env: Env;
167
106
  private allCoins;
168
- constructor(config: AggregatorConfig);
107
+ constructor(endpoint: string, signer: string, client: SuiClient, env: Env);
169
108
  getAllCoins(): Promise<CoinAsset[]>;
170
- findRouter(fromRouterParams: FindRouterParams): Promise<RouterData | null>;
109
+ findRouters(params: FindRouterParams): Promise<RouterData | null>;
110
+ expectInputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], amountOutLimit: BN, partner?: string): Promise<TransactionObjectArgument>;
111
+ expectOutputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], partner?: string): Promise<TransactionObjectArgument>;
171
112
  swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResult | null>;
172
- routerSwap(params: BuildRouterSwapParams): Promise<Transaction>;
113
+ routerSwap(params: BuildRouterSwapParams): Promise<TransactionObjectArgument>;
114
+ fastRouterSwap(params: BuildFastRouterSwapParams): Promise<void>;
115
+ publishedAt(): string;
116
+ transferOrDestoryCoin(txb: Transaction, coin: TransactionObjectArgument, coinType: string): void;
117
+ checkCoinThresholdAndMergeCoin(txb: Transaction, coins: TransactionObjectArgument[], coinType: string, amountLimit: BN): TransactionObjectArgument;
118
+ newDex(provider: string, partner?: string): Dex;
173
119
  signAndExecuteTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
174
120
  devInspectTransactionBlock(txb: Transaction): Promise<_mysten_sui_client.DevInspectResults>;
175
121
  sendTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
176
122
  }
177
123
  declare function parseRouterResponse(data: any): RouterData;
178
124
 
179
- declare function expectInputRouterSwap(client: SuiClient, params: BuildRouterSwapParams, txb: Transaction, fromCoin: TransactionObjectArgument, config: AggregatorConfig, partner?: string): Promise<TransactionObjectArgument[]>;
180
- declare function expectOutputRouterSwap(params: BuildRouterSwapParams, txb: Transaction, fromCoin: TransactionObjectArgument, config: AggregatorConfig, partner?: string): Promise<TransactionObjectArgument[]>;
125
+ declare const CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
126
+ interface Dex {
127
+ swap(client: AggregatorClient, ptb: Transaction, path: Path, inputCoin: TransactionObjectArgument): Promise<TransactionObjectArgument>;
128
+ }
181
129
 
182
130
  declare function isSortedSymbols(symbolX: string, symbolY: string): boolean;
183
131
  declare function composeType(address: string, generics: SuiAddress[]): SuiAddress;
@@ -198,7 +146,6 @@ declare function createTarget(packageName: string, moduleName: string, functionN
198
146
  /**
199
147
  * The address representing the clock in the system.
200
148
  */
201
- declare const CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
202
149
  /**
203
150
  * The address for CoinInfo module.
204
151
  */
@@ -208,14 +155,6 @@ declare const CoinInfoAddress = "0x1::coin::CoinInfo";
208
155
  */
209
156
  declare const CoinStoreAddress = "0x1::coin::CoinStore";
210
157
  declare const SuiZeroCoinFn = "0x2::coin::zero";
211
- declare const AGGREGATOR = "aggregator";
212
- declare const CETUS_DEX = "CETUS";
213
- declare const DEEPBOOK_DEX = "DEEPBOOK";
214
- declare const KRIYA_DEX = "KRIYA";
215
- declare const FLOWX_AMM = "FLOWX";
216
- declare const TURBOS_DEX = "TURBOS";
217
- declare const AFTERMATH_AMM = "AFTERMATH";
218
- declare const INTEGRATE = "integrate";
219
158
  declare const CETUS_MODULE = "cetus";
220
159
  declare const DEEPBOOK_MODULE = "deepbook";
221
160
  declare const KRIYA_MODULE = "kriya";
@@ -271,4 +210,61 @@ declare const TESTNET_AFTERMATH_INSURANCE_FUND_ID = "";
271
210
  declare const MAINNET_AFTERMATH_REFERRAL_VAULT_ID = "0x35d35b0e5b177593d8c3a801462485572fc30861e6ce96a55af6dc4730709278";
272
211
  declare const TESTNET_AFTERMATH_REFERRAL_VAULT_ID = "";
273
212
 
274
- 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, type RouterError, SWAP_A2B_FUNC, SWAP_B2A_FUNC, SuiZeroCoinFn, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, 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, parseRouterResponse, patchFixSuiObjectId };
213
+ interface FindRouterParams {
214
+ from: string;
215
+ target: string;
216
+ amount: BN;
217
+ byAmountIn: boolean;
218
+ depth?: number;
219
+ splitAlgorithm?: string;
220
+ splitFactor?: number;
221
+ splitCount?: number;
222
+ providers?: string[];
223
+ }
224
+ type ExtendedDetails = {
225
+ aftermathPoolFlatness?: number;
226
+ aftermathLpSupplyType?: string;
227
+ turbosFeeType?: string;
228
+ };
229
+ type Path = {
230
+ id: string;
231
+ direction: boolean;
232
+ provider: string;
233
+ from: string;
234
+ target: string;
235
+ feeRate: number;
236
+ amountIn: number;
237
+ amountOut: number;
238
+ extendedDetails?: ExtendedDetails;
239
+ version?: string;
240
+ };
241
+ type Router = {
242
+ path: Path[];
243
+ amountIn: BN;
244
+ amountOut: BN;
245
+ initialPrice: Decimal;
246
+ };
247
+ type RouterError = {
248
+ code: number;
249
+ msg: string;
250
+ };
251
+ type RouterData = {
252
+ amountIn: BN;
253
+ amountOut: BN;
254
+ routes: Router[];
255
+ insufficientLiquidity: boolean;
256
+ error?: RouterError;
257
+ };
258
+ type AggregatorResponse = {
259
+ code: number;
260
+ msg: string;
261
+ data: RouterData;
262
+ };
263
+ declare function getRouterResult(endpoint: string, params: FindRouterParams): Promise<RouterData | null>;
264
+
265
+ declare enum Env {
266
+ Mainnet = 0,
267
+ Testnet = 1
268
+ }
269
+
270
+ export { AFSUI, AFTERMATH, AFTERMATH_MODULE, AggregatorClient, type AggregatorResponse, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CETUS_MODULE, CETUS_PUBLISHED_AT, CHECK_COINS_THRESHOLD_FUNC, CLOCK_ADDRESS, CoinInfoAddress, CoinStoreAddress, DEEPBOOKV2, DEEPBOOK_CLOB_V2_MODULE, DEEPBOOK_CUSTODIAN_V2_MODULE, DEEPBOOK_MODULE, DEEPBOOK_PACKAGE_ID, DEEPBOOK_PUBLISHED_AT, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWX_AMM_MODULE, type FindRouterParams, FlashSwapA2BFunc, FlashSwapB2AFunc, FlashSwapFunc, FlashSwapWithPartnerA2BFunc, FlashSwapWithPartnerB2AFunc, FlashSwapWithPartnerFunc, HAEDAL, JOIN_FUNC, KRIYA, KRIYAV3, 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 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, type RouterError, SWAP_A2B_FUNC, SWAP_B2A_FUNC, SuiZeroCoinFn, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, 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, TURBOS_MODULE, TURBOS_VERSIONED, TWO, U128, U64_MAX, U64_MAX_BN, UTILS_MODULE, VOLO, ZERO, composeType, createTarget, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId };
package/dist/index.d.ts CHANGED
@@ -1,36 +1,9 @@
1
1
  import * as _mysten_sui_client from '@mysten/sui/client';
2
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';
3
+ import { TransactionObjectArgument, Transaction } from '@mysten/sui/transactions';
4
+ import { Signer } from '@mysten/sui/cryptography';
6
5
  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
- }
6
+ import Decimal from 'decimal.js';
34
7
 
35
8
  /**
36
9
  * Represents a SUI address, which is a string.
@@ -87,68 +60,33 @@ type CoinAsset = {
87
60
  balance: bigint;
88
61
  };
89
62
 
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 RouterError = {
114
- code: number;
115
- msg: string;
116
- };
117
- type RouterData = {
118
- amountIn: BN;
119
- amountOut: BN;
120
- routes: Router[];
121
- insufficientLiquidity: boolean;
122
- error?: RouterError;
123
- };
124
- type AggregatorResponse = {
125
- code: number;
126
- msg: string;
127
- data: RouterData;
128
- };
63
+ declare const CETUS = "CETUS";
64
+ declare const DEEPBOOKV2 = "DEEPBOOK";
65
+ declare const KRIYA = "KRIYA";
66
+ declare const FLOWXV2 = "FLOWX";
67
+ declare const KRIYAV3 = "KRIYAV3";
68
+ declare const TURBOS = "TURBOS";
69
+ declare const AFTERMATH = "AFTERMATH";
70
+ declare const HAEDAL = "HAEDAL";
71
+ declare const VOLO = "VOLO";
72
+ declare const AFSUI = "AFSUI";
129
73
  type BuildRouterSwapParams = {
130
74
  routers: Router[];
131
- amountIn: BN;
132
- amountOut: BN;
133
75
  byAmountIn: boolean;
76
+ inputCoin: TransactionObjectArgument;
134
77
  slippage: number;
135
- fromCoinType: string;
136
- targetCoinType: string;
78
+ txb: Transaction;
79
+ partner?: string;
80
+ };
81
+ type BuildFastRouterSwapParams = {
82
+ routers: Router[];
83
+ byAmountIn: boolean;
84
+ slippage: number;
85
+ txb: Transaction;
137
86
  partner?: string;
138
87
  isMergeTragetCoin?: boolean;
139
88
  refreshAllCoins?: boolean;
140
89
  };
141
- interface FindRouterParams {
142
- from: string;
143
- target: string;
144
- amount: BN;
145
- byAmountIn: boolean;
146
- depth: number | null;
147
- splitAlgorithm: string | null;
148
- splitFactor: number | null;
149
- splitCount: number | null;
150
- providers: string[] | null;
151
- }
152
90
  interface SwapInPoolsParams {
153
91
  from: string;
154
92
  target: string;
@@ -161,23 +99,33 @@ interface SwapInPoolsResult {
161
99
  routeData?: RouterData;
162
100
  }
163
101
  declare class AggregatorClient {
164
- private config;
165
- private wallet;
166
- private client;
102
+ endpoint: string;
103
+ signer: string;
104
+ client: SuiClient;
105
+ env: Env;
167
106
  private allCoins;
168
- constructor(config: AggregatorConfig);
107
+ constructor(endpoint: string, signer: string, client: SuiClient, env: Env);
169
108
  getAllCoins(): Promise<CoinAsset[]>;
170
- findRouter(fromRouterParams: FindRouterParams): Promise<RouterData | null>;
109
+ findRouters(params: FindRouterParams): Promise<RouterData | null>;
110
+ expectInputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], amountOutLimit: BN, partner?: string): Promise<TransactionObjectArgument>;
111
+ expectOutputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], partner?: string): Promise<TransactionObjectArgument>;
171
112
  swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResult | null>;
172
- routerSwap(params: BuildRouterSwapParams): Promise<Transaction>;
113
+ routerSwap(params: BuildRouterSwapParams): Promise<TransactionObjectArgument>;
114
+ fastRouterSwap(params: BuildFastRouterSwapParams): Promise<void>;
115
+ publishedAt(): string;
116
+ transferOrDestoryCoin(txb: Transaction, coin: TransactionObjectArgument, coinType: string): void;
117
+ checkCoinThresholdAndMergeCoin(txb: Transaction, coins: TransactionObjectArgument[], coinType: string, amountLimit: BN): TransactionObjectArgument;
118
+ newDex(provider: string, partner?: string): Dex;
173
119
  signAndExecuteTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
174
120
  devInspectTransactionBlock(txb: Transaction): Promise<_mysten_sui_client.DevInspectResults>;
175
121
  sendTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
176
122
  }
177
123
  declare function parseRouterResponse(data: any): RouterData;
178
124
 
179
- declare function expectInputRouterSwap(client: SuiClient, params: BuildRouterSwapParams, txb: Transaction, fromCoin: TransactionObjectArgument, config: AggregatorConfig, partner?: string): Promise<TransactionObjectArgument[]>;
180
- declare function expectOutputRouterSwap(params: BuildRouterSwapParams, txb: Transaction, fromCoin: TransactionObjectArgument, config: AggregatorConfig, partner?: string): Promise<TransactionObjectArgument[]>;
125
+ declare const CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
126
+ interface Dex {
127
+ swap(client: AggregatorClient, ptb: Transaction, path: Path, inputCoin: TransactionObjectArgument): Promise<TransactionObjectArgument>;
128
+ }
181
129
 
182
130
  declare function isSortedSymbols(symbolX: string, symbolY: string): boolean;
183
131
  declare function composeType(address: string, generics: SuiAddress[]): SuiAddress;
@@ -198,7 +146,6 @@ declare function createTarget(packageName: string, moduleName: string, functionN
198
146
  /**
199
147
  * The address representing the clock in the system.
200
148
  */
201
- declare const CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
202
149
  /**
203
150
  * The address for CoinInfo module.
204
151
  */
@@ -208,14 +155,6 @@ declare const CoinInfoAddress = "0x1::coin::CoinInfo";
208
155
  */
209
156
  declare const CoinStoreAddress = "0x1::coin::CoinStore";
210
157
  declare const SuiZeroCoinFn = "0x2::coin::zero";
211
- declare const AGGREGATOR = "aggregator";
212
- declare const CETUS_DEX = "CETUS";
213
- declare const DEEPBOOK_DEX = "DEEPBOOK";
214
- declare const KRIYA_DEX = "KRIYA";
215
- declare const FLOWX_AMM = "FLOWX";
216
- declare const TURBOS_DEX = "TURBOS";
217
- declare const AFTERMATH_AMM = "AFTERMATH";
218
- declare const INTEGRATE = "integrate";
219
158
  declare const CETUS_MODULE = "cetus";
220
159
  declare const DEEPBOOK_MODULE = "deepbook";
221
160
  declare const KRIYA_MODULE = "kriya";
@@ -271,4 +210,61 @@ declare const TESTNET_AFTERMATH_INSURANCE_FUND_ID = "";
271
210
  declare const MAINNET_AFTERMATH_REFERRAL_VAULT_ID = "0x35d35b0e5b177593d8c3a801462485572fc30861e6ce96a55af6dc4730709278";
272
211
  declare const TESTNET_AFTERMATH_REFERRAL_VAULT_ID = "";
273
212
 
274
- 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, type RouterError, SWAP_A2B_FUNC, SWAP_B2A_FUNC, SuiZeroCoinFn, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, 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, parseRouterResponse, patchFixSuiObjectId };
213
+ interface FindRouterParams {
214
+ from: string;
215
+ target: string;
216
+ amount: BN;
217
+ byAmountIn: boolean;
218
+ depth?: number;
219
+ splitAlgorithm?: string;
220
+ splitFactor?: number;
221
+ splitCount?: number;
222
+ providers?: string[];
223
+ }
224
+ type ExtendedDetails = {
225
+ aftermathPoolFlatness?: number;
226
+ aftermathLpSupplyType?: string;
227
+ turbosFeeType?: string;
228
+ };
229
+ type Path = {
230
+ id: string;
231
+ direction: boolean;
232
+ provider: string;
233
+ from: string;
234
+ target: string;
235
+ feeRate: number;
236
+ amountIn: number;
237
+ amountOut: number;
238
+ extendedDetails?: ExtendedDetails;
239
+ version?: string;
240
+ };
241
+ type Router = {
242
+ path: Path[];
243
+ amountIn: BN;
244
+ amountOut: BN;
245
+ initialPrice: Decimal;
246
+ };
247
+ type RouterError = {
248
+ code: number;
249
+ msg: string;
250
+ };
251
+ type RouterData = {
252
+ amountIn: BN;
253
+ amountOut: BN;
254
+ routes: Router[];
255
+ insufficientLiquidity: boolean;
256
+ error?: RouterError;
257
+ };
258
+ type AggregatorResponse = {
259
+ code: number;
260
+ msg: string;
261
+ data: RouterData;
262
+ };
263
+ declare function getRouterResult(endpoint: string, params: FindRouterParams): Promise<RouterData | null>;
264
+
265
+ declare enum Env {
266
+ Mainnet = 0,
267
+ Testnet = 1
268
+ }
269
+
270
+ export { AFSUI, AFTERMATH, AFTERMATH_MODULE, AggregatorClient, type AggregatorResponse, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CETUS_MODULE, CETUS_PUBLISHED_AT, CHECK_COINS_THRESHOLD_FUNC, CLOCK_ADDRESS, CoinInfoAddress, CoinStoreAddress, DEEPBOOKV2, DEEPBOOK_CLOB_V2_MODULE, DEEPBOOK_CUSTODIAN_V2_MODULE, DEEPBOOK_MODULE, DEEPBOOK_PACKAGE_ID, DEEPBOOK_PUBLISHED_AT, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWX_AMM_MODULE, type FindRouterParams, FlashSwapA2BFunc, FlashSwapB2AFunc, FlashSwapFunc, FlashSwapWithPartnerA2BFunc, FlashSwapWithPartnerB2AFunc, FlashSwapWithPartnerFunc, HAEDAL, JOIN_FUNC, KRIYA, KRIYAV3, 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 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, type RouterError, SWAP_A2B_FUNC, SWAP_B2A_FUNC, SuiZeroCoinFn, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, 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, TURBOS_MODULE, TURBOS_VERSIONED, TWO, U128, U64_MAX, U64_MAX_BN, UTILS_MODULE, VOLO, ZERO, composeType, createTarget, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId };