@cetusprotocol/aggregator-sdk 0.3.16 → 0.3.18
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/README.md +1 -1
- package/dist/index.d.mts +33 -11
- package/dist/index.d.ts +33 -11
- package/dist/index.js +209 -89
- package/dist/index.mjs +204 -89
- package/dist/src/api.d.ts +2 -0
- package/dist/src/client.d.ts +25 -9
- package/dist/src/transaction/afsui.d.ts +1 -1
- package/dist/src/transaction/aftermath.d.ts +1 -1
- package/dist/src/transaction/alphafi.d.ts +7 -0
- package/dist/src/transaction/bluefin.d.ts +1 -1
- package/dist/src/transaction/bluemove.d.ts +1 -1
- package/dist/src/transaction/cetus.d.ts +3 -3
- package/dist/src/transaction/deepbook_v2.d.ts +1 -1
- package/dist/src/transaction/deepbook_v3.d.ts +1 -1
- package/dist/src/transaction/flowx_v2.d.ts +1 -1
- package/dist/src/transaction/flowx_v3.d.ts +1 -1
- package/dist/src/transaction/haedal.d.ts +1 -1
- package/dist/src/transaction/haedal_pmm.d.ts +1 -1
- package/dist/src/transaction/index.d.ts +5 -1
- package/dist/src/transaction/kriya_v2.d.ts +1 -1
- package/dist/src/transaction/kriya_v3.d.ts +1 -1
- package/dist/src/transaction/scallop.d.ts +1 -1
- package/dist/src/transaction/suilend.d.ts +1 -2
- package/dist/src/transaction/turbos.d.ts +1 -1
- package/dist/src/transaction/volo.d.ts +1 -1
- package/package.json +1 -1
- package/src/api.ts +7 -3
- package/src/client.ts +129 -42
- package/src/transaction/afsui.ts +6 -3
- package/src/transaction/aftermath.ts +6 -3
- package/src/transaction/alphafi.ts +50 -0
- package/src/transaction/bluefin.ts +6 -3
- package/src/transaction/bluemove.ts +5 -4
- package/src/transaction/cetus.ts +13 -7
- package/src/transaction/deepbook_v2.ts +5 -4
- package/src/transaction/deepbook_v3.ts +5 -3
- package/src/transaction/flowx_v2.ts +5 -4
- package/src/transaction/flowx_v3.ts +5 -3
- package/src/transaction/haedal.ts +5 -3
- package/src/transaction/haedal_pmm.ts +5 -3
- package/src/transaction/index.ts +20 -1
- package/src/transaction/kriya_v2.ts +5 -4
- package/src/transaction/kriya_v3.ts +5 -4
- package/src/transaction/scallop.ts +5 -4
- package/src/transaction/suilend.ts +6 -10
- package/src/transaction/swap.ts +1 -0
- package/src/transaction/turbos.ts +5 -4
- package/src/transaction/volo.ts +5 -3
- package/src/utils/coin.ts +20 -8
- package/tests/router.test.ts +15 -22
package/dist/index.mjs
CHANGED
|
@@ -4999,7 +4999,7 @@ var Aftermath = class {
|
|
|
4999
4999
|
amountLimit(exportAmountOut) {
|
|
5000
5000
|
return new import_bn.default(exportAmountOut).mul(new import_bn.default(this.slippage)).div(new import_bn.default("1000000000000000000")).toString();
|
|
5001
5001
|
}
|
|
5002
|
-
swap(client, txb, path, inputCoin) {
|
|
5002
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
5003
5003
|
return __async(this, null, function* () {
|
|
5004
5004
|
const { direction, from, target } = path;
|
|
5005
5005
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
@@ -5021,8 +5021,9 @@ var Aftermath = class {
|
|
|
5021
5021
|
txb.pure.u64(this.slippage),
|
|
5022
5022
|
inputCoin
|
|
5023
5023
|
];
|
|
5024
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5024
5025
|
const res = txb.moveCall({
|
|
5025
|
-
target: `${
|
|
5026
|
+
target: `${publishedAt}::aftermath::${func}`,
|
|
5026
5027
|
typeArguments: [
|
|
5027
5028
|
coinAType,
|
|
5028
5029
|
coinBType,
|
|
@@ -5093,7 +5094,7 @@ var DeepbookV2 = class {
|
|
|
5093
5094
|
};
|
|
5094
5095
|
});
|
|
5095
5096
|
}
|
|
5096
|
-
swap(client, txb, path, inputCoin) {
|
|
5097
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
5097
5098
|
return __async(this, null, function* () {
|
|
5098
5099
|
const { direction, from, target } = path;
|
|
5099
5100
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
@@ -5108,8 +5109,9 @@ var DeepbookV2 = class {
|
|
|
5108
5109
|
accountCapRes.accountCap,
|
|
5109
5110
|
txb.object(CLOCK_ADDRESS)
|
|
5110
5111
|
];
|
|
5112
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5111
5113
|
const res = txb.moveCall({
|
|
5112
|
-
target: `${
|
|
5114
|
+
target: `${publishedAt}::deepbook::${func}`,
|
|
5113
5115
|
typeArguments: [coinAType, coinBType],
|
|
5114
5116
|
arguments: args
|
|
5115
5117
|
});
|
|
@@ -5128,13 +5130,14 @@ var KriyaV2 = class {
|
|
|
5128
5130
|
throw new Error("Kriya amm only supported on mainnet");
|
|
5129
5131
|
}
|
|
5130
5132
|
}
|
|
5131
|
-
swap(client, txb, path, inputCoin) {
|
|
5133
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
5132
5134
|
return __async(this, null, function* () {
|
|
5133
5135
|
const { direction, from, target } = path;
|
|
5134
5136
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
5135
5137
|
const args = [txb.object(path.id), inputCoin];
|
|
5138
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5136
5139
|
const res = txb.moveCall({
|
|
5137
|
-
target: `${
|
|
5140
|
+
target: `${publishedAt}::kriya_amm::${func}`,
|
|
5138
5141
|
typeArguments: [coinAType, coinBType],
|
|
5139
5142
|
arguments: args
|
|
5140
5143
|
});
|
|
@@ -5151,7 +5154,7 @@ var KriyaV3 = class {
|
|
|
5151
5154
|
}
|
|
5152
5155
|
this.version = "0xf5145a7ac345ca8736cf8c76047d00d6d378f30e81be6f6eb557184d9de93c78";
|
|
5153
5156
|
}
|
|
5154
|
-
swap(client, txb, path, inputCoin) {
|
|
5157
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
5155
5158
|
return __async(this, null, function* () {
|
|
5156
5159
|
const { direction, from, target } = path;
|
|
5157
5160
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
@@ -5161,8 +5164,9 @@ var KriyaV3 = class {
|
|
|
5161
5164
|
txb.object(this.version),
|
|
5162
5165
|
txb.object(CLOCK_ADDRESS)
|
|
5163
5166
|
];
|
|
5167
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5164
5168
|
const res = txb.moveCall({
|
|
5165
|
-
target: `${
|
|
5169
|
+
target: `${publishedAt}::kriya_clmm::${func}`,
|
|
5166
5170
|
typeArguments: [coinAType, coinBType],
|
|
5167
5171
|
arguments: args
|
|
5168
5172
|
});
|
|
@@ -5179,13 +5183,14 @@ var FlowxV2 = class {
|
|
|
5179
5183
|
}
|
|
5180
5184
|
this.container = "0xb65dcbf63fd3ad5d0ebfbf334780dc9f785eff38a4459e37ab08fa79576ee511";
|
|
5181
5185
|
}
|
|
5182
|
-
swap(client, txb, path, inputCoin) {
|
|
5186
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
5183
5187
|
return __async(this, null, function* () {
|
|
5184
5188
|
const { direction, from, target } = path;
|
|
5185
5189
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
5186
5190
|
const args = [txb.object(this.container), inputCoin];
|
|
5191
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5187
5192
|
const res = txb.moveCall({
|
|
5188
|
-
target: `${
|
|
5193
|
+
target: `${publishedAt}::flowx_amm::${func}`,
|
|
5189
5194
|
typeArguments: [coinAType, coinBType],
|
|
5190
5195
|
arguments: args
|
|
5191
5196
|
});
|
|
@@ -5203,7 +5208,7 @@ var FlowxV3 = class {
|
|
|
5203
5208
|
this.versioned = "0x67624a1533b5aff5d0dfcf5e598684350efd38134d2d245f475524c03a64e656";
|
|
5204
5209
|
this.poolRegistry = "0x27565d24a4cd51127ac90e4074a841bbe356cca7bf5759ddc14a975be1632abc";
|
|
5205
5210
|
}
|
|
5206
|
-
swap(client, txb, path, inputCoin) {
|
|
5211
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
5207
5212
|
return __async(this, null, function* () {
|
|
5208
5213
|
const { direction, from, target } = path;
|
|
5209
5214
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
@@ -5214,8 +5219,9 @@ var FlowxV3 = class {
|
|
|
5214
5219
|
txb.object(this.versioned),
|
|
5215
5220
|
txb.object(CLOCK_ADDRESS)
|
|
5216
5221
|
];
|
|
5222
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5217
5223
|
const res = txb.moveCall({
|
|
5218
|
-
target: `${
|
|
5224
|
+
target: `${publishedAt}::flowx_clmm::${func}`,
|
|
5219
5225
|
typeArguments: [coinAType, coinBType],
|
|
5220
5226
|
arguments: args
|
|
5221
5227
|
});
|
|
@@ -5232,7 +5238,7 @@ var Turbos = class {
|
|
|
5232
5238
|
}
|
|
5233
5239
|
this.versioned = "0xf1cf0e81048df168ebeb1b8030fad24b3e0b53ae827c25053fff0779c1445b6f";
|
|
5234
5240
|
}
|
|
5235
|
-
swap(client, txb, path, inputCoin) {
|
|
5241
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
5236
5242
|
return __async(this, null, function* () {
|
|
5237
5243
|
const { direction, from, target } = path;
|
|
5238
5244
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
@@ -5249,8 +5255,9 @@ var Turbos = class {
|
|
|
5249
5255
|
txb.object(CLOCK_ADDRESS),
|
|
5250
5256
|
txb.object(this.versioned)
|
|
5251
5257
|
];
|
|
5258
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5252
5259
|
const res = txb.moveCall({
|
|
5253
|
-
target: `${
|
|
5260
|
+
target: `${publishedAt}::turbos::${func}`,
|
|
5254
5261
|
typeArguments: [coinAType, coinBType, path.extendedDetails.turbosFeeType],
|
|
5255
5262
|
arguments: args
|
|
5256
5263
|
});
|
|
@@ -5265,7 +5272,7 @@ var Cetus = class {
|
|
|
5265
5272
|
this.globalConfig = env === 0 /* Mainnet */ ? "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f" : "0x9774e359588ead122af1c7e7f64e14ade261cfeecdb5d0eb4a5b3b4c8ab8bd3e";
|
|
5266
5273
|
this.partner = partner != null ? partner : env === 0 /* Mainnet */ ? "0x639b5e433da31739e800cd085f356e64cae222966d0f1b11bd9dc76b322ff58b" : "0x1f5fa5c820f40d43fc47815ad06d95e40a1942ff72a732a92e8ef4aa8cde70a5";
|
|
5267
5274
|
}
|
|
5268
|
-
flash_swap(client, txb, path, by_amount_in) {
|
|
5275
|
+
flash_swap(client, txb, path, by_amount_in, packages) {
|
|
5269
5276
|
const { direction, from, target } = path;
|
|
5270
5277
|
const [func, coinAType, coinBType] = direction ? ["flash_swap_a2b", from, target] : ["flash_swap_b2a", target, from];
|
|
5271
5278
|
let amount = by_amount_in ? path.amountIn : path.amountOut;
|
|
@@ -5277,8 +5284,9 @@ var Cetus = class {
|
|
|
5277
5284
|
txb.pure.bool(by_amount_in),
|
|
5278
5285
|
txb.object(CLOCK_ADDRESS)
|
|
5279
5286
|
];
|
|
5287
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5280
5288
|
const res = txb.moveCall({
|
|
5281
|
-
target: `${
|
|
5289
|
+
target: `${publishedAt}::cetus::${func}`,
|
|
5282
5290
|
typeArguments: [coinAType, coinBType],
|
|
5283
5291
|
arguments: args
|
|
5284
5292
|
});
|
|
@@ -5288,7 +5296,7 @@ var Cetus = class {
|
|
|
5288
5296
|
payAmount: res[2]
|
|
5289
5297
|
};
|
|
5290
5298
|
}
|
|
5291
|
-
repay_flash_swap(client, txb, path, inputCoin, receipt) {
|
|
5299
|
+
repay_flash_swap(client, txb, path, inputCoin, receipt, packages) {
|
|
5292
5300
|
const { direction, from, target } = path;
|
|
5293
5301
|
const [func, coinAType, coinBType] = direction ? ["repay_flash_swap_a2b", from, target] : ["repay_flash_swap_b2a", target, from];
|
|
5294
5302
|
const args = [
|
|
@@ -5298,14 +5306,15 @@ var Cetus = class {
|
|
|
5298
5306
|
inputCoin,
|
|
5299
5307
|
receipt
|
|
5300
5308
|
];
|
|
5309
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5301
5310
|
const res = txb.moveCall({
|
|
5302
|
-
target: `${
|
|
5311
|
+
target: `${publishedAt}::cetus::${func}`,
|
|
5303
5312
|
typeArguments: [coinAType, coinBType],
|
|
5304
5313
|
arguments: args
|
|
5305
5314
|
});
|
|
5306
5315
|
return res[0];
|
|
5307
5316
|
}
|
|
5308
|
-
swap(client, txb, path, inputCoin) {
|
|
5317
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
5309
5318
|
return __async(this, null, function* () {
|
|
5310
5319
|
const { direction, from, target } = path;
|
|
5311
5320
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
@@ -5316,8 +5325,9 @@ var Cetus = class {
|
|
|
5316
5325
|
inputCoin,
|
|
5317
5326
|
txb.object(CLOCK_ADDRESS)
|
|
5318
5327
|
];
|
|
5328
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5319
5329
|
const res = txb.moveCall({
|
|
5320
|
-
target: `${
|
|
5330
|
+
target: `${publishedAt}::cetus::${func}`,
|
|
5321
5331
|
typeArguments: [coinAType, coinBType],
|
|
5322
5332
|
arguments: args
|
|
5323
5333
|
});
|
|
@@ -5665,13 +5675,21 @@ function mintZeroCoin(txb, coinType) {
|
|
|
5665
5675
|
}
|
|
5666
5676
|
function buildInputCoin(txb, allCoins, amount, coinType) {
|
|
5667
5677
|
const usedCoinAsests = CoinUtils.getCoinAssets(coinType, allCoins);
|
|
5668
|
-
if (amount === BigInt(0)
|
|
5669
|
-
|
|
5670
|
-
|
|
5671
|
-
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
|
|
5678
|
+
if (amount === BigInt(0)) {
|
|
5679
|
+
if (CoinUtils.isSuiCoin(coinType) || usedCoinAsests.length === 0 && !CoinUtils.isSuiCoin(coinType)) {
|
|
5680
|
+
const zeroCoin = mintZeroCoin(txb, coinType);
|
|
5681
|
+
return {
|
|
5682
|
+
targetCoin: zeroCoin,
|
|
5683
|
+
isMintZeroCoin: true,
|
|
5684
|
+
targetCoinAmount: 0
|
|
5685
|
+
};
|
|
5686
|
+
} else {
|
|
5687
|
+
return {
|
|
5688
|
+
targetCoin: txb.object(usedCoinAsests[0].coinObjectId),
|
|
5689
|
+
isMintZeroCoin: false,
|
|
5690
|
+
targetCoinAmount: Number(usedCoinAsests[0].balance.toString())
|
|
5691
|
+
};
|
|
5692
|
+
}
|
|
5675
5693
|
}
|
|
5676
5694
|
let totalCoinBalance = CoinUtils.calculateTotalBalance(usedCoinAsests);
|
|
5677
5695
|
if (totalCoinBalance < amount) {
|
|
@@ -5706,8 +5724,11 @@ function buildInputCoin(txb, allCoins, amount, coinType) {
|
|
|
5706
5724
|
mergedCoin.map((coin) => txb.object(coin))
|
|
5707
5725
|
);
|
|
5708
5726
|
}
|
|
5727
|
+
const targetCoin = txb.splitCoins(txb.object(masterCoin), [
|
|
5728
|
+
txb.pure.u64(amount.toString())
|
|
5729
|
+
]);
|
|
5709
5730
|
return {
|
|
5710
|
-
targetCoin
|
|
5731
|
+
targetCoin,
|
|
5711
5732
|
isMintZeroCoin: false,
|
|
5712
5733
|
targetCoinAmount: Number(amount.toString())
|
|
5713
5734
|
};
|
|
@@ -5892,7 +5913,8 @@ function swapInPools(client, params, sender, env) {
|
|
|
5892
5913
|
initialPrice
|
|
5893
5914
|
}
|
|
5894
5915
|
],
|
|
5895
|
-
insufficientLiquidity: false
|
|
5916
|
+
insufficientLiquidity: false,
|
|
5917
|
+
byAmountIn: params.byAmountIn
|
|
5896
5918
|
};
|
|
5897
5919
|
const result = {
|
|
5898
5920
|
isExceed: event.is_exceed,
|
|
@@ -5909,7 +5931,7 @@ var Haedal = class {
|
|
|
5909
5931
|
throw new Error("Haedal only supported on mainnet");
|
|
5910
5932
|
}
|
|
5911
5933
|
}
|
|
5912
|
-
swap(client, txb, path, inputCoin) {
|
|
5934
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
5913
5935
|
return __async(this, null, function* () {
|
|
5914
5936
|
const { direction } = path;
|
|
5915
5937
|
if (!direction) {
|
|
@@ -5917,8 +5939,9 @@ var Haedal = class {
|
|
|
5917
5939
|
}
|
|
5918
5940
|
const func = "swap_a2b";
|
|
5919
5941
|
const args = [txb.object(path.id), txb.object("0x5"), inputCoin];
|
|
5942
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5920
5943
|
const res = txb.moveCall({
|
|
5921
|
-
target: `${
|
|
5944
|
+
target: `${publishedAt}::haedal::${func}`,
|
|
5922
5945
|
typeArguments: [],
|
|
5923
5946
|
arguments: args
|
|
5924
5947
|
});
|
|
@@ -5938,7 +5961,7 @@ var Afsui = class {
|
|
|
5938
5961
|
this.referVault = "0x4ce9a19b594599536c53edb25d22532f82f18038dc8ef618afd00fbbfb9845ef";
|
|
5939
5962
|
this.validator = "0xd30018ec3f5ff1a3c75656abf927a87d7f0529e6dc89c7ddd1bd27ecb05e3db2";
|
|
5940
5963
|
}
|
|
5941
|
-
swap(client, txb, path, inputCoin) {
|
|
5964
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
5942
5965
|
return __async(this, null, function* () {
|
|
5943
5966
|
const { direction } = path;
|
|
5944
5967
|
if (!direction) {
|
|
@@ -5953,8 +5976,9 @@ var Afsui = class {
|
|
|
5953
5976
|
txb.object(this.validator),
|
|
5954
5977
|
inputCoin
|
|
5955
5978
|
];
|
|
5979
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5956
5980
|
const res = txb.moveCall({
|
|
5957
|
-
target: `${
|
|
5981
|
+
target: `${publishedAt}::afsui::${func}`,
|
|
5958
5982
|
typeArguments: [],
|
|
5959
5983
|
arguments: args
|
|
5960
5984
|
});
|
|
@@ -5972,7 +5996,7 @@ var Volo = class {
|
|
|
5972
5996
|
this.nativePool = "0x7fa2faa111b8c65bea48a23049bfd81ca8f971a262d981dcd9a17c3825cb5baf";
|
|
5973
5997
|
this.metadata = "0x680cd26af32b2bde8d3361e804c53ec1d1cfe24c7f039eb7f549e8dfde389a60";
|
|
5974
5998
|
}
|
|
5975
|
-
swap(client, txb, path, inputCoin) {
|
|
5999
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
5976
6000
|
return __async(this, null, function* () {
|
|
5977
6001
|
const { direction } = path;
|
|
5978
6002
|
if (!direction) {
|
|
@@ -5985,8 +6009,9 @@ var Volo = class {
|
|
|
5985
6009
|
txb.object("0x5"),
|
|
5986
6010
|
inputCoin
|
|
5987
6011
|
];
|
|
6012
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5988
6013
|
const res = txb.moveCall({
|
|
5989
|
-
target: `${
|
|
6014
|
+
target: `${publishedAt}::volo::${func}`,
|
|
5990
6015
|
typeArguments: [],
|
|
5991
6016
|
arguments: args
|
|
5992
6017
|
});
|
|
@@ -6003,13 +6028,14 @@ var Bluemove = class {
|
|
|
6003
6028
|
}
|
|
6004
6029
|
this.dexInfo = "0x3f2d9f724f4a1ce5e71676448dc452be9a6243dac9c5b975a588c8c867066e92";
|
|
6005
6030
|
}
|
|
6006
|
-
swap(client, txb, path, inputCoin) {
|
|
6031
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6007
6032
|
return __async(this, null, function* () {
|
|
6008
6033
|
const { direction, from, target } = path;
|
|
6009
6034
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
6010
6035
|
const args = [txb.object(this.dexInfo), inputCoin];
|
|
6036
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
6011
6037
|
const res = txb.moveCall({
|
|
6012
|
-
target: `${
|
|
6038
|
+
target: `${publishedAt}::bluemove::${func}`,
|
|
6013
6039
|
typeArguments: [coinAType, coinBType],
|
|
6014
6040
|
arguments: args
|
|
6015
6041
|
});
|
|
@@ -6023,7 +6049,7 @@ var DeepbookV3 = class {
|
|
|
6023
6049
|
constructor(env) {
|
|
6024
6050
|
this.deepbookV3Config = env === 0 /* Mainnet */ ? "0xe4099d0cda04f3aa80028fac91a9b3dbe50d08f2ff42aa2c29473926e34ca48c" : "0xe19b5d072346cae83a037d4e3c8492068a74410a74e5830b3a68012db38296aa";
|
|
6025
6051
|
}
|
|
6026
|
-
swap(client, txb, path, inputCoin, deepbookv3DeepFee) {
|
|
6052
|
+
swap(client, txb, path, inputCoin, packages, deepbookv3DeepFee) {
|
|
6027
6053
|
return __async(this, null, function* () {
|
|
6028
6054
|
const { direction, from, target } = path;
|
|
6029
6055
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
@@ -6040,8 +6066,9 @@ var DeepbookV3 = class {
|
|
|
6040
6066
|
deepFee,
|
|
6041
6067
|
txb.object(CLOCK_ADDRESS)
|
|
6042
6068
|
];
|
|
6069
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
|
|
6043
6070
|
const res = txb.moveCall({
|
|
6044
|
-
target: `${
|
|
6071
|
+
target: `${publishedAt}::deepbookv3::${func}`,
|
|
6045
6072
|
typeArguments: [coinAType, coinBType],
|
|
6046
6073
|
arguments: args
|
|
6047
6074
|
});
|
|
@@ -6059,7 +6086,7 @@ var Scallop = class {
|
|
|
6059
6086
|
this.version = env === 0 /* Mainnet */ ? "0x07871c4b3c847a0f674510d4978d5cf6f960452795e8ff6f189fd2088a3f6ac7" : "0x0";
|
|
6060
6087
|
this.market = env === 0 /* Mainnet */ ? "0xa757975255146dc9686aa823b7838b507f315d704f428cbadad2f4ea061939d9" : "0x0";
|
|
6061
6088
|
}
|
|
6062
|
-
swap(client, txb, path, inputCoin) {
|
|
6089
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6063
6090
|
return __async(this, null, function* () {
|
|
6064
6091
|
const { direction, from, target } = path;
|
|
6065
6092
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", from, target];
|
|
@@ -6077,8 +6104,9 @@ var Scallop = class {
|
|
|
6077
6104
|
inputCoin,
|
|
6078
6105
|
txb.object(CLOCK_ADDRESS)
|
|
6079
6106
|
];
|
|
6107
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
|
|
6080
6108
|
const res = txb.moveCall({
|
|
6081
|
-
target: `${
|
|
6109
|
+
target: `${publishedAt}::scallop::${func}`,
|
|
6082
6110
|
typeArguments: [coinAType, coinBType],
|
|
6083
6111
|
arguments: args
|
|
6084
6112
|
});
|
|
@@ -6093,20 +6121,20 @@ var Suilend = class {
|
|
|
6093
6121
|
if (env !== 0 /* Mainnet */) {
|
|
6094
6122
|
throw new Error("Suilend only supported on mainnet");
|
|
6095
6123
|
}
|
|
6096
|
-
this.liquid_staking_pool = env === 0 /* Mainnet */ ? "0x15eda7330c8f99c30e430b4d82fd7ab2af3ead4ae17046fcb224aa9bad394f6b" : "0x0";
|
|
6097
6124
|
this.sui_system_state = env === 0 /* Mainnet */ ? "0x0000000000000000000000000000000000000000000000000000000000000005" : "0x0";
|
|
6098
6125
|
}
|
|
6099
|
-
swap(client, txb, path, inputCoin) {
|
|
6126
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6100
6127
|
return __async(this, null, function* () {
|
|
6101
6128
|
const { direction, from, target } = path;
|
|
6102
6129
|
const [func, springCoinType] = direction ? ["swap_a2b", target] : ["swap_b2a", from];
|
|
6103
6130
|
const args = [
|
|
6104
|
-
txb.object(
|
|
6131
|
+
txb.object(path.id),
|
|
6105
6132
|
txb.object(this.sui_system_state),
|
|
6106
6133
|
inputCoin
|
|
6107
6134
|
];
|
|
6135
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
|
|
6108
6136
|
const res = txb.moveCall({
|
|
6109
|
-
target: `${
|
|
6137
|
+
target: `${publishedAt}::suilend::${func}`,
|
|
6110
6138
|
typeArguments: [springCoinType],
|
|
6111
6139
|
arguments: args
|
|
6112
6140
|
});
|
|
@@ -6123,7 +6151,7 @@ var Bluefin = class {
|
|
|
6123
6151
|
}
|
|
6124
6152
|
this.globalConfig = "0x03db251ba509a8d5d8777b6338836082335d93eecbdd09a11e190a1cff51c352";
|
|
6125
6153
|
}
|
|
6126
|
-
swap(client, txb, path, inputCoin) {
|
|
6154
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6127
6155
|
return __async(this, null, function* () {
|
|
6128
6156
|
const { direction, from, target } = path;
|
|
6129
6157
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
@@ -6133,8 +6161,9 @@ var Bluefin = class {
|
|
|
6133
6161
|
inputCoin,
|
|
6134
6162
|
txb.object(CLOCK_ADDRESS)
|
|
6135
6163
|
];
|
|
6164
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
|
|
6136
6165
|
const res = txb.moveCall({
|
|
6137
|
-
target: `${
|
|
6166
|
+
target: `${publishedAt}::bluefin::${func}`,
|
|
6138
6167
|
typeArguments: [coinAType, coinBType],
|
|
6139
6168
|
arguments: args
|
|
6140
6169
|
});
|
|
@@ -6156,7 +6185,7 @@ var HaedalPmm = class {
|
|
|
6156
6185
|
this.pythClient = new SuiPythClient(suiClient, pythStateId, wormholeStateId);
|
|
6157
6186
|
}
|
|
6158
6187
|
}
|
|
6159
|
-
swap(client, txb, path, inputCoin) {
|
|
6188
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6160
6189
|
return __async(this, null, function* () {
|
|
6161
6190
|
const { direction, from, target } = path;
|
|
6162
6191
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
@@ -6181,8 +6210,9 @@ var HaedalPmm = class {
|
|
|
6181
6210
|
inputCoin,
|
|
6182
6211
|
txb.object(CLOCK_ADDRESS)
|
|
6183
6212
|
];
|
|
6213
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
|
|
6184
6214
|
const res = txb.moveCall({
|
|
6185
|
-
target: `${
|
|
6215
|
+
target: `${publishedAt}::haedalpmm::${func}`,
|
|
6186
6216
|
typeArguments: [coinAType, coinBType],
|
|
6187
6217
|
arguments: args
|
|
6188
6218
|
});
|
|
@@ -6191,6 +6221,34 @@ var HaedalPmm = class {
|
|
|
6191
6221
|
}
|
|
6192
6222
|
};
|
|
6193
6223
|
|
|
6224
|
+
// src/transaction/alphafi.ts
|
|
6225
|
+
var Alphafi = class {
|
|
6226
|
+
constructor(env) {
|
|
6227
|
+
if (env !== 0 /* Mainnet */) {
|
|
6228
|
+
throw new Error("Alphafi only supported on mainnet");
|
|
6229
|
+
}
|
|
6230
|
+
this.sui_system_state = env === 0 /* Mainnet */ ? "0x0000000000000000000000000000000000000000000000000000000000000005" : "0x0";
|
|
6231
|
+
}
|
|
6232
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6233
|
+
return __async(this, null, function* () {
|
|
6234
|
+
const { direction, from, target } = path;
|
|
6235
|
+
const [func, stCoinType] = direction ? ["swap_a2b", target] : ["swap_b2a", from];
|
|
6236
|
+
const args = [
|
|
6237
|
+
txb.object(path.id),
|
|
6238
|
+
txb.object(this.sui_system_state),
|
|
6239
|
+
inputCoin
|
|
6240
|
+
];
|
|
6241
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
|
|
6242
|
+
const res = txb.moveCall({
|
|
6243
|
+
target: `${publishedAt}::alphafi::${func}`,
|
|
6244
|
+
typeArguments: [stCoinType],
|
|
6245
|
+
arguments: args
|
|
6246
|
+
});
|
|
6247
|
+
return res;
|
|
6248
|
+
});
|
|
6249
|
+
}
|
|
6250
|
+
};
|
|
6251
|
+
|
|
6194
6252
|
// src/client.ts
|
|
6195
6253
|
var CETUS = "CETUS";
|
|
6196
6254
|
var DEEPBOOKV2 = "DEEPBOOK";
|
|
@@ -6209,8 +6267,15 @@ var SCALLOP = "SCALLOP";
|
|
|
6209
6267
|
var SUILEND = "SUILEND";
|
|
6210
6268
|
var BLUEFIN = "BLUEFIN";
|
|
6211
6269
|
var HAEDALPMM = "HAEDALPMM";
|
|
6270
|
+
var ALPHAFI = "ALPHAFI";
|
|
6212
6271
|
var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
6213
|
-
|
|
6272
|
+
function isBuilderRouterSwapParams(params) {
|
|
6273
|
+
return Array.isArray(params.routers);
|
|
6274
|
+
}
|
|
6275
|
+
function isBuilderFastRouterSwapParams(params) {
|
|
6276
|
+
return Array.isArray(params.routers);
|
|
6277
|
+
}
|
|
6278
|
+
var AggregatorClient19 = class {
|
|
6214
6279
|
constructor(endpoint, signer, client, env) {
|
|
6215
6280
|
this.endpoint = endpoint ? processEndpoint(endpoint) : DEFAULT_ENDPOINT;
|
|
6216
6281
|
this.client = client || new SuiClient({ url: getFullnodeUrl("mainnet") });
|
|
@@ -6260,7 +6325,7 @@ var AggregatorClient10 = class {
|
|
|
6260
6325
|
return getRouterResult(this.endpoint, params);
|
|
6261
6326
|
});
|
|
6262
6327
|
}
|
|
6263
|
-
expectInputSwap(txb, inputCoin, routers, amountOutLimit, partner, deepbookv3DeepFee) {
|
|
6328
|
+
expectInputSwap(txb, inputCoin, routers, amountOutLimit, partner, deepbookv3DeepFee, packages) {
|
|
6264
6329
|
return __async(this, null, function* () {
|
|
6265
6330
|
if (routers.length === 0) {
|
|
6266
6331
|
throw new Error("No router found");
|
|
@@ -6277,26 +6342,29 @@ var AggregatorClient10 = class {
|
|
|
6277
6342
|
let nextCoin = inputCoins[i];
|
|
6278
6343
|
for (const path of routers[i].path) {
|
|
6279
6344
|
const dex = this.newDex(path.provider, partner);
|
|
6280
|
-
nextCoin = yield dex.swap(this, txb, path, nextCoin, deepbookv3DeepFee);
|
|
6345
|
+
nextCoin = yield dex.swap(this, txb, path, nextCoin, packages, deepbookv3DeepFee);
|
|
6281
6346
|
}
|
|
6282
6347
|
outputCoins.push(nextCoin);
|
|
6283
6348
|
}
|
|
6284
|
-
this.
|
|
6349
|
+
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(this.publishedAtV2(), packages);
|
|
6350
|
+
this.transferOrDestoryCoin(txb, inputCoin, inputCoinType, this.publishedAtV2());
|
|
6285
6351
|
const mergedTargetCointhis = this.checkCoinThresholdAndMergeCoin(
|
|
6286
6352
|
txb,
|
|
6287
6353
|
outputCoins,
|
|
6288
6354
|
outputCoinType,
|
|
6289
|
-
amountOutLimit
|
|
6355
|
+
amountOutLimit,
|
|
6356
|
+
aggregatorV2PublishedAt
|
|
6290
6357
|
);
|
|
6291
6358
|
return mergedTargetCointhis;
|
|
6292
6359
|
});
|
|
6293
6360
|
}
|
|
6294
|
-
expectOutputSwap(txb, inputCoin, routers, partner) {
|
|
6361
|
+
expectOutputSwap(txb, inputCoin, routers, partner, packages) {
|
|
6295
6362
|
return __async(this, null, function* () {
|
|
6296
6363
|
const returnCoins = [];
|
|
6297
6364
|
const receipts = [];
|
|
6298
6365
|
const targetCoins = [];
|
|
6299
6366
|
const dex = new Cetus(this.env, partner);
|
|
6367
|
+
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(this.publishedAtV2(), packages);
|
|
6300
6368
|
for (let i = 0; i < routers.length; i++) {
|
|
6301
6369
|
const router = routers[i];
|
|
6302
6370
|
for (let j = router.path.length - 1; j >= 0; j--) {
|
|
@@ -6319,7 +6387,7 @@ var AggregatorClient10 = class {
|
|
|
6319
6387
|
if (j === 0) {
|
|
6320
6388
|
inputCoin = repayResult;
|
|
6321
6389
|
} else {
|
|
6322
|
-
this.transferOrDestoryCoin(txb, repayResult, path.from);
|
|
6390
|
+
this.transferOrDestoryCoin(txb, repayResult, path.from, aggregatorV2PublishedAt);
|
|
6323
6391
|
}
|
|
6324
6392
|
if (j === router.path.length - 1) {
|
|
6325
6393
|
targetCoins.push(nextRepayCoin);
|
|
@@ -6327,7 +6395,7 @@ var AggregatorClient10 = class {
|
|
|
6327
6395
|
}
|
|
6328
6396
|
}
|
|
6329
6397
|
const inputCoinType = routers[0].path[0].from;
|
|
6330
|
-
this.transferOrDestoryCoin(txb, inputCoin, inputCoinType);
|
|
6398
|
+
this.transferOrDestoryCoin(txb, inputCoin, inputCoinType, aggregatorV2PublishedAt);
|
|
6331
6399
|
if (targetCoins.length > 1) {
|
|
6332
6400
|
const vec = txb.makeMoveVec({ elements: targetCoins.slice(1) });
|
|
6333
6401
|
txb.moveCall({
|
|
@@ -6357,16 +6425,17 @@ var AggregatorClient10 = class {
|
|
|
6357
6425
|
routers,
|
|
6358
6426
|
inputCoin,
|
|
6359
6427
|
slippage,
|
|
6360
|
-
byAmountIn,
|
|
6361
6428
|
txb,
|
|
6362
6429
|
partner,
|
|
6363
6430
|
deepbookv3DeepFee
|
|
6364
6431
|
} = params;
|
|
6365
|
-
const
|
|
6432
|
+
const routerData = Array.isArray(routers) ? routers : routers.routes;
|
|
6433
|
+
const byAmountIn = isBuilderRouterSwapParams(params) ? params.byAmountIn : params.routers.byAmountIn;
|
|
6434
|
+
const amountIn = routerData.reduce(
|
|
6366
6435
|
(acc, router) => acc.add(router.amountIn),
|
|
6367
6436
|
new import_bn5.default(0)
|
|
6368
6437
|
);
|
|
6369
|
-
const amountOut =
|
|
6438
|
+
const amountOut = routerData.reduce(
|
|
6370
6439
|
(acc, router) => acc.add(router.amountOut),
|
|
6371
6440
|
new import_bn5.default(0)
|
|
6372
6441
|
);
|
|
@@ -6375,25 +6444,29 @@ var AggregatorClient10 = class {
|
|
|
6375
6444
|
byAmountIn,
|
|
6376
6445
|
slippage
|
|
6377
6446
|
);
|
|
6447
|
+
const packages = isBuilderRouterSwapParams(params) ? void 0 : params.routers.packages;
|
|
6448
|
+
console.log("packages11", packages);
|
|
6449
|
+
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(this.publishedAtV2(), packages);
|
|
6378
6450
|
if (byAmountIn) {
|
|
6379
6451
|
const targetCoin2 = yield this.expectInputSwap(
|
|
6380
6452
|
txb,
|
|
6381
6453
|
inputCoin,
|
|
6382
|
-
|
|
6454
|
+
routerData,
|
|
6383
6455
|
amountLimit,
|
|
6384
6456
|
partner,
|
|
6385
|
-
deepbookv3DeepFee
|
|
6457
|
+
deepbookv3DeepFee,
|
|
6458
|
+
packages
|
|
6386
6459
|
);
|
|
6387
6460
|
return targetCoin2;
|
|
6388
6461
|
}
|
|
6389
6462
|
const splitedInputCoins = txb.splitCoins(inputCoin, [
|
|
6390
6463
|
amountLimit.toString()
|
|
6391
6464
|
]);
|
|
6392
|
-
this.transferOrDestoryCoin(txb, inputCoin,
|
|
6465
|
+
this.transferOrDestoryCoin(txb, inputCoin, routerData[0].path[0].from, aggregatorV2PublishedAt);
|
|
6393
6466
|
const targetCoin = yield this.expectOutputSwap(
|
|
6394
6467
|
txb,
|
|
6395
6468
|
splitedInputCoins[0],
|
|
6396
|
-
|
|
6469
|
+
routerData,
|
|
6397
6470
|
partner
|
|
6398
6471
|
);
|
|
6399
6472
|
return targetCoin;
|
|
@@ -6405,25 +6478,25 @@ var AggregatorClient10 = class {
|
|
|
6405
6478
|
return __async(this, null, function* () {
|
|
6406
6479
|
const {
|
|
6407
6480
|
routers,
|
|
6408
|
-
byAmountIn,
|
|
6409
6481
|
slippage,
|
|
6410
6482
|
txb,
|
|
6411
6483
|
partner,
|
|
6412
|
-
isMergeTragetCoin,
|
|
6413
6484
|
refreshAllCoins,
|
|
6414
6485
|
payDeepFeeAmount
|
|
6415
6486
|
} = params;
|
|
6416
|
-
const
|
|
6487
|
+
const routerData = Array.isArray(routers) ? routers : routers.routes;
|
|
6488
|
+
const fromCoinType = routerData[0].path[0].from;
|
|
6417
6489
|
let fromCoins = yield this.getCoins(fromCoinType, refreshAllCoins);
|
|
6418
|
-
const targetCoinType =
|
|
6419
|
-
const amountIn =
|
|
6490
|
+
const targetCoinType = routerData[0].path[routerData[0].path.length - 1].target;
|
|
6491
|
+
const amountIn = routerData.reduce(
|
|
6420
6492
|
(acc, router) => acc.add(router.amountIn),
|
|
6421
6493
|
new import_bn5.default(0)
|
|
6422
6494
|
);
|
|
6423
|
-
const amountOut =
|
|
6495
|
+
const amountOut = routerData.reduce(
|
|
6424
6496
|
(acc, router) => acc.add(router.amountOut),
|
|
6425
6497
|
new import_bn5.default(0)
|
|
6426
6498
|
);
|
|
6499
|
+
const byAmountIn = isBuilderFastRouterSwapParams(params) ? params.byAmountIn : params.routers.byAmountIn;
|
|
6427
6500
|
const amountLimit = CalculateAmountLimit(
|
|
6428
6501
|
byAmountIn ? amountOut : amountIn,
|
|
6429
6502
|
byAmountIn,
|
|
@@ -6446,16 +6519,27 @@ var AggregatorClient10 = class {
|
|
|
6446
6519
|
this.deepbookv3DeepFeeType()
|
|
6447
6520
|
).targetCoin;
|
|
6448
6521
|
}
|
|
6449
|
-
const
|
|
6450
|
-
routers,
|
|
6522
|
+
const routerSwapParams = isBuilderFastRouterSwapParams(params) ? {
|
|
6523
|
+
routers: routerData,
|
|
6451
6524
|
inputCoin: buildFromCoinRes.targetCoin,
|
|
6452
6525
|
slippage,
|
|
6453
6526
|
byAmountIn,
|
|
6454
6527
|
txb,
|
|
6455
6528
|
partner,
|
|
6456
6529
|
deepbookv3DeepFee: deepCoin
|
|
6457
|
-
}
|
|
6458
|
-
|
|
6530
|
+
} : {
|
|
6531
|
+
routers: params.routers,
|
|
6532
|
+
inputCoin: buildFromCoinRes.targetCoin,
|
|
6533
|
+
slippage,
|
|
6534
|
+
byAmountIn,
|
|
6535
|
+
txb,
|
|
6536
|
+
partner,
|
|
6537
|
+
deepbookv3DeepFee: deepCoin
|
|
6538
|
+
};
|
|
6539
|
+
const targetCoin = yield this.routerSwap(routerSwapParams);
|
|
6540
|
+
if (CoinUtils.isSuiCoin(targetCoinType)) {
|
|
6541
|
+
txb.mergeCoins(txb.gas, [targetCoin]);
|
|
6542
|
+
} else {
|
|
6459
6543
|
let targetCoins = yield this.getCoins(targetCoinType, refreshAllCoins);
|
|
6460
6544
|
const targetCoinRes = buildInputCoin(
|
|
6461
6545
|
txb,
|
|
@@ -6463,21 +6547,22 @@ var AggregatorClient10 = class {
|
|
|
6463
6547
|
BigInt(0),
|
|
6464
6548
|
targetCoinType
|
|
6465
6549
|
);
|
|
6550
|
+
const packages = isBuilderFastRouterSwapParams(params) ? void 0 : params.routers.packages;
|
|
6551
|
+
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(this.publishedAtV2(), packages);
|
|
6466
6552
|
txb.mergeCoins(targetCoinRes.targetCoin, [targetCoin]);
|
|
6467
6553
|
if (targetCoinRes.isMintZeroCoin) {
|
|
6468
6554
|
this.transferOrDestoryCoin(
|
|
6469
6555
|
txb,
|
|
6470
6556
|
targetCoinRes.targetCoin,
|
|
6471
|
-
targetCoinType
|
|
6557
|
+
targetCoinType,
|
|
6558
|
+
aggregatorV2PublishedAt
|
|
6472
6559
|
);
|
|
6473
6560
|
}
|
|
6474
|
-
} else {
|
|
6475
|
-
this.transferOrDestoryCoin(txb, targetCoin, targetCoinType);
|
|
6476
6561
|
}
|
|
6477
6562
|
});
|
|
6478
6563
|
}
|
|
6479
6564
|
// Include cetus、deepbookv2、flowxv2 & v3、kriyav2 & v3、turbos、aftermath、haedal、afsui、volo、bluemove
|
|
6480
|
-
|
|
6565
|
+
publishedAtV2() {
|
|
6481
6566
|
if (this.env === 0 /* Mainnet */) {
|
|
6482
6567
|
return "0x3fb42ddf908af45f9fc3c59eab227888ff24ba2e137b3b55bf80920fd47e11af";
|
|
6483
6568
|
} else {
|
|
@@ -6485,9 +6570,9 @@ var AggregatorClient10 = class {
|
|
|
6485
6570
|
}
|
|
6486
6571
|
}
|
|
6487
6572
|
// Include deepbookv3, scallop, bluefin
|
|
6488
|
-
|
|
6573
|
+
publishedAtV2Extend() {
|
|
6489
6574
|
if (this.env === 0 /* Mainnet */) {
|
|
6490
|
-
return "
|
|
6575
|
+
return "0xf2fcea41dc217385019828375764fa06d9bd25e8e4726ba1962680849fb8d613";
|
|
6491
6576
|
} else {
|
|
6492
6577
|
return "0xabb6a81c8a216828e317719e06125de5bb2cb0fe8f9916ff8c023ca5be224c78";
|
|
6493
6578
|
}
|
|
@@ -6499,14 +6584,14 @@ var AggregatorClient10 = class {
|
|
|
6499
6584
|
return "0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP";
|
|
6500
6585
|
}
|
|
6501
6586
|
}
|
|
6502
|
-
transferOrDestoryCoin(txb, coin, coinType) {
|
|
6587
|
+
transferOrDestoryCoin(txb, coin, coinType, aggregatorV2PublishedAt) {
|
|
6503
6588
|
txb.moveCall({
|
|
6504
|
-
target: `${
|
|
6589
|
+
target: `${aggregatorV2PublishedAt}::utils::transfer_or_destroy_coin`,
|
|
6505
6590
|
typeArguments: [coinType],
|
|
6506
6591
|
arguments: [coin]
|
|
6507
6592
|
});
|
|
6508
6593
|
}
|
|
6509
|
-
checkCoinThresholdAndMergeCoin(txb, coins, coinType, amountLimit) {
|
|
6594
|
+
checkCoinThresholdAndMergeCoin(txb, coins, coinType, amountLimit, aggregatorV2PublishedAt) {
|
|
6510
6595
|
let targetCoin = coins[0];
|
|
6511
6596
|
if (coins.length > 1) {
|
|
6512
6597
|
let vec = txb.makeMoveVec({ elements: coins.slice(1) });
|
|
@@ -6518,7 +6603,7 @@ var AggregatorClient10 = class {
|
|
|
6518
6603
|
targetCoin = coins[0];
|
|
6519
6604
|
}
|
|
6520
6605
|
txb.moveCall({
|
|
6521
|
-
target: `${
|
|
6606
|
+
target: `${aggregatorV2PublishedAt}::utils::check_coin_threshold`,
|
|
6522
6607
|
typeArguments: [coinType],
|
|
6523
6608
|
arguments: [targetCoin, txb.pure.u64(amountLimit.toString())]
|
|
6524
6609
|
});
|
|
@@ -6560,6 +6645,8 @@ var AggregatorClient10 = class {
|
|
|
6560
6645
|
return new Bluefin(this.env);
|
|
6561
6646
|
case HAEDALPMM:
|
|
6562
6647
|
return new HaedalPmm(this.env, this.client);
|
|
6648
|
+
case ALPHAFI:
|
|
6649
|
+
return new Alphafi(this.env);
|
|
6563
6650
|
default:
|
|
6564
6651
|
throw new Error(`Unsupported dex ${provider}`);
|
|
6565
6652
|
}
|
|
@@ -6607,7 +6694,7 @@ var AggregatorClient10 = class {
|
|
|
6607
6694
|
});
|
|
6608
6695
|
}
|
|
6609
6696
|
};
|
|
6610
|
-
function parseRouterResponse(data) {
|
|
6697
|
+
function parseRouterResponse(data, byAmountIn) {
|
|
6611
6698
|
let totalDeepFee = 0;
|
|
6612
6699
|
for (const route of data.routes) {
|
|
6613
6700
|
for (const path of route.path) {
|
|
@@ -6616,9 +6703,17 @@ function parseRouterResponse(data) {
|
|
|
6616
6703
|
}
|
|
6617
6704
|
}
|
|
6618
6705
|
}
|
|
6706
|
+
let packages = void 0;
|
|
6707
|
+
if (data.packages != null) {
|
|
6708
|
+
packages = /* @__PURE__ */ new Map();
|
|
6709
|
+
for (const [key, value] of Object.entries(data.packages)) {
|
|
6710
|
+
packages.set(key, value);
|
|
6711
|
+
}
|
|
6712
|
+
}
|
|
6619
6713
|
let routerData = {
|
|
6620
6714
|
amountIn: new import_bn5.default(data.amount_in.toString()),
|
|
6621
6715
|
amountOut: new import_bn5.default(data.amount_out.toString()),
|
|
6716
|
+
byAmountIn,
|
|
6622
6717
|
insufficientLiquidity: false,
|
|
6623
6718
|
routes: data.routes.map((route) => {
|
|
6624
6719
|
return {
|
|
@@ -6658,13 +6753,30 @@ function parseRouterResponse(data) {
|
|
|
6658
6753
|
initialPrice: new decimal_default(route.initial_price.toString())
|
|
6659
6754
|
};
|
|
6660
6755
|
}),
|
|
6661
|
-
totalDeepFee
|
|
6756
|
+
totalDeepFee,
|
|
6757
|
+
packages
|
|
6662
6758
|
};
|
|
6663
6759
|
return routerData;
|
|
6664
6760
|
}
|
|
6665
6761
|
|
|
6666
6762
|
// src/transaction/index.ts
|
|
6667
6763
|
var CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
|
|
6764
|
+
var AGGREGATOR_V2 = "aggregator_v2";
|
|
6765
|
+
var AGGREGATOR_V2_EXTEND = "aggregator_v2_extend";
|
|
6766
|
+
function getAggregatorV2PublishedAt(aggregatorV2PublishedAt, packages) {
|
|
6767
|
+
var _a;
|
|
6768
|
+
if (packages instanceof Map) {
|
|
6769
|
+
return (_a = packages.get(AGGREGATOR_V2)) != null ? _a : aggregatorV2PublishedAt;
|
|
6770
|
+
}
|
|
6771
|
+
return aggregatorV2PublishedAt;
|
|
6772
|
+
}
|
|
6773
|
+
function getAggregatorV2ExtendPublishedAt(aggregatorV2ExtendPublishedAt, packages) {
|
|
6774
|
+
var _a;
|
|
6775
|
+
if (packages instanceof Map) {
|
|
6776
|
+
return (_a = packages.get(AGGREGATOR_V2_EXTEND)) != null ? _a : aggregatorV2ExtendPublishedAt;
|
|
6777
|
+
}
|
|
6778
|
+
return aggregatorV2ExtendPublishedAt;
|
|
6779
|
+
}
|
|
6668
6780
|
|
|
6669
6781
|
// src/utils/msafe.ts
|
|
6670
6782
|
var import_bn6 = __toESM(require_bn());
|
|
@@ -6716,6 +6828,7 @@ function getRouterResult(endpoint, params) {
|
|
|
6716
6828
|
amountIn: ZERO,
|
|
6717
6829
|
amountOut: ZERO,
|
|
6718
6830
|
routes: [],
|
|
6831
|
+
byAmountIn: params.byAmountIn,
|
|
6719
6832
|
insufficientLiquidity: false,
|
|
6720
6833
|
error: {
|
|
6721
6834
|
code: 10001 /* NumberTooLarge */,
|
|
@@ -6732,6 +6845,7 @@ function getRouterResult(endpoint, params) {
|
|
|
6732
6845
|
amountIn: ZERO,
|
|
6733
6846
|
amountOut: ZERO,
|
|
6734
6847
|
routes: [],
|
|
6848
|
+
byAmountIn: params.byAmountIn,
|
|
6735
6849
|
insufficientLiquidity,
|
|
6736
6850
|
error: {
|
|
6737
6851
|
code: 10004 /* HoneyPot */,
|
|
@@ -6742,7 +6856,7 @@ function getRouterResult(endpoint, params) {
|
|
|
6742
6856
|
};
|
|
6743
6857
|
}
|
|
6744
6858
|
if (data.data != null) {
|
|
6745
|
-
const res = parseRouterResponse(data.data);
|
|
6859
|
+
const res = parseRouterResponse(data.data, params.byAmountIn);
|
|
6746
6860
|
return res;
|
|
6747
6861
|
}
|
|
6748
6862
|
return {
|
|
@@ -6750,6 +6864,7 @@ function getRouterResult(endpoint, params) {
|
|
|
6750
6864
|
amountOut: ZERO,
|
|
6751
6865
|
routes: [],
|
|
6752
6866
|
insufficientLiquidity,
|
|
6867
|
+
byAmountIn: params.byAmountIn,
|
|
6753
6868
|
error: {
|
|
6754
6869
|
code: 10003 /* InsufficientLiquidity */,
|
|
6755
6870
|
msg: getAggregatorServerErrorMessage(
|
|
@@ -6793,7 +6908,7 @@ function getRouter(endpoint, params) {
|
|
|
6793
6908
|
url += `&providers=${providers.join(",")}`;
|
|
6794
6909
|
}
|
|
6795
6910
|
}
|
|
6796
|
-
url += "&v=
|
|
6911
|
+
url += "&v=1000318";
|
|
6797
6912
|
const response = yield fetch(url);
|
|
6798
6913
|
return response;
|
|
6799
6914
|
} catch (error) {
|
|
@@ -6883,4 +6998,4 @@ decimal.js/decimal.mjs:
|
|
|
6883
6998
|
*)
|
|
6884
6999
|
*/
|
|
6885
7000
|
|
|
6886
|
-
export { AFSUI, AFTERMATH,
|
|
7001
|
+
export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI, AggregatorClient19 as AggregatorClient, BLUEFIN, BLUEMOVE, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, Env, FLOWXV2, FLOWXV3, HAEDAL, HAEDALPMM, KRIYA, KRIYAV3, ONE, SCALLOP, SUILEND, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, buildInputCoin, checkInvalidSuiAddress, compareCoins, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
|