@cetusprotocol/aggregator-sdk 1.2.0 → 1.3.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,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,8 @@ 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";
317
+ declare const FERRADLMM = "FERRADLMM";
243
318
  declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v3";
244
319
  declare const ALL_DEXES: string[];
245
320
  type BuildRouterSwapParamsV3 = {
@@ -293,6 +368,7 @@ type AggregatorClientParams = {
293
368
  partner?: string;
294
369
  overlayFeeRate?: number;
295
370
  overlayFeeReceiver?: string;
371
+ cetusDlmmPartner?: string;
296
372
  };
297
373
  declare class AggregatorClient {
298
374
  endpoint: string;
@@ -305,6 +381,7 @@ declare class AggregatorClient {
305
381
  protected overlayFeeRate: number;
306
382
  protected overlayFeeReceiver: string;
307
383
  protected partner?: string;
384
+ protected cetusDlmmPartner?: string;
308
385
  private static readonly CONFIG;
309
386
  constructor(params: AggregatorClientParams);
310
387
  newPythClients(pythUrls: string[]): SuiPriceServiceConnection[];
@@ -312,13 +389,16 @@ declare class AggregatorClient {
312
389
  getDeepbookV3Config(): Promise<DeepbookV3ConfigResponse | null>;
313
390
  getOneCoinUsedToMerge(coinType: string): Promise<string | null>;
314
391
  findRouters(params: FindRouterParams): Promise<RouterDataV3 | null>;
392
+ findMergeSwapRouters(params: MergeSwapParams): Promise<MergeSwapRouterData | null>;
315
393
  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;
394
+ newDexRouterV3(provider: string, pythPriceIDs: Map<string, string>, partner?: string, cetusDlmmPartner?: string): DexRouter;
395
+ expectInputSwapV3(txb: Transaction, inputCoin: TransactionObjectArgument, routerData: RouterDataV3, expectAmountOut: string, amountOutLimit: string, pythPriceIDs: Map<string, string>, partner?: string, cetusDlmmPartner?: string): TransactionObjectArgument;
318
396
  expectOutputSwapV3(txb: Transaction, inputCoin: TransactionObjectArgument, routerData: RouterDataV3, amountOut: string, _amountLimit: string, // it will set when build inputcoin
319
397
  partner?: string): TransactionObjectArgument;
320
398
  routerSwap(params: BuildRouterSwapParamsV3): Promise<TransactionObjectArgument>;
321
399
  fastRouterSwap(params: BuildFastRouterSwapParamsV3): Promise<void>;
400
+ mergeSwap(params: BuildMergeSwapParams): Promise<TransactionObjectArgument>;
401
+ fastMergeSwap(params: BuildFastMergeSwapParams): Promise<void>;
322
402
  fixableRouterSwapV3(params: BuildRouterSwapParamsV3): Promise<TransactionObjectArgument>;
323
403
  swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResultV3>;
324
404
  updatePythPriceIDs(priceIDs: string[], txb: Transaction): Promise<Map<string, string>>;
@@ -725,14 +805,7 @@ declare enum TransactionErrorCode {
725
805
  MissTurbosFeeType = "MissTurbosFeeType",
726
806
  MissAftermathLpSupplyType = "MissAftermathLpSupplyType"
727
807
  }
728
- declare enum AggregatorServerErrorCode {
729
- NumberTooLarge = 1000,
730
- RateLimitExceeded = 1001,
731
- InsufficientLiquidity = 1002,
732
- HoneyPot = 1003
733
- }
734
808
  type AggregatorErrorCode = TypesErrorCode;
735
- declare function getAggregatorServerErrorMessage(code: AggregatorServerErrorCode): string;
736
809
  /**
737
810
  * 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
811
  * The key functionality of this code includes:
@@ -745,6 +818,21 @@ declare class AggregatorError extends Error {
745
818
  constructor(message: string, errorCode?: AggregatorErrorCode | string);
746
819
  static isAggregatorErrorCode(e: any, code: AggregatorErrorCode): boolean;
747
820
  }
821
+ declare enum AggregatorServerErrorCode {
822
+ NumberTooLarge = 1000,
823
+ RateLimitExceeded = 1001,
824
+ InsufficientLiquidity = 1002,
825
+ HoneyPot = 1003,
826
+ BadRequest = 1004,
827
+ Forbidden = 1005,
828
+ InternalServerError = 1006,
829
+ NotFoundRoute = 1007,
830
+ ServiceUnavailable = 1008,
831
+ UnsupportedApiVersion = 1009,
832
+ HoneyPotScam = 1010,
833
+ UnknownError = 400
834
+ }
835
+ declare function getAggregatorServerErrorMessage(code: AggregatorServerErrorCode, msg?: string): string;
748
836
 
749
837
  type BuildRouterSwapParams = {
750
838
  routers: Router[];
@@ -906,4 +994,4 @@ declare class CoinUtils {
906
994
  static calculateTotalBalance(coins: CoinAsset[]): bigint;
907
995
  }
908
996
 
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 };
997
+ 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, FERRADLMM, 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,8 @@ 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";
317
+ declare const FERRADLMM = "FERRADLMM";
243
318
  declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v3";
244
319
  declare const ALL_DEXES: string[];
245
320
  type BuildRouterSwapParamsV3 = {
@@ -293,6 +368,7 @@ type AggregatorClientParams = {
293
368
  partner?: string;
294
369
  overlayFeeRate?: number;
295
370
  overlayFeeReceiver?: string;
371
+ cetusDlmmPartner?: string;
296
372
  };
297
373
  declare class AggregatorClient {
298
374
  endpoint: string;
@@ -305,6 +381,7 @@ declare class AggregatorClient {
305
381
  protected overlayFeeRate: number;
306
382
  protected overlayFeeReceiver: string;
307
383
  protected partner?: string;
384
+ protected cetusDlmmPartner?: string;
308
385
  private static readonly CONFIG;
309
386
  constructor(params: AggregatorClientParams);
310
387
  newPythClients(pythUrls: string[]): SuiPriceServiceConnection[];
@@ -312,13 +389,16 @@ declare class AggregatorClient {
312
389
  getDeepbookV3Config(): Promise<DeepbookV3ConfigResponse | null>;
313
390
  getOneCoinUsedToMerge(coinType: string): Promise<string | null>;
314
391
  findRouters(params: FindRouterParams): Promise<RouterDataV3 | null>;
392
+ findMergeSwapRouters(params: MergeSwapParams): Promise<MergeSwapRouterData | null>;
315
393
  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;
394
+ newDexRouterV3(provider: string, pythPriceIDs: Map<string, string>, partner?: string, cetusDlmmPartner?: string): DexRouter;
395
+ expectInputSwapV3(txb: Transaction, inputCoin: TransactionObjectArgument, routerData: RouterDataV3, expectAmountOut: string, amountOutLimit: string, pythPriceIDs: Map<string, string>, partner?: string, cetusDlmmPartner?: string): TransactionObjectArgument;
318
396
  expectOutputSwapV3(txb: Transaction, inputCoin: TransactionObjectArgument, routerData: RouterDataV3, amountOut: string, _amountLimit: string, // it will set when build inputcoin
319
397
  partner?: string): TransactionObjectArgument;
320
398
  routerSwap(params: BuildRouterSwapParamsV3): Promise<TransactionObjectArgument>;
321
399
  fastRouterSwap(params: BuildFastRouterSwapParamsV3): Promise<void>;
400
+ mergeSwap(params: BuildMergeSwapParams): Promise<TransactionObjectArgument>;
401
+ fastMergeSwap(params: BuildFastMergeSwapParams): Promise<void>;
322
402
  fixableRouterSwapV3(params: BuildRouterSwapParamsV3): Promise<TransactionObjectArgument>;
323
403
  swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResultV3>;
324
404
  updatePythPriceIDs(priceIDs: string[], txb: Transaction): Promise<Map<string, string>>;
@@ -725,14 +805,7 @@ declare enum TransactionErrorCode {
725
805
  MissTurbosFeeType = "MissTurbosFeeType",
726
806
  MissAftermathLpSupplyType = "MissAftermathLpSupplyType"
727
807
  }
728
- declare enum AggregatorServerErrorCode {
729
- NumberTooLarge = 1000,
730
- RateLimitExceeded = 1001,
731
- InsufficientLiquidity = 1002,
732
- HoneyPot = 1003
733
- }
734
808
  type AggregatorErrorCode = TypesErrorCode;
735
- declare function getAggregatorServerErrorMessage(code: AggregatorServerErrorCode): string;
736
809
  /**
737
810
  * 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
811
  * The key functionality of this code includes:
@@ -745,6 +818,21 @@ declare class AggregatorError extends Error {
745
818
  constructor(message: string, errorCode?: AggregatorErrorCode | string);
746
819
  static isAggregatorErrorCode(e: any, code: AggregatorErrorCode): boolean;
747
820
  }
821
+ declare enum AggregatorServerErrorCode {
822
+ NumberTooLarge = 1000,
823
+ RateLimitExceeded = 1001,
824
+ InsufficientLiquidity = 1002,
825
+ HoneyPot = 1003,
826
+ BadRequest = 1004,
827
+ Forbidden = 1005,
828
+ InternalServerError = 1006,
829
+ NotFoundRoute = 1007,
830
+ ServiceUnavailable = 1008,
831
+ UnsupportedApiVersion = 1009,
832
+ HoneyPotScam = 1010,
833
+ UnknownError = 400
834
+ }
835
+ declare function getAggregatorServerErrorMessage(code: AggregatorServerErrorCode, msg?: string): string;
748
836
 
749
837
  type BuildRouterSwapParams = {
750
838
  routers: Router[];
@@ -906,4 +994,4 @@ declare class CoinUtils {
906
994
  static calculateTotalBalance(coins: CoinAsset[]): bigint;
907
995
  }
908
996
 
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 };
997
+ 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, FERRADLMM, 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 };