@cetusprotocol/aggregator-sdk 0.15.0 → 1.0.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 CHANGED
@@ -1,258 +1,10 @@
1
1
  import * as _mysten_sui_client from '@mysten/sui/client';
2
- import { SuiClient } from '@mysten/sui/client';
3
- import { TransactionObjectArgument, Transaction } from '@mysten/sui/transactions';
4
- import { Signer } from '@mysten/sui/cryptography';
2
+ import { SuiClient, DevInspectResults, SuiMoveObject } from '@mysten/sui/client';
3
+ import { Transaction, TransactionObjectArgument, TransactionArgument } from '@mysten/sui/transactions';
5
4
  import BN from 'bn.js';
6
5
  import Decimal from 'decimal.js';
7
- import { SuiPriceServiceConnection } from '@pythnetwork/pyth-sui-js';
8
-
9
- /**
10
- * Represents a SUI address, which is a string.
11
- */
12
- type SuiAddress = string;
13
- /**
14
- * Represents a SUI object identifier, which is a string.
15
- */
16
- type SuiObjectIdType = string;
17
- /**
18
- * Represents a SUI struct tag.
19
- */
20
- type SuiStructTag = {
21
- /**
22
- * The full address of the struct.
23
- */
24
- full_address: string;
25
- /**
26
- * The source address of the struct.
27
- */
28
- source_address: string;
29
- /**
30
- * The address of the struct.
31
- */
32
- address: SuiAddress;
33
- /**
34
- * The module to which the struct belongs.
35
- */
36
- module: string;
37
- /**
38
- * The name of the struct.
39
- */
40
- name: string;
41
- /**
42
- * An array of type arguments (SUI addresses) for the struct.
43
- */
44
- type_arguments: SuiAddress[];
45
- };
46
- /**
47
- * Represents a coin asset with address, object ID, and balance information.
48
- */
49
- type CoinAsset = {
50
- /**
51
- * The address type of the coin asset.
52
- */
53
- coinAddress: SuiAddress;
54
- /**
55
- * The object identifier of the coin asset.
56
- */
57
- coinObjectId: SuiObjectIdType;
58
- /**
59
- * The balance amount of the coin asset.
60
- */
61
- balance: bigint;
62
- };
63
-
64
- declare const CETUS = "CETUS";
65
- declare const DEEPBOOKV2 = "DEEPBOOK";
66
- declare const KRIYA = "KRIYA";
67
- declare const FLOWXV2 = "FLOWX";
68
- declare const FLOWXV3 = "FLOWXV3";
69
- declare const KRIYAV3 = "KRIYAV3";
70
- declare const TURBOS = "TURBOS";
71
- declare const AFTERMATH = "AFTERMATH";
72
- declare const HAEDAL = "HAEDAL";
73
- declare const VOLO = "VOLO";
74
- declare const AFSUI = "AFSUI";
75
- declare const BLUEMOVE = "BLUEMOVE";
76
- declare const DEEPBOOKV3 = "DEEPBOOKV3";
77
- declare const SCALLOP = "SCALLOP";
78
- declare const SUILEND = "SUILEND";
79
- declare const BLUEFIN = "BLUEFIN";
80
- declare const HAEDALPMM = "HAEDALPMM";
81
- declare const ALPHAFI = "ALPHAFI";
82
- declare const SPRINGSUI = "SPRINGSUI";
83
- declare const STEAMM = "STEAMM";
84
- declare const METASTABLE = "METASTABLE";
85
- declare const OBRIC = "OBRIC";
86
- declare const HAWAL = "HAWAL";
87
- declare const STEAMM_OMM = "STEAMM_OMM";
88
- declare const MOMENTUM = "MOMENTUM";
89
- declare const STEAMM_OMM_V2 = "STEAMM_OMM_V2";
90
- declare const MAGMA = "MAGMA";
91
- declare const SEVENK = "SEVENK";
92
- declare const HAEDALHMMV2 = "HAEDALHMMV2";
93
- declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
94
- declare const ALL_DEXES: string[];
95
- type BuildRouterSwapParams = {
96
- routers: Router[];
97
- byAmountIn: boolean;
98
- inputCoin: TransactionObjectArgument;
99
- slippage: number;
100
- txb: Transaction;
101
- partner?: string;
102
- deepbookv3DeepFee?: TransactionObjectArgument;
103
- };
104
- type BuildFastRouterSwapParams = {
105
- routers: Router[];
106
- byAmountIn: boolean;
107
- slippage: number;
108
- txb: Transaction;
109
- partner?: string;
110
- refreshAllCoins?: boolean;
111
- payDeepFeeAmount?: number;
112
- };
113
- type BuildRouterSwapParamsV2 = {
114
- routers: RouterData;
115
- inputCoin: TransactionObjectArgument;
116
- slippage: number;
117
- txb: Transaction;
118
- partner?: string;
119
- deepbookv3DeepFee?: TransactionObjectArgument;
120
- };
121
- type BuildFastRouterSwapParamsV2 = {
122
- routers: RouterData;
123
- slippage: number;
124
- txb: Transaction;
125
- partner?: string;
126
- refreshAllCoins?: boolean;
127
- payDeepFeeAmount?: number;
128
- };
129
- interface SwapInPoolsParams {
130
- from: string;
131
- target: string;
132
- amount: BN;
133
- byAmountIn: boolean;
134
- pools: string[];
135
- }
136
- interface SwapInPoolsResult {
137
- isExceed: boolean;
138
- routeData?: RouterData;
139
- }
140
- declare function getAllProviders(): string[];
141
- /**
142
- * Get all providers excluding the specified ones
143
- * @param excludeProviders Array of provider names to exclude
144
- * @returns Filtered provider list
145
- */
146
- declare function getProvidersExcluding(excludeProviders: string[]): string[];
147
- /**
148
- * Get only the specified providers
149
- * @param includeProviders Array of provider names to include
150
- * @returns Filtered provider list
151
- */
152
- declare function getProvidersIncluding(includeProviders: string[]): string[];
153
- type AggregatorClientParams = {
154
- endpoint?: string;
155
- signer?: string;
156
- client?: SuiClient;
157
- env?: Env;
158
- pythUrls?: string[];
159
- apiKey?: string;
160
- partner?: string;
161
- overlayFeeRate?: number;
162
- overlayFeeReceiver?: string;
163
- };
164
- declare class AggregatorClient {
165
- endpoint: string;
166
- signer: string;
167
- client: SuiClient;
168
- env: Env;
169
- apiKey: string;
170
- private allCoins;
171
- private pythConnections;
172
- private pythClient;
173
- private overlayFeeRate;
174
- private overlayFeeReceiver;
175
- private partner?;
176
- private static readonly CONFIG;
177
- constructor(params: AggregatorClientParams);
178
- newPythClients(pythUrls: string[]): SuiPriceServiceConnection[];
179
- getCoins(coinType: string, refresh?: boolean): Promise<CoinAsset[]>;
180
- findRouters(params: FindRouterParams): Promise<RouterData | null>;
181
- executeFlexibleInputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], expectedAmountOut: string, amountLimit: string, pythPriceIDs: Map<string, string>, partner?: string, deepbookv3DeepFee?: TransactionObjectArgument, packages?: Map<string, string>): Promise<TransactionObjectArgument>;
182
- expectInputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], expectedAmountOut: string, amountLimit: string, pythPriceIDs: Map<string, string>, partner?: string, deepbookv3DeepFee?: TransactionObjectArgument, packages?: Map<string, string>): Promise<TransactionObjectArgument>;
183
- expectOutputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], partner?: string, packages?: Map<string, string>): Promise<TransactionObjectArgument>;
184
- swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResult | null>;
185
- routerSwap(params: BuildRouterSwapParams | BuildRouterSwapParamsV2): Promise<TransactionObjectArgument>;
186
- fixableRouterSwap(params: BuildRouterSwapParamsV2): Promise<TransactionObjectArgument>;
187
- fastRouterSwap(params: BuildFastRouterSwapParams | BuildFastRouterSwapParamsV2): Promise<void>;
188
- publishedAtV2(): string;
189
- publishedAtV2Extend(): string;
190
- publishedAtV2Extend2(): string;
191
- deepbookv3DeepFeeType(): string;
192
- transferOrDestoryCoin(txb: Transaction, coin: TransactionObjectArgument, coinType: string, aggregatorV2PublishedAt: string): void;
193
- checkCoinThresholdAndMergeCoin(txb: Transaction, coins: TransactionObjectArgument[], coinType: string, expectedAmountOut: string, threshold: string, aggregatorV2ExtendPublishedAt: string): TransactionObjectArgument;
194
- newDex(provider: string, pythPriceIDs: Map<string, string>, partner?: string): Dex;
195
- signAndExecuteTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
196
- devInspectTransactionBlock(txb: Transaction): Promise<_mysten_sui_client.DevInspectResults>;
197
- sendTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
198
- getDeepbookV3Config(): Promise<DeepbookV3Config | null>;
199
- updatePythPriceIDs(priceIDs: string[], txb: Transaction): Promise<Map<string, string>>;
200
- }
201
- declare function findPythPriceIDs(routes: Router[]): string[];
202
- declare function parseRouterResponse(data: any, byAmountIn: boolean): RouterData;
203
-
204
- declare const CLOCK_ADDRESS: string;
205
- declare const AGGREGATOR_V2 = "aggregator_v2";
206
- declare const AGGREGATOR_V2_EXTEND = "aggregator_v2_extend";
207
- declare const AGGREGATOR_V2_EXTEND2 = "aggregator_v2_extend2";
208
- declare function getAggregatorV2PublishedAt(aggregatorV2PublishedAt: string, packages?: Map<string, string> | Record<string, string>): string;
209
- declare function getAggregatorV2ExtendPublishedAt(aggregatorV2ExtendPublishedAt: string, packages?: Map<string, string> | Record<string, string>): string;
210
- declare function getAggregatorV2Extend2PublishedAt(aggregatorV2Extend2PublishedAt: string, packages?: Map<string, string> | Record<string, string>): string;
211
- interface Dex {
212
- swap(client: AggregatorClient, ptb: Transaction, path: Path, inputCoin: TransactionObjectArgument, packages?: Map<string, string>, deepbookv3DeepFee?: TransactionObjectArgument): Promise<TransactionObjectArgument>;
213
- }
214
-
215
- declare function isSortedSymbols(symbolX: string, symbolY: string): boolean;
216
- declare function composeType(address: string, generics: SuiAddress[]): SuiAddress;
217
- declare function composeType(address: string, struct: string, generics?: SuiAddress[]): SuiAddress;
218
- declare function composeType(address: string, module: string, struct: string, generics?: SuiAddress[]): SuiAddress;
219
- declare function extractAddressFromType(type: string): string;
220
- declare function extractStructTagFromType(type: string): SuiStructTag;
221
- declare function normalizeCoinType(coinType: string): string;
222
- declare function fixSuiObjectId(value: string): string;
223
- /**
224
- * Recursively traverses the given data object and patches any string values that represent Sui object IDs.
225
- *
226
- * @param {any} data - The data object to be patched.
227
- */
228
- declare function patchFixSuiObjectId(data: any): void;
229
- declare function createTarget(packageName: string, moduleName: string, functionName: string): `${string}::${string}::${string}`;
230
-
231
- declare const dealWithFastRouterSwapParamsForMsafe: (data: any) => any;
232
- declare const restituteMsafeFastRouterSwapParams: (data: any) => any;
233
-
234
- declare function processEndpoint(endpoint: string): string;
235
-
236
- declare function completionCoin(s: string): string;
237
- declare function compareCoins(coinA: string, coinB: string): boolean;
238
- declare function mintZeroCoin(txb: Transaction, coinType: string): TransactionObjectArgument;
239
- type BuildCoinResult = {
240
- targetCoin: TransactionObjectArgument;
241
- isMintZeroCoin: boolean;
242
- targetCoinAmount: number;
243
- };
244
- declare function buildInputCoin(txb: Transaction, allCoins: CoinAsset[], amount: bigint, coinType: string): BuildCoinResult;
245
-
246
- declare function printTransaction(tx: Transaction, isPrint?: boolean): Promise<void>;
247
- declare function checkInvalidSuiAddress(address: string): boolean;
248
-
249
- declare const ZERO: BN;
250
- declare const ONE: BN;
251
- declare const TWO: BN;
252
- declare const U128: BN;
253
- declare const U64_MAX_BN: BN;
254
- declare const U64_MAX = "18446744073709551615";
255
- declare const TEN_POW_NINE = 1000000000;
6
+ import { SuiPriceServiceConnection, SuiPythClient } from '@pythnetwork/pyth-sui-js';
7
+ import { Signer } from '@mysten/sui/cryptography';
256
8
 
