@cetusprotocol/aggregator-sdk 1.2.0 → 1.2.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.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _mysten_sui_client from '@mysten/sui/client';
2
2
  import { SuiClient, DevInspectResults, SuiMoveObject } from '@mysten/sui/client';
3
- import { Transaction, TransactionObjectArgument, TransactionArgument } from '@mysten/sui/transactions';
3
+ import { TransactionObjectArgument, Transaction, TransactionArgument } from '@mysten/sui/transactions';
4
4
  import BN from 'bn.js';
5
5
  import Decimal from 'decimal.js';
6
6
  import { SuiPriceServiceConnection, SuiPythClient } from '@pythnetwork/pyth-sui-js';
@@ -18,6 +18,64 @@ interface FindRouterParams {
18
18
  providers?: string[];
19
19
  liquidityChanges?: PreSwapLpChangeParams[];
20
20
  }
21
+ interface MergeSwapFromCoin {
22
+ coinType: string;
23
+ amount: BN | string | number;
24
+ }
25
+ interface MergeSwapFromCoin {
26
+ coinType: string;
27
+ amount: BN | string | number;
28
+ }
29
+ interface MergeSwapParams {
30
+ target: string;
31
+ byAmountIn: boolean;
32
+ depth?: number;
33
+ providers?: string[];
34
+ froms: MergeSwapFromCoin[];
35
+ }
36
+ interface MergeSwapParams {
37
+ target: string;
38
+ byAmountIn: boolean;
39
+ depth?: number;
40
+ providers?: string[];
41
+ froms: MergeSwapFromCoin[];
42
+ }
43
+ interface MergeSwapInputCoin {
44
+ coinType: string;
45
+ coin: TransactionObjectArgument;
46
+ }
47
+ interface MergeSwapInputCoin {
48
+ coinType: string;
49
+ coin: TransactionObjectArgument;
50
+ }
51
+ interface BuildMergeSwapParams {
52
+ router: MergeSwapRouterData;
53
+ inputCoins: MergeSwapInputCoin[];
54
+ slippage: number;
55
+ txb: Transaction;
56
+ partner?: string;
57
+ }
58
+ interface BuildMergeSwapParams {
59
+ router: MergeSwapRouterData;
60
+ inputCoins: MergeSwapInputCoin[];
61
+ slippage: number;
62
+ txb: Transaction;
63
+ partner?: string;
64
+ }
65
+ interface BuildFastMergeSwapParams {
66
+ router: MergeSwapRouterData;
67
+ slippage: number;
68
+ txb: Transaction;
69
+ partner?: string;
70
+ payDeepFeeAmount?: number;
71
+ }
72
+ interface BuildFastMergeSwapParams {
73
+ router: MergeSwapRouterData;
74
+ slippage: number;
75
+ txb: Transaction;
76
+ partner?: string;
77
+ payDeepFeeAmount?: number;
78
+ }
21
79
  interface PreSwapLpChangeParams {
22
80
  poolID: string;
23
81
  ticklower: number;
@@ -113,6 +171,20 @@ type RouterDataV3 = {
113
171
  error?: RouterError;
114
172
  overlayFee?: number;
115
173
  };
174
+ type MergeRoute = {
175
+ amountIn: BN;
176
+ amountOut: BN;
177
+ deviationRatio: string;
178
+ paths: Path[];
179
+ };
180
+ type MergeSwapRouterData = {
181
+ quoteID?: string;
182
+ totalAmountOut: BN;
183
+ allRoutes: MergeRoute[];
184
+ packages?: Map<string, string>;
185
+ gas?: number;
186
+ error?: RouterError;
187
+ };
116
188
  type FlattenedPath = {
117
189
  path: Path;
118
190
  isLastUseOfIntermediateToken: boolean;
@@ -199,6 +271,7 @@ declare class AggregatorConfig {
199
271
  }
200
272
 
201
273
  declare function getRouterResult(endpoint: string, apiKey: string, params: FindRouterParams, overlayFee: number, overlayFeeReceiver: string): Promise<RouterDataV3 | null>;
274
+ declare function getMergeSwapResult(endpoint: string, apiKey: string, params: MergeSwapParams, overlayFee: number, overlayFeeReceiver: string): Promise<MergeSwapRouterData | null>;
202
275
  declare function getDeepbookV3Config(endpoint: string): Promise<DeepbookV3ConfigResponse | null>;
203
276
  declare function processFlattenRoutes(routerData: RouterDataV3): ProcessedRouterData;
204
277
 
@@ -240,6 +313,7 @@ declare const MAGMA = "MAGMA";
240
313
  declare const SEVENK = "SEVENK";
241
314
  declare const HAEDALHMMV2 = "HAEDALHMMV2";
242
315
  declare const FULLSAIL = "FULLSAIL";
316
+ declare const CETUSDLMM = "CETUSDLMM";
243
317
  declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v3";
244
318
  declare const ALL_DEXES: string[];
245
319
  type BuildRouterSwapParamsV3 = {
@@ -293,6 +367,7 @@ type AggregatorClientParams = {
293
367
  partner?: string;
294
368
  overlayFeeRate?: number;
295
369
  overlayFeeReceiver?: string;
370
+ cetusDlmmPartner?: string;
296
371
  };
297
372
  declare class AggregatorClient {
298
373
  endpoint: string;
@@ -305,6 +380,7 @@ declare class AggregatorClient {
305
380
  protected overlayFeeRate: number;
306
381
  protected overlayFeeReceiver: string;
307
382
  protected partner?: string;
383
+ protected cetusDlmmPartner?: string;
308
384
  private static readonly CONFIG;
309
385
  constructor(params: AggregatorClientParams);
310
386
  newPythClients(pythUrls: string[]): SuiPriceServiceConnection[];
@@ -312,13 +388,16 @@ declare class AggregatorClient {
312
388
  getDeepbookV3Config(): Promise<DeepbookV3ConfigResponse | null>;
313
389
  getOneCoinUsedToMerge(coinType: string): Promise<string | null>;
314
390
  findRouters(params: FindRouterParams): Promise<RouterDataV3 | null>;
391
+ findMergeSwapRouters(params: MergeSwapParams): Promise<MergeSwapRouterData | null>;
315
392
  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>;
316
- newDexRouterV3(provider: string, pythPriceIDs: Map<string, string>, partner?: string): DexRouter;
317
- expectInputSwapV3(txb: Transaction, inputCoin: TransactionObjectArgument, routerData: RouterDataV3, expectAmountOut: string, amountOutLimit: string, pythPriceIDs: Map<string, string>, partner?: string): TransactionObjectArgument;
393
+ newDexRouterV3(provider: string, pythPriceIDs: Map<string, string>, partner?: string, cetusDlmmPartner?: string): DexRouter;
394
+ expectInputSwapV3(txb: Transaction, inputCoin: TransactionObjectArgument, routerData: RouterDataV3, expectAmountOut: string, amountOutLimit: string, pythPriceIDs: Map<string, string>, partner?: string, cetusDlmmPartner?: string): TransactionObjectArgument;
318
395
  expectOutputSwapV3(txb: Transaction, inputCoin: TransactionObjectArgument, routerData: RouterDataV3, amountOut: string, _amountLimit: string, // it will set when build inputcoin
319
396
  partner?: string): TransactionObjectArgument;
320
397
  routerSwap(params: BuildRouterSwapParamsV3): Promise<TransactionObjectArgument>;
321
398
  fastRouterSwap(params: BuildFastRouterSwapParamsV3): Promise<void>;
399
+ mergeSwap(params: BuildMergeSwapParams): Promise<TransactionObjectArgument>;
400
+ fastMergeSwap(params: BuildFastMergeSwapParams): Promise<void>;
322
401
  fixableRouterSwapV3(params: BuildRouterSwapParamsV3): Promise<TransactionObjectArgument>;
323
402
  swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResultV3>;
324
403
  updatePythPriceIDs(priceIDs: string[], txb: Transaction): Promise<Map<string, string>>;
@@ -725,14 +804,7 @@ declare enum TransactionErrorCode {
725
804
  MissTurbosFeeType = "MissTurbosFeeType",
726
805
  MissAftermathLpSupplyType = "MissAftermathLpSupplyType"
727
806
  }
728
- declare enum AggregatorServerErrorCode {
729
- NumberTooLarge = 1000,
730
- RateLimitExceeded = 1001,
731
- InsufficientLiquidity = 1002,
732
- HoneyPot = 1003
733
- }
734
807
  type AggregatorErrorCode = TypesErrorCode;
735
- declare function getAggregatorServerErrorMessage(code: AggregatorServerErrorCode): string;
736
808
  /**
737
809
  * AggregatorError is a custom error class that extends the built-in Error class. It is used to represent errors that occur during aggregation operations.
738
810
  * The key functionality of this code includes:
@@ -745,6 +817,21 @@ declare class AggregatorError extends Error {
745
817
  constructor(message: string, errorCode?: AggregatorErrorCode | string);
746
818
  static isAggregatorErrorCode(e: any, code: AggregatorErrorCode): boolean;
747
819
  }
820
+ declare enum AggregatorServerErrorCode {
821
+ NumberTooLarge = 1000,
822
+ RateLimitExceeded = 1001,
823
+ InsufficientLiquidity = 1002,
824
+ HoneyPot = 1003,
825
+ BadRequest = 1004,
826
+ Forbidden = 1005,
827
+ InternalServerError = 1006,
828
+ NotFoundRoute = 1007,
829
+ ServiceUnavailable = 1008,
830
+ UnsupportedApiVersion = 1009,
831
+ HoneyPotScam = 1010,
832
+ UnknownError = 400
833
+ }
834
+ declare function getAggregatorServerErrorMessage(code: AggregatorServerErrorCode, msg?: string): string;
748
835
 
749
836
  type BuildRouterSwapParams = {
750
837
  routers: Router[];
@@ -906,4 +993,4 @@ declare class CoinUtils {
906
993
  static calculateTotalBalance(coins: CoinAsset[]): bigint;
907
994
  }
908
995
 
909
- 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 RouterDataV3, 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, 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 };
996
+ 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 BuildFastMergeSwapParams, type BuildFastRouterSwapParams, type BuildFastRouterSwapParamsV2, type BuildFastRouterSwapParamsV3, type BuildMergeSwapParams, type BuildRouterSwapParams, type BuildRouterSwapParamsV2, type BuildRouterSwapParamsV3, CETUS, CETUSDLMM, 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 MergeRoute, type MergeSwapFromCoin, type MergeSwapInputCoin, type MergeSwapParams, type MergeSwapRouterData, 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 RouterDataV3, 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, 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, getMergeSwapResult, getOrCreateAccountCap, getProvidersExcluding, getProvidersIncluding, getRouterResult, isSortedSymbols, isValidDowngradeUuid6, mintZeroCoin, normalizeCoinType, parseAftermathFeeType, parseTurbosPoolFeeType, patchFixSuiObjectId, printTransaction, processEndpoint, processFlattenRoutes, restituteMsafeFastRouterSwapParams };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _mysten_sui_client from '@mysten/sui/client';
2
2
  import { SuiClient, DevInspectResults, SuiMoveObject } from '@mysten/sui/client';
3
- import { Transaction, TransactionObjectArgument, TransactionArgument } from '@mysten/sui/transactions';
3
+ import { TransactionObjectArgument, Transaction, TransactionArgument } from '@mysten/sui/transactions';
4
4
  import BN from 'bn.js';
5
5
  import Decimal from 'decimal.js';
6
6
  import { SuiPriceServiceConnection, SuiPythClient } from '@pythnetwork/pyth-sui-js';
@@ -18,6 +18,64 @@ interface FindRouterParams {
18
18
  providers?: string[];
19
19
  liquidityChanges?: PreSwapLpChangeParams[];
20
20
  }
21
+ interface MergeSwapFromCoin {
22
+ coinType: string;
23
+ amount: BN | string | number;
24
+ }
25
+ interface MergeSwapFromCoin {
26
+ coinType: string;
27
+ amount: BN | string | number;
28
+ }
29
+ interface MergeSwapParams {
30
+ target: string;
31
+ byAmountIn: boolean;
32
+ depth?: number;
33
+ providers?: string[];
34
+ froms: MergeSwapFromCoin[];
35
+ }
36
+ interface MergeSwapParams {
37
+ target: string;
38
+ byAmountIn: boolean;
39
+ depth?: number;
40
+ providers?: string[];
41
+ froms: MergeSwapFromCoin[];
42
+ }
43
+ interface MergeSwapInputCoin {
44
+ coinType: string;
45
+ coin: TransactionObjectArgument;
46
+ }
47
+ interface MergeSwapInputCoin {
48
+ coinType: string;
49
+ coin: TransactionObjectArgument;
50
+ }
51
+ interface BuildMergeSwapParams {
52
+ router: MergeSwapRouterData;
53
+ inputCoins: MergeSwapInputCoin[];
54
+ slippage: number;
55
+ txb: Transaction;
56
+ partner?: string;
57
+ }
58
+ interface BuildMergeSwapParams {
59
+ router: MergeSwapRouterData;
60
+ inputCoins: MergeSwapInputCoin[];
61
+ slippage: number;
62
+ txb: Transaction;
63
+ partner?: string;
64
+ }
65
+ interface BuildFastMergeSwapParams {
66
+ router: MergeSwapRouterData;
67
+ slippage: number;
68
+ txb: Transaction;
69
+ partner?: string;
70
+ payDeepFeeAmount?: number;
71
+ }
72
+ interface BuildFastMergeSwapParams {
73
+ router: MergeSwapRouterData;
74
+ slippage: number;
75
+ txb: Transaction;
76
+ partner?: string;
77
+ payDeepFeeAmount?: number;
78
+ }
21
79
  interface PreSwapLpChangeParams {
22
80
  poolID: string;
23
81
  ticklower: number;
@@ -113,6 +171,20 @@ type RouterDataV3 = {
113
171
  error?: RouterError;
114
172
  overlayFee?: number;
115
173
  };
174
+ type MergeRoute = {
175
+ amountIn: BN;
176
+ amountOut: BN;
177
+ deviationRatio: string;
178
+ paths: Path[];
179
+ };
180
+ type MergeSwapRouterData = {
181
+ quoteID?: string;
182
+ totalAmountOut: BN;
183
+ allRoutes: MergeRoute[];
184
+ packages?: Map<string, string>;
185
+ gas?: number;
186
+ error?: RouterError;
187
+ };
116
188
  type FlattenedPath = {
117
189
  path: Path;
118
190
  isLastUseOfIntermediateToken: boolean;
@@ -199,6 +271,7 @@ declare class AggregatorConfig {
199
271
  }
200
272
 
201
273
  declare function getRouterResult(endpoint: string, apiKey: string, params: FindRouterParams, overlayFee: number, overlayFeeReceiver: string): Promise<RouterDataV3 | null>;
274
+ declare function getMergeSwapResult(endpoint: string, apiKey: string, params: MergeSwapParams, overlayFee: number, overlayFeeReceiver: string): Promise<MergeSwapRouterData | null>;
202
275
  declare function getDeepbookV3Config(endpoint: string): Promise<DeepbookV3ConfigResponse | null>;
203
276
  declare function processFlattenRoutes(routerData: RouterDataV3): ProcessedRouterData;
204
277
 
@@ -240,6 +313,7 @@ declare const MAGMA = "MAGMA";
240
313
  declare const SEVENK = "SEVENK";
241
314
  declare const HAEDALHMMV2 = "HAEDALHMMV2";
242
315
  declare const FULLSAIL = "FULLSAIL";
316
+ declare const CETUSDLMM = "CETUSDLMM";
243
317
  declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v3";
244
318
  declare const ALL_DEXES: string[];
245
319
  type BuildRouterSwapParamsV3 = {
@@ -293,6 +367,7 @@ type AggregatorClientParams = {
293
367
  partner?: string;
294
368
  overlayFeeRate?: number;
295
369
  overlayFeeReceiver?: string;
370
+ cetusDlmmPartner?: string;
296
371
  };
297
372
  declare class AggregatorClient {
298
373
  endpoint: string;
@@ -305,6 +380,7 @@ declare class AggregatorClient {
305
380
  protected overlayFeeRate: number;
306
381
  protected overlayFeeReceiver: string;
307
382
  protected partner?: string;
383
+ protected cetusDlmmPartner?: string;
308
384
  private static readonly CONFIG;
309
385
  constructor(params: AggregatorClientParams);
310
386
  newPythClients(pythUrls: string[]): SuiPriceServiceConnection[];
@@ -312,13 +388,16 @@ declare class AggregatorClient {
312
388
  getDeepbookV3Config(): Promise<DeepbookV3ConfigResponse | null>;
313
389
  getOneCoinUsedToMerge(coinType: string): Promise<string | null>;
314
390
  findRouters(params: FindRouterParams): Promise<RouterDataV3 | null>;
391
+ findMergeSwapRouters(params: MergeSwapParams): Promise<MergeSwapRouterData | null>;
315
392
  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>;
316
- newDexRouterV3(provider: string, pythPriceIDs: Map<string, string>, partner?: string): DexRouter;
317
- expectInputSwapV3(txb: Transaction, inputCoin: TransactionObjectArgument, routerData: RouterDataV3, expectAmountOut: string, amountOutLimit: string, pythPriceIDs: Map<string, string>, partner?: string): TransactionObjectArgument;
393
+ newDexRouterV3(provider: string, pythPriceIDs: Map<string, string>, partner?: string, cetusDlmmPartner?: string): DexRouter;
394
+ expectInputSwapV3(txb: Transaction, inputCoin: TransactionObjectArgument, routerData: RouterDataV3, expectAmountOut: string, amountOutLimit: string, pythPriceIDs: Map<string, string>, partner?: string, cetusDlmmPartner?: string): TransactionObjectArgument;
318
395
  expectOutputSwapV3(txb: Transaction, inputCoin: TransactionObjectArgument, routerData: RouterDataV3, amountOut: string, _amountLimit: string, // it will set when build inputcoin
319
396
  partner?: string): TransactionObjectArgument;
320
397
  routerSwap(params: BuildRouterSwapParamsV3): Promise<TransactionObjectArgument>;
321
398
  fastRouterSwap(params: BuildFastRouterSwapParamsV3): Promise<void>;
399
+ mergeSwap(params: BuildMergeSwapParams): Promise<TransactionObjectArgument>;
400
+ fastMergeSwap(params: BuildFastMergeSwapParams): Promise<void>;
322
401
  fixableRouterSwapV3(params: BuildRouterSwapParamsV3): Promise<TransactionObjectArgument>;
323
402
  swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResultV3>;
324
403
  updatePythPriceIDs(priceIDs: string[], txb: Transaction): Promise<Map<string, string>>;
@@ -725,14 +804,7 @@ declare enum TransactionErrorCode {
725
804
  MissTurbosFeeType = "MissTurbosFeeType",
726
805
  MissAftermathLpSupplyType = "MissAftermathLpSupplyType"
727
806
  }
728
- declare enum AggregatorServerErrorCode {
729
- NumberTooLarge = 1000,
730
- RateLimitExceeded = 1001,
731
- InsufficientLiquidity = 1002,
732
- HoneyPot = 1003
733
- }
734
807
  type AggregatorErrorCode = TypesErrorCode;
735
- declare function getAggregatorServerErrorMessage(code: AggregatorServerErrorCode): string;
736
808
  /**
737
809
  * AggregatorError is a custom error class that extends the built-in Error class. It is used to represent errors that occur during aggregation operations.
738
810
  * The key functionality of this code includes:
@@ -745,6 +817,21 @@ declare class AggregatorError extends Error {
745
817
  constructor(message: string, errorCode?: AggregatorErrorCode | string);
746
818
  static isAggregatorErrorCode(e: any, code: AggregatorErrorCode): boolean;
747
819
  }
820
+ declare enum AggregatorServerErrorCode {
821
+ NumberTooLarge = 1000,
822
+ RateLimitExceeded = 1001,
823
+ InsufficientLiquidity = 1002,
824
+ HoneyPot = 1003,
825
+ BadRequest = 1004,
826
+ Forbidden = 1005,
827
+ InternalServerError = 1006,
828
+ NotFoundRoute = 1007,
829
+ ServiceUnavailable = 1008,
830
+ UnsupportedApiVersion = 1009,
831
+ HoneyPotScam = 1010,
832
+ UnknownError = 400
833
+ }
834
+ declare function getAggregatorServerErrorMessage(code: AggregatorServerErrorCode, msg?: string): string;
748
835
 
749
836
  type BuildRouterSwapParams = {
750
837
  routers: Router[];
@@ -906,4 +993,4 @@ declare class CoinUtils {
906
993
  static calculateTotalBalance(coins: CoinAsset[]): bigint;
907
994
  }
908
995
 
909
- 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 RouterDataV3, 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, 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 };
996
+ 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 BuildFastMergeSwapParams, type BuildFastRouterSwapParams, type BuildFastRouterSwapParamsV2, type BuildFastRouterSwapParamsV3, type BuildMergeSwapParams, type BuildRouterSwapParams, type BuildRouterSwapParamsV2, type BuildRouterSwapParamsV3, CETUS, CETUSDLMM, 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 MergeRoute, type MergeSwapFromCoin, type MergeSwapInputCoin, type MergeSwapParams, type MergeSwapRouterData, 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 RouterDataV3, 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, 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, getMergeSwapResult, getOrCreateAccountCap, getProvidersExcluding, getProvidersIncluding, getRouterResult, isSortedSymbols, isValidDowngradeUuid6, mintZeroCoin, normalizeCoinType, parseAftermathFeeType, parseTurbosPoolFeeType, patchFixSuiObjectId, printTransaction, processEndpoint, processFlattenRoutes, restituteMsafeFastRouterSwapParams };