@cetusprotocol/aggregator-sdk 0.3.17 → 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/dist/index.d.mts +33 -11
- package/dist/index.d.ts +33 -11
- package/dist/index.js +205 -88
- package/dist/index.mjs +200 -88
- 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 +15 -7
- package/tests/router.test.ts +12 -19
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) {
|
|
@@ -5895,7 +5913,8 @@ function swapInPools(client, params, sender, env) {
|
|
|
5895
5913
|
initialPrice
|
|
5896
5914
|
}
|
|
5897
5915
|
],
|
|
5898
|
-
insufficientLiquidity: false
|
|
5916
|
+
insufficientLiquidity: false,
|
|
5917
|
+
byAmountIn: params.byAmountIn
|
|
5899
5918
|
};
|
|
5900
5919
|
const result = {
|
|
5901
5920
|
isExceed: event.is_exceed,
|
|
@@ -5912,7 +5931,7 @@ var Haedal = class {
|
|
|
5912
5931
|
throw new Error("Haedal only supported on mainnet");
|
|
5913
5932
|
}
|
|
5914
5933
|
}
|
|
5915
|
-
swap(client, txb, path, inputCoin) {
|
|
5934
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
5916
5935
|
return __async(this, null, function* () {
|
|
5917
5936
|
const { direction } = path;
|
|
5918
5937
|
if (!direction) {
|
|
@@ -5920,8 +5939,9 @@ var Haedal = class {
|
|
|
5920
5939
|
}
|
|
5921
5940
|
const func = "swap_a2b";
|
|
5922
5941
|
const args = [txb.object(path.id), txb.object("0x5"), inputCoin];
|
|
5942
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5923
5943
|
const res = txb.moveCall({
|
|
5924
|
-
target: `${
|
|
5944
|
+
target: `${publishedAt}::haedal::${func}`,
|
|
5925
5945
|
typeArguments: [],
|
|
5926
5946
|
arguments: args
|
|
5927
5947
|
});
|
|
@@ -5941,7 +5961,7 @@ var Afsui = class {
|
|
|
5941
5961
|
this.referVault = "0x4ce9a19b594599536c53edb25d22532f82f18038dc8ef618afd00fbbfb9845ef";
|
|
5942
5962
|
this.validator = "0xd30018ec3f5ff1a3c75656abf927a87d7f0529e6dc89c7ddd1bd27ecb05e3db2";
|
|
5943
5963
|
}
|
|
5944
|
-
swap(client, txb, path, inputCoin) {
|
|
5964
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
5945
5965
|
return __async(this, null, function* () {
|
|
5946
5966
|
const { direction } = path;
|
|
5947
5967
|
if (!direction) {
|
|
@@ -5956,8 +5976,9 @@ var Afsui = class {
|
|
|
5956
5976
|
txb.object(this.validator),
|
|
5957
5977
|
inputCoin
|
|
5958
5978
|
];
|
|
5979
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5959
5980
|
const res = txb.moveCall({
|
|
5960
|
-
target: `${
|
|
5981
|
+
target: `${publishedAt}::afsui::${func}`,
|
|
5961
5982
|
typeArguments: [],
|
|
5962
5983
|
arguments: args
|
|
5963
5984
|
});
|
|
@@ -5975,7 +5996,7 @@ var Volo = class {
|
|
|
5975
5996
|
this.nativePool = "0x7fa2faa111b8c65bea48a23049bfd81ca8f971a262d981dcd9a17c3825cb5baf";
|
|
5976
5997
|
this.metadata = "0x680cd26af32b2bde8d3361e804c53ec1d1cfe24c7f039eb7f549e8dfde389a60";
|
|
5977
5998
|
}
|
|
5978
|
-
swap(client, txb, path, inputCoin) {
|
|
5999
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
5979
6000
|
return __async(this, null, function* () {
|
|
5980
6001
|
const { direction } = path;
|
|
5981
6002
|
if (!direction) {
|
|
@@ -5988,8 +6009,9 @@ var Volo = class {
|
|
|
5988
6009
|
txb.object("0x5"),
|
|
5989
6010
|
inputCoin
|
|
5990
6011
|
];
|
|
6012
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5991
6013
|
const res = txb.moveCall({
|
|
5992
|
-
target: `${
|
|
6014
|
+
target: `${publishedAt}::volo::${func}`,
|
|
5993
6015
|
typeArguments: [],
|
|
5994
6016
|
arguments: args
|
|
5995
6017
|
});
|
|
@@ -6006,13 +6028,14 @@ var Bluemove = class {
|
|
|
6006
6028
|
}
|
|
6007
6029
|
this.dexInfo = "0x3f2d9f724f4a1ce5e71676448dc452be9a6243dac9c5b975a588c8c867066e92";
|
|
6008
6030
|
}
|
|
6009
|
-
swap(client, txb, path, inputCoin) {
|
|
6031
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6010
6032
|
return __async(this, null, function* () {
|
|
6011
6033
|
const { direction, from, target } = path;
|
|
6012
6034
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
6013
6035
|
const args = [txb.object(this.dexInfo), inputCoin];
|
|
6036
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
6014
6037
|
const res = txb.moveCall({
|
|
6015
|
-
target: `${
|
|
6038
|
+
target: `${publishedAt}::bluemove::${func}`,
|
|
6016
6039
|
typeArguments: [coinAType, coinBType],
|
|
6017
6040
|
arguments: args
|
|
6018
6041
|
});
|
|
@@ -6026,7 +6049,7 @@ var DeepbookV3 = class {
|
|
|
6026
6049
|
constructor(env) {
|
|
6027
6050
|
this.deepbookV3Config = env === 0 /* Mainnet */ ? "0xe4099d0cda04f3aa80028fac91a9b3dbe50d08f2ff42aa2c29473926e34ca48c" : "0xe19b5d072346cae83a037d4e3c8492068a74410a74e5830b3a68012db38296aa";
|
|
6028
6051
|
}
|
|
6029
|
-
swap(client, txb, path, inputCoin, deepbookv3DeepFee) {
|
|
6052
|
+
swap(client, txb, path, inputCoin, packages, deepbookv3DeepFee) {
|
|
6030
6053
|
return __async(this, null, function* () {
|
|
6031
6054
|
const { direction, from, target } = path;
|
|
6032
6055
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
@@ -6043,8 +6066,9 @@ var DeepbookV3 = class {
|
|
|
6043
6066
|
deepFee,
|
|
6044
6067
|
txb.object(CLOCK_ADDRESS)
|
|
6045
6068
|
];
|
|
6069
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
|
|
6046
6070
|
const res = txb.moveCall({
|
|
6047
|
-
target: `${
|
|
6071
|
+
target: `${publishedAt}::deepbookv3::${func}`,
|
|
6048
6072
|
typeArguments: [coinAType, coinBType],
|
|
6049
6073
|
arguments: args
|
|
6050
6074
|
});
|
|
@@ -6062,7 +6086,7 @@ var Scallop = class {
|
|
|
6062
6086
|
this.version = env === 0 /* Mainnet */ ? "0x07871c4b3c847a0f674510d4978d5cf6f960452795e8ff6f189fd2088a3f6ac7" : "0x0";
|
|
6063
6087
|
this.market = env === 0 /* Mainnet */ ? "0xa757975255146dc9686aa823b7838b507f315d704f428cbadad2f4ea061939d9" : "0x0";
|
|
6064
6088
|
}
|
|
6065
|
-
swap(client, txb, path, inputCoin) {
|
|
6089
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6066
6090
|
return __async(this, null, function* () {
|
|
6067
6091
|
const { direction, from, target } = path;
|
|
6068
6092
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", from, target];
|
|
@@ -6080,8 +6104,9 @@ var Scallop = class {
|
|
|
6080
6104
|
inputCoin,
|
|
6081
6105
|
txb.object(CLOCK_ADDRESS)
|
|
6082
6106
|
];
|
|
6107
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
|
|
6083
6108
|
const res = txb.moveCall({
|
|
6084
|
-
target: `${
|
|
6109
|
+
target: `${publishedAt}::scallop::${func}`,
|
|
6085
6110
|
typeArguments: [coinAType, coinBType],
|
|
6086
6111
|
arguments: args
|
|
6087
6112
|
});
|
|
@@ -6096,20 +6121,20 @@ var Suilend = class {
|
|
|
6096
6121
|
if (env !== 0 /* Mainnet */) {
|
|
6097
6122
|
throw new Error("Suilend only supported on mainnet");
|
|
6098
6123
|
}
|
|
6099
|
-
this.liquid_staking_pool = env === 0 /* Mainnet */ ? "0x15eda7330c8f99c30e430b4d82fd7ab2af3ead4ae17046fcb224aa9bad394f6b" : "0x0";
|
|
6100
6124
|
this.sui_system_state = env === 0 /* Mainnet */ ? "0x0000000000000000000000000000000000000000000000000000000000000005" : "0x0";
|
|
6101
6125
|
}
|
|
6102
|
-
swap(client, txb, path, inputCoin) {
|
|
6126
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6103
6127
|
return __async(this, null, function* () {
|
|
6104
6128
|
const { direction, from, target } = path;
|
|
6105
6129
|
const [func, springCoinType] = direction ? ["swap_a2b", target] : ["swap_b2a", from];
|
|
6106
6130
|
const args = [
|
|
6107
|
-
txb.object(
|
|
6131
|
+
txb.object(path.id),
|
|
6108
6132
|
txb.object(this.sui_system_state),
|
|
6109
6133
|
inputCoin
|
|
6110
6134
|
];
|
|
6135
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
|
|
6111
6136
|
const res = txb.moveCall({
|
|
6112
|
-
target: `${
|
|
6137
|
+
target: `${publishedAt}::suilend::${func}`,
|
|
6113
6138
|
typeArguments: [springCoinType],
|
|
6114
6139
|
arguments: args
|
|
6115
6140
|
});
|
|
@@ -6126,7 +6151,7 @@ var Bluefin = class {
|
|
|
6126
6151
|
}
|
|
6127
6152
|
this.globalConfig = "0x03db251ba509a8d5d8777b6338836082335d93eecbdd09a11e190a1cff51c352";
|
|
6128
6153
|
}
|
|
6129
|
-
swap(client, txb, path, inputCoin) {
|
|
6154
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6130
6155
|
return __async(this, null, function* () {
|
|
6131
6156
|
const { direction, from, target } = path;
|
|
6132
6157
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
@@ -6136,8 +6161,9 @@ var Bluefin = class {
|
|
|
6136
6161
|
inputCoin,
|
|
6137
6162
|
txb.object(CLOCK_ADDRESS)
|
|
6138
6163
|
];
|
|
6164
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
|
|
6139
6165
|
const res = txb.moveCall({
|
|
6140
|
-
target: `${
|
|
6166
|
+
target: `${publishedAt}::bluefin::${func}`,
|
|
6141
6167
|
typeArguments: [coinAType, coinBType],
|
|
6142
6168
|
arguments: args
|
|
6143
6169
|
});
|
|
@@ -6159,7 +6185,7 @@ var HaedalPmm = class {
|
|
|
6159
6185
|
this.pythClient = new SuiPythClient(suiClient, pythStateId, wormholeStateId);
|
|
6160
6186
|
}
|
|
6161
6187
|
}
|
|
6162
|
-
swap(client, txb, path, inputCoin) {
|
|
6188
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6163
6189
|
return __async(this, null, function* () {
|
|
6164
6190
|
const { direction, from, target } = path;
|
|
6165
6191
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
@@ -6184,8 +6210,9 @@ var HaedalPmm = class {
|
|
|
6184
6210
|
inputCoin,
|
|
6185
6211
|
txb.object(CLOCK_ADDRESS)
|
|
6186
6212
|
];
|
|
6213
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
|
|
6187
6214
|
const res = txb.moveCall({
|
|
6188
|
-
target: `${
|
|
6215
|
+
target: `${publishedAt}::haedalpmm::${func}`,
|
|
6189
6216
|
typeArguments: [coinAType, coinBType],
|
|
6190
6217
|
arguments: args
|
|
6191
6218
|
});
|
|
@@ -6194,6 +6221,34 @@ var HaedalPmm = class {
|
|
|
6194
6221
|
}
|
|
6195
6222
|
};
|
|
6196
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
|
+
|
|
6197
6252
|
// src/client.ts
|
|
6198
6253
|
var CETUS = "CETUS";
|
|
6199
6254
|
var DEEPBOOKV2 = "DEEPBOOK";
|
|
@@ -6212,8 +6267,15 @@ var SCALLOP = "SCALLOP";
|
|
|
6212
6267
|
var SUILEND = "SUILEND";
|
|
6213
6268
|
var BLUEFIN = "BLUEFIN";
|
|
6214
6269
|
var HAEDALPMM = "HAEDALPMM";
|
|
6270
|
+
var ALPHAFI = "ALPHAFI";
|
|
6215
6271
|
var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
6216
|
-
|
|
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 {
|
|
6217
6279
|
constructor(endpoint, signer, client, env) {
|
|
6218
6280
|
this.endpoint = endpoint ? processEndpoint(endpoint) : DEFAULT_ENDPOINT;
|
|
6219
6281
|
this.client = client || new SuiClient({ url: getFullnodeUrl("mainnet") });
|
|
@@ -6263,7 +6325,7 @@ var AggregatorClient10 = class {
|
|
|
6263
6325
|
return getRouterResult(this.endpoint, params);
|
|
6264
6326
|
});
|
|
6265
6327
|
}
|
|
6266
|
-
expectInputSwap(txb, inputCoin, routers, amountOutLimit, partner, deepbookv3DeepFee) {
|
|
6328
|
+
expectInputSwap(txb, inputCoin, routers, amountOutLimit, partner, deepbookv3DeepFee, packages) {
|
|
6267
6329
|
return __async(this, null, function* () {
|
|
6268
6330
|
if (routers.length === 0) {
|
|
6269
6331
|
throw new Error("No router found");
|
|
@@ -6280,26 +6342,29 @@ var AggregatorClient10 = class {
|
|
|
6280
6342
|
let nextCoin = inputCoins[i];
|
|
6281
6343
|
for (const path of routers[i].path) {
|
|
6282
6344
|
const dex = this.newDex(path.provider, partner);
|
|
6283
|
-
nextCoin = yield dex.swap(this, txb, path, nextCoin, deepbookv3DeepFee);
|
|
6345
|
+
nextCoin = yield dex.swap(this, txb, path, nextCoin, packages, deepbookv3DeepFee);
|
|
6284
6346
|
}
|
|
6285
6347
|
outputCoins.push(nextCoin);
|
|
6286
6348
|
}
|
|
6287
|
-
this.
|
|
6349
|
+
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(this.publishedAtV2(), packages);
|
|
6350
|
+
this.transferOrDestoryCoin(txb, inputCoin, inputCoinType, this.publishedAtV2());
|
|
6288
6351
|
const mergedTargetCointhis = this.checkCoinThresholdAndMergeCoin(
|
|
6289
6352
|
txb,
|
|
6290
6353
|
outputCoins,
|
|
6291
6354
|
outputCoinType,
|
|
6292
|
-
amountOutLimit
|
|
6355
|
+
amountOutLimit,
|
|
6356
|
+
aggregatorV2PublishedAt
|
|
6293
6357
|
);
|
|
6294
6358
|
return mergedTargetCointhis;
|
|
6295
6359
|
});
|
|
6296
6360
|
}
|
|
6297
|
-
expectOutputSwap(txb, inputCoin, routers, partner) {
|
|
6361
|
+
expectOutputSwap(txb, inputCoin, routers, partner, packages) {
|
|
6298
6362
|
return __async(this, null, function* () {
|
|
6299
6363
|
const returnCoins = [];
|
|
6300
6364
|
const receipts = [];
|
|
6301
6365
|
const targetCoins = [];
|
|
6302
6366
|
const dex = new Cetus(this.env, partner);
|
|
6367
|
+
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(this.publishedAtV2(), packages);
|
|
6303
6368
|
for (let i = 0; i < routers.length; i++) {
|
|
6304
6369
|
const router = routers[i];
|
|
6305
6370
|
for (let j = router.path.length - 1; j >= 0; j--) {
|
|
@@ -6322,7 +6387,7 @@ var AggregatorClient10 = class {
|
|
|
6322
6387
|
if (j === 0) {
|
|
6323
6388
|
inputCoin = repayResult;
|
|
6324
6389
|
} else {
|
|
6325
|
-
this.transferOrDestoryCoin(txb, repayResult, path.from);
|
|
6390
|
+
this.transferOrDestoryCoin(txb, repayResult, path.from, aggregatorV2PublishedAt);
|
|
6326
6391
|
}
|
|
6327
6392
|
if (j === router.path.length - 1) {
|
|
6328
6393
|
targetCoins.push(nextRepayCoin);
|
|
@@ -6330,7 +6395,7 @@ var AggregatorClient10 = class {
|
|
|
6330
6395
|
}
|
|
6331
6396
|
}
|
|
6332
6397
|
const inputCoinType = routers[0].path[0].from;
|
|
6333
|
-
this.transferOrDestoryCoin(txb, inputCoin, inputCoinType);
|
|
6398
|
+
this.transferOrDestoryCoin(txb, inputCoin, inputCoinType, aggregatorV2PublishedAt);
|
|
6334
6399
|
if (targetCoins.length > 1) {
|
|
6335
6400
|
const vec = txb.makeMoveVec({ elements: targetCoins.slice(1) });
|
|
6336
6401
|
txb.moveCall({
|
|
@@ -6360,16 +6425,17 @@ var AggregatorClient10 = class {
|
|
|
6360
6425
|
routers,
|
|
6361
6426
|
inputCoin,
|
|
6362
6427
|
slippage,
|
|
6363
|
-
byAmountIn,
|
|
6364
6428
|
txb,
|
|
6365
6429
|
partner,
|
|
6366
6430
|
deepbookv3DeepFee
|
|
6367
6431
|
} = params;
|
|
6368
|
-
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(
|
|
6369
6435
|
(acc, router) => acc.add(router.amountIn),
|
|
6370
6436
|
new import_bn5.default(0)
|
|
6371
6437
|
);
|
|
6372
|
-
const amountOut =
|
|
6438
|
+
const amountOut = routerData.reduce(
|
|
6373
6439
|
(acc, router) => acc.add(router.amountOut),
|
|
6374
6440
|
new import_bn5.default(0)
|
|
6375
6441
|
);
|
|
@@ -6378,25 +6444,29 @@ var AggregatorClient10 = class {
|
|
|
6378
6444
|
byAmountIn,
|
|
6379
6445
|
slippage
|
|
6380
6446
|
);
|
|
6447
|
+
const packages = isBuilderRouterSwapParams(params) ? void 0 : params.routers.packages;
|
|
6448
|
+
console.log("packages11", packages);
|
|
6449
|
+
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(this.publishedAtV2(), packages);
|
|
6381
6450
|
if (byAmountIn) {
|
|
6382
6451
|
const targetCoin2 = yield this.expectInputSwap(
|
|
6383
6452
|
txb,
|
|
6384
6453
|
inputCoin,
|
|
6385
|
-
|
|
6454
|
+
routerData,
|
|
6386
6455
|
amountLimit,
|
|
6387
6456
|
partner,
|
|
6388
|
-
deepbookv3DeepFee
|
|
6457
|
+
deepbookv3DeepFee,
|
|
6458
|
+
packages
|
|
6389
6459
|
);
|
|
6390
6460
|
return targetCoin2;
|
|
6391
6461
|
}
|
|
6392
6462
|
const splitedInputCoins = txb.splitCoins(inputCoin, [
|
|
6393
6463
|
amountLimit.toString()
|
|
6394
6464
|
]);
|
|
6395
|
-
this.transferOrDestoryCoin(txb, inputCoin,
|
|
6465
|
+
this.transferOrDestoryCoin(txb, inputCoin, routerData[0].path[0].from, aggregatorV2PublishedAt);
|
|
6396
6466
|
const targetCoin = yield this.expectOutputSwap(
|
|
6397
6467
|
txb,
|
|
6398
6468
|
splitedInputCoins[0],
|
|
6399
|
-
|
|
6469
|
+
routerData,
|
|
6400
6470
|
partner
|
|
6401
6471
|
);
|
|
6402
6472
|
return targetCoin;
|
|
@@ -6408,25 +6478,25 @@ var AggregatorClient10 = class {
|
|
|
6408
6478
|
return __async(this, null, function* () {
|
|
6409
6479
|
const {
|
|
6410
6480
|
routers,
|
|
6411
|
-
byAmountIn,
|
|
6412
6481
|
slippage,
|
|
6413
6482
|
txb,
|
|
6414
6483
|
partner,
|
|
6415
|
-
isMergeTragetCoin,
|
|
6416
6484
|
refreshAllCoins,
|
|
6417
6485
|
payDeepFeeAmount
|
|
6418
6486
|
} = params;
|
|
6419
|
-
const
|
|
6487
|
+
const routerData = Array.isArray(routers) ? routers : routers.routes;
|
|
6488
|
+
const fromCoinType = routerData[0].path[0].from;
|
|
6420
6489
|
let fromCoins = yield this.getCoins(fromCoinType, refreshAllCoins);
|
|
6421
|
-
const targetCoinType =
|
|
6422
|
-
const amountIn =
|
|
6490
|
+
const targetCoinType = routerData[0].path[routerData[0].path.length - 1].target;
|
|
6491
|
+
const amountIn = routerData.reduce(
|
|
6423
6492
|
(acc, router) => acc.add(router.amountIn),
|
|
6424
6493
|
new import_bn5.default(0)
|
|
6425
6494
|
);
|
|
6426
|
-
const amountOut =
|
|
6495
|
+
const amountOut = routerData.reduce(
|
|
6427
6496
|
(acc, router) => acc.add(router.amountOut),
|
|
6428
6497
|
new import_bn5.default(0)
|
|
6429
6498
|
);
|
|
6499
|
+
const byAmountIn = isBuilderFastRouterSwapParams(params) ? params.byAmountIn : params.routers.byAmountIn;
|
|
6430
6500
|
const amountLimit = CalculateAmountLimit(
|
|
6431
6501
|
byAmountIn ? amountOut : amountIn,
|
|
6432
6502
|
byAmountIn,
|
|
@@ -6449,16 +6519,27 @@ var AggregatorClient10 = class {
|
|
|
6449
6519
|
this.deepbookv3DeepFeeType()
|
|
6450
6520
|
).targetCoin;
|
|
6451
6521
|
}
|
|
6452
|
-
const
|
|
6453
|
-
routers,
|
|
6522
|
+
const routerSwapParams = isBuilderFastRouterSwapParams(params) ? {
|
|
6523
|
+
routers: routerData,
|
|
6454
6524
|
inputCoin: buildFromCoinRes.targetCoin,
|
|
6455
6525
|
slippage,
|
|
6456
6526
|
byAmountIn,
|
|
6457
6527
|
txb,
|
|
6458
6528
|
partner,
|
|
6459
6529
|
deepbookv3DeepFee: deepCoin
|
|
6460
|
-
}
|
|
6461
|
-
|
|
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 {
|
|
6462
6543
|
let targetCoins = yield this.getCoins(targetCoinType, refreshAllCoins);
|
|
6463
6544
|
const targetCoinRes = buildInputCoin(
|
|
6464
6545
|
txb,
|
|
@@ -6466,21 +6547,22 @@ var AggregatorClient10 = class {
|
|
|
6466
6547
|
BigInt(0),
|
|
6467
6548
|
targetCoinType
|
|
6468
6549
|
);
|
|
6550
|
+
const packages = isBuilderFastRouterSwapParams(params) ? void 0 : params.routers.packages;
|
|
6551
|
+
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(this.publishedAtV2(), packages);
|
|
6469
6552
|
txb.mergeCoins(targetCoinRes.targetCoin, [targetCoin]);
|
|
6470
6553
|
if (targetCoinRes.isMintZeroCoin) {
|
|
6471
6554
|
this.transferOrDestoryCoin(
|
|
6472
6555
|
txb,
|
|
6473
6556
|
targetCoinRes.targetCoin,
|
|
6474
|
-
targetCoinType
|
|
6557
|
+
targetCoinType,
|
|
6558
|
+
aggregatorV2PublishedAt
|
|
6475
6559
|
);
|
|
6476
6560
|
}
|
|
6477
|
-
} else {
|
|
6478
|
-
this.transferOrDestoryCoin(txb, targetCoin, targetCoinType);
|
|
6479
6561
|
}
|
|
6480
6562
|
});
|
|
6481
6563
|
}
|
|
6482
6564
|
// Include cetus、deepbookv2、flowxv2 & v3、kriyav2 & v3、turbos、aftermath、haedal、afsui、volo、bluemove
|
|
6483
|
-
|
|
6565
|
+
publishedAtV2() {
|
|
6484
6566
|
if (this.env === 0 /* Mainnet */) {
|
|
6485
6567
|
return "0x3fb42ddf908af45f9fc3c59eab227888ff24ba2e137b3b55bf80920fd47e11af";
|
|
6486
6568
|
} else {
|
|
@@ -6488,9 +6570,9 @@ var AggregatorClient10 = class {
|
|
|
6488
6570
|
}
|
|
6489
6571
|
}
|
|
6490
6572
|
// Include deepbookv3, scallop, bluefin
|
|
6491
|
-
|
|
6573
|
+
publishedAtV2Extend() {
|
|
6492
6574
|
if (this.env === 0 /* Mainnet */) {
|
|
6493
|
-
return "
|
|
6575
|
+
return "0xf2fcea41dc217385019828375764fa06d9bd25e8e4726ba1962680849fb8d613";
|
|
6494
6576
|
} else {
|
|
6495
6577
|
return "0xabb6a81c8a216828e317719e06125de5bb2cb0fe8f9916ff8c023ca5be224c78";
|
|
6496
6578
|
}
|
|
@@ -6502,14 +6584,14 @@ var AggregatorClient10 = class {
|
|
|
6502
6584
|
return "0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP";
|
|
6503
6585
|
}
|
|
6504
6586
|
}
|
|
6505
|
-
transferOrDestoryCoin(txb, coin, coinType) {
|
|
6587
|
+
transferOrDestoryCoin(txb, coin, coinType, aggregatorV2PublishedAt) {
|
|
6506
6588
|
txb.moveCall({
|
|
6507
|
-
target: `${
|
|
6589
|
+
target: `${aggregatorV2PublishedAt}::utils::transfer_or_destroy_coin`,
|
|
6508
6590
|
typeArguments: [coinType],
|
|
6509
6591
|
arguments: [coin]
|
|
6510
6592
|
});
|
|
6511
6593
|
}
|
|
6512
|
-
checkCoinThresholdAndMergeCoin(txb, coins, coinType, amountLimit) {
|
|
6594
|
+
checkCoinThresholdAndMergeCoin(txb, coins, coinType, amountLimit, aggregatorV2PublishedAt) {
|
|
6513
6595
|
let targetCoin = coins[0];
|
|
6514
6596
|
if (coins.length > 1) {
|
|
6515
6597
|
let vec = txb.makeMoveVec({ elements: coins.slice(1) });
|
|
@@ -6521,7 +6603,7 @@ var AggregatorClient10 = class {
|
|
|
6521
6603
|
targetCoin = coins[0];
|
|
6522
6604
|
}
|
|
6523
6605
|
txb.moveCall({
|
|
6524
|
-
target: `${
|
|
6606
|
+
target: `${aggregatorV2PublishedAt}::utils::check_coin_threshold`,
|
|
6525
6607
|
typeArguments: [coinType],
|
|
6526
6608
|
arguments: [targetCoin, txb.pure.u64(amountLimit.toString())]
|
|
6527
6609
|
});
|
|
@@ -6563,6 +6645,8 @@ var AggregatorClient10 = class {
|
|
|
6563
6645
|
return new Bluefin(this.env);
|
|
6564
6646
|
case HAEDALPMM:
|
|
6565
6647
|
return new HaedalPmm(this.env, this.client);
|
|
6648
|
+
case ALPHAFI:
|
|
6649
|
+
return new Alphafi(this.env);
|
|
6566
6650
|
default:
|
|
6567
6651
|
throw new Error(`Unsupported dex ${provider}`);
|
|
6568
6652
|
}
|
|
@@ -6610,7 +6694,7 @@ var AggregatorClient10 = class {
|
|
|
6610
6694
|
});
|
|
6611
6695
|
}
|
|
6612
6696
|
};
|
|
6613
|
-
function parseRouterResponse(data) {
|
|
6697
|
+
function parseRouterResponse(data, byAmountIn) {
|
|
6614
6698
|
let totalDeepFee = 0;
|
|
6615
6699
|
for (const route of data.routes) {
|
|
6616
6700
|
for (const path of route.path) {
|
|
@@ -6619,9 +6703,17 @@ function parseRouterResponse(data) {
|
|
|
6619
6703
|
}
|
|
6620
6704
|
}
|
|
6621
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
|
+
}
|
|
6622
6713
|
let routerData = {
|
|
6623
6714
|
amountIn: new import_bn5.default(data.amount_in.toString()),
|
|
6624
6715
|
amountOut: new import_bn5.default(data.amount_out.toString()),
|
|
6716
|
+
byAmountIn,
|
|
6625
6717
|
insufficientLiquidity: false,
|
|
6626
6718
|
routes: data.routes.map((route) => {
|
|
6627
6719
|
return {
|
|
@@ -6661,13 +6753,30 @@ function parseRouterResponse(data) {
|
|
|
6661
6753
|
initialPrice: new decimal_default(route.initial_price.toString())
|
|
6662
6754
|
};
|
|
6663
6755
|
}),
|
|
6664
|
-
totalDeepFee
|
|
6756
|
+
totalDeepFee,
|
|
6757
|
+
packages
|
|
6665
6758
|
};
|
|
6666
6759
|
return routerData;
|
|
6667
6760
|
}
|
|
6668
6761
|
|
|
6669
6762
|
// src/transaction/index.ts
|
|
6670
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
|
+
}
|
|
6671
6780
|
|
|
6672
6781
|
// src/utils/msafe.ts
|
|
6673
6782
|
var import_bn6 = __toESM(require_bn());
|
|
@@ -6719,6 +6828,7 @@ function getRouterResult(endpoint, params) {
|
|
|
6719
6828
|
amountIn: ZERO,
|
|
6720
6829
|
amountOut: ZERO,
|
|
6721
6830
|
routes: [],
|
|
6831
|
+
byAmountIn: params.byAmountIn,
|
|
6722
6832
|
insufficientLiquidity: false,
|
|
6723
6833
|
error: {
|
|
6724
6834
|
code: 10001 /* NumberTooLarge */,
|
|
@@ -6735,6 +6845,7 @@ function getRouterResult(endpoint, params) {
|
|
|
6735
6845
|
amountIn: ZERO,
|
|
6736
6846
|
amountOut: ZERO,
|
|
6737
6847
|
routes: [],
|
|
6848
|
+
byAmountIn: params.byAmountIn,
|
|
6738
6849
|
insufficientLiquidity,
|
|
6739
6850
|
error: {
|
|
6740
6851
|
code: 10004 /* HoneyPot */,
|
|
@@ -6745,7 +6856,7 @@ function getRouterResult(endpoint, params) {
|
|
|
6745
6856
|
};
|
|
6746
6857
|
}
|
|
6747
6858
|
if (data.data != null) {
|
|
6748
|
-
const res = parseRouterResponse(data.data);
|
|
6859
|
+
const res = parseRouterResponse(data.data, params.byAmountIn);
|
|
6749
6860
|
return res;
|
|
6750
6861
|
}
|
|
6751
6862
|
return {
|
|
@@ -6753,6 +6864,7 @@ function getRouterResult(endpoint, params) {
|
|
|
6753
6864
|
amountOut: ZERO,
|
|
6754
6865
|
routes: [],
|
|
6755
6866
|
insufficientLiquidity,
|
|
6867
|
+
byAmountIn: params.byAmountIn,
|
|
6756
6868
|
error: {
|
|
6757
6869
|
code: 10003 /* InsufficientLiquidity */,
|
|
6758
6870
|
msg: getAggregatorServerErrorMessage(
|
|
@@ -6796,7 +6908,7 @@ function getRouter(endpoint, params) {
|
|
|
6796
6908
|
url += `&providers=${providers.join(",")}`;
|
|
6797
6909
|
}
|
|
6798
6910
|
}
|
|
6799
|
-
url += "&v=
|
|
6911
|
+
url += "&v=1000318";
|
|
6800
6912
|
const response = yield fetch(url);
|
|
6801
6913
|
return response;
|
|
6802
6914
|
} catch (error) {
|
|
@@ -6886,4 +6998,4 @@ decimal.js/decimal.mjs:
|
|
|
6886
6998
|
*)
|
|
6887
6999
|
*/
|
|
6888
7000
|
|
|
6889
|
-
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 };
|