@cetusprotocol/aggregator-sdk 1.1.3 → 1.1.5
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 +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +24 -44
- package/dist/index.mjs +24 -44
- package/package.json +2 -2
- package/test.json +267 -0
- package/.claude/settings.local.json +0 -41
- 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
|
@@ -627,7 +627,7 @@ declare const SuiZeroCoinFn = "0x2::coin::zero";
|
|
|
627
627
|
declare const DEEPBOOK_PACKAGE_ID = "0x000000000000000000000000000000000000000000000000000000000000dee9";
|
|
628
628
|
declare const DEEPBOOK_PUBLISHED_AT = "0x000000000000000000000000000000000000000000000000000000000000dee9";
|
|
629
629
|
declare const CETUS_PUBLISHED_AT = "0x70968826ad1b4ba895753f634b0aea68d0672908ca1075a2abdf0fc9e0b2fc6a";
|
|
630
|
-
declare const CETUS_V3_PUBLISHED_AT = "
|
|
630
|
+
declare const CETUS_V3_PUBLISHED_AT = "0xb1e11ceaf3e7cd3031ef5e24804478ec3441c5aecdace910bdaca317a0c1c535";
|
|
631
631
|
declare const MAINNET_CETUS_GLOBAL_CONFIG_ID = "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f";
|
|
632
632
|
declare const TESTNET_CETUS_GLOBAL_CONFIG_ID = "0x6f4149091a5aea0e818e7243a13adcfb403842d670b9a2089de058512620687a";
|
|
633
633
|
declare const MAINNET_FLOWX_AMM_CONTAINER_ID = "0xb65dcbf63fd3ad5d0ebfbf334780dc9f785eff38a4459e37ab08fa79576ee511";
|
|
@@ -679,9 +679,9 @@ declare const DEEPBOOK_V3_DEEP_FEE_TYPES: {
|
|
|
679
679
|
declare const CLIENT_CONFIG: {
|
|
680
680
|
readonly DEFAULT_PYTH_URL: "https://hermes.pyth.network";
|
|
681
681
|
readonly PYTH_TIMEOUT: 3000;
|
|
682
|
-
readonly
|
|
682
|
+
readonly MAX_OVERLAY_FEE_RATE: 0.1;
|
|
683
|
+
readonly MAX_OVERLAY_FEE_RATE_NUMERATOR: 100000;
|
|
683
684
|
readonly FEE_RATE_MULTIPLIER: 1000000;
|
|
684
|
-
readonly MAX_FEE_RATE: 100000;
|
|
685
685
|
readonly DEFAULT_OVERLAY_FEE_RECEIVER: "0x0";
|
|
686
686
|
readonly ERRORS: {
|
|
687
687
|
readonly SIGNER_REQUIRED: "Signer is required, but not provided.";
|
|
@@ -702,7 +702,7 @@ declare const AGGREGATOR_V3_CONFIG: {
|
|
|
702
702
|
readonly MAX_FEE_RATE: 100000;
|
|
703
703
|
readonly MAX_AMOUNT_IN: "18446744073709551615";
|
|
704
704
|
readonly DEFAULT_PUBLISHED_AT: {
|
|
705
|
-
readonly Mainnet: "
|
|
705
|
+
readonly Mainnet: "0x33ec64e9bb369bf045ddc198c81adbf2acab424da37465d95296ee02045d2b17";
|
|
706
706
|
readonly Testnet: "0x0";
|
|
707
707
|
};
|
|
708
708
|
};
|
|
@@ -794,7 +794,7 @@ declare const GAS_TYPE_ARG = "0x2::sui::SUI";
|
|
|
794
794
|
declare const GAS_TYPE_ARG_LONG = "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";
|
|
795
795
|
declare const GAS_SYMBOL = "SUI";
|
|
796
796
|
declare const DEFAULT_NFT_TRANSFER_GAS_FEE = 450;
|
|
797
|
-
declare const SUI_SYSTEM_STATE_OBJECT_ID = "
|
|
797
|
+
declare const SUI_SYSTEM_STATE_OBJECT_ID = "0x0000000000000000000000000000000000000005";
|
|
798
798
|
/**
|
|
799
799
|
* This class provides helper methods for working with coins.
|
|
800
800
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -627,7 +627,7 @@ declare const SuiZeroCoinFn = "0x2::coin::zero";
|
|
|
627
627
|
declare const DEEPBOOK_PACKAGE_ID = "0x000000000000000000000000000000000000000000000000000000000000dee9";
|
|
628
628
|
declare const DEEPBOOK_PUBLISHED_AT = "0x000000000000000000000000000000000000000000000000000000000000dee9";
|
|
629
629
|
declare const CETUS_PUBLISHED_AT = "0x70968826ad1b4ba895753f634b0aea68d0672908ca1075a2abdf0fc9e0b2fc6a";
|
|
630
|
-
declare const CETUS_V3_PUBLISHED_AT = "
|
|
630
|
+
declare const CETUS_V3_PUBLISHED_AT = "0xb1e11ceaf3e7cd3031ef5e24804478ec3441c5aecdace910bdaca317a0c1c535";
|
|
631
631
|
declare const MAINNET_CETUS_GLOBAL_CONFIG_ID = "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f";
|
|
632
632
|
declare const TESTNET_CETUS_GLOBAL_CONFIG_ID = "0x6f4149091a5aea0e818e7243a13adcfb403842d670b9a2089de058512620687a";
|
|
633
633
|
declare const MAINNET_FLOWX_AMM_CONTAINER_ID = "0xb65dcbf63fd3ad5d0ebfbf334780dc9f785eff38a4459e37ab08fa79576ee511";
|
|
@@ -679,9 +679,9 @@ declare const DEEPBOOK_V3_DEEP_FEE_TYPES: {
|
|
|
679
679
|
declare const CLIENT_CONFIG: {
|
|
680
680
|
readonly DEFAULT_PYTH_URL: "https://hermes.pyth.network";
|
|
681
681
|
readonly PYTH_TIMEOUT: 3000;
|
|
682
|
-
readonly
|
|
682
|
+
readonly MAX_OVERLAY_FEE_RATE: 0.1;
|
|
683
|
+
readonly MAX_OVERLAY_FEE_RATE_NUMERATOR: 100000;
|
|
683
684
|
readonly FEE_RATE_MULTIPLIER: 1000000;
|
|
684
|
-
readonly MAX_FEE_RATE: 100000;
|
|
685
685
|
readonly DEFAULT_OVERLAY_FEE_RECEIVER: "0x0";
|
|
686
686
|
readonly ERRORS: {
|
|
687
687
|
readonly SIGNER_REQUIRED: "Signer is required, but not provided.";
|
|
@@ -702,7 +702,7 @@ declare const AGGREGATOR_V3_CONFIG: {
|
|
|
702
702
|
readonly MAX_FEE_RATE: 100000;
|
|
703
703
|
readonly MAX_AMOUNT_IN: "18446744073709551615";
|
|
704
704
|
readonly DEFAULT_PUBLISHED_AT: {
|
|
705
|
-
readonly Mainnet: "
|
|
705
|
+
readonly Mainnet: "0x33ec64e9bb369bf045ddc198c81adbf2acab424da37465d95296ee02045d2b17";
|
|
706
706
|
readonly Testnet: "0x0";
|
|
707
707
|
};
|
|
708
708
|
};
|
|
@@ -794,7 +794,7 @@ declare const GAS_TYPE_ARG = "0x2::sui::SUI";
|
|
|
794
794
|
declare const GAS_TYPE_ARG_LONG = "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";
|
|
795
795
|
declare const GAS_SYMBOL = "SUI";
|
|
796
796
|
declare const DEFAULT_NFT_TRANSFER_GAS_FEE = 450;
|
|
797
|
-
declare const SUI_SYSTEM_STATE_OBJECT_ID = "
|
|
797
|
+
declare const SUI_SYSTEM_STATE_OBJECT_ID = "0x0000000000000000000000000000000000000005";
|
|
798
798
|
/**
|
|
799
799
|
* This class provides helper methods for working with coins.
|
|
800
800
|
*/
|
package/dist/index.js
CHANGED
|
@@ -2999,7 +2999,7 @@ var GAS_TYPE_ARG = "0x2::sui::SUI";
|
|
|
2999
2999
|
var GAS_TYPE_ARG_LONG = "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";
|
|
3000
3000
|
var GAS_SYMBOL = "SUI";
|
|
3001
3001
|
var DEFAULT_NFT_TRANSFER_GAS_FEE = 450;
|
|
3002
|
-
var SUI_SYSTEM_STATE_OBJECT_ID = "
|
|
3002
|
+
var SUI_SYSTEM_STATE_OBJECT_ID = "0x0000000000000000000000000000000000000005";
|
|
3003
3003
|
var CoinUtils = class _CoinUtils {
|
|
3004
3004
|
/**
|
|
3005
3005
|
* Get the coin type argument from a SuiMoveObject.
|
|
@@ -3107,18 +3107,10 @@ var CoinUtils = class _CoinUtils {
|
|
|
3107
3107
|
* @returns The CoinAsset objects that have a balance greater than or equal to the given amount.
|
|
3108
3108
|
*/
|
|
3109
3109
|
static selectCoinObjectIdGreaterThanOrEqual(coins, amount, exclude = []) {
|
|
3110
|
-
const selectedResult = _CoinUtils.selectCoinAssetGreaterThanOrEqual(
|
|
3111
|
-
|
|
3112
|
-
amount,
|
|
3113
|
-
exclude
|
|
3114
|
-
);
|
|
3115
|
-
const objectArray = selectedResult.selectedCoins.map(
|
|
3116
|
-
(item) => item.coinObjectId
|
|
3117
|
-
);
|
|
3110
|
+
const selectedResult = _CoinUtils.selectCoinAssetGreaterThanOrEqual(coins, amount, exclude);
|
|
3111
|
+
const objectArray = selectedResult.selectedCoins.map((item) => item.coinObjectId);
|
|
3118
3112
|
const remainCoins = selectedResult.remainingCoins;
|
|
3119
|
-
const amountArray = selectedResult.selectedCoins.map(
|
|
3120
|
-
(item) => item.balance.toString()
|
|
3121
|
-
);
|
|
3113
|
+
const amountArray = selectedResult.selectedCoins.map((item) => item.balance.toString());
|
|
3122
3114
|
return { objectArray, remainCoins, amountArray };
|
|
3123
3115
|
}
|
|
3124
3116
|
/**
|
|
@@ -3130,9 +3122,7 @@ var CoinUtils = class _CoinUtils {
|
|
|
3130
3122
|
* @returns The CoinAsset objects that have a balance greater than or equal to the given amount.
|
|
3131
3123
|
*/
|
|
3132
3124
|
static selectCoinAssetGreaterThanOrEqual(coins, amount, exclude = []) {
|
|
3133
|
-
const sortedCoins = _CoinUtils.sortByBalance(
|
|
3134
|
-
coins.filter((c) => !exclude.includes(c.coinObjectId))
|
|
3135
|
-
);
|
|
3125
|
+
const sortedCoins = _CoinUtils.sortByBalance(coins.filter((c) => !exclude.includes(c.coinObjectId)));
|
|
3136
3126
|
const total = _CoinUtils.calculateTotalBalance(sortedCoins);
|
|
3137
3127
|
if (total < amount) {
|
|
3138
3128
|
return { selectedCoins: [], remainingCoins: sortedCoins };
|
|
@@ -3145,13 +3135,9 @@ var CoinUtils = class _CoinUtils {
|
|
|
3145
3135
|
const remainingCoins = [...sortedCoins];
|
|
3146
3136
|
while (sum2 < total) {
|
|
3147
3137
|
const target = amount - sum2;
|
|
3148
|
-
const coinWithSmallestSufficientBalanceIndex = remainingCoins.findIndex(
|
|
3149
|
-
(c) => c.balance >= target
|
|
3150
|
-
);
|
|
3138
|
+
const coinWithSmallestSufficientBalanceIndex = remainingCoins.findIndex((c) => c.balance >= target);
|
|
3151
3139
|
if (coinWithSmallestSufficientBalanceIndex !== -1) {
|
|
3152
|
-
selectedCoins.push(
|
|
3153
|
-
remainingCoins[coinWithSmallestSufficientBalanceIndex]
|
|
3154
|
-
);
|
|
3140
|
+
selectedCoins.push(remainingCoins[coinWithSmallestSufficientBalanceIndex]);
|
|
3155
3141
|
remainingCoins.splice(coinWithSmallestSufficientBalanceIndex, 1);
|
|
3156
3142
|
break;
|
|
3157
3143
|
}
|
|
@@ -3161,10 +3147,7 @@ var CoinUtils = class _CoinUtils {
|
|
|
3161
3147
|
sum2 += coinWithLargestBalance.balance;
|
|
3162
3148
|
}
|
|
3163
3149
|
}
|
|
3164
|
-
return {
|
|
3165
|
-
selectedCoins: _CoinUtils.sortByBalance(selectedCoins),
|
|
3166
|
-
remainingCoins: _CoinUtils.sortByBalance(remainingCoins)
|
|
3167
|
-
};
|
|
3150
|
+
return { selectedCoins: _CoinUtils.sortByBalance(selectedCoins), remainingCoins: _CoinUtils.sortByBalance(remainingCoins) };
|
|
3168
3151
|
}
|
|
3169
3152
|
/**
|
|
3170
3153
|
* Sort the CoinAsset objects by their balance.
|
|
@@ -3173,14 +3156,10 @@ var CoinUtils = class _CoinUtils {
|
|
|
3173
3156
|
* @returns The sorted CoinAsset objects.
|
|
3174
3157
|
*/
|
|
3175
3158
|
static sortByBalance(coins) {
|
|
3176
|
-
return coins.sort(
|
|
3177
|
-
(a, b) => a.balance < b.balance ? -1 : a.balance > b.balance ? 1 : 0
|
|
3178
|
-
);
|
|
3159
|
+
return coins.sort((a, b) => a.balance < b.balance ? -1 : a.balance > b.balance ? 1 : 0);
|
|
3179
3160
|
}
|
|
3180
3161
|
static sortByBalanceDes(coins) {
|
|
3181
|
-
return coins.sort(
|
|
3182
|
-
(a, b) => a.balance > b.balance ? -1 : a.balance < b.balance ? 0 : 1
|
|
3183
|
-
);
|
|
3162
|
+
return coins.sort((a, b) => a.balance > b.balance ? -1 : a.balance < b.balance ? 0 : 1);
|
|
3184
3163
|
}
|
|
3185
3164
|
/**
|
|
3186
3165
|
* Calculate the total balance of a list of CoinAsset objects.
|
|
@@ -3361,7 +3340,7 @@ var SuiZeroCoinFn = "0x2::coin::zero";
|
|
|
3361
3340
|
var DEEPBOOK_PACKAGE_ID = "0x000000000000000000000000000000000000000000000000000000000000dee9";
|
|
3362
3341
|
var DEEPBOOK_PUBLISHED_AT = "0x000000000000000000000000000000000000000000000000000000000000dee9";
|
|
3363
3342
|
var CETUS_PUBLISHED_AT = "0x70968826ad1b4ba895753f634b0aea68d0672908ca1075a2abdf0fc9e0b2fc6a";
|
|
3364
|
-
var CETUS_V3_PUBLISHED_AT = "
|
|
3343
|
+
var CETUS_V3_PUBLISHED_AT = "0xb1e11ceaf3e7cd3031ef5e24804478ec3441c5aecdace910bdaca317a0c1c535";
|
|
3365
3344
|
var MAINNET_CETUS_GLOBAL_CONFIG_ID = "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f";
|
|
3366
3345
|
var TESTNET_CETUS_GLOBAL_CONFIG_ID = "0x6f4149091a5aea0e818e7243a13adcfb403842d670b9a2089de058512620687a";
|
|
3367
3346
|
var MAINNET_FLOWX_AMM_CONTAINER_ID = "0xb65dcbf63fd3ad5d0ebfbf334780dc9f785eff38a4459e37ab08fa79576ee511";
|
|
@@ -3418,9 +3397,9 @@ var DEEPBOOK_V3_DEEP_FEE_TYPES = {
|
|
|
3418
3397
|
var CLIENT_CONFIG = {
|
|
3419
3398
|
DEFAULT_PYTH_URL: "https://hermes.pyth.network",
|
|
3420
3399
|
PYTH_TIMEOUT: 3e3,
|
|
3421
|
-
|
|
3400
|
+
MAX_OVERLAY_FEE_RATE: 0.1,
|
|
3401
|
+
MAX_OVERLAY_FEE_RATE_NUMERATOR: 1e5,
|
|
3422
3402
|
FEE_RATE_MULTIPLIER: 1e6,
|
|
3423
|
-
MAX_FEE_RATE: 1e5,
|
|
3424
3403
|
DEFAULT_OVERLAY_FEE_RECEIVER: "0x0",
|
|
3425
3404
|
// Error Messages
|
|
3426
3405
|
ERRORS: {
|
|
@@ -3443,13 +3422,13 @@ var AGGREGATOR_V3_CONFIG = {
|
|
|
3443
3422
|
// 10%
|
|
3444
3423
|
MAX_AMOUNT_IN: U64_MAX,
|
|
3445
3424
|
DEFAULT_PUBLISHED_AT: {
|
|
3446
|
-
Mainnet: "
|
|
3425
|
+
Mainnet: "0x33ec64e9bb369bf045ddc198c81adbf2acab424da37465d95296ee02045d2b17",
|
|
3447
3426
|
Testnet: "0x0"
|
|
3448
3427
|
}
|
|
3449
3428
|
};
|
|
3450
3429
|
|
|
3451
3430
|
// src/api.ts
|
|
3452
|
-
var SDK_VERSION =
|
|
3431
|
+
var SDK_VERSION = 1010105;
|
|
3453
3432
|
function parseRouterResponse(data, byAmountIn) {
|
|
3454
3433
|
let packages = /* @__PURE__ */ new Map();
|
|
3455
3434
|
if (data.packages) {
|
|
@@ -3612,7 +3591,6 @@ function getRouter(endpoint, apiKey, params) {
|
|
|
3612
3591
|
url += `&apiKey=${apiKey}`;
|
|
3613
3592
|
}
|
|
3614
3593
|
url += `&v=${SDK_VERSION}`;
|
|
3615
|
-
console.log("url", url);
|
|
3616
3594
|
const response = yield fetch(url);
|
|
3617
3595
|
return response;
|
|
3618
3596
|
} catch (error) {
|
|
@@ -3703,7 +3681,6 @@ function processFlattenRoutes(routerData) {
|
|
|
3703
3681
|
flattenedPaths[i].isLastUseOfIntermediateToken = true;
|
|
3704
3682
|
}
|
|
3705
3683
|
}
|
|
3706
|
-
console.log("flattenedPaths", flattenedPaths);
|
|
3707
3684
|
return {
|
|
3708
3685
|
quoteID: routerData.quoteID || "",
|
|
3709
3686
|
amountIn: routerData.amountIn,
|
|
@@ -6719,7 +6696,7 @@ var SpringsuiRouter = class {
|
|
|
6719
6696
|
const args = [
|
|
6720
6697
|
swapContext,
|
|
6721
6698
|
txb.object(swapData.poolId),
|
|
6722
|
-
txb.object(
|
|
6699
|
+
txb.object("0x5"),
|
|
6723
6700
|
txb.pure.u64(swapData.amountIn),
|
|
6724
6701
|
txb.pure.bool(swapData.direction)
|
|
6725
6702
|
];
|
|
@@ -7401,7 +7378,8 @@ var VoloRouter = class {
|
|
|
7401
7378
|
swapContext,
|
|
7402
7379
|
txb.object(this.stakePool),
|
|
7403
7380
|
txb.object(this.metadata),
|
|
7404
|
-
txb.object(
|
|
7381
|
+
txb.object("0x5"),
|
|
7382
|
+
// SuiSystemState
|
|
7405
7383
|
txb.pure.bool(swapData.direction),
|
|
7406
7384
|
txb.pure.u64(swapData.amountIn)
|
|
7407
7385
|
];
|
|
@@ -7452,7 +7430,8 @@ var AfsuiRouter = class {
|
|
|
7452
7430
|
swapContext,
|
|
7453
7431
|
txb.object(this.stakedSuiVault),
|
|
7454
7432
|
txb.object(this.safe),
|
|
7455
|
-
txb.object(
|
|
7433
|
+
txb.object("0x5"),
|
|
7434
|
+
// SuiSystemState
|
|
7456
7435
|
txb.object(this.referVault),
|
|
7457
7436
|
txb.object(this.validator),
|
|
7458
7437
|
txb.pure.bool(swapData.direction),
|
|
@@ -7497,7 +7476,8 @@ var HaedalRouter = class {
|
|
|
7497
7476
|
const args = [
|
|
7498
7477
|
swapContext,
|
|
7499
7478
|
txb.object(swapData.poolId),
|
|
7500
|
-
txb.object(
|
|
7479
|
+
txb.object("0x5"),
|
|
7480
|
+
// SuiSystemState
|
|
7501
7481
|
txb.pure.bool(swapData.direction),
|
|
7502
7482
|
txb.pure.u64(swapData.amountIn)
|
|
7503
7483
|
];
|
|
@@ -8256,7 +8236,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
8256
8236
|
this.apiKey = params.apiKey || "";
|
|
8257
8237
|
this.partner = params.partner;
|
|
8258
8238
|
if (params.overlayFeeRate) {
|
|
8259
|
-
if (params.overlayFeeRate > 0 && params.overlayFeeRate <= CLIENT_CONFIG.
|
|
8239
|
+
if (params.overlayFeeRate > 0 && params.overlayFeeRate <= CLIENT_CONFIG.MAX_OVERLAY_FEE_RATE) {
|
|
8260
8240
|
this.overlayFeeRate = params.overlayFeeRate * AGGREGATOR_V3_CONFIG.FEE_DENOMINATOR;
|
|
8261
8241
|
if (this.overlayFeeRate > AGGREGATOR_V3_CONFIG.MAX_FEE_RATE) {
|
|
8262
8242
|
throw new Error(
|
|
@@ -8897,7 +8877,7 @@ function recordFirstCoinIndex(paths) {
|
|
|
8897
8877
|
return newCoinRecord;
|
|
8898
8878
|
}
|
|
8899
8879
|
function checkOverlayFeeConfig(overlayFeeRate, overlayFeeReceiver) {
|
|
8900
|
-
if (overlayFeeRate > CLIENT_CONFIG.
|
|
8880
|
+
if (overlayFeeRate > CLIENT_CONFIG.MAX_OVERLAY_FEE_RATE_NUMERATOR) {
|
|
8901
8881
|
throw new Error(CLIENT_CONFIG.ERRORS.INVALID_OVERLAY_FEE_RATE);
|
|
8902
8882
|
}
|
|
8903
8883
|
if (overlayFeeReceiver === "0x0" && overlayFeeRate > 0) {
|
package/dist/index.mjs
CHANGED
|
@@ -2993,7 +2993,7 @@ var GAS_TYPE_ARG = "0x2::sui::SUI";
|
|
|
2993
2993
|
var GAS_TYPE_ARG_LONG = "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";
|
|
2994
2994
|
var GAS_SYMBOL = "SUI";
|
|
2995
2995
|
var DEFAULT_NFT_TRANSFER_GAS_FEE = 450;
|
|
2996
|
-
var SUI_SYSTEM_STATE_OBJECT_ID = "
|
|
2996
|
+
var SUI_SYSTEM_STATE_OBJECT_ID = "0x0000000000000000000000000000000000000005";
|
|
2997
2997
|
var CoinUtils = class _CoinUtils {
|
|
2998
2998
|
/**
|
|
2999
2999
|
* Get the coin type argument from a SuiMoveObject.
|
|
@@ -3101,18 +3101,10 @@ var CoinUtils = class _CoinUtils {
|
|
|
3101
3101
|
* @returns The CoinAsset objects that have a balance greater than or equal to the given amount.
|
|
3102
3102
|
*/
|
|
3103
3103
|
static selectCoinObjectIdGreaterThanOrEqual(coins, amount, exclude = []) {
|
|
3104
|
-
const selectedResult = _CoinUtils.selectCoinAssetGreaterThanOrEqual(
|
|
3105
|
-
|
|
3106
|
-
amount,
|
|
3107
|
-
exclude
|
|
3108
|
-
);
|
|
3109
|
-
const objectArray = selectedResult.selectedCoins.map(
|
|
3110
|
-
(item) => item.coinObjectId
|
|
3111
|
-
);
|
|
3104
|
+
const selectedResult = _CoinUtils.selectCoinAssetGreaterThanOrEqual(coins, amount, exclude);
|
|
3105
|
+
const objectArray = selectedResult.selectedCoins.map((item) => item.coinObjectId);
|
|
3112
3106
|
const remainCoins = selectedResult.remainingCoins;
|
|
3113
|
-
const amountArray = selectedResult.selectedCoins.map(
|
|
3114
|
-
(item) => item.balance.toString()
|
|
3115
|
-
);
|
|
3107
|
+
const amountArray = selectedResult.selectedCoins.map((item) => item.balance.toString());
|
|
3116
3108
|
return { objectArray, remainCoins, amountArray };
|
|
3117
3109
|
}
|
|
3118
3110
|
/**
|
|
@@ -3124,9 +3116,7 @@ var CoinUtils = class _CoinUtils {
|
|
|
3124
3116
|
* @returns The CoinAsset objects that have a balance greater than or equal to the given amount.
|
|
3125
3117
|
*/
|
|
3126
3118
|
static selectCoinAssetGreaterThanOrEqual(coins, amount, exclude = []) {
|
|
3127
|
-
const sortedCoins = _CoinUtils.sortByBalance(
|
|
3128
|
-
coins.filter((c) => !exclude.includes(c.coinObjectId))
|
|
3129
|
-
);
|
|
3119
|
+
const sortedCoins = _CoinUtils.sortByBalance(coins.filter((c) => !exclude.includes(c.coinObjectId)));
|
|
3130
3120
|
const total = _CoinUtils.calculateTotalBalance(sortedCoins);
|
|
3131
3121
|
if (total < amount) {
|
|
3132
3122
|
return { selectedCoins: [], remainingCoins: sortedCoins };
|
|
@@ -3139,13 +3129,9 @@ var CoinUtils = class _CoinUtils {
|
|
|
3139
3129
|
const remainingCoins = [...sortedCoins];
|
|
3140
3130
|
while (sum2 < total) {
|
|
3141
3131
|
const target = amount - sum2;
|
|
3142
|
-
const coinWithSmallestSufficientBalanceIndex = remainingCoins.findIndex(
|
|
3143
|
-
(c) => c.balance >= target
|
|
3144
|
-
);
|
|
3132
|
+
const coinWithSmallestSufficientBalanceIndex = remainingCoins.findIndex((c) => c.balance >= target);
|
|
3145
3133
|
if (coinWithSmallestSufficientBalanceIndex !== -1) {
|
|
3146
|
-
selectedCoins.push(
|
|
3147
|
-
remainingCoins[coinWithSmallestSufficientBalanceIndex]
|
|
3148
|
-
);
|
|
3134
|
+
selectedCoins.push(remainingCoins[coinWithSmallestSufficientBalanceIndex]);
|
|
3149
3135
|
remainingCoins.splice(coinWithSmallestSufficientBalanceIndex, 1);
|
|
3150
3136
|
break;
|
|
3151
3137
|
}
|
|
@@ -3155,10 +3141,7 @@ var CoinUtils = class _CoinUtils {
|
|
|
3155
3141
|
sum2 += coinWithLargestBalance.balance;
|
|
3156
3142
|
}
|
|
3157
3143
|
}
|
|
3158
|
-
return {
|
|
3159
|
-
selectedCoins: _CoinUtils.sortByBalance(selectedCoins),
|
|
3160
|
-
remainingCoins: _CoinUtils.sortByBalance(remainingCoins)
|
|
3161
|
-
};
|
|
3144
|
+
return { selectedCoins: _CoinUtils.sortByBalance(selectedCoins), remainingCoins: _CoinUtils.sortByBalance(remainingCoins) };
|
|
3162
3145
|
}
|
|
3163
3146
|
/**
|
|
3164
3147
|
* Sort the CoinAsset objects by their balance.
|
|
@@ -3167,14 +3150,10 @@ var CoinUtils = class _CoinUtils {
|
|
|
3167
3150
|
* @returns The sorted CoinAsset objects.
|
|
3168
3151
|
*/
|
|
3169
3152
|
static sortByBalance(coins) {
|
|
3170
|
-
return coins.sort(
|
|
3171
|
-
(a, b) => a.balance < b.balance ? -1 : a.balance > b.balance ? 1 : 0
|
|
3172
|
-
);
|
|
3153
|
+
return coins.sort((a, b) => a.balance < b.balance ? -1 : a.balance > b.balance ? 1 : 0);
|
|
3173
3154
|
}
|
|
3174
3155
|
static sortByBalanceDes(coins) {
|
|
3175
|
-
return coins.sort(
|
|
3176
|
-
(a, b) => a.balance > b.balance ? -1 : a.balance < b.balance ? 0 : 1
|
|
3177
|
-
);
|
|
3156
|
+
return coins.sort((a, b) => a.balance > b.balance ? -1 : a.balance < b.balance ? 0 : 1);
|
|
3178
3157
|
}
|
|
3179
3158
|
/**
|
|
3180
3159
|
* Calculate the total balance of a list of CoinAsset objects.
|
|
@@ -3355,7 +3334,7 @@ var SuiZeroCoinFn = "0x2::coin::zero";
|
|
|
3355
3334
|
var DEEPBOOK_PACKAGE_ID = "0x000000000000000000000000000000000000000000000000000000000000dee9";
|
|
3356
3335
|
var DEEPBOOK_PUBLISHED_AT = "0x000000000000000000000000000000000000000000000000000000000000dee9";
|
|
3357
3336
|
var CETUS_PUBLISHED_AT = "0x70968826ad1b4ba895753f634b0aea68d0672908ca1075a2abdf0fc9e0b2fc6a";
|
|
3358
|
-
var CETUS_V3_PUBLISHED_AT = "
|
|
3337
|
+
var CETUS_V3_PUBLISHED_AT = "0xb1e11ceaf3e7cd3031ef5e24804478ec3441c5aecdace910bdaca317a0c1c535";
|
|
3359
3338
|
var MAINNET_CETUS_GLOBAL_CONFIG_ID = "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f";
|
|
3360
3339
|
var TESTNET_CETUS_GLOBAL_CONFIG_ID = "0x6f4149091a5aea0e818e7243a13adcfb403842d670b9a2089de058512620687a";
|
|
3361
3340
|
var MAINNET_FLOWX_AMM_CONTAINER_ID = "0xb65dcbf63fd3ad5d0ebfbf334780dc9f785eff38a4459e37ab08fa79576ee511";
|
|
@@ -3412,9 +3391,9 @@ var DEEPBOOK_V3_DEEP_FEE_TYPES = {
|
|
|
3412
3391
|
var CLIENT_CONFIG = {
|
|
3413
3392
|
DEFAULT_PYTH_URL: "https://hermes.pyth.network",
|
|
3414
3393
|
PYTH_TIMEOUT: 3e3,
|
|
3415
|
-
|
|
3394
|
+
MAX_OVERLAY_FEE_RATE: 0.1,
|
|
3395
|
+
MAX_OVERLAY_FEE_RATE_NUMERATOR: 1e5,
|
|
3416
3396
|
FEE_RATE_MULTIPLIER: 1e6,
|
|
3417
|
-
MAX_FEE_RATE: 1e5,
|
|
3418
3397
|
DEFAULT_OVERLAY_FEE_RECEIVER: "0x0",
|
|
3419
3398
|
// Error Messages
|
|
3420
3399
|
ERRORS: {
|
|
@@ -3437,13 +3416,13 @@ var AGGREGATOR_V3_CONFIG = {
|
|
|
3437
3416
|
// 10%
|
|
3438
3417
|
MAX_AMOUNT_IN: U64_MAX,
|
|
3439
3418
|
DEFAULT_PUBLISHED_AT: {
|
|
3440
|
-
Mainnet: "
|
|
3419
|
+
Mainnet: "0x33ec64e9bb369bf045ddc198c81adbf2acab424da37465d95296ee02045d2b17",
|
|
3441
3420
|
Testnet: "0x0"
|
|
3442
3421
|
}
|
|
3443
3422
|
};
|
|
3444
3423
|
|
|
3445
3424
|
// src/api.ts
|
|
3446
|
-
var SDK_VERSION =
|
|
3425
|
+
var SDK_VERSION = 1010105;
|
|
3447
3426
|
function parseRouterResponse(data, byAmountIn) {
|
|
3448
3427
|
let packages = /* @__PURE__ */ new Map();
|
|
3449
3428
|
if (data.packages) {
|
|
@@ -3606,7 +3585,6 @@ function getRouter(endpoint, apiKey, params) {
|
|
|
3606
3585
|
url += `&apiKey=${apiKey}`;
|
|
3607
3586
|
}
|
|
3608
3587
|
url += `&v=${SDK_VERSION}`;
|
|
3609
|
-
console.log("url", url);
|
|
3610
3588
|
const response = yield fetch(url);
|
|
3611
3589
|
return response;
|
|
3612
3590
|
} catch (error) {
|
|
@@ -3697,7 +3675,6 @@ function processFlattenRoutes(routerData) {
|
|
|
3697
3675
|
flattenedPaths[i].isLastUseOfIntermediateToken = true;
|
|
3698
3676
|
}
|
|
3699
3677
|
}
|
|
3700
|
-
console.log("flattenedPaths", flattenedPaths);
|
|
3701
3678
|
return {
|
|
3702
3679
|
quoteID: routerData.quoteID || "",
|
|
3703
3680
|
amountIn: routerData.amountIn,
|
|
@@ -6713,7 +6690,7 @@ var SpringsuiRouter = class {
|
|
|
6713
6690
|
const args = [
|
|
6714
6691
|
swapContext,
|
|
6715
6692
|
txb.object(swapData.poolId),
|
|
6716
|
-
txb.object(
|
|
6693
|
+
txb.object("0x5"),
|
|
6717
6694
|
txb.pure.u64(swapData.amountIn),
|
|
6718
6695
|
txb.pure.bool(swapData.direction)
|
|
6719
6696
|
];
|
|
@@ -7395,7 +7372,8 @@ var VoloRouter = class {
|
|
|
7395
7372
|
swapContext,
|
|
7396
7373
|
txb.object(this.stakePool),
|
|
7397
7374
|
txb.object(this.metadata),
|
|
7398
|
-
txb.object(
|
|
7375
|
+
txb.object("0x5"),
|
|
7376
|
+
// SuiSystemState
|
|
7399
7377
|
txb.pure.bool(swapData.direction),
|
|
7400
7378
|
txb.pure.u64(swapData.amountIn)
|
|
7401
7379
|
];
|
|
@@ -7446,7 +7424,8 @@ var AfsuiRouter = class {
|
|
|
7446
7424
|
swapContext,
|
|
7447
7425
|
txb.object(this.stakedSuiVault),
|
|
7448
7426
|
txb.object(this.safe),
|
|
7449
|
-
txb.object(
|
|
7427
|
+
txb.object("0x5"),
|
|
7428
|
+
// SuiSystemState
|
|
7450
7429
|
txb.object(this.referVault),
|
|
7451
7430
|
txb.object(this.validator),
|
|
7452
7431
|
txb.pure.bool(swapData.direction),
|
|
@@ -7491,7 +7470,8 @@ var HaedalRouter = class {
|
|
|
7491
7470
|
const args = [
|
|
7492
7471
|
swapContext,
|
|
7493
7472
|
txb.object(swapData.poolId),
|
|
7494
|
-
txb.object(
|
|
7473
|
+
txb.object("0x5"),
|
|
7474
|
+
// SuiSystemState
|
|
7495
7475
|
txb.pure.bool(swapData.direction),
|
|
7496
7476
|
txb.pure.u64(swapData.amountIn)
|
|
7497
7477
|
];
|
|
@@ -8250,7 +8230,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
8250
8230
|
this.apiKey = params.apiKey || "";
|
|
8251
8231
|
this.partner = params.partner;
|
|
8252
8232
|
if (params.overlayFeeRate) {
|
|
8253
|
-
if (params.overlayFeeRate > 0 && params.overlayFeeRate <= CLIENT_CONFIG.
|
|
8233
|
+
if (params.overlayFeeRate > 0 && params.overlayFeeRate <= CLIENT_CONFIG.MAX_OVERLAY_FEE_RATE) {
|
|
8254
8234
|
this.overlayFeeRate = params.overlayFeeRate * AGGREGATOR_V3_CONFIG.FEE_DENOMINATOR;
|
|
8255
8235
|
if (this.overlayFeeRate > AGGREGATOR_V3_CONFIG.MAX_FEE_RATE) {
|
|
8256
8236
|
throw new Error(
|
|
@@ -8891,7 +8871,7 @@ function recordFirstCoinIndex(paths) {
|
|
|
8891
8871
|
return newCoinRecord;
|
|
8892
8872
|
}
|
|
8893
8873
|
function checkOverlayFeeConfig(overlayFeeRate, overlayFeeReceiver) {
|
|
8894
|
-
if (overlayFeeRate > CLIENT_CONFIG.
|
|
8874
|
+
if (overlayFeeRate > CLIENT_CONFIG.MAX_OVERLAY_FEE_RATE_NUMERATOR) {
|
|
8895
8875
|
throw new Error(CLIENT_CONFIG.ERRORS.INVALID_OVERLAY_FEE_RATE);
|
|
8896
8876
|
}
|
|
8897
8877
|
if (overlayFeeReceiver === "0x0" && overlayFeeRate > 0) {
|
package/package.json
CHANGED