@cetusprotocol/aggregator-sdk 0.16.0 → 1.0.1

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