@cetusprotocol/aggregator-sdk 0.0.0-experimental-20250829163315 → 0.0.0-experimental-20250903180855
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 +8 -9
- package/dist/index.d.ts +8 -9
- package/dist/index.js +54 -99
- package/dist/index.mjs +55 -99
- package/package.json +1 -1
- package/test.json +267 -0
- package/benchmark-results/benchmark-results-2025-07-17T12-03-15-563Z.csv +0 -3
- package/benchmark-results/benchmark-results-2025-07-17T12-03-15-563Z.json +0 -56
- package/benchmark-results/benchmark-results-2025-07-17T12-03-34-148Z.csv +0 -3
- package/benchmark-results/benchmark-results-2025-07-17T12-03-34-148Z.json +0 -56
- package/benchmark-results/benchmark-results-2025-07-21T03-31-59-263Z.csv +0 -21
- package/benchmark-results/benchmark-results-2025-07-21T03-31-59-263Z.json +0 -444
- package/benchmark-results/benchmark-results-2025-07-21T07-54-54-916Z.csv +0 -21
- package/benchmark-results/benchmark-results-2025-07-21T07-54-54-916Z.json +0 -503
- package/benchmark-results/error-report-2025-07-17T12-03-34-148Z.md +0 -18
- package/benchmark-results/error-report-2025-07-21T03-31-59-263Z.md +0 -18
- package/benchmark-results/error-report-2025-07-21T07-54-54-916Z.md +0 -18
- package/benchmark-results/gas-analysis-report-2025-07-17T12-03-15-563Z.md +0 -80
- package/benchmark-results/gas-analysis-report-2025-07-17T12-03-34-148Z.md +0 -80
- package/benchmark-results/gas-analysis-report-2025-07-21T03-31-59-263Z.md +0 -296
- package/benchmark-results/gas-analysis-report-2025-07-21T07-54-54-916Z.md +0 -323
package/dist/index.d.mts
CHANGED
|
@@ -107,7 +107,7 @@ type RouterDataV3 = {
|
|
|
107
107
|
byAmountIn: boolean;
|
|
108
108
|
paths: Path[];
|
|
109
109
|
insufficientLiquidity: boolean;
|
|
110
|
-
deviationRatio
|
|
110
|
+
deviationRatio: number;
|
|
111
111
|
packages?: Map<string, string>;
|
|
112
112
|
totalDeepFee?: number;
|
|
113
113
|
error?: RouterError;
|
|
@@ -240,7 +240,6 @@ declare const MAGMA = "MAGMA";
|
|
|
240
240
|
declare const SEVENK = "SEVENK";
|
|
241
241
|
declare const HAEDALHMMV2 = "HAEDALHMMV2";
|
|
242
242
|
declare const FULLSAIL = "FULLSAIL";
|
|
243
|
-
declare const CETUSDLMM = "CETUSDLMM";
|
|
244
243
|
declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v3";
|
|
245
244
|
declare const ALL_DEXES: string[];
|
|
246
245
|
type BuildRouterSwapParamsV3 = {
|
|
@@ -294,7 +293,6 @@ type AggregatorClientParams = {
|
|
|
294
293
|
partner?: string;
|
|
295
294
|
overlayFeeRate?: number;
|
|
296
295
|
overlayFeeReceiver?: string;
|
|
297
|
-
cetusDlmmPartner?: string;
|
|
298
296
|
};
|
|
299
297
|
declare class AggregatorClient {
|
|
300
298
|
endpoint: string;
|
|
@@ -307,16 +305,16 @@ declare class AggregatorClient {
|
|
|
307
305
|
protected overlayFeeRate: number;
|
|
308
306
|
protected overlayFeeReceiver: string;
|
|
309
307
|
protected partner?: string;
|
|
310
|
-
protected cetusDlmmPartner?: string;
|
|
311
308
|
private static readonly CONFIG;
|
|
312
309
|
constructor(params: AggregatorClientParams);
|
|
313
310
|
newPythClients(pythUrls: string[]): SuiPriceServiceConnection[];
|
|
314
311
|
deepbookv3DeepFeeType(): string;
|
|
312
|
+
getDeepbookV3Config(): Promise<DeepbookV3ConfigResponse | null>;
|
|
315
313
|
getOneCoinUsedToMerge(coinType: string): Promise<string | null>;
|
|
316
314
|
findRouters(params: FindRouterParams): Promise<RouterDataV3 | null>;
|
|
317
315
|
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>;
|
|
318
|
-
newDexRouterV3(provider: string, pythPriceIDs: Map<string, string>, partner?: string
|
|
319
|
-
expectInputSwapV3(txb: Transaction, inputCoin: TransactionObjectArgument, routerData: RouterDataV3, expectAmountOut: string, amountOutLimit: string, pythPriceIDs: Map<string, string>, partner?: string
|
|
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;
|
|
320
318
|
expectOutputSwapV3(txb: Transaction, inputCoin: TransactionObjectArgument, routerData: RouterDataV3, amountOut: string, _amountLimit: string, // it will set when build inputcoin
|
|
321
319
|
partner?: string): TransactionObjectArgument;
|
|
322
320
|
routerSwap(params: BuildRouterSwapParamsV3): Promise<TransactionObjectArgument>;
|
|
@@ -629,7 +627,7 @@ declare const SuiZeroCoinFn = "0x2::coin::zero";
|
|
|
629
627
|
declare const DEEPBOOK_PACKAGE_ID = "0x000000000000000000000000000000000000000000000000000000000000dee9";
|
|
630
628
|
declare const DEEPBOOK_PUBLISHED_AT = "0x000000000000000000000000000000000000000000000000000000000000dee9";
|
|
631
629
|
declare const CETUS_PUBLISHED_AT = "0x70968826ad1b4ba895753f634b0aea68d0672908ca1075a2abdf0fc9e0b2fc6a";
|
|
632
|
-
declare const CETUS_V3_PUBLISHED_AT = "
|
|
630
|
+
declare const CETUS_V3_PUBLISHED_AT = "0x73a9bcf98bd1f4602bd4bb76f235b20253a17722cda3438d1710b70c831168af";
|
|
633
631
|
declare const MAINNET_CETUS_GLOBAL_CONFIG_ID = "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f";
|
|
634
632
|
declare const TESTNET_CETUS_GLOBAL_CONFIG_ID = "0x6f4149091a5aea0e818e7243a13adcfb403842d670b9a2089de058512620687a";
|
|
635
633
|
declare const MAINNET_FLOWX_AMM_CONTAINER_ID = "0xb65dcbf63fd3ad5d0ebfbf334780dc9f785eff38a4459e37ab08fa79576ee511";
|
|
@@ -695,6 +693,7 @@ declare const CLIENT_CONFIG: {
|
|
|
695
693
|
readonly QUOTE_ID_REQUIRED: "Quote ID is required";
|
|
696
694
|
readonly AGGREGATOR_V3_PACKAGE_REQUIRED: "Aggregator V3 package is required";
|
|
697
695
|
readonly PACKAGES_REQUIRED: "Packages are required";
|
|
696
|
+
readonly OVERLAY_FEE_RECEIVER_REQUIRED: "Overlay fee rate is set, but overlay fee receiver is not set";
|
|
698
697
|
};
|
|
699
698
|
};
|
|
700
699
|
declare const AGGREGATOR_V3_CONFIG: {
|
|
@@ -702,7 +701,7 @@ declare const AGGREGATOR_V3_CONFIG: {
|
|
|
702
701
|
readonly MAX_FEE_RATE: 100000;
|
|
703
702
|
readonly MAX_AMOUNT_IN: "18446744073709551615";
|
|
704
703
|
readonly DEFAULT_PUBLISHED_AT: {
|
|
705
|
-
readonly Mainnet: "
|
|
704
|
+
readonly Mainnet: "0x0422e3239f174320760dd675ba3835cf4b1c511be4a36e819cb61fab7d5d404a";
|
|
706
705
|
readonly Testnet: "0x0";
|
|
707
706
|
};
|
|
708
707
|
};
|
|
@@ -906,4 +905,4 @@ declare class CoinUtils {
|
|
|
906
905
|
static calculateTotalBalance(coins: CoinAsset[]): bigint;
|
|
907
906
|
}
|
|
908
907
|
|
|
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,
|
|
908
|
+
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -107,7 +107,7 @@ type RouterDataV3 = {
|
|
|
107
107
|
byAmountIn: boolean;
|
|
108
108
|
paths: Path[];
|
|
109
109
|
insufficientLiquidity: boolean;
|
|
110
|
-
deviationRatio
|
|
110
|
+
deviationRatio: number;
|
|
111
111
|
packages?: Map<string, string>;
|
|
112
112
|
totalDeepFee?: number;
|
|
113
113
|
error?: RouterError;
|
|
@@ -240,7 +240,6 @@ declare const MAGMA = "MAGMA";
|
|
|
240
240
|
declare const SEVENK = "SEVENK";
|
|
241
241
|
declare const HAEDALHMMV2 = "HAEDALHMMV2";
|
|
242
242
|
declare const FULLSAIL = "FULLSAIL";
|
|
243
|
-
declare const CETUSDLMM = "CETUSDLMM";
|
|
244
243
|
declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v3";
|
|
245
244
|
declare const ALL_DEXES: string[];
|
|
246
245
|
type BuildRouterSwapParamsV3 = {
|
|
@@ -294,7 +293,6 @@ type AggregatorClientParams = {
|
|
|
294
293
|
partner?: string;
|
|
295
294
|
overlayFeeRate?: number;
|
|
296
295
|
overlayFeeReceiver?: string;
|
|
297
|
-
cetusDlmmPartner?: string;
|
|
298
296
|
};
|
|
299
297
|
declare class AggregatorClient {
|
|
300
298
|
endpoint: string;
|
|
@@ -307,16 +305,16 @@ declare class AggregatorClient {
|
|
|
307
305
|
protected overlayFeeRate: number;
|
|
308
306
|
protected overlayFeeReceiver: string;
|
|
309
307
|
protected partner?: string;
|
|
310
|
-
protected cetusDlmmPartner?: string;
|
|
311
308
|
private static readonly CONFIG;
|
|
312
309
|
constructor(params: AggregatorClientParams);
|
|
313
310
|
newPythClients(pythUrls: string[]): SuiPriceServiceConnection[];
|
|
314
311
|
deepbookv3DeepFeeType(): string;
|
|
312
|
+
getDeepbookV3Config(): Promise<DeepbookV3ConfigResponse | null>;
|
|
315
313
|
getOneCoinUsedToMerge(coinType: string): Promise<string | null>;
|
|
316
314
|
findRouters(params: FindRouterParams): Promise<RouterDataV3 | null>;
|
|
317
315
|
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>;
|
|
318
|
-
newDexRouterV3(provider: string, pythPriceIDs: Map<string, string>, partner?: string
|
|
319
|
-
expectInputSwapV3(txb: Transaction, inputCoin: TransactionObjectArgument, routerData: RouterDataV3, expectAmountOut: string, amountOutLimit: string, pythPriceIDs: Map<string, string>, partner?: string
|
|
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;
|
|
320
318
|
expectOutputSwapV3(txb: Transaction, inputCoin: TransactionObjectArgument, routerData: RouterDataV3, amountOut: string, _amountLimit: string, // it will set when build inputcoin
|
|
321
319
|
partner?: string): TransactionObjectArgument;
|
|
322
320
|
routerSwap(params: BuildRouterSwapParamsV3): Promise<TransactionObjectArgument>;
|
|
@@ -629,7 +627,7 @@ declare const SuiZeroCoinFn = "0x2::coin::zero";
|
|
|
629
627
|
declare const DEEPBOOK_PACKAGE_ID = "0x000000000000000000000000000000000000000000000000000000000000dee9";
|
|
630
628
|
declare const DEEPBOOK_PUBLISHED_AT = "0x000000000000000000000000000000000000000000000000000000000000dee9";
|
|
631
629
|
declare const CETUS_PUBLISHED_AT = "0x70968826ad1b4ba895753f634b0aea68d0672908ca1075a2abdf0fc9e0b2fc6a";
|
|
632
|
-
declare const CETUS_V3_PUBLISHED_AT = "
|
|
630
|
+
declare const CETUS_V3_PUBLISHED_AT = "0x73a9bcf98bd1f4602bd4bb76f235b20253a17722cda3438d1710b70c831168af";
|
|
633
631
|
declare const MAINNET_CETUS_GLOBAL_CONFIG_ID = "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f";
|
|
634
632
|
declare const TESTNET_CETUS_GLOBAL_CONFIG_ID = "0x6f4149091a5aea0e818e7243a13adcfb403842d670b9a2089de058512620687a";
|
|
635
633
|
declare const MAINNET_FLOWX_AMM_CONTAINER_ID = "0xb65dcbf63fd3ad5d0ebfbf334780dc9f785eff38a4459e37ab08fa79576ee511";
|
|
@@ -695,6 +693,7 @@ declare const CLIENT_CONFIG: {
|
|
|
695
693
|
readonly QUOTE_ID_REQUIRED: "Quote ID is required";
|
|
696
694
|
readonly AGGREGATOR_V3_PACKAGE_REQUIRED: "Aggregator V3 package is required";
|
|
697
695
|
readonly PACKAGES_REQUIRED: "Packages are required";
|
|
696
|
+
readonly OVERLAY_FEE_RECEIVER_REQUIRED: "Overlay fee rate is set, but overlay fee receiver is not set";
|
|
698
697
|
};
|
|
699
698
|
};
|
|
700
699
|
declare const AGGREGATOR_V3_CONFIG: {
|
|
@@ -702,7 +701,7 @@ declare const AGGREGATOR_V3_CONFIG: {
|
|
|
702
701
|
readonly MAX_FEE_RATE: 100000;
|
|
703
702
|
readonly MAX_AMOUNT_IN: "18446744073709551615";
|
|
704
703
|
readonly DEFAULT_PUBLISHED_AT: {
|
|
705
|
-
readonly Mainnet: "
|
|
704
|
+
readonly Mainnet: "0x0422e3239f174320760dd675ba3835cf4b1c511be4a36e819cb61fab7d5d404a";
|
|
706
705
|
readonly Testnet: "0x0";
|
|
707
706
|
};
|
|
708
707
|
};
|
|
@@ -906,4 +905,4 @@ declare class CoinUtils {
|
|
|
906
905
|
static calculateTotalBalance(coins: CoinAsset[]): bigint;
|
|
907
906
|
}
|
|
908
907
|
|
|
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,
|
|
908
|
+
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 };
|
package/dist/index.js
CHANGED
|
@@ -3340,7 +3340,7 @@ var SuiZeroCoinFn = "0x2::coin::zero";
|
|
|
3340
3340
|
var DEEPBOOK_PACKAGE_ID = "0x000000000000000000000000000000000000000000000000000000000000dee9";
|
|
3341
3341
|
var DEEPBOOK_PUBLISHED_AT = "0x000000000000000000000000000000000000000000000000000000000000dee9";
|
|
3342
3342
|
var CETUS_PUBLISHED_AT = "0x70968826ad1b4ba895753f634b0aea68d0672908ca1075a2abdf0fc9e0b2fc6a";
|
|
3343
|
-
var CETUS_V3_PUBLISHED_AT = "
|
|
3343
|
+
var CETUS_V3_PUBLISHED_AT = "0x73a9bcf98bd1f4602bd4bb76f235b20253a17722cda3438d1710b70c831168af";
|
|
3344
3344
|
var MAINNET_CETUS_GLOBAL_CONFIG_ID = "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f";
|
|
3345
3345
|
var TESTNET_CETUS_GLOBAL_CONFIG_ID = "0x6f4149091a5aea0e818e7243a13adcfb403842d670b9a2089de058512620687a";
|
|
3346
3346
|
var MAINNET_FLOWX_AMM_CONTAINER_ID = "0xb65dcbf63fd3ad5d0ebfbf334780dc9f785eff38a4459e37ab08fa79576ee511";
|
|
@@ -3411,7 +3411,8 @@ var CLIENT_CONFIG = {
|
|
|
3411
3411
|
PYTH_UNAVAILABLE: "All Pyth price nodes are unavailable. Cannot fetch price data. Please switch to or add new available Pyth nodes",
|
|
3412
3412
|
QUOTE_ID_REQUIRED: "Quote ID is required",
|
|
3413
3413
|
AGGREGATOR_V3_PACKAGE_REQUIRED: "Aggregator V3 package is required",
|
|
3414
|
-
PACKAGES_REQUIRED: "Packages are required"
|
|
3414
|
+
PACKAGES_REQUIRED: "Packages are required",
|
|
3415
|
+
OVERLAY_FEE_RECEIVER_REQUIRED: "Overlay fee rate is set, but overlay fee receiver is not set"
|
|
3415
3416
|
}
|
|
3416
3417
|
};
|
|
3417
3418
|
var AGGREGATOR_V3_CONFIG = {
|
|
@@ -3420,13 +3421,13 @@ var AGGREGATOR_V3_CONFIG = {
|
|
|
3420
3421
|
// 10%
|
|
3421
3422
|
MAX_AMOUNT_IN: U64_MAX,
|
|
3422
3423
|
DEFAULT_PUBLISHED_AT: {
|
|
3423
|
-
Mainnet: "
|
|
3424
|
+
Mainnet: "0x0422e3239f174320760dd675ba3835cf4b1c511be4a36e819cb61fab7d5d404a",
|
|
3424
3425
|
Testnet: "0x0"
|
|
3425
3426
|
}
|
|
3426
3427
|
};
|
|
3427
3428
|
|
|
3428
3429
|
// src/api.ts
|
|
3429
|
-
var SDK_VERSION =
|
|
3430
|
+
var SDK_VERSION = 1010102;
|
|
3430
3431
|
function parseRouterResponse(data, byAmountIn) {
|
|
3431
3432
|
let packages = /* @__PURE__ */ new Map();
|
|
3432
3433
|
if (data.packages) {
|
|
@@ -3444,6 +3445,7 @@ function parseRouterResponse(data, byAmountIn) {
|
|
|
3444
3445
|
amountOut: new import_bn2.default(data.amount_out.toString()),
|
|
3445
3446
|
byAmountIn,
|
|
3446
3447
|
insufficientLiquidity: false,
|
|
3448
|
+
deviationRatio: data.deviation_ratio,
|
|
3447
3449
|
packages,
|
|
3448
3450
|
paths: data.paths.map((path) => ({
|
|
3449
3451
|
id: path.id,
|
|
@@ -3588,7 +3590,6 @@ function getRouter(endpoint, apiKey, params) {
|
|
|
3588
3590
|
url += `&apiKey=${apiKey}`;
|
|
3589
3591
|
}
|
|
3590
3592
|
url += `&v=${SDK_VERSION}`;
|
|
3591
|
-
console.log("url", url);
|
|
3592
3593
|
const response = yield fetch(url);
|
|
3593
3594
|
return response;
|
|
3594
3595
|
} catch (error) {
|
|
@@ -3679,7 +3680,6 @@ function processFlattenRoutes(routerData) {
|
|
|
3679
3680
|
flattenedPaths[i].isLastUseOfIntermediateToken = true;
|
|
3680
3681
|
}
|
|
3681
3682
|
}
|
|
3682
|
-
console.log("flattenedPaths", flattenedPaths);
|
|
3683
3683
|
return {
|
|
3684
3684
|
quoteID: routerData.quoteID || "",
|
|
3685
3685
|
amountIn: routerData.amountIn,
|
|
@@ -8093,53 +8093,6 @@ var FullsailRouter = class {
|
|
|
8093
8093
|
});
|
|
8094
8094
|
}
|
|
8095
8095
|
};
|
|
8096
|
-
var CetusDlmmRouter = class {
|
|
8097
|
-
constructor(env, partner) {
|
|
8098
|
-
if (env !== 0 /* Mainnet */) {
|
|
8099
|
-
throw new Error("CetusRouter only supported on mainnet");
|
|
8100
|
-
}
|
|
8101
|
-
this.globalConfig = "0xc75b549b59be1a7cce72990e046cd3e6376e4c9f3b19ef16baa041b68ea709ba";
|
|
8102
|
-
this.partner = partner != null ? partner : "0x4e6a368a69a13fb953629a74e3dd43ed9dcb0dfda0a1d83f984a7efa2a739c0a";
|
|
8103
|
-
this.versioned = "0x99fc84d595fa0b90c72295e8a3674b1b171abcf808c287ce3e854148424e4bf9";
|
|
8104
|
-
}
|
|
8105
|
-
swap(txb, flattenedPath, swapContext, _extends) {
|
|
8106
|
-
const swapData = this.prepareSwapData(flattenedPath);
|
|
8107
|
-
this.executeSwapContract(txb, swapData, swapContext);
|
|
8108
|
-
}
|
|
8109
|
-
prepareSwapData(flattenedPath) {
|
|
8110
|
-
if (flattenedPath.path.publishedAt == null) {
|
|
8111
|
-
throw new Error("Cetus not set publishedAt");
|
|
8112
|
-
}
|
|
8113
|
-
const path = flattenedPath.path;
|
|
8114
|
-
const [coinAType, coinBType] = path.direction ? [path.from, path.target] : [path.target, path.from];
|
|
8115
|
-
const amountIn = flattenedPath.isLastUseOfIntermediateToken ? AGGREGATOR_V3_CONFIG.MAX_AMOUNT_IN : path.amountIn;
|
|
8116
|
-
return {
|
|
8117
|
-
coinAType,
|
|
8118
|
-
coinBType,
|
|
8119
|
-
direction: path.direction,
|
|
8120
|
-
amountIn,
|
|
8121
|
-
publishedAt: path.publishedAt,
|
|
8122
|
-
poolId: path.id
|
|
8123
|
-
};
|
|
8124
|
-
}
|
|
8125
|
-
executeSwapContract(txb, swapData, swapContext) {
|
|
8126
|
-
const args = [
|
|
8127
|
-
swapContext,
|
|
8128
|
-
txb.object(this.globalConfig),
|
|
8129
|
-
txb.object(swapData.poolId),
|
|
8130
|
-
txb.object(this.partner),
|
|
8131
|
-
txb.pure.bool(swapData.direction),
|
|
8132
|
-
txb.pure.u64(swapData.amountIn),
|
|
8133
|
-
txb.object(this.versioned),
|
|
8134
|
-
txb.object(utils.SUI_CLOCK_OBJECT_ID)
|
|
8135
|
-
];
|
|
8136
|
-
txb.moveCall({
|
|
8137
|
-
target: `${swapData.publishedAt}::cetus_dlmm::swap`,
|
|
8138
|
-
typeArguments: [swapData.coinAType, swapData.coinBType],
|
|
8139
|
-
arguments: args
|
|
8140
|
-
});
|
|
8141
|
-
}
|
|
8142
|
-
};
|
|
8143
8096
|
|
|
8144
8097
|
// src/client.ts
|
|
8145
8098
|
var CETUS = "CETUS";
|
|
@@ -8172,7 +8125,6 @@ var MAGMA = "MAGMA";
|
|
|
8172
8125
|
var SEVENK = "SEVENK";
|
|
8173
8126
|
var HAEDALHMMV2 = "HAEDALHMMV2";
|
|
8174
8127
|
var FULLSAIL = "FULLSAIL";
|
|
8175
|
-
var CETUSDLMM = "CETUSDLMM";
|
|
8176
8128
|
var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v3";
|
|
8177
8129
|
var ALL_DEXES = [
|
|
8178
8130
|
CETUS,
|
|
@@ -8203,8 +8155,7 @@ var ALL_DEXES = [
|
|
|
8203
8155
|
MAGMA,
|
|
8204
8156
|
SEVENK,
|
|
8205
8157
|
HAEDALHMMV2,
|
|
8206
|
-
FULLSAIL
|
|
8207
|
-
CETUSDLMM
|
|
8158
|
+
FULLSAIL
|
|
8208
8159
|
];
|
|
8209
8160
|
function getAllProviders() {
|
|
8210
8161
|
return ALL_DEXES;
|
|
@@ -8283,7 +8234,6 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
8283
8234
|
);
|
|
8284
8235
|
this.apiKey = params.apiKey || "";
|
|
8285
8236
|
this.partner = params.partner;
|
|
8286
|
-
this.cetusDlmmPartner = params.cetusDlmmPartner;
|
|
8287
8237
|
if (params.overlayFeeRate) {
|
|
8288
8238
|
if (params.overlayFeeRate > 0 && params.overlayFeeRate <= CLIENT_CONFIG.MAX_OVERLAY_FEE_RATE) {
|
|
8289
8239
|
this.overlayFeeRate = params.overlayFeeRate * AGGREGATOR_V3_CONFIG.FEE_DENOMINATOR;
|
|
@@ -8316,6 +8266,11 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
8316
8266
|
return DEEPBOOK_V3_DEEP_FEE_TYPES.Testnet;
|
|
8317
8267
|
}
|
|
8318
8268
|
}
|
|
8269
|
+
getDeepbookV3Config() {
|
|
8270
|
+
return __async(this, null, function* () {
|
|
8271
|
+
return yield getDeepbookV3Config(this.endpoint);
|
|
8272
|
+
});
|
|
8273
|
+
}
|
|
8319
8274
|
getOneCoinUsedToMerge(coinType) {
|
|
8320
8275
|
return __async(this, null, function* () {
|
|
8321
8276
|
try {
|
|
@@ -8348,7 +8303,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
8348
8303
|
return __async(this, null, function* () {
|
|
8349
8304
|
});
|
|
8350
8305
|
}
|
|
8351
|
-
newDexRouterV3(provider, pythPriceIDs, partner
|
|
8306
|
+
newDexRouterV3(provider, pythPriceIDs, partner) {
|
|
8352
8307
|
switch (provider) {
|
|
8353
8308
|
case CETUS:
|
|
8354
8309
|
return new CetusRouter(this.env, partner);
|
|
@@ -8408,15 +8363,13 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
8408
8363
|
return new HaedalHMMV2Router(this.env, pythPriceIDs);
|
|
8409
8364
|
case FULLSAIL:
|
|
8410
8365
|
return new FullsailRouter(this.env);
|
|
8411
|
-
case CETUSDLMM:
|
|
8412
|
-
return new CetusDlmmRouter(this.env, cetusDlmmPartner);
|
|
8413
8366
|
default:
|
|
8414
8367
|
throw new Error(
|
|
8415
8368
|
`${CLIENT_CONFIG.ERRORS.UNSUPPORTED_DEX} ${provider}`
|
|
8416
8369
|
);
|
|
8417
8370
|
}
|
|
8418
8371
|
}
|
|
8419
|
-
expectInputSwapV3(txb, inputCoin, routerData, expectAmountOut, amountOutLimit, pythPriceIDs, partner
|
|
8372
|
+
expectInputSwapV3(txb, inputCoin, routerData, expectAmountOut, amountOutLimit, pythPriceIDs, partner) {
|
|
8420
8373
|
if (routerData.quoteID == null) {
|
|
8421
8374
|
throw new Error(CLIENT_CONFIG.ERRORS.QUOTE_ID_REQUIRED);
|
|
8422
8375
|
}
|
|
@@ -8441,12 +8394,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
8441
8394
|
if (!dexRouters.has(path.provider)) {
|
|
8442
8395
|
dexRouters.set(
|
|
8443
8396
|
path.provider,
|
|
8444
|
-
this.newDexRouterV3(
|
|
8445
|
-
path.provider,
|
|
8446
|
-
pythPriceIDs,
|
|
8447
|
-
partner,
|
|
8448
|
-
cetusDlmmPartner
|
|
8449
|
-
)
|
|
8397
|
+
this.newDexRouterV3(path.provider, pythPriceIDs, partner)
|
|
8450
8398
|
);
|
|
8451
8399
|
}
|
|
8452
8400
|
const dex = dexRouters.get(path.provider);
|
|
@@ -8573,20 +8521,22 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
8573
8521
|
}
|
|
8574
8522
|
routerSwap(params) {
|
|
8575
8523
|
return __async(this, null, function* () {
|
|
8576
|
-
const { router, inputCoin, slippage, txb,
|
|
8524
|
+
const { router, inputCoin, slippage, txb, partner } = params;
|
|
8577
8525
|
if (slippage > 1 || slippage < 0) {
|
|
8578
8526
|
throw new Error(CLIENT_CONFIG.ERRORS.INVALID_SLIPPAGE);
|
|
8579
8527
|
}
|
|
8528
|
+
if (!params.router.packages || !params.router.packages.get(PACKAGE_NAMES.AGGREGATOR_V3)) {
|
|
8529
|
+
throw new Error(CLIENT_CONFIG.ERRORS.PACKAGES_REQUIRED);
|
|
8530
|
+
}
|
|
8580
8531
|
const byAmountIn = params.router.byAmountIn;
|
|
8581
8532
|
const amountIn = router.amountIn;
|
|
8582
8533
|
const amountOut = router.amountOut;
|
|
8534
|
+
checkOverlayFeeConfig(this.overlayFeeRate, this.overlayFeeReceiver);
|
|
8583
8535
|
let overlayFee = new import_bn6.default(0);
|
|
8584
|
-
if (
|
|
8585
|
-
|
|
8586
|
-
|
|
8587
|
-
|
|
8588
|
-
overlayFee = amountIn.mul(new import_bn6.default(this.overlayFeeRate)).div(new import_bn6.default(1e6));
|
|
8589
|
-
}
|
|
8536
|
+
if (byAmountIn) {
|
|
8537
|
+
overlayFee = amountOut.mul(new import_bn6.default(this.overlayFeeRate)).div(new import_bn6.default(1e6));
|
|
8538
|
+
} else {
|
|
8539
|
+
overlayFee = amountIn.mul(new import_bn6.default(this.overlayFeeRate)).div(new import_bn6.default(1e6));
|
|
8590
8540
|
}
|
|
8591
8541
|
const expectedAmountOut = byAmountIn ? amountOut.sub(overlayFee) : amountOut;
|
|
8592
8542
|
const expectedAmountIn = byAmountIn ? amountIn : amountIn.add(overlayFee);
|
|
@@ -8595,9 +8545,6 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
8595
8545
|
byAmountIn,
|
|
8596
8546
|
slippage
|
|
8597
8547
|
);
|
|
8598
|
-
if (!params.router.packages || !params.router.packages.get(PACKAGE_NAMES.AGGREGATOR_V3)) {
|
|
8599
|
-
throw new Error(CLIENT_CONFIG.ERRORS.PACKAGES_REQUIRED);
|
|
8600
|
-
}
|
|
8601
8548
|
const priceIDs = findPythPriceIDs(router.paths);
|
|
8602
8549
|
const priceInfoObjectIds = priceIDs.length > 0 ? yield this.updatePythPriceIDs(priceIDs, txb) : /* @__PURE__ */ new Map();
|
|
8603
8550
|
if (byAmountIn) {
|
|
@@ -8630,17 +8577,16 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
8630
8577
|
const fromCoinType = router.paths[0].from;
|
|
8631
8578
|
const targetCoinType = router.paths[router.paths.length - 1].target;
|
|
8632
8579
|
const byAmountIn = router.byAmountIn;
|
|
8580
|
+
checkOverlayFeeConfig(this.overlayFeeRate, this.overlayFeeReceiver);
|
|
8633
8581
|
let overlayFee = 0;
|
|
8634
|
-
if (
|
|
8635
|
-
|
|
8636
|
-
|
|
8637
|
-
|
|
8638
|
-
|
|
8639
|
-
|
|
8640
|
-
|
|
8641
|
-
|
|
8642
|
-
);
|
|
8643
|
-
}
|
|
8582
|
+
if (byAmountIn) {
|
|
8583
|
+
overlayFee = Number(
|
|
8584
|
+
router.amountOut.mul(new import_bn6.default(this.overlayFeeRate)).div(new import_bn6.default(1e6)).toString()
|
|
8585
|
+
);
|
|
8586
|
+
} else {
|
|
8587
|
+
overlayFee = Number(
|
|
8588
|
+
router.amountIn.mul(new import_bn6.default(this.overlayFeeRate)).div(new import_bn6.default(1e6)).toString()
|
|
8589
|
+
);
|
|
8644
8590
|
}
|
|
8645
8591
|
const expectedAmountOut = byAmountIn ? router.amountOut.sub(new import_bn6.default(overlayFee)) : router.amountOut;
|
|
8646
8592
|
const expectedAmountIn = byAmountIn ? router.amountIn : router.amountIn.add(new import_bn6.default(overlayFee));
|
|
@@ -8692,18 +8638,17 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
8692
8638
|
}
|
|
8693
8639
|
fixableRouterSwapV3(params) {
|
|
8694
8640
|
return __async(this, null, function* () {
|
|
8695
|
-
const { router, inputCoin, slippage, txb,
|
|
8641
|
+
const { router, inputCoin, slippage, txb, partner } = params;
|
|
8642
|
+
checkOverlayFeeConfig(this.overlayFeeRate, this.overlayFeeReceiver);
|
|
8696
8643
|
let overlayFee = 0;
|
|
8697
|
-
if (
|
|
8698
|
-
|
|
8699
|
-
|
|
8700
|
-
|
|
8701
|
-
|
|
8702
|
-
|
|
8703
|
-
|
|
8704
|
-
|
|
8705
|
-
);
|
|
8706
|
-
}
|
|
8644
|
+
if (router.byAmountIn) {
|
|
8645
|
+
overlayFee = Number(
|
|
8646
|
+
router.amountOut.mul(new import_bn6.default(this.overlayFeeRate)).div(new import_bn6.default(1e6)).toString()
|
|
8647
|
+
);
|
|
8648
|
+
} else {
|
|
8649
|
+
overlayFee = Number(
|
|
8650
|
+
router.amountIn.mul(new import_bn6.default(this.overlayFeeRate)).div(new import_bn6.default(1e6)).toString()
|
|
8651
|
+
);
|
|
8707
8652
|
}
|
|
8708
8653
|
const expectedAmountOut = router.byAmountIn ? router.amountOut.sub(new import_bn6.default(overlayFee)) : router.amountOut;
|
|
8709
8654
|
const expectedAmountIn = router.byAmountIn ? router.amountIn : router.amountIn.add(new import_bn6.default(overlayFee));
|
|
@@ -8812,6 +8757,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
8812
8757
|
const routeData = {
|
|
8813
8758
|
amountIn,
|
|
8814
8759
|
amountOut: new import_bn6.default((_d = event.amount_out) != null ? _d : 0),
|
|
8760
|
+
deviationRatio: 0,
|
|
8815
8761
|
paths: [
|
|
8816
8762
|
{
|
|
8817
8763
|
id: pools[tempIndex],
|
|
@@ -8929,6 +8875,16 @@ function recordFirstCoinIndex(paths) {
|
|
|
8929
8875
|
}
|
|
8930
8876
|
return newCoinRecord;
|
|
8931
8877
|
}
|
|
8878
|
+
function checkOverlayFeeConfig(overlayFeeRate, overlayFeeReceiver) {
|
|
8879
|
+
if (overlayFeeRate > CLIENT_CONFIG.MAX_OVERLAY_FEE_RATE) {
|
|
8880
|
+
throw new Error(CLIENT_CONFIG.ERRORS.INVALID_OVERLAY_FEE_RATE);
|
|
8881
|
+
}
|
|
8882
|
+
if (overlayFeeReceiver === "0x0" && overlayFeeRate > 0) {
|
|
8883
|
+
throw new Error(
|
|
8884
|
+
CLIENT_CONFIG.ERRORS.OVERLAY_FEE_RECEIVER_REQUIRED
|
|
8885
|
+
);
|
|
8886
|
+
}
|
|
8887
|
+
}
|
|
8932
8888
|
|
|
8933
8889
|
// src/types/sui.ts
|
|
8934
8890
|
var getDefaultSuiInputType = (value) => {
|
|
@@ -8970,7 +8926,6 @@ exports.AggregatorServerErrorCode = AggregatorServerErrorCode;
|
|
|
8970
8926
|
exports.BLUEFIN = BLUEFIN;
|
|
8971
8927
|
exports.BLUEMOVE = BLUEMOVE;
|
|
8972
8928
|
exports.CETUS = CETUS;
|
|
8973
|
-
exports.CETUSDLMM = CETUSDLMM;
|
|
8974
8929
|
exports.CETUS_DEX = CETUS_DEX;
|
|
8975
8930
|
exports.CETUS_MODULE = CETUS_MODULE;
|
|
8976
8931
|
exports.CETUS_PUBLISHED_AT = CETUS_PUBLISHED_AT;
|