257
9
  interface FindRouterParams {
258
10
  from: string;
@@ -273,43 +25,44 @@ interface PreSwapLpChangeParams {
273
25
  deltaLiquidity: number;
274
26
  }
275
27
  type ExtendedDetails = {
276
- aftermathPoolFlatness?: number;
277
- aftermathLpSupplyType?: string;
278
- turbosFeeType?: string;
28
+ aftermath_pool_flatness?: number;
29
+ aftermath_lp_supply_type?: string;
30
+ turbos_fee_type?: string;
279
31
  afterSqrtPrice?: string;
280
32
  deepbookv3DeepFee?: number;
281
33
  scallopScoinTreasury?: string;
282
- haedalPmmBasePriceSeed?: string;
283
- haedalPmmQuotePriceSeed?: string;
284
- haedalHmmV2BasePriceSeed?: string;
285
- steammBankA?: string;
286
- steammBankB?: string;
287
- steammLendingMarket?: string;
288
- steammLendingMarketType?: string;
289
- steammBCoinAType?: string;
290
- steammBCoinBType?: string;
291
- steammLPToken?: string;
292
- steammOracleRegistryId?: string;
293
- steammOraclePythPriceSeedA?: string;
294
- steammOraclePythPriceSeedB?: string;
295
- steammOracleIndexA?: number;
296
- steammOracleIndexB?: number;
297
- metastablePriceSeed?: string;
298
- metastableETHPriceSeed?: string;
299
- metastableWhitelistedAppId?: string;
300
- metastableCreateCapPkgId?: string;
301
- metastableCreateCapModule?: string;
302
- metastableCreateCapAllTypeParams?: boolean;
303
- metastableRegistryId?: string;
304
- obricCoinAPriceSeed?: string;
305
- obricCoinBPriceSeed?: string;
306
- obricCoinAPriceId?: string;
307
- obricCoinBPriceId?: string;
308
- sevenkCoinAPriceSeed?: string;
309
- sevenkCoinBPriceSeed?: string;
310
- sevenkCoinAOracleId?: string;
311
- sevenkCoinBOracleId?: string;
312
- sevenkLPCapType?: string;
34
+ scallop_scoin_treasury?: string;
35
+ haedal_pmm_base_price_seed?: string;
36
+ haedal_pmm_quote_price_seed?: string;
37
+ haedalhmmv2_base_price_seed?: string;
38
+ steamm_bank_a?: string;
39
+ steamm_bank_b?: string;
40
+ steamm_lending_market?: string;
41
+ steamm_lending_market_type?: string;
42
+ steamm_btoken_a_type?: string;
43
+ steamm_btoken_b_type?: string;
44
+ steamm_lp_token_type?: string;
45
+ steamm_oracle_registry_id?: string;
46
+ steamm_oracle_pyth_price_seed_a?: string;
47
+ steamm_oracle_pyth_price_seed_b?: string;
48
+ steamm_oracle_index_a?: number;
49
+ steamm_oracle_index_b?: number;
50
+ metastable_price_seed?: string;
51
+ metastable_eth_price_seed?: string;
52
+ metastable_whitelisted_app_id?: string;
53
+ metastable_create_cap_pkg_id?: string;
54
+ metastable_create_cap_module?: string;
55
+ metastable_create_cap_all_type_params?: boolean;
56
+ metastable_registry_id?: string;
57
+ obric_coin_a_price_seed?: string;
58
+ obric_coin_b_price_seed?: string;
59
+ obric_coin_a_price_id?: string;
60
+ obric_coin_b_price_id?: string;
61
+ sevenk_coin_a_price_seed?: string;
62
+ sevenk_coin_b_price_seed?: string;
63
+ sevenk_oracle_config_a?: string;
64
+ sevenk_oracle_config_b?: string;
65
+ sevenk_lp_cap_type?: string;
313
66
  };
314
67
  type Path = {
315
68
  id: string;
@@ -321,6 +74,7 @@ type Path = {
321
74
  amountIn: string;
322
75
  amountOut: string;
323
76
  version?: string;
77
+ publishedAt?: string;
324
78
  extendedDetails?: ExtendedDetails;
325
79
  };
326
80
  type Router = {
@@ -334,6 +88,7 @@ type RouterError = {
334
88
  msg: string;
335
89
  };
336
90
  type RouterData = {
91
+ quoteID?: string;
337
92
  amountIn: BN;
338
93
  amountOut: BN;
339
94
  byAmountIn: boolean;
@@ -345,12 +100,41 @@ type RouterData = {
345
100
  error?: RouterError;
346
101
  overlayFee?: number;
347
102
  };
103
+ type RouterDataV3 = {
104
+ quoteID?: string;
105
+ amountIn: BN;
106
+ amountOut: BN;
107
+ byAmountIn: boolean;
108
+ paths: Path[];
109
+ insufficientLiquidity: boolean;
110
+ deviationRatio?: number;
111
+ packages?: Map<string, string>;
112
+ totalDeepFee?: number;
113
+ error?: RouterError;
114
+ overlayFee?: number;
115
+ };
116
+ type FlattenedPath = {
117
+ path: Path;
118
+ isLastUseOfIntermediateToken: boolean;
119
+ };
120
+ type ProcessedRouterData = {
121
+ quoteID: string;
122
+ amountIn: BN;
123
+ amountOut: BN;
124
+ byAmountIn: boolean;
125
+ flattenedPaths: FlattenedPath[];
126
+ fromCoinType: string;
127
+ targetCoinType: string;
128
+ packages?: Map<string, string>;
129
+ totalDeepFee?: number;
130
+ error?: RouterError;
131
+ overlayFee?: number;
132
+ };
348
133
  type AggregatorResponse = {
349
134
  code: number;
350
135
  msg: string;
351
136
  data: RouterData;
352
137
  };
353
- declare function getRouterResult(endpoint: string, apiKey: string, params: FindRouterParams, overlayFee: number, overlayFeeReceiver: string): Promise<RouterData | null>;
354
138
  type DeepbookV3Config = {
355
139
  id: string;
356
140
  is_alternative_payment: boolean;
@@ -368,11 +152,767 @@ type DeepbookV3ConfigResponse = {
368
152
  msg: string;
369
153
  data: DeepbookV3Config;
370
154
  };
371
- declare function getDeepbookV3Config(endpoint: string): Promise<DeepbookV3ConfigResponse | null>;
372
-
373
- declare enum Env {
374
- Mainnet = 0,
375
- Testnet = 1
155
+ interface SwapInPoolsParams$1 {
156
+ from: string;
157
+ target: string;
158
+ amount: BN;
159
+ byAmountIn: boolean;
160
+ pools: string[];
161
+ }
162
+ interface SwapInPoolsResult {
163
+ isExceed: boolean;
164
+ routeData?: RouterData;
165
+ }
166
+ type BuildRouterSwapParams = {
167
+ routers: Router[];
168
+ amountIn: BN;
169
+ amountOut: BN;
170
+ byAmountIn: boolean;
171
+ slippage: number;
172
+ fromCoinType: string;
173
+ targetCoinType: string;
174
+ partner?: string;
175
+ isMergeTragetCoin?: boolean;
176
+ refreshAllCoins?: boolean;
177
+ };
178
+ type PathV2 = {
179
+ id: string;
180
+ a2b: boolean;
181
+ provider: string;
182
+ from: string;
183
+ target: string;
184
+ feeRate: number;
185
+ amountIn: number;
186
+ amountOut: number;
187
+ extendedDetails?: ExtendedDetails;
188
+ version?: string;
189
+ };
190
+ type RouterV2 = {
191
+ path: PathV2[];
192
+ amountIn: BN;
193
+ amountOut: BN;
194
+ initialPrice: Decimal;
195
+ };
196
+ type RouterDataV2 = {
197
+ amountIn: BN;
198
+ amountOut: BN;
199
+ routes: RouterV2[];
200
+ insufficientLiquidity: boolean;
201
+ };
202
+
203
+ type Package = {
204
+ packageName: string;
205
+ packageId: string;
206
+ publishedAt: string;
207
+ };
208
+ declare enum Env {
209
+ Mainnet = 0,
210
+ Testnet = 1
211
+ }
212
+ declare class AggregatorConfig {
213
+ private endpoint;
214
+ private fullNodeUrl;
215
+ private signer;
216
+ private env;
217
+ constructor(endpoint: string, fullNodeUrl: string, signer: string, env: Env);
218
+ getAggregatorUrl(): string;
219
+ getFullNodeUrl(): string;
220
+ getWallet(): string;
221
+ getENV(): Env;
222
+ }
223
+
224
+ declare function getRouterResult(endpoint: string, apiKey: string, params: FindRouterParams, overlayFee: number, overlayFeeReceiver: string): Promise<RouterDataV3 | null>;
225
+ declare function getDeepbookV3Config(endpoint: string): Promise<DeepbookV3ConfigResponse | null>;
226
+ declare function processFlattenRoutes(routerData: RouterDataV3, fixable?: boolean): ProcessedRouterData;
227
+
228
+ interface Extends {
229
+ deepbookv3DeepFee?: TransactionObjectArgument;
230
+ pythPriceIDs?: Map<string, string>;
231
+ }
232
+ interface DexRouter {
233
+ swap(txb: Transaction, flattenedPath: FlattenedPath, swapContext: TransactionObjectArgument, _extends?: Extends): void;
234
+ }
235
+
236
+ type BuildRouterSwapParamsV3 = {
237
+ router: RouterDataV3;
238
+ inputCoin: TransactionObjectArgument;
239
+ slippage: number;
240
+ txb: Transaction;
241
+ partner?: string;
242
+ deepbookv3DeepFee?: TransactionObjectArgument;
243
+ fixable?: boolean;
244
+ };
245
+ type BuildFastRouterSwapParamsV3 = {
246
+ router: RouterDataV3;
247
+ slippage: number;
248
+ txb: Transaction;
249
+ partner?: string;
250
+ refreshAllCoins?: boolean;
251
+ payDeepFeeAmount?: number;
252
+ };
253
+ interface SwapInPoolsParams {
254
+ from: string;
255
+ target: string;
256
+ amount: BN;
257
+ byAmountIn: boolean;
258
+ pools: string[];
259
+ }
260
+ interface SwapInPoolsResultV3 {
261
+ isExceed: boolean;
262
+ routeData?: RouterDataV3;
263
+ }
264
+ type AggregatorClientParams$1 = {
265
+ endpoint?: string;
266
+ signer?: string;
267
+ client?: SuiClient;
268
+ env?: Env;
269
+ pythUrls?: string[];
270
+ apiKey?: string;
271
+ partner?: string;
272
+ overlayFeeRate?: number;
273
+ overlayFeeReceiver?: string;
274
+ };
275
+ declare class AggregatorClient {
276
+ endpoint: string;
277
+ signer: string;
278
+ client: SuiClient;
279
+ env: Env;
280
+ apiKey: string;
281
+ protected pythConnections: SuiPriceServiceConnection[];
282
+ protected pythClient: SuiPythClient;
283
+ protected overlayFeeRate: number;
284
+ protected overlayFeeReceiver: string;
285
+ protected partner?: string;
286
+ private static readonly CONFIG;
287
+ constructor(params: AggregatorClientParams$1);
288
+ newPythClients(pythUrls: string[]): SuiPriceServiceConnection[];
289
+ deepbookv3DeepFeeType(): string;
290
+ getOneCoinUsedToMerge(coinType: string): Promise<string | null>;
291
+ findRouters(params: FindRouterParams): Promise<RouterDataV3 | null>;
292
+ executeFlexibleInputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routerData: RouterDataV3, expectedAmountOut: string, amountLimit: string, pythPriceIDs: Map<string, string>, partner?: string, deepbookv3DeepFee?: TransactionObjectArgument, packages?: Map<string, string>): Promise<void>;
293
+ newDexRouterV3(provider: string, pythPriceIDs: Map<string, string>, partner?: string): DexRouter;
294
+ expectInputSwapV3(txb: Transaction, inputCoin: TransactionObjectArgument, routerData: RouterDataV3, expectAmountOut: string, amountOutLimit: string, pythPriceIDs: Map<string, string>, fixable?: boolean, partner?: string): TransactionObjectArgument;
295
+ expectOutputSwapV3(txb: Transaction, inputCoin: TransactionObjectArgument, routerData: RouterDataV3, amountOut: string, _amountLimit: string, // it will set when build inputcoin
296
+ partner?: string): TransactionObjectArgument;
297
+ routerSwap(params: BuildRouterSwapParamsV3): Promise<TransactionObjectArgument>;
298
+ fastRouterSwap(params: BuildFastRouterSwapParamsV3): Promise<void>;
299
+ fixableRouterSwapV3(params: BuildRouterSwapParamsV3): Promise<TransactionObjectArgument>;
300
+ swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResultV3>;
301
+ updatePythPriceIDs(priceIDs: string[], txb: Transaction): Promise<Map<string, string>>;
302
+ devInspectTransactionBlock(txb: Transaction): Promise<_mysten_sui_client.DevInspectResults>;
303
+ sendTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
304
+ }
305
+
306
+ /**
307
+ * Generate a downgraded UUID6 format identifier
308
+ * This creates a time-based identifier with reduced entropy for better compatibility
309
+ * @returns A downgrade_uuid6 string in format: downgrade_xxxxxxxx-xxxx-6xxx-xxxx-xxxxxxxxxxxx
310
+ */
311
+ declare function generateDowngradeUuid6(): string;
312
+ /**
313
+ * Generate a simplified downgrade UUID6 with timestamp-based components
314
+ * @returns A simplified downgrade_uuid6 string
315
+ */
316
+ declare function generateSimpleDowngradeUuid6(): string;
317
+ /**
318
+ * Validate if a string is a valid downgrade_uuid6 format
319
+ * @param uuid The string to validate
320
+ * @returns true if valid downgrade_uuid6 format
321
+ */
322
+ declare function isValidDowngradeUuid6(uuid: string): boolean;
323
+ /**
324
+ * Extract timestamp from downgrade_uuid6 if possible
325
+ * @param uuid The downgrade_uuid6 string
326
+ * @returns timestamp in milliseconds or null if cannot extract
327
+ */
328
+ declare function extractTimestampFromDowngradeUuid6(uuid: string): number | null;
329
+
330
+ declare function processEndpoint(endpoint: string): string;
331
+
332
+ type GetOrCreateAccountCapResult = {
333
+ accountCap: TransactionObjectArgument;
334
+ isCreate: boolean;
335
+ };
336
+ declare function getOrCreateAccountCap(txb: Transaction, client: SuiClient, owner: string): Promise<GetOrCreateAccountCapResult>;
337
+
338
+ /**
339
+ * Represents a SUI address, which is a string.
340
+ */
341
+ type SuiAddress = string;
342
+ /**
343
+ * Represents a SUI object identifier, which is a string.
344
+ */
345
+ type SuiObjectIdType = string;
346
+ /**
347
+ * Represents a BigNumber, which can be a Decimal.Value, number, or string.
348
+ */
349
+ type BigNumber = Decimal.Value | number | string;
350
+ /**
351
+ * Represents a SUI resource, which can be of any type.
352
+ */
353
+ type SuiResource = any;
354
+ /**
355
+ * Represents a Non-Fungible Token (NFT) with associated metadata.
356
+ */
357
+ type NFT = {
358
+ /**
359
+ * The address or identifier of the creator of the NFT.
360
+ */
361
+ creator: string;
362
+ /**
363
+ * A description providing additional information about the NFT.
364
+ */
365
+ description: string;
366
+ /**
367
+ * The URL to the image representing the NFT visually.
368
+ */
369
+ image_url: string;
370
+ /**
371
+ * A link associated with the NFT, providing more details or interactions.
372
+ */
373
+ link: string;
374
+ /**
375
+ * The name or title of the NFT.
376
+ */
377
+ name: string;
378
+ /**
379
+ * The URL to the project or collection associated with the NFT.
380
+ */
381
+ project_url: string;
382
+ };
383
+ /**
384
+ * Represents a SUI struct tag.
385
+ */
386
+ type SuiStructTag = {
387
+ /**
388
+ * The full address of the struct.
389
+ */
390
+ full_address: string;
391
+ /**
392
+ * The source address of the struct.
393
+ */
394
+ source_address: string;
395
+ /**
396
+ * The address of the struct.
397
+ */
398
+ address: SuiAddress;
399
+ /**
400
+ * The module to which the struct belongs.
401
+ */
402
+ module: string;
403
+ /**
404
+ * The name of the struct.
405
+ */
406
+ name: string;
407
+ /**
408
+ * An array of type arguments (SUI addresses) for the struct.
409
+ */
410
+ type_arguments: SuiAddress[];
411
+ };
412
+ /**
413
+ * Represents basic SUI data types.
414
+ */
415
+ type SuiBasicTypes = 'address' | 'bool' | 'u8' | 'u16' | 'u32' | 'u64' | 'u128' | 'u256';
416
+ /**
417
+ * Represents a SUI transaction argument, which can be of various types.
418
+ */
419
+ type SuiTxArg = TransactionArgument | string | number | bigint | boolean;
420
+ /**
421
+ * Represents input types for SUI data.
422
+ */
423
+ type SuiInputTypes = 'object' | SuiBasicTypes;
424
+ /**
425
+ * Gets the default SUI input type based on the provided value.
426
+ * @param value - The value to determine the default input type for.
427
+ * @returns The default SUI input type.
428
+ * @throws Error if the type of the value is unknown.
429
+ */
430
+ declare const getDefaultSuiInputType: (value: any) => SuiInputTypes;
431
+ /**
432
+ * Represents a coin asset with address, object ID, and balance information.
433
+ */
434
+ type CoinAsset = {
435
+ /**
436
+ * The address type of the coin asset.
437
+ */
438
+ coinAddress: SuiAddress;
439
+ /**
440
+ * The object identifier of the coin asset.
441
+ */
442
+ coinObjectId: SuiObjectIdType;
443
+ /**
444
+ * The balance amount of the coin asset.
445
+ */
446
+ balance: bigint;
447
+ };
448
+
449
+ declare function completionCoin(s: string): string;
450
+ declare function mintZeroCoin(txb: Transaction, coinType: string): TransactionObjectArgument;
451
+ declare function compareCoins(coinA: string, coinB: string): boolean;
452
+ declare function parseTurbosPoolFeeType(typeData: string): string | null;
453
+ declare function parseAftermathFeeType(typeData: string): string | undefined;
454
+ type BuildCoinResult = {
455
+ targetCoin: TransactionObjectArgument;
456
+ isMintZeroCoin: boolean;
457
+ targetCoinAmount: number;
458
+ };
459
+ declare function buildInputCoin(txb: Transaction, allCoins: CoinAsset[], amount: bigint, coinType: string): BuildCoinResult;
460
+
461
+ declare function getAggregatorV2PublishedAt(publishedAt: string, packages?: Map<string, string>): string;
462
+ declare function getAggregatorV2ExtendPublishedAt(publishedAt: string, packages?: Map<string, string>): string;
463
+ declare function getAggregatorV2Extend2PublishedAt(publishedAt: string, packages?: Map<string, string>): string;
464
+
465
+ declare function isSortedSymbols(symbolX: string, symbolY: string): boolean;
466
+ declare function composeType(address: string, generics: SuiAddress[]): SuiAddress;
467
+ declare function composeType(address: string, struct: string, generics?: SuiAddress[]): SuiAddress;
468
+ declare function composeType(address: string, module: string, struct: string, generics?: SuiAddress[]): SuiAddress;
469
+ declare function extractAddressFromType(type: string): string;
470
+ declare function extractStructTagFromType(type: string): SuiStructTag;
471
+ declare function normalizeCoinType(coinType: string): string;
472
+ declare function fixSuiObjectId(value: string): string;
473
+ /**
474
+ * Recursively traverses the given data object and patches any string values that represent Sui object IDs.
475
+ *
476
+ * @param {any} data - The data object to be patched.
477
+ */
478
+ declare function patchFixSuiObjectId(data: any): void;
479
+ declare function createTarget(packageName: string, moduleName: string, functionName: string): `${string}::${string}::${string}`;
480
+
481
+ interface Dex {
482
+ swap(client: AggregatorClient, ptb: Transaction, path: Path, inputCoin: TransactionObjectArgument, packages?: Map<string, string>, deepbookv3DeepFee?: TransactionObjectArgument): Promise<TransactionObjectArgument>;
483
+ }
484
+
485
+ interface GasMetrics {
486
+ computationCost: string;
487
+ storageCost: string;
488
+ storageRebate: string;
489
+ nonRefundableStorageFee: string;
490
+ totalGasCost: string;
491
+ gasUsed: string;
492
+ gasPrice: string;
493
+ success: boolean;
494
+ error?: string;
495
+ }
496
+ interface SwapGasAnalysis {
497
+ gasMetrics: GasMetrics;
498
+ amountIn: BN;
499
+ amountOut: BN;
500
+ priceImpact: number;
501
+ gasEfficiency: number;
502
+ provider: string;
503
+ route: string[];
504
+ timestamp: number;
505
+ isEstimated?: boolean;
506
+ originalPathCount?: number;
507
+ mergedPathCount?: number;
508
+ }
509
+ interface ComparisonResult {
510
+ v2: SwapGasAnalysis[];
511
+ v3: SwapGasAnalysis[];
512
+ summary: {
513
+ v2AverageGas: string;
514
+ v3AverageGas: string;
515
+ gasSavingsPercent: number;
516
+ v2SuccessRate: number;
517
+ v3SuccessRate: number;
518
+ totalTests: number;
519
+ };
520
+ }
521
+ /**
522
+ * Extract gas metrics from DevInspectResults
523
+ */
524
+ declare function extractGasMetrics(result: DevInspectResults): GasMetrics;
525
+ /**
526
+ * Calculate gas efficiency (amount out per gas unit)
527
+ */
528
+ declare function calculateGasEfficiency(amountOut: BN, totalGasCost: string): number;
529
+ /**
530
+ * Calculate price impact percentage
531
+ */
532
+ declare function calculatePriceImpact(amountIn: BN, amountOut: BN, expectedRate?: number): number;
533
+ /**
534
+ * Compare gas metrics between two analyses
535
+ */
536
+ declare function compareGasMetrics(v2Analysis: SwapGasAnalysis[], v3Analysis: SwapGasAnalysis[]): ComparisonResult;
537
+ /**
538
+ * Format gas metrics for human readable output
539
+ */
540
+ declare function formatGasMetrics(metrics: GasMetrics, isEstimated?: boolean): string;
541
+ /**
542
+ * Export results to JSON format
543
+ */
544
+ declare function exportToJSON(comparison: ComparisonResult): string;
545
+ /**
546
+ * Export results to CSV format
547
+ */
548
+ declare function exportToCSV(comparison: ComparisonResult): string;
549
+
550
+ declare const dealWithFastRouterSwapParamsForMsafe: (data: any) => any;
551
+ declare const restituteMsafeFastRouterSwapParams: (data: any) => any;
552
+
553
+ declare function printTransaction(tx: Transaction, isPrint?: boolean): Promise<void>;
554
+ declare function checkInvalidSuiAddress(address: string): boolean;
555
+
556
+ declare const ZERO: BN;
557
+ declare const ONE: BN;
558
+ declare const TWO: BN;
559
+ declare const U128: BN;
560
+ declare const U64_MAX_BN: BN;
561
+ declare const U64_MAX = "18446744073709551615";
562
+ declare const TEN_POW_NINE = 1000000000;
563
+ declare const AGGREGATOR = "aggregator";
564
+ declare const CETUS_DEX = "CETUS";
565
+ declare const DEEPBOOK_DEX = "DEEPBOOK";
566
+ declare const KRIYA_DEX = "KRIYA";
567
+ declare const FLOWX_AMM = "FLOWX";
568
+ declare const TURBOS_DEX = "TURBOS";
569
+ declare const AFTERMATH_AMM = "AFTERMATH";
570
+ declare const INTEGRATE = "integrate";
571
+ declare const CETUS_MODULE = "cetus";
572
+ declare const DEEPBOOK_MODULE = "deepbook";
573
+ declare const KRIYA_MODULE = "kriya";
574
+ declare const UTILS_MODULE = "utils";
575
+ declare const POOL_MODULT = "pool";
576
+ declare const PAY_MODULE = "pay";
577
+ declare const FLOWX_AMM_MODULE = "flowx_amm";
578
+ declare const TURBOS_MODULE = "turbos";
579
+ declare const AFTERMATH_MODULE = "aftermath";
580
+ declare const DEEPBOOK_CUSTODIAN_V2_MODULE = "custodian_v2";
581
+ declare const DEEPBOOK_CLOB_V2_MODULE = "clob_v2";
582
+ declare const FlashSwapFunc = "flash_swap";
583
+ declare const FlashSwapWithPartnerFunc = "flash_swap_with_partner";
584
+ declare const RepayFalshSwapFunc = "repay_flash_swap";
585
+ declare const RepayFlashSwapWithPartnerFunc = "repay_flash_swap_with_partner";
586
+ declare const FlashSwapA2BFunc = "flash_swap_a2b";
587
+ declare const FlashSwapB2AFunc = "flash_swap_b2a";
588
+ declare const FlashSwapWithPartnerA2BFunc = "flash_swap_with_partner_a2b";
589
+ declare const FlashSwapWithPartnerB2AFunc = "flash_swap_with_partner_b2a";
590
+ declare const REPAY_FLASH_SWAP_A2B_FUNC = "repay_flash_swap_a2b";
591
+ declare const REPAY_FLASH_SWAP_B2A_FUNC = "repay_flash_swap_b2a";
592
+ declare const REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC = "repay_flash_swap_with_partner_a2b";
593
+ declare const REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC = "repay_flash_swap_with_partner_b2a";
594
+ declare const SWAP_A2B_FUNC = "swap_a2b";
595
+ declare const SWAP_B2A_FUNC = "swap_b2a";
596
+ declare const TRANSFER_OR_DESTORY_COIN_FUNC = "transfer_or_destroy_coin";
597
+ declare const CHECK_COINS_THRESHOLD_FUNC = "check_coins_threshold";
598
+ declare const JOIN_FUNC = "join_vec";
599
+ declare const TRANSFER_ACCOUNT_CAP = "transfer_account_cap";
600
+ declare const CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
601
+ declare const CoinInfoAddress = "0x1::coin::CoinInfo";
602
+ declare const CoinStoreAddress = "0x1::coin::CoinStore";
603
+ declare const SuiZeroCoinFn = "0x2::coin::zero";
604
+ declare const DEEPBOOK_PACKAGE_ID = "0x000000000000000000000000000000000000000000000000000000000000dee9";
605
+ declare const DEEPBOOK_PUBLISHED_AT = "0x000000000000000000000000000000000000000000000000000000000000dee9";
606
+ declare const CETUS_PUBLISHED_AT = "0x70968826ad1b4ba895753f634b0aea68d0672908ca1075a2abdf0fc9e0b2fc6a";
607
+ declare const CETUS_V3_PUBLISHED_AT = "0xb85d33ef69a8308f7b1ae341e48bd8817476c144f14344d3ce612c16480d16f2";
608
+ declare const MAINNET_CETUS_GLOBAL_CONFIG_ID = "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f";
609
+ declare const TESTNET_CETUS_GLOBAL_CONFIG_ID = "0x6f4149091a5aea0e818e7243a13adcfb403842d670b9a2089de058512620687a";
610
+ declare const MAINNET_FLOWX_AMM_CONTAINER_ID = "0xb65dcbf63fd3ad5d0ebfbf334780dc9f785eff38a4459e37ab08fa79576ee511";
611
+ declare const TESTNET_FLOWX_AMM_CONTAINER_ID = "";
612
+ declare const TURBOS_VERSIONED = "0xf1cf0e81048df168ebeb1b8030fad24b3e0b53ae827c25053fff0779c1445b6f";
613
+ declare const MAINNET_AFTERMATH_REGISTRY_ID = "0xfcc774493db2c45c79f688f88d28023a3e7d98e4ee9f48bbf5c7990f651577ae";
614
+ declare const TESTNET_AFTERMATH_REGISTRY_ID = "";
615
+ declare const MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID = "0xf194d9b1bcad972e45a7dd67dd49b3ee1e3357a00a50850c52cd51bb450e13b4";
616
+ declare const TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID = "";
617
+ declare const MAINNET_AFTERMATH_TREASURY_ID = "0x28e499dff5e864a2eafe476269a4f5035f1c16f338da7be18b103499abf271ce";
618
+ declare const TESTNET_AFTERMATH_TREASURY_ID = "";
619
+ declare const MAINNET_AFTERMATH_INSURANCE_FUND_ID = "0xf0c40d67b078000e18032334c3325c47b9ec9f3d9ae4128be820d54663d14e3b";
620
+ declare const TESTNET_AFTERMATH_INSURANCE_FUND_ID = "";
621
+ declare const MAINNET_AFTERMATH_REFERRAL_VAULT_ID = "0x35d35b0e5b177593d8c3a801462485572fc30861e6ce96a55af6dc4730709278";
622
+ declare const TESTNET_AFTERMATH_REFERRAL_VAULT_ID = "";
623
+ declare const CETUS = "CETUS";
624
+ declare const KRIYA = "KRIYA";
625
+ declare const FLOWXV2 = "FLOWX";
626
+ declare const FLOWXV3 = "FLOWXV3";
627
+ declare const KRIYAV3 = "KRIYAV3";
628
+ declare const TURBOS = "TURBOS";
629
+ declare const DEEPBOOKV2 = "DEEPBOOK";
630
+ declare const DEEPBOOKV3 = "DEEPBOOKV3";
631
+ declare const AFTERMATH = "AFTERMATH";
632
+ declare const HAEDAL = "HAEDAL";
633
+ declare const HAEDALPMM = "HAEDALPMM";
634
+ declare const VOLO = "VOLO";
635
+ declare const BLUEMOVE = "BLUEMOVE";
636
+ declare const BLUEFIN = "BLUEFIN";
637
+ declare const SCALLOP = "SCALLOP";
638
+ declare const SUILEND = "SUILEND";
639
+ declare const AFSUI = "AFSUI";
640
+ declare const ALPHAFI = "ALPHAFI";
641
+ declare const SPRINGSUI = "SPRINGSUI";
642
+ declare const STEAMM = "STEAMM";
643
+ declare const STEAMM_OMM = "STEAMM_OMM";
644
+ declare const STEAMM_OMM_V2 = "STEAMM_OMM_V2";
645
+ declare const METASTABLE = "METASTABLE";
646
+ declare const OBRIC = "OBRIC";
647
+ declare const HAWAL = "HAWAL";
648
+ declare const MOMENTUM = "MOMENTUM";
649
+ declare const MAGMA = "MAGMA";
650
+ declare const SEVENK = "SEVENK";
651
+ declare const HAEDALHMMV2 = "HAEDALHMMV2";
652
+ declare const FULLSAIL = "FULLSAIL";
653
+ declare const ALL_DEXES: string[];
654
+ declare const PACKAGE_NAMES: {
655
+ readonly AGGREGATOR_V3: "aggregator_v3";
656
+ };
657
+ declare const DEFAULT_AGG_V3_ENDPOINT = "https://api-sui.cetus.zone/router_v3";
658
+ declare const DEFAULT_AGG_V2_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
659
+ declare const PYTH_CONFIG: {
660
+ readonly Testnet: {
661
+ readonly wormholeStateId: "0x31358d198147da50db32eda2562951d53973a0c0ad5ed738e9b17d88b213d790";
662
+ readonly pythStateId: "0x243759059f4c3111179da5878c12f68d612c21a8d54d85edc86164bb18be1c7c";
663
+ };
664
+ readonly Mainnet: {
665
+ readonly wormholeStateId: "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c";
666
+ readonly pythStateId: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8";
667
+ };
668
+ };
669
+ declare const PUBLISHED_ADDRESSES: {
670
+ readonly V2: {
671
+ readonly Mainnet: "0x8ae871505a80d8bf6bf9c05906cda6edfeea460c85bebe2e26a4313f5e67874a";
672
+ readonly Testnet: "0x52eae33adeb44de55cfb3f281d4cc9e02d976181c0952f5323648b5717b33934";
673
+ };
674
+ readonly V2_EXTEND: {
675
+ readonly Mainnet: "0x8a2f7a5b20665eeccc79de3aa37c3b6c473eca233ada1e1cd4678ec07d4d4073";
676
+ readonly Testnet: "0xabb6a81c8a216828e317719e06125de5bb2cb0fe8f9916ff8c023ca5be224c78";
677
+ };
678
+ readonly V2_EXTEND2: {
679
+ readonly Mainnet: "0x5cb7499fc49c2642310e24a4ecffdbee00133f97e80e2b45bca90c64d55de880";
680
+ readonly Testnet: "0x0";
681
+ };
682
+ };
683
+ declare const DEEPBOOK_V3_DEEP_FEE_TYPES: {
684
+ readonly Mainnet: "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP";
685
+ readonly Testnet: "0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP";
686
+ };
687
+ declare const CLIENT_CONFIG: {
688
+ readonly DEFAULT_PYTH_URL: "https://hermes.pyth.network";
689
+ readonly PYTH_TIMEOUT: 3000;
690
+ readonly MAX_OVERLAY_FEE_RATE: 0.1;
691
+ readonly FEE_RATE_MULTIPLIER: 1000000;
692
+ readonly DEFAULT_OVERLAY_FEE_RECEIVER: "0x0";
693
+ readonly ERRORS: {
694
+ readonly SIGNER_REQUIRED: "Signer is required, but not provided.";
695
+ readonly INVALID_OVERLAY_FEE_RATE: "Overlay fee rate must be between 0 and 0.1";
696
+ readonly INVALID_SLIPPAGE: "Invalid slippage value. Must be between 0 and 1 (e.g., 0.01 represents 1% slippage)";
697
+ readonly NO_ROUTER_FOUND: "No router found";
698
+ readonly EMPTY_PATH: "Empty path";
699
+ readonly UNSUPPORTED_DEX: "Unsupported dex";
700
+ readonly PYTH_UNAVAILABLE: "All Pyth price nodes are unavailable. Cannot fetch price data. Please switch to or add new available Pyth nodes";
701
+ readonly QUOTE_ID_REQUIRED: "Quote ID is required";
702
+ readonly AGGREGATOR_V3_PACKAGE_REQUIRED: "Aggregator V3 package is required";
703
+ readonly PACKAGES_REQUIRED: "Packages are required";
704
+ };
705
+ };
706
+ declare const AGGREGATOR_V3_CONFIG: {
707
+ readonly FEE_DENOMINATOR: 1000000;
708
+ readonly MAX_FEE_RATE: 100000;
709
+ readonly MAX_AMOUNT_IN: "18446744073709551615";
710
+ readonly DEFAULT_PUBLISHED_AT: {
711
+ readonly Mainnet: "0x07c27e879ba9282506284b0fef26d393978906fc9496550d978c6f493dbfa3e5";
712
+ readonly Testnet: "0x0";
713
+ };
714
+ };
715
+
716
+ declare enum TypesErrorCode {
717
+ InvalidType = "InvalidType"
718
+ }
719
+ declare enum ConfigErrorCode {
720
+ MissAggregatorPackage = "MissAggregatorPackage",
721
+ MissGlobalConfig = "MissGlobalConfig",
722
+ InvalidWallet = "InvalidWallet",
723
+ SimulateError = "SimulateError"
724
+ }
725
+ declare enum TransactionErrorCode {
726
+ InsufficientBalance = "InsufficientBalance",
727
+ SimulateEventError = "simulateEventError",
728
+ CannotGetDecimals = "CannotGetDecimals",
729
+ MissCoinA = "MissCoinA",
730
+ MissCoinB = "MissCoinB",
731
+ MissTurbosFeeType = "MissTurbosFeeType",
732
+ MissAftermathLpSupplyType = "MissAftermathLpSupplyType"
733
+ }
734
+ declare enum AggregatorServerErrorCode {
735
+ NumberTooLarge = 1000,
736
+ RateLimitExceeded = 1001,
737
+ InsufficientLiquidity = 1002,
738
+ HoneyPot = 1003
739
+ }
740
+ type AggregatorErrorCode = TypesErrorCode;
741
+ declare function getAggregatorServerErrorMessage(code: AggregatorServerErrorCode): string;
742
+ /**
743
+ * AggregatorError is a custom error class that extends the built-in Error class. It is used to represent errors that occur during aggregation operations.
744
+ * The key functionality of this code includes:
745
+ * - Defining the AggregatorError class that represents an error during aggregation. It includes a message property and an optional errorCode property.
746
+ * - Providing a static method isAggregatorErrorCode() that checks if a given error instance is an instance of AggregatorError and has a specific error code.
747
+ */
748
+ declare class AggregatorError extends Error {
749
+ message: string;
750
+ errorCode?: AggregatorErrorCode;
751
+ constructor(message: string, errorCode?: AggregatorErrorCode);
752
+ static isAggregatorErrorCode(e: any, code: AggregatorErrorCode): boolean;
753
+ }
754
+
755
+ type BuildFastRouterSwapParams = {
756
+ routers: Router[];
757
+ byAmountIn: boolean;
758
+ slippage: number;
759
+ txb: Transaction;
760
+ partner?: string;
761
+ refreshAllCoins?: boolean;
762
+ payDeepFeeAmount?: number;
763
+ };
764
+ type BuildRouterSwapParamsV2 = {
765
+ routers: RouterData;
766
+ inputCoin: TransactionObjectArgument;
767
+ slippage: number;
768
+ txb: Transaction;
769
+ partner?: string;
770
+ deepbookv3DeepFee?: TransactionObjectArgument;
771
+ };
772
+ type BuildFastRouterSwapParamsV2 = {
773
+ routers: RouterData;
774
+ slippage: number;
775
+ txb: Transaction;
776
+ partner?: string;
777
+ refreshAllCoins?: boolean;
778
+ payDeepFeeAmount?: number;
779
+ };
780
+
781
+ interface PythConfig {
782
+ wormholeStateId: string;
783
+ pythStateId: string;
784
+ }
785
+ type AggregatorClientParams = {
786
+ endpoint?: string;
787
+ signer?: string;
788
+ client?: _mysten_sui_client.SuiClient;
789
+ env?: Env;
790
+ pythUrls?: string[];
791
+ apiKey?: string;
792
+ partner?: string;
793
+ overlayFeeRate?: number;
794
+ overlayFeeReceiver?: string;
795
+ };
796
+
797
+ declare const DEFAULT_GAS_BUDGET_FOR_SPLIT = 1000;
798
+ declare const DEFAULT_GAS_BUDGET_FOR_MERGE = 500;
799
+ declare const DEFAULT_GAS_BUDGET_FOR_TRANSFER = 100;
800
+ declare const DEFAULT_GAS_BUDGET_FOR_TRANSFER_SUI = 100;
801
+ declare const DEFAULT_GAS_BUDGET_FOR_STAKE = 1000;
802
+ declare const GAS_TYPE_ARG = "0x2::sui::SUI";
803
+ declare const GAS_TYPE_ARG_LONG = "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";
804
+ declare const GAS_SYMBOL = "SUI";
805
+ declare const DEFAULT_NFT_TRANSFER_GAS_FEE = 450;
806
+ declare const SUI_SYSTEM_STATE_OBJECT_ID = "0x0000000000000000000000000000000000000005";
807
+ /**
808
+ * This class provides helper methods for working with coins.
809
+ */
810
+ declare class CoinUtils {
811
+ /**
812
+ * Get the coin type argument from a SuiMoveObject.
813
+ *
814
+ * @param obj The SuiMoveObject to get the coin type argument from.
815
+ * @returns The coin type argument, or null if it is not found.
816
+ */
817
+ static getCoinTypeArg(obj: SuiMoveObject): string | null;
818
+ /**
819
+ * Get whether a SuiMoveObject is a SUI coin.
820
+ *
821
+ * @param obj The SuiMoveObject to check.
822
+ * @returns Whether the SuiMoveObject is a SUI coin.
823
+ */
824
+ static isSUI(obj: SuiMoveObject): boolean;
825
+ /**
826
+ * Get the coin symbol from a coin type argument.
827
+ *
828
+ * @param coinTypeArg The coin type argument to get the symbol from.
829
+ * @returns The coin symbol.
830
+ */
831
+ static getCoinSymbol(coinTypeArg: string): string;
832
+ /**
833
+ * Get the balance of a SuiMoveObject.
834
+ *
835
+ * @param obj The SuiMoveObject to get the balance from.
836
+ * @returns The balance of the SuiMoveObject.
837
+ */
838
+ static getBalance(obj: SuiMoveObject): bigint;
839
+ /**
840
+ * Get the total balance of a list of CoinAsset objects for a given coin address.
841
+ *
842
+ * @param objs The list of CoinAsset objects to get the total balance for.
843
+ * @param coinAddress The coin address to get the total balance for.
844
+ * @returns The total balance of the CoinAsset objects for the given coin address.
845
+ */
846
+ static totalBalance(objs: CoinAsset[], coinAddress: SuiAddress): bigint;
847
+ /**
848
+ * Get the ID of a SuiMoveObject.
849
+ *
850
+ * @param obj The SuiMoveObject to get the ID from.
851
+ * @returns The ID of the SuiMoveObject.
852
+ */
853
+ static getID(obj: SuiMoveObject): string;
854
+ /**
855
+ * Get the coin type from a coin type argument.
856
+ *
857
+ * @param coinTypeArg The coin type argument to get the coin type from.
858
+ * @returns The coin type.
859
+ */
860
+ static getCoinTypeFromArg(coinTypeArg: string): string;
861
+ /**
862
+ * Get the CoinAsset objects for a given coin type.
863
+ *
864
+ * @param coinType The coin type to get the CoinAsset objects for.
865
+ * @param allSuiObjects The list of all SuiMoveObjects.
866
+ * @returns The CoinAsset objects for the given coin type.
867
+ */
868
+ static getCoinAssets(coinType: string, allSuiObjects: CoinAsset[]): CoinAsset[];
869
+ /**
870
+ * Get whether a coin address is a SUI coin.
871
+ *
872
+ * @param coinAddress The coin address to check.
873
+ * @returns Whether the coin address is a SUI coin.
874
+ */
875
+ static isSuiCoin(coinAddress: SuiAddress): boolean;
876
+ /**
877
+ * Select the CoinAsset objects from a list of CoinAsset objects that have a balance greater than or equal to a given amount.
878
+ *
879
+ * @param coins The list of CoinAsset objects to select from.
880
+ * @param amount The amount to select CoinAsset objects with a balance greater than or equal to.
881
+ * @param exclude A list of CoinAsset objects to exclude from the selection.
882
+ * @returns The CoinAsset objects that have a balance greater than or equal to the given amount.
883
+ */
884
+ static selectCoinObjectIdGreaterThanOrEqual(coins: CoinAsset[], amount: bigint, exclude?: string[]): {
885
+ objectArray: string[];
886
+ remainCoins: CoinAsset[];
887
+ amountArray: string[];
888
+ };
889
+ /**
890
+ * Select the CoinAsset objects from a list of CoinAsset objects that have a balance greater than or equal to a given amount.
891
+ *
892
+ * @param coins The list of CoinAsset objects to select from.
893
+ * @param amount The amount to select CoinAsset objects with a balance greater than or equal to.
894
+ * @param exclude A list of CoinAsset objects to exclude from the selection.
895
+ * @returns The CoinAsset objects that have a balance greater than or equal to the given amount.
896
+ */
897
+ static selectCoinAssetGreaterThanOrEqual(coins: CoinAsset[], amount: bigint, exclude?: string[]): {
898
+ selectedCoins: CoinAsset[];
899
+ remainingCoins: CoinAsset[];
900
+ };
901
+ /**
902
+ * Sort the CoinAsset objects by their balance.
903
+ *
904
+ * @param coins The CoinAsset objects to sort.
905
+ * @returns The sorted CoinAsset objects.
906
+ */
907
+ static sortByBalance(coins: CoinAsset[]): CoinAsset[];
908
+ static sortByBalanceDes(coins: CoinAsset[]): CoinAsset[];
909
+ /**
910
+ * Calculate the total balance of a list of CoinAsset objects.
911
+ *
912
+ * @param coins The list of CoinAsset objects to calculate the total balance for.
913
+ * @returns The total balance of the CoinAsset objects.
914
+ */
915
+ static calculateTotalBalance(coins: CoinAsset[]): bigint;
376
916
  }
377
917
 
378
- export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, AGGREGATOR_V2_EXTEND2, ALL_DEXES, ALPHAFI, AggregatorClient, type AggregatorClientParams, type AggregatorResponse, BLUEFIN, BLUEMOVE, type BuildCoinResult, type BuildFastRouterSwapParams, type BuildFastRouterSwapParamsV2, type BuildRouterSwapParams, type BuildRouterSwapParamsV2, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, HAEDALHMMV2, HAEDALPMM, HAWAL, KRIYA, KRIYAV3, MAGMA, METASTABLE, MOMENTUM, OBRIC, ONE, type Path, type PreSwapLpChangeParams, type Router, type RouterData, type RouterError, SCALLOP, SEVENK, SPRINGSUI, STEAMM, STEAMM_OMM, STEAMM_OMM_V2, SUILEND, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, buildInputCoin, checkInvalidSuiAddress, compareCoins, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, findPythPriceIDs, fixSuiObjectId, getAggregatorV2Extend2PublishedAt, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getAllProviders, getDeepbookV3Config, getProvidersExcluding, getProvidersIncluding, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
918
+ export { AFSUI, AFTERMATH, AFTERMATH_AMM, AFTERMATH_MODULE, AGGREGATOR, AGGREGATOR_V3_CONFIG, ALL_DEXES, ALPHAFI, AggregatorClient, type AggregatorClientParams, AggregatorConfig, AggregatorError, type AggregatorErrorCode, type AggregatorResponse, AggregatorServerErrorCode, BLUEFIN, BLUEMOVE, type BigNumber, type BuildCoinResult, type BuildFastRouterSwapParams, type BuildFastRouterSwapParamsV2, type BuildRouterSwapParams, type BuildRouterSwapParamsV2, CETUS, CETUS_DEX, CETUS_MODULE, CETUS_PUBLISHED_AT, CETUS_V3_PUBLISHED_AT, CHECK_COINS_THRESHOLD_FUNC, CLIENT_CONFIG, CLOCK_ADDRESS, type CoinAsset, CoinInfoAddress, CoinStoreAddress, CoinUtils, type ComparisonResult, ConfigErrorCode, DEEPBOOKV2, DEEPBOOKV3, DEEPBOOK_CLOB_V2_MODULE, DEEPBOOK_CUSTODIAN_V2_MODULE, DEEPBOOK_DEX, DEEPBOOK_MODULE, DEEPBOOK_PACKAGE_ID, DEEPBOOK_PUBLISHED_AT, DEEPBOOK_V3_DEEP_FEE_TYPES, DEFAULT_AGG_V2_ENDPOINT, DEFAULT_AGG_V3_ENDPOINT, DEFAULT_GAS_BUDGET_FOR_MERGE, DEFAULT_GAS_BUDGET_FOR_SPLIT, DEFAULT_GAS_BUDGET_FOR_STAKE, DEFAULT_GAS_BUDGET_FOR_TRANSFER, DEFAULT_GAS_BUDGET_FOR_TRANSFER_SUI, DEFAULT_NFT_TRANSFER_GAS_FEE, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, FLOWX_AMM, FLOWX_AMM_MODULE, FULLSAIL, type FindRouterParams, FlashSwapA2BFunc, FlashSwapB2AFunc, FlashSwapFunc, FlashSwapWithPartnerA2BFunc, FlashSwapWithPartnerB2AFunc, FlashSwapWithPartnerFunc, type FlattenedPath, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, type GasMetrics, type GetOrCreateAccountCapResult, HAEDAL, HAEDALHMMV2, HAEDALPMM, HAWAL, INTEGRATE, JOIN_FUNC, KRIYA, KRIYAV3, KRIYA_DEX, KRIYA_MODULE, MAGMA, 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, METASTABLE, MOMENTUM, type NFT, OBRIC, ONE, PACKAGE_NAMES, PAY_MODULE, POOL_MODULT, PUBLISHED_ADDRESSES, PYTH_CONFIG, type Package, type Path, type PathV2, type PreSwapLpChangeParams, type ProcessedRouterData, type PythConfig, 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 RouterDataV2, type RouterError, type RouterV2, SCALLOP, SEVENK, SPRINGSUI, STEAMM, STEAMM_OMM, STEAMM_OMM_V2, SUILEND, SUI_SYSTEM_STATE_OBJECT_ID, SWAP_A2B_FUNC, SWAP_B2A_FUNC, type SuiAddress, type SuiBasicTypes, type SuiInputTypes, type SuiObjectIdType, type SuiResource, type SuiStructTag, type SuiTxArg, SuiZeroCoinFn, type SwapGasAnalysis, type SwapInPoolsParams$1 as 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_DEX, TURBOS_MODULE, TURBOS_VERSIONED, TWO, TransactionErrorCode, TypesErrorCode, U128, U64_MAX, U64_MAX_BN, UTILS_MODULE, VOLO, ZERO, buildInputCoin, calculateGasEfficiency, calculatePriceImpact, checkInvalidSuiAddress, compareCoins, compareGasMetrics, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, exportToCSV, exportToJSON, extractAddressFromType, extractGasMetrics, extractStructTagFromType, extractTimestampFromDowngradeUuid6, fixSuiObjectId, formatGasMetrics, generateDowngradeUuid6, generateSimpleDowngradeUuid6, getAggregatorServerErrorMessage, getAggregatorV2Extend2PublishedAt, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getDeepbookV3Config, getDefaultSuiInputType, getOrCreateAccountCap, getRouterResult, isSortedSymbols, isValidDowngradeUuid6, mintZeroCoin, normalizeCoinType, parseAftermathFeeType, parseTurbosPoolFeeType, patchFixSuiObjectId, printTransaction, processEndpoint, processFlattenRoutes, restituteMsafeFastRouterSwapParams };