@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.js
CHANGED
|
@@ -5001,7 +5001,7 @@ var Aftermath = class {
|
|
|
5001
5001
|
amountLimit(exportAmountOut) {
|
|
5002
5002
|
return new import_bn.default(exportAmountOut).mul(new import_bn.default(this.slippage)).div(new import_bn.default("1000000000000000000")).toString();
|
|
5003
5003
|
}
|
|
5004
|
-
swap(client, txb, path, inputCoin) {
|
|
5004
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
5005
5005
|
return __async(this, null, function* () {
|
|
5006
5006
|
const { direction, from, target } = path;
|
|
5007
5007
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
@@ -5023,8 +5023,9 @@ var Aftermath = class {
|
|
|
5023
5023
|
txb.pure.u64(this.slippage),
|
|
5024
5024
|
inputCoin
|
|
5025
5025
|
];
|
|
5026
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5026
5027
|
const res = txb.moveCall({
|
|
5027
|
-
target: `${
|
|
5028
|
+
target: `${publishedAt}::aftermath::${func}`,
|
|
5028
5029
|
typeArguments: [
|
|
5029
5030
|
coinAType,
|
|
5030
5031
|
coinBType,
|
|
@@ -5095,7 +5096,7 @@ var DeepbookV2 = class {
|
|
|
5095
5096
|
};
|
|
5096
5097
|
});
|
|
5097
5098
|
}
|
|
5098
|
-
swap(client, txb, path, inputCoin) {
|
|
5099
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
5099
5100
|
return __async(this, null, function* () {
|
|
5100
5101
|
const { direction, from, target } = path;
|
|
5101
5102
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
@@ -5110,8 +5111,9 @@ var DeepbookV2 = class {
|
|
|
5110
5111
|
accountCapRes.accountCap,
|
|
5111
5112
|
txb.object(CLOCK_ADDRESS)
|
|
5112
5113
|
];
|
|
5114
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5113
5115
|
const res = txb.moveCall({
|
|
5114
|
-
target: `${
|
|
5116
|
+
target: `${publishedAt}::deepbook::${func}`,
|
|
5115
5117
|
typeArguments: [coinAType, coinBType],
|
|
5116
5118
|
arguments: args
|
|
5117
5119
|
});
|
|
@@ -5130,13 +5132,14 @@ var KriyaV2 = class {
|
|
|
5130
5132
|
throw new Error("Kriya amm only supported on mainnet");
|
|
5131
5133
|
}
|
|
5132
5134
|
}
|
|
5133
|
-
swap(client, txb, path, inputCoin) {
|
|
5135
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
5134
5136
|
return __async(this, null, function* () {
|
|
5135
5137
|
const { direction, from, target } = path;
|
|
5136
5138
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
5137
5139
|
const args = [txb.object(path.id), inputCoin];
|
|
5140
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5138
5141
|
const res = txb.moveCall({
|
|
5139
|
-
target: `${
|
|
5142
|
+
target: `${publishedAt}::kriya_amm::${func}`,
|
|
5140
5143
|
typeArguments: [coinAType, coinBType],
|
|
5141
5144
|
arguments: args
|
|
5142
5145
|
});
|
|
@@ -5153,7 +5156,7 @@ var KriyaV3 = class {
|
|
|
5153
5156
|
}
|
|
5154
5157
|
this.version = "0xf5145a7ac345ca8736cf8c76047d00d6d378f30e81be6f6eb557184d9de93c78";
|
|
5155
5158
|
}
|
|
5156
|
-
swap(client, txb, path, inputCoin) {
|
|
5159
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
5157
5160
|
return __async(this, null, function* () {
|
|
5158
5161
|
const { direction, from, target } = path;
|
|
5159
5162
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
@@ -5163,8 +5166,9 @@ var KriyaV3 = class {
|
|
|
5163
5166
|
txb.object(this.version),
|
|
5164
5167
|
txb.object(CLOCK_ADDRESS)
|
|
5165
5168
|
];
|
|
5169
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5166
5170
|
const res = txb.moveCall({
|
|
5167
|
-
target: `${
|
|
5171
|
+
target: `${publishedAt}::kriya_clmm::${func}`,
|
|
5168
5172
|
typeArguments: [coinAType, coinBType],
|
|
5169
5173
|
arguments: args
|
|
5170
5174
|
});
|
|
@@ -5181,13 +5185,14 @@ var FlowxV2 = class {
|
|
|
5181
5185
|
}
|
|
5182
5186
|
this.container = "0xb65dcbf63fd3ad5d0ebfbf334780dc9f785eff38a4459e37ab08fa79576ee511";
|
|
5183
5187
|
}
|
|
5184
|
-
swap(client, txb, path, inputCoin) {
|
|
5188
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
5185
5189
|
return __async(this, null, function* () {
|
|
5186
5190
|
const { direction, from, target } = path;
|
|
5187
5191
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
5188
5192
|
const args = [txb.object(this.container), inputCoin];
|
|
5193
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5189
5194
|
const res = txb.moveCall({
|
|
5190
|
-
target: `${
|
|
5195
|
+
target: `${publishedAt}::flowx_amm::${func}`,
|
|
5191
5196
|
typeArguments: [coinAType, coinBType],
|
|
5192
5197
|
arguments: args
|
|
5193
5198
|
});
|
|
@@ -5205,7 +5210,7 @@ var FlowxV3 = class {
|
|
|
5205
5210
|
this.versioned = "0x67624a1533b5aff5d0dfcf5e598684350efd38134d2d245f475524c03a64e656";
|
|
5206
5211
|
this.poolRegistry = "0x27565d24a4cd51127ac90e4074a841bbe356cca7bf5759ddc14a975be1632abc";
|
|
5207
5212
|
}
|
|
5208
|
-
swap(client, txb, path, inputCoin) {
|
|
5213
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
5209
5214
|
return __async(this, null, function* () {
|
|
5210
5215
|
const { direction, from, target } = path;
|
|
5211
5216
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
@@ -5216,8 +5221,9 @@ var FlowxV3 = class {
|
|
|
5216
5221
|
txb.object(this.versioned),
|
|
5217
5222
|
txb.object(CLOCK_ADDRESS)
|
|
5218
5223
|
];
|
|
5224
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5219
5225
|
const res = txb.moveCall({
|
|
5220
|
-
target: `${
|
|
5226
|
+
target: `${publishedAt}::flowx_clmm::${func}`,
|
|
5221
5227
|
typeArguments: [coinAType, coinBType],
|
|
5222
5228
|
arguments: args
|
|
5223
5229
|
});
|
|
@@ -5234,7 +5240,7 @@ var Turbos = class {
|
|
|
5234
5240
|
}
|
|
5235
5241
|
this.versioned = "0xf1cf0e81048df168ebeb1b8030fad24b3e0b53ae827c25053fff0779c1445b6f";
|
|
5236
5242
|
}
|
|
5237
|
-
swap(client, txb, path, inputCoin) {
|
|
5243
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
5238
5244
|
return __async(this, null, function* () {
|
|
5239
5245
|
const { direction, from, target } = path;
|
|
5240
5246
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
@@ -5251,8 +5257,9 @@ var Turbos = class {
|
|
|
5251
5257
|
txb.object(CLOCK_ADDRESS),
|
|
5252
5258
|
txb.object(this.versioned)
|
|
5253
5259
|
];
|
|
5260
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5254
5261
|
const res = txb.moveCall({
|
|
5255
|
-
target: `${
|
|
5262
|
+
target: `${publishedAt}::turbos::${func}`,
|
|
5256
5263
|
typeArguments: [coinAType, coinBType, path.extendedDetails.turbosFeeType],
|
|
5257
5264
|
arguments: args
|
|
5258
5265
|
});
|
|
@@ -5267,7 +5274,7 @@ var Cetus = class {
|
|
|
5267
5274
|
this.globalConfig = env === 0 /* Mainnet */ ? "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f" : "0x9774e359588ead122af1c7e7f64e14ade261cfeecdb5d0eb4a5b3b4c8ab8bd3e";
|
|
5268
5275
|
this.partner = partner != null ? partner : env === 0 /* Mainnet */ ? "0x639b5e433da31739e800cd085f356e64cae222966d0f1b11bd9dc76b322ff58b" : "0x1f5fa5c820f40d43fc47815ad06d95e40a1942ff72a732a92e8ef4aa8cde70a5";
|
|
5269
5276
|
}
|
|
5270
|
-
flash_swap(client, txb, path, by_amount_in) {
|
|
5277
|
+
flash_swap(client, txb, path, by_amount_in, packages) {
|
|
5271
5278
|
const { direction, from, target } = path;
|
|
5272
5279
|
const [func, coinAType, coinBType] = direction ? ["flash_swap_a2b", from, target] : ["flash_swap_b2a", target, from];
|
|
5273
5280
|
let amount = by_amount_in ? path.amountIn : path.amountOut;
|
|
@@ -5279,8 +5286,9 @@ var Cetus = class {
|
|
|
5279
5286
|
txb.pure.bool(by_amount_in),
|
|
5280
5287
|
txb.object(CLOCK_ADDRESS)
|
|
5281
5288
|
];
|
|
5289
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5282
5290
|
const res = txb.moveCall({
|
|
5283
|
-
target: `${
|
|
5291
|
+
target: `${publishedAt}::cetus::${func}`,
|
|
5284
5292
|
typeArguments: [coinAType, coinBType],
|
|
5285
5293
|
arguments: args
|
|
5286
5294
|
});
|
|
@@ -5290,7 +5298,7 @@ var Cetus = class {
|
|
|
5290
5298
|
payAmount: res[2]
|
|
5291
5299
|
};
|
|
5292
5300
|
}
|
|
5293
|
-
repay_flash_swap(client, txb, path, inputCoin, receipt) {
|
|
5301
|
+
repay_flash_swap(client, txb, path, inputCoin, receipt, packages) {
|
|
5294
5302
|
const { direction, from, target } = path;
|
|
5295
5303
|
const [func, coinAType, coinBType] = direction ? ["repay_flash_swap_a2b", from, target] : ["repay_flash_swap_b2a", target, from];
|
|
5296
5304
|
const args = [
|
|
@@ -5300,14 +5308,15 @@ var Cetus = class {
|
|
|
5300
5308
|
inputCoin,
|
|
5301
5309
|
receipt
|
|
5302
5310
|
];
|
|
5311
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5303
5312
|
const res = txb.moveCall({
|
|
5304
|
-
target: `${
|
|
5313
|
+
target: `${publishedAt}::cetus::${func}`,
|
|
5305
5314
|
typeArguments: [coinAType, coinBType],
|
|
5306
5315
|
arguments: args
|
|
5307
5316
|
});
|
|
5308
5317
|
return res[0];
|
|
5309
5318
|
}
|
|
5310
|
-
swap(client, txb, path, inputCoin) {
|
|
5319
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
5311
5320
|
return __async(this, null, function* () {
|
|
5312
5321
|
const { direction, from, target } = path;
|
|
5313
5322
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
@@ -5318,8 +5327,9 @@ var Cetus = class {
|
|
|
5318
5327
|
inputCoin,
|
|
5319
5328
|
txb.object(CLOCK_ADDRESS)
|
|
5320
5329
|
];
|
|
5330
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5321
5331
|
const res = txb.moveCall({
|
|
5322
|
-
target: `${
|
|
5332
|
+
target: `${publishedAt}::cetus::${func}`,
|
|
5323
5333
|
typeArguments: [coinAType, coinBType],
|
|
5324
5334
|
arguments: args
|
|
5325
5335
|
});
|
|
@@ -5667,13 +5677,21 @@ function mintZeroCoin(txb, coinType) {
|
|
|
5667
5677
|
}
|
|
5668
5678
|
function buildInputCoin(txb, allCoins, amount, coinType) {
|
|
5669
5679
|
const usedCoinAsests = CoinUtils.getCoinAssets(coinType, allCoins);
|
|
5670
|
-
if (amount === BigInt(0)
|
|
5671
|
-
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
|
|
5680
|
+
if (amount === BigInt(0)) {
|
|
5681
|
+
if (CoinUtils.isSuiCoin(coinType) || usedCoinAsests.length === 0 && !CoinUtils.isSuiCoin(coinType)) {
|
|
5682
|
+
const zeroCoin = mintZeroCoin(txb, coinType);
|
|
5683
|
+
return {
|
|
5684
|
+
targetCoin: zeroCoin,
|
|
5685
|
+
isMintZeroCoin: true,
|
|
5686
|
+
targetCoinAmount: 0
|
|
5687
|
+
};
|
|
5688
|
+
} else {
|
|
5689
|
+
return {
|
|
5690
|
+
targetCoin: txb.object(usedCoinAsests[0].coinObjectId),
|
|
5691
|
+
isMintZeroCoin: false,
|
|
5692
|
+
targetCoinAmount: Number(usedCoinAsests[0].balance.toString())
|
|
5693
|
+
};
|
|
5694
|
+
}
|
|
5677
5695
|
}
|
|
5678
5696
|
let totalCoinBalance = CoinUtils.calculateTotalBalance(usedCoinAsests);
|
|
5679
5697
|
if (totalCoinBalance < amount) {
|
|
@@ -5897,7 +5915,8 @@ function swapInPools(client, params, sender, env) {
|
|
|
5897
5915
|
initialPrice
|
|
5898
5916
|
}
|
|
5899
5917
|
],
|
|
5900
|
-
insufficientLiquidity: false
|
|
5918
|
+
insufficientLiquidity: false,
|
|
5919
|
+
byAmountIn: params.byAmountIn
|
|
5901
5920
|
};
|
|
5902
5921
|
const result = {
|
|
5903
5922
|
isExceed: event.is_exceed,
|
|
@@ -5914,7 +5933,7 @@ var Haedal = class {
|
|
|
5914
5933
|
throw new Error("Haedal only supported on mainnet");
|
|
5915
5934
|
}
|
|
5916
5935
|
}
|
|
5917
|
-
swap(client, txb, path, inputCoin) {
|
|
5936
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
5918
5937
|
return __async(this, null, function* () {
|
|
5919
5938
|
const { direction } = path;
|
|
5920
5939
|
if (!direction) {
|
|
@@ -5922,8 +5941,9 @@ var Haedal = class {
|
|
|
5922
5941
|
}
|
|
5923
5942
|
const func = "swap_a2b";
|
|
5924
5943
|
const args = [txb.object(path.id), txb.object("0x5"), inputCoin];
|
|
5944
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5925
5945
|
const res = txb.moveCall({
|
|
5926
|
-
target: `${
|
|
5946
|
+
target: `${publishedAt}::haedal::${func}`,
|
|
5927
5947
|
typeArguments: [],
|
|
5928
5948
|
arguments: args
|
|
5929
5949
|
});
|
|
@@ -5943,7 +5963,7 @@ var Afsui = class {
|
|
|
5943
5963
|
this.referVault = "0x4ce9a19b594599536c53edb25d22532f82f18038dc8ef618afd00fbbfb9845ef";
|
|
5944
5964
|
this.validator = "0xd30018ec3f5ff1a3c75656abf927a87d7f0529e6dc89c7ddd1bd27ecb05e3db2";
|
|
5945
5965
|
}
|
|
5946
|
-
swap(client, txb, path, inputCoin) {
|
|
5966
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
5947
5967
|
return __async(this, null, function* () {
|
|
5948
5968
|
const { direction } = path;
|
|
5949
5969
|
if (!direction) {
|
|
@@ -5958,8 +5978,9 @@ var Afsui = class {
|
|
|
5958
5978
|
txb.object(this.validator),
|
|
5959
5979
|
inputCoin
|
|
5960
5980
|
];
|
|
5981
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5961
5982
|
const res = txb.moveCall({
|
|
5962
|
-
target: `${
|
|
5983
|
+
target: `${publishedAt}::afsui::${func}`,
|
|
5963
5984
|
typeArguments: [],
|
|
5964
5985
|
arguments: args
|
|
5965
5986
|
});
|
|
@@ -5977,7 +5998,7 @@ var Volo = class {
|
|
|
5977
5998
|
this.nativePool = "0x7fa2faa111b8c65bea48a23049bfd81ca8f971a262d981dcd9a17c3825cb5baf";
|
|
5978
5999
|
this.metadata = "0x680cd26af32b2bde8d3361e804c53ec1d1cfe24c7f039eb7f549e8dfde389a60";
|
|
5979
6000
|
}
|
|
5980
|
-
swap(client, txb, path, inputCoin) {
|
|
6001
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
5981
6002
|
return __async(this, null, function* () {
|
|
5982
6003
|
const { direction } = path;
|
|
5983
6004
|
if (!direction) {
|
|
@@ -5990,8 +6011,9 @@ var Volo = class {
|
|
|
5990
6011
|
txb.object("0x5"),
|
|
5991
6012
|
inputCoin
|
|
5992
6013
|
];
|
|
6014
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5993
6015
|
const res = txb.moveCall({
|
|
5994
|
-
target: `${
|
|
6016
|
+
target: `${publishedAt}::volo::${func}`,
|
|
5995
6017
|
typeArguments: [],
|
|
5996
6018
|
arguments: args
|
|
5997
6019
|
});
|
|
@@ -6008,13 +6030,14 @@ var Bluemove = class {
|
|
|
6008
6030
|
}
|
|
6009
6031
|
this.dexInfo = "0x3f2d9f724f4a1ce5e71676448dc452be9a6243dac9c5b975a588c8c867066e92";
|
|
6010
6032
|
}
|
|
6011
|
-
swap(client, txb, path, inputCoin) {
|
|
6033
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6012
6034
|
return __async(this, null, function* () {
|
|
6013
6035
|
const { direction, from, target } = path;
|
|
6014
6036
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
6015
6037
|
const args = [txb.object(this.dexInfo), inputCoin];
|
|
6038
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
6016
6039
|
const res = txb.moveCall({
|
|
6017
|
-
target: `${
|
|
6040
|
+
target: `${publishedAt}::bluemove::${func}`,
|
|
6018
6041
|
typeArguments: [coinAType, coinBType],
|
|
6019
6042
|
arguments: args
|
|
6020
6043
|
});
|
|
@@ -6028,7 +6051,7 @@ var DeepbookV3 = class {
|
|
|
6028
6051
|
constructor(env) {
|
|
6029
6052
|
this.deepbookV3Config = env === 0 /* Mainnet */ ? "0xe4099d0cda04f3aa80028fac91a9b3dbe50d08f2ff42aa2c29473926e34ca48c" : "0xe19b5d072346cae83a037d4e3c8492068a74410a74e5830b3a68012db38296aa";
|
|
6030
6053
|
}
|
|
6031
|
-
swap(client, txb, path, inputCoin, deepbookv3DeepFee) {
|
|
6054
|
+
swap(client, txb, path, inputCoin, packages, deepbookv3DeepFee) {
|
|
6032
6055
|
return __async(this, null, function* () {
|
|
6033
6056
|
const { direction, from, target } = path;
|
|
6034
6057
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
@@ -6045,8 +6068,9 @@ var DeepbookV3 = class {
|
|
|
6045
6068
|
deepFee,
|
|
6046
6069
|
txb.object(CLOCK_ADDRESS)
|
|
6047
6070
|
];
|
|
6071
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
|
|
6048
6072
|
const res = txb.moveCall({
|
|
6049
|
-
target: `${
|
|
6073
|
+
target: `${publishedAt}::deepbookv3::${func}`,
|
|
6050
6074
|
typeArguments: [coinAType, coinBType],
|
|
6051
6075
|
arguments: args
|
|
6052
6076
|
});
|
|
@@ -6064,7 +6088,7 @@ var Scallop = class {
|
|
|
6064
6088
|
this.version = env === 0 /* Mainnet */ ? "0x07871c4b3c847a0f674510d4978d5cf6f960452795e8ff6f189fd2088a3f6ac7" : "0x0";
|
|
6065
6089
|
this.market = env === 0 /* Mainnet */ ? "0xa757975255146dc9686aa823b7838b507f315d704f428cbadad2f4ea061939d9" : "0x0";
|
|
6066
6090
|
}
|
|
6067
|
-
swap(client, txb, path, inputCoin) {
|
|
6091
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6068
6092
|
return __async(this, null, function* () {
|
|
6069
6093
|
const { direction, from, target } = path;
|
|
6070
6094
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", from, target];
|
|
@@ -6082,8 +6106,9 @@ var Scallop = class {
|
|
|
6082
6106
|
inputCoin,
|
|
6083
6107
|
txb.object(CLOCK_ADDRESS)
|
|
6084
6108
|
];
|
|
6109
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
|
|
6085
6110
|
const res = txb.moveCall({
|
|
6086
|
-
target: `${
|
|
6111
|
+
target: `${publishedAt}::scallop::${func}`,
|
|
6087
6112
|
typeArguments: [coinAType, coinBType],
|
|
6088
6113
|
arguments: args
|
|
6089
6114
|
});
|
|
@@ -6098,20 +6123,20 @@ var Suilend = class {
|
|
|
6098
6123
|
if (env !== 0 /* Mainnet */) {
|
|
6099
6124
|
throw new Error("Suilend only supported on mainnet");
|
|
6100
6125
|
}
|
|
6101
|
-
this.liquid_staking_pool = env === 0 /* Mainnet */ ? "0x15eda7330c8f99c30e430b4d82fd7ab2af3ead4ae17046fcb224aa9bad394f6b" : "0x0";
|
|
6102
6126
|
this.sui_system_state = env === 0 /* Mainnet */ ? "0x0000000000000000000000000000000000000000000000000000000000000005" : "0x0";
|
|
6103
6127
|
}
|
|
6104
|
-
swap(client, txb, path, inputCoin) {
|
|
6128
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6105
6129
|
return __async(this, null, function* () {
|
|
6106
6130
|
const { direction, from, target } = path;
|
|
6107
6131
|
const [func, springCoinType] = direction ? ["swap_a2b", target] : ["swap_b2a", from];
|
|
6108
6132
|
const args = [
|
|
6109
|
-
txb.object(
|
|
6133
|
+
txb.object(path.id),
|
|
6110
6134
|
txb.object(this.sui_system_state),
|
|
6111
6135
|
inputCoin
|
|
6112
6136
|
];
|
|
6137
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
|
|
6113
6138
|
const res = txb.moveCall({
|
|
6114
|
-
target: `${
|
|
6139
|
+
target: `${publishedAt}::suilend::${func}`,
|
|
6115
6140
|
typeArguments: [springCoinType],
|
|
6116
6141
|
arguments: args
|
|
6117
6142
|
});
|
|
@@ -6128,7 +6153,7 @@ var Bluefin = class {
|
|
|
6128
6153
|
}
|
|
6129
6154
|
this.globalConfig = "0x03db251ba509a8d5d8777b6338836082335d93eecbdd09a11e190a1cff51c352";
|
|
6130
6155
|
}
|
|
6131
|
-
swap(client, txb, path, inputCoin) {
|
|
6156
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6132
6157
|
return __async(this, null, function* () {
|
|
6133
6158
|
const { direction, from, target } = path;
|
|
6134
6159
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
@@ -6138,8 +6163,9 @@ var Bluefin = class {
|
|
|
6138
6163
|
inputCoin,
|
|
6139
6164
|
txb.object(CLOCK_ADDRESS)
|
|
6140
6165
|
];
|
|
6166
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
|
|
6141
6167
|
const res = txb.moveCall({
|
|
6142
|
-
target: `${
|
|
6168
|
+
target: `${publishedAt}::bluefin::${func}`,
|
|
6143
6169
|
typeArguments: [coinAType, coinBType],
|
|
6144
6170
|
arguments: args
|
|
6145
6171
|
});
|
|
@@ -6161,7 +6187,7 @@ var HaedalPmm = class {
|
|
|
6161
6187
|
this.pythClient = new pythSuiJs.SuiPythClient(suiClient, pythStateId, wormholeStateId);
|
|
6162
6188
|
}
|
|
6163
6189
|
}
|
|
6164
|
-
swap(client, txb, path, inputCoin) {
|
|
6190
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6165
6191
|
return __async(this, null, function* () {
|
|
6166
6192
|
const { direction, from, target } = path;
|
|
6167
6193
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
@@ -6186,8 +6212,9 @@ var HaedalPmm = class {
|
|
|
6186
6212
|
inputCoin,
|
|
6187
6213
|
txb.object(CLOCK_ADDRESS)
|
|
6188
6214
|
];
|
|
6215
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
|
|
6189
6216
|
const res = txb.moveCall({
|
|
6190
|
-
target: `${
|
|
6217
|
+
target: `${publishedAt}::haedalpmm::${func}`,
|
|
6191
6218
|
typeArguments: [coinAType, coinBType],
|
|
6192
6219
|
arguments: args
|
|
6193
6220
|
});
|
|
@@ -6196,6 +6223,34 @@ var HaedalPmm = class {
|
|
|
6196
6223
|
}
|
|
6197
6224
|
};
|
|
6198
6225
|
|
|
6226
|
+
// src/transaction/alphafi.ts
|
|
6227
|
+
var Alphafi = class {
|
|
6228
|
+
constructor(env) {
|
|
6229
|
+
if (env !== 0 /* Mainnet */) {
|
|
6230
|
+
throw new Error("Alphafi only supported on mainnet");
|
|
6231
|
+
}
|
|
6232
|
+
this.sui_system_state = env === 0 /* Mainnet */ ? "0x0000000000000000000000000000000000000000000000000000000000000005" : "0x0";
|
|
6233
|
+
}
|
|
6234
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6235
|
+
return __async(this, null, function* () {
|
|
6236
|
+
const { direction, from, target } = path;
|
|
6237
|
+
const [func, stCoinType] = direction ? ["swap_a2b", target] : ["swap_b2a", from];
|
|
6238
|
+
const args = [
|
|
6239
|
+
txb.object(path.id),
|
|
6240
|
+
txb.object(this.sui_system_state),
|
|
6241
|
+
inputCoin
|
|
6242
|
+
];
|
|
6243
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
|
|
6244
|
+
const res = txb.moveCall({
|
|
6245
|
+
target: `${publishedAt}::alphafi::${func}`,
|
|
6246
|
+
typeArguments: [stCoinType],
|
|
6247
|
+
arguments: args
|
|
6248
|
+
});
|
|
6249
|
+
return res;
|
|
6250
|
+
});
|
|
6251
|
+
}
|
|
6252
|
+
};
|
|
6253
|
+
|
|
6199
6254
|
// src/client.ts
|
|
6200
6255
|
var CETUS = "CETUS";
|
|
6201
6256
|
var DEEPBOOKV2 = "DEEPBOOK";
|
|
@@ -6214,8 +6269,15 @@ var SCALLOP = "SCALLOP";
|
|
|
6214
6269
|
var SUILEND = "SUILEND";
|
|
6215
6270
|
var BLUEFIN = "BLUEFIN";
|
|
6216
6271
|
var HAEDALPMM = "HAEDALPMM";
|
|
6272
|
+
var ALPHAFI = "ALPHAFI";
|
|
6217
6273
|
var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
6218
|
-
|
|
6274
|
+
function isBuilderRouterSwapParams(params) {
|
|
6275
|
+
return Array.isArray(params.routers);
|
|
6276
|
+
}
|
|
6277
|
+
function isBuilderFastRouterSwapParams(params) {
|
|
6278
|
+
return Array.isArray(params.routers);
|
|
6279
|
+
}
|
|
6280
|
+
var AggregatorClient19 = class {
|
|
6219
6281
|
constructor(endpoint, signer, client$1, env) {
|
|
6220
6282
|
this.endpoint = endpoint ? processEndpoint(endpoint) : DEFAULT_ENDPOINT;
|
|
6221
6283
|
this.client = client$1 || new client.SuiClient({ url: client.getFullnodeUrl("mainnet") });
|
|
@@ -6265,7 +6327,7 @@ var AggregatorClient10 = class {
|
|
|
6265
6327
|
return getRouterResult(this.endpoint, params);
|
|
6266
6328
|
});
|
|
6267
6329
|
}
|
|
6268
|
-
expectInputSwap(txb, inputCoin, routers, amountOutLimit, partner, deepbookv3DeepFee) {
|
|
6330
|
+
expectInputSwap(txb, inputCoin, routers, amountOutLimit, partner, deepbookv3DeepFee, packages) {
|
|
6269
6331
|
return __async(this, null, function* () {
|
|
6270
6332
|
if (routers.length === 0) {
|
|
6271
6333
|
throw new Error("No router found");
|
|
@@ -6282,26 +6344,29 @@ var AggregatorClient10 = class {
|
|
|
6282
6344
|
let nextCoin = inputCoins[i];
|
|
6283
6345
|
for (const path of routers[i].path) {
|
|
6284
6346
|
const dex = this.newDex(path.provider, partner);
|
|
6285
|
-
nextCoin = yield dex.swap(this, txb, path, nextCoin, deepbookv3DeepFee);
|
|
6347
|
+
nextCoin = yield dex.swap(this, txb, path, nextCoin, packages, deepbookv3DeepFee);
|
|
6286
6348
|
}
|
|
6287
6349
|
outputCoins.push(nextCoin);
|
|
6288
6350
|
}
|
|
6289
|
-
this.
|
|
6351
|
+
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(this.publishedAtV2(), packages);
|
|
6352
|
+
this.transferOrDestoryCoin(txb, inputCoin, inputCoinType, this.publishedAtV2());
|
|
6290
6353
|
const mergedTargetCointhis = this.checkCoinThresholdAndMergeCoin(
|
|
6291
6354
|
txb,
|
|
6292
6355
|
outputCoins,
|
|
6293
6356
|
outputCoinType,
|
|
6294
|
-
amountOutLimit
|
|
6357
|
+
amountOutLimit,
|
|
6358
|
+
aggregatorV2PublishedAt
|
|
6295
6359
|
);
|
|
6296
6360
|
return mergedTargetCointhis;
|
|
6297
6361
|
});
|
|
6298
6362
|
}
|
|
6299
|
-
expectOutputSwap(txb, inputCoin, routers, partner) {
|
|
6363
|
+
expectOutputSwap(txb, inputCoin, routers, partner, packages) {
|
|
6300
6364
|
return __async(this, null, function* () {
|
|
6301
6365
|
const returnCoins = [];
|
|
6302
6366
|
const receipts = [];
|
|
6303
6367
|
const targetCoins = [];
|
|
6304
6368
|
const dex = new Cetus(this.env, partner);
|
|
6369
|
+
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(this.publishedAtV2(), packages);
|
|
6305
6370
|
for (let i = 0; i < routers.length; i++) {
|
|
6306
6371
|
const router = routers[i];
|
|
6307
6372
|
for (let j = router.path.length - 1; j >= 0; j--) {
|
|
@@ -6324,7 +6389,7 @@ var AggregatorClient10 = class {
|
|
|
6324
6389
|
if (j === 0) {
|
|
6325
6390
|
inputCoin = repayResult;
|
|
6326
6391
|
} else {
|
|
6327
|
-
this.transferOrDestoryCoin(txb, repayResult, path.from);
|
|
6392
|
+
this.transferOrDestoryCoin(txb, repayResult, path.from, aggregatorV2PublishedAt);
|
|
6328
6393
|
}
|
|
6329
6394
|
if (j === router.path.length - 1) {
|
|
6330
6395
|
targetCoins.push(nextRepayCoin);
|
|
@@ -6332,7 +6397,7 @@ var AggregatorClient10 = class {
|
|
|
6332
6397
|
}
|
|
6333
6398
|
}
|
|
6334
6399
|
const inputCoinType = routers[0].path[0].from;
|
|
6335
|
-
this.transferOrDestoryCoin(txb, inputCoin, inputCoinType);
|
|
6400
|
+
this.transferOrDestoryCoin(txb, inputCoin, inputCoinType, aggregatorV2PublishedAt);
|
|
6336
6401
|
if (targetCoins.length > 1) {
|
|
6337
6402
|
const vec = txb.makeMoveVec({ elements: targetCoins.slice(1) });
|
|
6338
6403
|
txb.moveCall({
|
|
@@ -6362,16 +6427,17 @@ var AggregatorClient10 = class {
|
|
|
6362
6427
|
routers,
|
|
6363
6428
|
inputCoin,
|
|
6364
6429
|
slippage,
|
|
6365
|
-
byAmountIn,
|
|
6366
6430
|
txb,
|
|
6367
6431
|
partner,
|
|
6368
6432
|
deepbookv3DeepFee
|
|
6369
6433
|
} = params;
|
|
6370
|
-
const
|
|
6434
|
+
const routerData = Array.isArray(routers) ? routers : routers.routes;
|
|
6435
|
+
const byAmountIn = isBuilderRouterSwapParams(params) ? params.byAmountIn : params.routers.byAmountIn;
|
|
6436
|
+
const amountIn = routerData.reduce(
|
|
6371
6437
|
(acc, router) => acc.add(router.amountIn),
|
|
6372
6438
|
new import_bn5.default(0)
|
|
6373
6439
|
);
|
|
6374
|
-
const amountOut =
|
|
6440
|
+
const amountOut = routerData.reduce(
|
|
6375
6441
|
(acc, router) => acc.add(router.amountOut),
|
|
6376
6442
|
new import_bn5.default(0)
|
|
6377
6443
|
);
|
|
@@ -6380,25 +6446,29 @@ var AggregatorClient10 = class {
|
|
|
6380
6446
|
byAmountIn,
|
|
6381
6447
|
slippage
|
|
6382
6448
|
);
|
|
6449
|
+
const packages = isBuilderRouterSwapParams(params) ? void 0 : params.routers.packages;
|
|
6450
|
+
console.log("packages11", packages);
|
|
6451
|
+
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(this.publishedAtV2(), packages);
|
|
6383
6452
|
if (byAmountIn) {
|
|
6384
6453
|
const targetCoin2 = yield this.expectInputSwap(
|
|
6385
6454
|
txb,
|
|
6386
6455
|
inputCoin,
|
|
6387
|
-
|
|
6456
|
+
routerData,
|
|
6388
6457
|
amountLimit,
|
|
6389
6458
|
partner,
|
|
6390
|
-
deepbookv3DeepFee
|
|
6459
|
+
deepbookv3DeepFee,
|
|
6460
|
+
packages
|
|
6391
6461
|
);
|
|
6392
6462
|
return targetCoin2;
|
|
6393
6463
|
}
|
|
6394
6464
|
const splitedInputCoins = txb.splitCoins(inputCoin, [
|
|
6395
6465
|
amountLimit.toString()
|
|
6396
6466
|
]);
|
|
6397
|
-
this.transferOrDestoryCoin(txb, inputCoin,
|
|
6467
|
+
this.transferOrDestoryCoin(txb, inputCoin, routerData[0].path[0].from, aggregatorV2PublishedAt);
|
|
6398
6468
|
const targetCoin = yield this.expectOutputSwap(
|
|
6399
6469
|
txb,
|
|
6400
6470
|
splitedInputCoins[0],
|
|
6401
|
-
|
|
6471
|
+
routerData,
|
|
6402
6472
|
partner
|
|
6403
6473
|
);
|
|
6404
6474
|
return targetCoin;
|
|
@@ -6410,25 +6480,25 @@ var AggregatorClient10 = class {
|
|
|
6410
6480
|
return __async(this, null, function* () {
|
|
6411
6481
|
const {
|
|
6412
6482
|
routers,
|
|
6413
|
-
byAmountIn,
|
|
6414
6483
|
slippage,
|
|
6415
6484
|
txb,
|
|
6416
6485
|
partner,
|
|
6417
|
-
isMergeTragetCoin,
|
|
6418
6486
|
refreshAllCoins,
|
|
6419
6487
|
payDeepFeeAmount
|
|
6420
6488
|
} = params;
|
|
6421
|
-
const
|
|
6489
|
+
const routerData = Array.isArray(routers) ? routers : routers.routes;
|
|
6490
|
+
const fromCoinType = routerData[0].path[0].from;
|
|
6422
6491
|
let fromCoins = yield this.getCoins(fromCoinType, refreshAllCoins);
|
|
6423
|
-
const targetCoinType =
|
|
6424
|
-
const amountIn =
|
|
6492
|
+
const targetCoinType = routerData[0].path[routerData[0].path.length - 1].target;
|
|
6493
|
+
const amountIn = routerData.reduce(
|
|
6425
6494
|
(acc, router) => acc.add(router.amountIn),
|
|
6426
6495
|
new import_bn5.default(0)
|
|
6427
6496
|
);
|
|
6428
|
-
const amountOut =
|
|
6497
|
+
const amountOut = routerData.reduce(
|
|
6429
6498
|
(acc, router) => acc.add(router.amountOut),
|
|
6430
6499
|
new import_bn5.default(0)
|
|
6431
6500
|
);
|
|
6501
|
+
const byAmountIn = isBuilderFastRouterSwapParams(params) ? params.byAmountIn : params.routers.byAmountIn;
|
|
6432
6502
|
const amountLimit = CalculateAmountLimit(
|
|
6433
6503
|
byAmountIn ? amountOut : amountIn,
|
|
6434
6504
|
byAmountIn,
|
|
@@ -6451,16 +6521,27 @@ var AggregatorClient10 = class {
|
|
|
6451
6521
|
this.deepbookv3DeepFeeType()
|
|
6452
6522
|
).targetCoin;
|
|
6453
6523
|
}
|
|
6454
|
-
const
|
|
6455
|
-
routers,
|
|
6524
|
+
const routerSwapParams = isBuilderFastRouterSwapParams(params) ? {
|
|
6525
|
+
routers: routerData,
|
|
6456
6526
|
inputCoin: buildFromCoinRes.targetCoin,
|
|
6457
6527
|
slippage,
|
|
6458
6528
|
byAmountIn,
|
|
6459
6529
|
txb,
|
|
6460
6530
|
partner,
|
|
6461
6531
|
deepbookv3DeepFee: deepCoin
|
|
6462
|
-
}
|
|
6463
|
-
|
|
6532
|
+
} : {
|
|
6533
|
+
routers: params.routers,
|
|
6534
|
+
inputCoin: buildFromCoinRes.targetCoin,
|
|
6535
|
+
slippage,
|
|
6536
|
+
byAmountIn,
|
|
6537
|
+
txb,
|
|
6538
|
+
partner,
|
|
6539
|
+
deepbookv3DeepFee: deepCoin
|
|
6540
|
+
};
|
|
6541
|
+
const targetCoin = yield this.routerSwap(routerSwapParams);
|
|
6542
|
+
if (CoinUtils.isSuiCoin(targetCoinType)) {
|
|
6543
|
+
txb.mergeCoins(txb.gas, [targetCoin]);
|
|
6544
|
+
} else {
|
|
6464
6545
|
let targetCoins = yield this.getCoins(targetCoinType, refreshAllCoins);
|
|
6465
6546
|
const targetCoinRes = buildInputCoin(
|
|
6466
6547
|
txb,
|
|
@@ -6468,21 +6549,22 @@ var AggregatorClient10 = class {
|
|
|
6468
6549
|
BigInt(0),
|
|
6469
6550
|
targetCoinType
|
|
6470
6551
|
);
|
|
6552
|
+
const packages = isBuilderFastRouterSwapParams(params) ? void 0 : params.routers.packages;
|
|
6553
|
+
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(this.publishedAtV2(), packages);
|
|
6471
6554
|
txb.mergeCoins(targetCoinRes.targetCoin, [targetCoin]);
|
|
6472
6555
|
if (targetCoinRes.isMintZeroCoin) {
|
|
6473
6556
|
this.transferOrDestoryCoin(
|
|
6474
6557
|
txb,
|
|
6475
6558
|
targetCoinRes.targetCoin,
|
|
6476
|
-
targetCoinType
|
|
6559
|
+
targetCoinType,
|
|
6560
|
+
aggregatorV2PublishedAt
|
|
6477
6561
|
);
|
|
6478
6562
|
}
|
|
6479
|
-
} else {
|
|
6480
|
-
this.transferOrDestoryCoin(txb, targetCoin, targetCoinType);
|
|
6481
6563
|
}
|
|
6482
6564
|
});
|
|
6483
6565
|
}
|
|
6484
6566
|
// Include cetus、deepbookv2、flowxv2 & v3、kriyav2 & v3、turbos、aftermath、haedal、afsui、volo、bluemove
|
|
6485
|
-
|
|
6567
|
+
publishedAtV2() {
|
|
6486
6568
|
if (this.env === 0 /* Mainnet */) {
|
|
6487
6569
|
return "0x3fb42ddf908af45f9fc3c59eab227888ff24ba2e137b3b55bf80920fd47e11af";
|
|
6488
6570
|
} else {
|
|
@@ -6490,9 +6572,9 @@ var AggregatorClient10 = class {
|
|
|
6490
6572
|
}
|
|
6491
6573
|
}
|
|
6492
6574
|
// Include deepbookv3, scallop, bluefin
|
|
6493
|
-
|
|
6575
|
+
publishedAtV2Extend() {
|
|
6494
6576
|
if (this.env === 0 /* Mainnet */) {
|
|
6495
|
-
return "
|
|
6577
|
+
return "0xf2fcea41dc217385019828375764fa06d9bd25e8e4726ba1962680849fb8d613";
|
|
6496
6578
|
} else {
|
|
6497
6579
|
return "0xabb6a81c8a216828e317719e06125de5bb2cb0fe8f9916ff8c023ca5be224c78";
|
|
6498
6580
|
}
|
|
@@ -6504,14 +6586,14 @@ var AggregatorClient10 = class {
|
|
|
6504
6586
|
return "0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP";
|
|
6505
6587
|
}
|
|
6506
6588
|
}
|
|
6507
|
-
transferOrDestoryCoin(txb, coin, coinType) {
|
|
6589
|
+
transferOrDestoryCoin(txb, coin, coinType, aggregatorV2PublishedAt) {
|
|
6508
6590
|
txb.moveCall({
|
|
6509
|
-
target: `${
|
|
6591
|
+
target: `${aggregatorV2PublishedAt}::utils::transfer_or_destroy_coin`,
|
|
6510
6592
|
typeArguments: [coinType],
|
|
6511
6593
|
arguments: [coin]
|
|
6512
6594
|
});
|
|
6513
6595
|
}
|
|
6514
|
-
checkCoinThresholdAndMergeCoin(txb, coins, coinType, amountLimit) {
|
|
6596
|
+
checkCoinThresholdAndMergeCoin(txb, coins, coinType, amountLimit, aggregatorV2PublishedAt) {
|
|
6515
6597
|
let targetCoin = coins[0];
|
|
6516
6598
|
if (coins.length > 1) {
|
|
6517
6599
|
let vec = txb.makeMoveVec({ elements: coins.slice(1) });
|
|
@@ -6523,7 +6605,7 @@ var AggregatorClient10 = class {
|
|
|
6523
6605
|
targetCoin = coins[0];
|
|
6524
6606
|
}
|
|
6525
6607
|
txb.moveCall({
|
|
6526
|
-
target: `${
|
|
6608
|
+
target: `${aggregatorV2PublishedAt}::utils::check_coin_threshold`,
|
|
6527
6609
|
typeArguments: [coinType],
|
|
6528
6610
|
arguments: [targetCoin, txb.pure.u64(amountLimit.toString())]
|
|
6529
6611
|
});
|
|
@@ -6565,6 +6647,8 @@ var AggregatorClient10 = class {
|
|
|
6565
6647
|
return new Bluefin(this.env);
|
|
6566
6648
|
case HAEDALPMM:
|
|
6567
6649
|
return new HaedalPmm(this.env, this.client);
|
|
6650
|
+
case ALPHAFI:
|
|
6651
|
+
return new Alphafi(this.env);
|
|
6568
6652
|
default:
|
|
6569
6653
|
throw new Error(`Unsupported dex ${provider}`);
|
|
6570
6654
|
}
|
|
@@ -6612,7 +6696,7 @@ var AggregatorClient10 = class {
|
|
|
6612
6696
|
});
|
|
6613
6697
|
}
|
|
6614
6698
|
};
|
|
6615
|
-
function parseRouterResponse(data) {
|
|
6699
|
+
function parseRouterResponse(data, byAmountIn) {
|
|
6616
6700
|
let totalDeepFee = 0;
|
|
6617
6701
|
for (const route of data.routes) {
|
|
6618
6702
|
for (const path of route.path) {
|
|
@@ -6621,9 +6705,17 @@ function parseRouterResponse(data) {
|
|
|
6621
6705
|
}
|
|
6622
6706
|
}
|
|
6623
6707
|
}
|
|
6708
|
+
let packages = void 0;
|
|
6709
|
+
if (data.packages != null) {
|
|
6710
|
+
packages = /* @__PURE__ */ new Map();
|
|
6711
|
+
for (const [key, value] of Object.entries(data.packages)) {
|
|
6712
|
+
packages.set(key, value);
|
|
6713
|
+
}
|
|
6714
|
+
}
|
|
6624
6715
|
let routerData = {
|
|
6625
6716
|
amountIn: new import_bn5.default(data.amount_in.toString()),
|
|
6626
6717
|
amountOut: new import_bn5.default(data.amount_out.toString()),
|
|
6718
|
+
byAmountIn,
|
|
6627
6719
|
insufficientLiquidity: false,
|
|
6628
6720
|
routes: data.routes.map((route) => {
|
|
6629
6721
|
return {
|
|
@@ -6663,13 +6755,30 @@ function parseRouterResponse(data) {
|
|
|
6663
6755
|
initialPrice: new decimal_default(route.initial_price.toString())
|
|
6664
6756
|
};
|
|
6665
6757
|
}),
|
|
6666
|
-
totalDeepFee
|
|
6758
|
+
totalDeepFee,
|
|
6759
|
+
packages
|
|
6667
6760
|
};
|
|
6668
6761
|
return routerData;
|
|
6669
6762
|
}
|
|
6670
6763
|
|
|
6671
6764
|
// src/transaction/index.ts
|
|
6672
6765
|
var CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
|
|
6766
|
+
var AGGREGATOR_V2 = "aggregator_v2";
|
|
6767
|
+
var AGGREGATOR_V2_EXTEND = "aggregator_v2_extend";
|
|
6768
|
+
function getAggregatorV2PublishedAt(aggregatorV2PublishedAt, packages) {
|
|
6769
|
+
var _a;
|
|
6770
|
+
if (packages instanceof Map) {
|
|
6771
|
+
return (_a = packages.get(AGGREGATOR_V2)) != null ? _a : aggregatorV2PublishedAt;
|
|
6772
|
+
}
|
|
6773
|
+
return aggregatorV2PublishedAt;
|
|
6774
|
+
}
|
|
6775
|
+
function getAggregatorV2ExtendPublishedAt(aggregatorV2ExtendPublishedAt, packages) {
|
|
6776
|
+
var _a;
|
|
6777
|
+
if (packages instanceof Map) {
|
|
6778
|
+
return (_a = packages.get(AGGREGATOR_V2_EXTEND)) != null ? _a : aggregatorV2ExtendPublishedAt;
|
|
6779
|
+
}
|
|
6780
|
+
return aggregatorV2ExtendPublishedAt;
|
|
6781
|
+
}
|
|
6673
6782
|
|
|
6674
6783
|
// src/utils/msafe.ts
|
|
6675
6784
|
var import_bn6 = __toESM(require_bn());
|
|
@@ -6721,6 +6830,7 @@ function getRouterResult(endpoint, params) {
|
|
|
6721
6830
|
amountIn: ZERO,
|
|
6722
6831
|
amountOut: ZERO,
|
|
6723
6832
|
routes: [],
|
|
6833
|
+
byAmountIn: params.byAmountIn,
|
|
6724
6834
|
insufficientLiquidity: false,
|
|
6725
6835
|
error: {
|
|
6726
6836
|
code: 10001 /* NumberTooLarge */,
|
|
@@ -6737,6 +6847,7 @@ function getRouterResult(endpoint, params) {
|
|
|
6737
6847
|
amountIn: ZERO,
|
|
6738
6848
|
amountOut: ZERO,
|
|
6739
6849
|
routes: [],
|
|
6850
|
+
byAmountIn: params.byAmountIn,
|
|
6740
6851
|
insufficientLiquidity,
|
|
6741
6852
|
error: {
|
|
6742
6853
|
code: 10004 /* HoneyPot */,
|
|
@@ -6747,7 +6858,7 @@ function getRouterResult(endpoint, params) {
|
|
|
6747
6858
|
};
|
|
6748
6859
|
}
|
|
6749
6860
|
if (data.data != null) {
|
|
6750
|
-
const res = parseRouterResponse(data.data);
|
|
6861
|
+
const res = parseRouterResponse(data.data, params.byAmountIn);
|
|
6751
6862
|
return res;
|
|
6752
6863
|
}
|
|
6753
6864
|
return {
|
|
@@ -6755,6 +6866,7 @@ function getRouterResult(endpoint, params) {
|
|
|
6755
6866
|
amountOut: ZERO,
|
|
6756
6867
|
routes: [],
|
|
6757
6868
|
insufficientLiquidity,
|
|
6869
|
+
byAmountIn: params.byAmountIn,
|
|
6758
6870
|
error: {
|
|
6759
6871
|
code: 10003 /* InsufficientLiquidity */,
|
|
6760
6872
|
msg: getAggregatorServerErrorMessage(
|
|
@@ -6798,7 +6910,7 @@ function getRouter(endpoint, params) {
|
|
|
6798
6910
|
url += `&providers=${providers.join(",")}`;
|
|
6799
6911
|
}
|
|
6800
6912
|
}
|
|
6801
|
-
url += "&v=
|
|
6913
|
+
url += "&v=1000318";
|
|
6802
6914
|
const response = yield fetch(url);
|
|
6803
6915
|
return response;
|
|
6804
6916
|
} catch (error) {
|
|
@@ -6890,7 +7002,10 @@ decimal.js/decimal.mjs:
|
|
|
6890
7002
|
|
|
6891
7003
|
exports.AFSUI = AFSUI;
|
|
6892
7004
|
exports.AFTERMATH = AFTERMATH;
|
|
6893
|
-
exports.
|
|
7005
|
+
exports.AGGREGATOR_V2 = AGGREGATOR_V2;
|
|
7006
|
+
exports.AGGREGATOR_V2_EXTEND = AGGREGATOR_V2_EXTEND;
|
|
7007
|
+
exports.ALPHAFI = ALPHAFI;
|
|
7008
|
+
exports.AggregatorClient = AggregatorClient19;
|
|
6894
7009
|
exports.BLUEFIN = BLUEFIN;
|
|
6895
7010
|
exports.BLUEMOVE = BLUEMOVE;
|
|
6896
7011
|
exports.CETUS = CETUS;
|
|
@@ -6926,6 +7041,8 @@ exports.dealWithFastRouterSwapParamsForMsafe = dealWithFastRouterSwapParamsForMs
|
|
|
6926
7041
|
exports.extractAddressFromType = extractAddressFromType;
|
|
6927
7042
|
exports.extractStructTagFromType = extractStructTagFromType;
|
|
6928
7043
|
exports.fixSuiObjectId = fixSuiObjectId;
|
|
7044
|
+
exports.getAggregatorV2ExtendPublishedAt = getAggregatorV2ExtendPublishedAt;
|
|
7045
|
+
exports.getAggregatorV2PublishedAt = getAggregatorV2PublishedAt;
|
|
6929
7046
|
exports.getDeepbookV3Config = getDeepbookV3Config;
|
|
6930
7047
|
exports.getRouterResult = getRouterResult;
|
|
6931
7048
|
exports.isSortedSymbols = isSortedSymbols;
|