@cetusprotocol/aggregator-sdk 0.3.17 → 0.3.19
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 +34 -11
- package/dist/index.d.ts +34 -11
- package/dist/index.js +209 -88
- package/dist/index.mjs +203 -88
- package/dist/src/api.d.ts +2 -0
- package/dist/src/client.d.ts +26 -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/example/package.json +17 -0
- package/example/swap.ts +21 -0
- package/example/tsconfig.json +12 -0
- package/package.json +1 -1
- package/src/api.ts +7 -3
- package/src/client.ts +132 -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,16 @@ var SCALLOP = "SCALLOP";
|
|
|
6214
6269
|
var SUILEND = "SUILEND";
|
|
6215
6270
|
var BLUEFIN = "BLUEFIN";
|
|
6216
6271
|
var HAEDALPMM = "HAEDALPMM";
|
|
6272
|
+
var ALPHAFI = "ALPHAFI";
|
|
6273
|
+
var SPRINGSUI = "SPRINGSUI";
|
|
6217
6274
|
var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
6218
|
-
|
|
6275
|
+
function isBuilderRouterSwapParams(params) {
|
|
6276
|
+
return Array.isArray(params.routers);
|
|
6277
|
+
}
|
|
6278
|
+
function isBuilderFastRouterSwapParams(params) {
|
|
6279
|
+
return Array.isArray(params.routers);
|
|
6280
|
+
}
|
|
6281
|
+
var AggregatorClient19 = class {
|
|
6219
6282
|
constructor(endpoint, signer, client$1, env) {
|
|
6220
6283
|
this.endpoint = endpoint ? processEndpoint(endpoint) : DEFAULT_ENDPOINT;
|
|
6221
6284
|
this.client = client$1 || new client.SuiClient({ url: client.getFullnodeUrl("mainnet") });
|
|
@@ -6265,7 +6328,7 @@ var AggregatorClient10 = class {
|
|
|
6265
6328
|
return getRouterResult(this.endpoint, params);
|
|
6266
6329
|
});
|
|
6267
6330
|
}
|
|
6268
|
-
expectInputSwap(txb, inputCoin, routers, amountOutLimit, partner, deepbookv3DeepFee) {
|
|
6331
|
+
expectInputSwap(txb, inputCoin, routers, amountOutLimit, partner, deepbookv3DeepFee, packages) {
|
|
6269
6332
|
return __async(this, null, function* () {
|
|
6270
6333
|
if (routers.length === 0) {
|
|
6271
6334
|
throw new Error("No router found");
|
|
@@ -6282,26 +6345,29 @@ var AggregatorClient10 = class {
|
|
|
6282
6345
|
let nextCoin = inputCoins[i];
|
|
6283
6346
|
for (const path of routers[i].path) {
|
|
6284
6347
|
const dex = this.newDex(path.provider, partner);
|
|
6285
|
-
nextCoin = yield dex.swap(this, txb, path, nextCoin, deepbookv3DeepFee);
|
|
6348
|
+
nextCoin = yield dex.swap(this, txb, path, nextCoin, packages, deepbookv3DeepFee);
|
|
6286
6349
|
}
|
|
6287
6350
|
outputCoins.push(nextCoin);
|
|
6288
6351
|
}
|
|
6289
|
-
this.
|
|
6352
|
+
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(this.publishedAtV2(), packages);
|
|
6353
|
+
this.transferOrDestoryCoin(txb, inputCoin, inputCoinType, this.publishedAtV2());
|
|
6290
6354
|
const mergedTargetCointhis = this.checkCoinThresholdAndMergeCoin(
|
|
6291
6355
|
txb,
|
|
6292
6356
|
outputCoins,
|
|
6293
6357
|
outputCoinType,
|
|
6294
|
-
amountOutLimit
|
|
6358
|
+
amountOutLimit,
|
|
6359
|
+
aggregatorV2PublishedAt
|
|
6295
6360
|
);
|
|
6296
6361
|
return mergedTargetCointhis;
|
|
6297
6362
|
});
|
|
6298
6363
|
}
|
|
6299
|
-
expectOutputSwap(txb, inputCoin, routers, partner) {
|
|
6364
|
+
expectOutputSwap(txb, inputCoin, routers, partner, packages) {
|
|
6300
6365
|
return __async(this, null, function* () {
|
|
6301
6366
|
const returnCoins = [];
|
|
6302
6367
|
const receipts = [];
|
|
6303
6368
|
const targetCoins = [];
|
|
6304
6369
|
const dex = new Cetus(this.env, partner);
|
|
6370
|
+
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(this.publishedAtV2(), packages);
|
|
6305
6371
|
for (let i = 0; i < routers.length; i++) {
|
|
6306
6372
|
const router = routers[i];
|
|
6307
6373
|
for (let j = router.path.length - 1; j >= 0; j--) {
|
|
@@ -6324,7 +6390,7 @@ var AggregatorClient10 = class {
|
|
|
6324
6390
|
if (j === 0) {
|
|
6325
6391
|
inputCoin = repayResult;
|
|
6326
6392
|
} else {
|
|
6327
|
-
this.transferOrDestoryCoin(txb, repayResult, path.from);
|
|
6393
|
+
this.transferOrDestoryCoin(txb, repayResult, path.from, aggregatorV2PublishedAt);
|
|
6328
6394
|
}
|
|
6329
6395
|
if (j === router.path.length - 1) {
|
|
6330
6396
|
targetCoins.push(nextRepayCoin);
|
|
@@ -6332,7 +6398,7 @@ var AggregatorClient10 = class {
|
|
|
6332
6398
|
}
|
|
6333
6399
|
}
|
|
6334
6400
|
const inputCoinType = routers[0].path[0].from;
|
|
6335
|
-
this.transferOrDestoryCoin(txb, inputCoin, inputCoinType);
|
|
6401
|
+
this.transferOrDestoryCoin(txb, inputCoin, inputCoinType, aggregatorV2PublishedAt);
|
|
6336
6402
|
if (targetCoins.length > 1) {
|
|
6337
6403
|
const vec = txb.makeMoveVec({ elements: targetCoins.slice(1) });
|
|
6338
6404
|
txb.moveCall({
|
|
@@ -6362,16 +6428,17 @@ var AggregatorClient10 = class {
|
|
|
6362
6428
|
routers,
|
|
6363
6429
|
inputCoin,
|
|
6364
6430
|
slippage,
|
|
6365
|
-
byAmountIn,
|
|
6366
6431
|
txb,
|
|
6367
6432
|
partner,
|
|
6368
6433
|
deepbookv3DeepFee
|
|
6369
6434
|
} = params;
|
|
6370
|
-
const
|
|
6435
|
+
const routerData = Array.isArray(routers) ? routers : routers.routes;
|
|
6436
|
+
const byAmountIn = isBuilderRouterSwapParams(params) ? params.byAmountIn : params.routers.byAmountIn;
|
|
6437
|
+
const amountIn = routerData.reduce(
|
|
6371
6438
|
(acc, router) => acc.add(router.amountIn),
|
|
6372
6439
|
new import_bn5.default(0)
|
|
6373
6440
|
);
|
|
6374
|
-
const amountOut =
|
|
6441
|
+
const amountOut = routerData.reduce(
|
|
6375
6442
|
(acc, router) => acc.add(router.amountOut),
|
|
6376
6443
|
new import_bn5.default(0)
|
|
6377
6444
|
);
|
|
@@ -6380,25 +6447,29 @@ var AggregatorClient10 = class {
|
|
|
6380
6447
|
byAmountIn,
|
|
6381
6448
|
slippage
|
|
6382
6449
|
);
|
|
6450
|
+
const packages = isBuilderRouterSwapParams(params) ? void 0 : params.routers.packages;
|
|
6451
|
+
console.log("packages11", packages);
|
|
6452
|
+
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(this.publishedAtV2(), packages);
|
|
6383
6453
|
if (byAmountIn) {
|
|
6384
6454
|
const targetCoin2 = yield this.expectInputSwap(
|
|
6385
6455
|
txb,
|
|
6386
6456
|
inputCoin,
|
|
6387
|
-
|
|
6457
|
+
routerData,
|
|
6388
6458
|
amountLimit,
|
|
6389
6459
|
partner,
|
|
6390
|
-
deepbookv3DeepFee
|
|
6460
|
+
deepbookv3DeepFee,
|
|
6461
|
+
packages
|
|
6391
6462
|
);
|
|
6392
6463
|
return targetCoin2;
|
|
6393
6464
|
}
|
|
6394
6465
|
const splitedInputCoins = txb.splitCoins(inputCoin, [
|
|
6395
6466
|
amountLimit.toString()
|
|
6396
6467
|
]);
|
|
6397
|
-
this.transferOrDestoryCoin(txb, inputCoin,
|
|
6468
|
+
this.transferOrDestoryCoin(txb, inputCoin, routerData[0].path[0].from, aggregatorV2PublishedAt);
|
|
6398
6469
|
const targetCoin = yield this.expectOutputSwap(
|
|
6399
6470
|
txb,
|
|
6400
6471
|
splitedInputCoins[0],
|
|
6401
|
-
|
|
6472
|
+
routerData,
|
|
6402
6473
|
partner
|
|
6403
6474
|
);
|
|
6404
6475
|
return targetCoin;
|
|
@@ -6410,25 +6481,25 @@ var AggregatorClient10 = class {
|
|
|
6410
6481
|
return __async(this, null, function* () {
|
|
6411
6482
|
const {
|
|
6412
6483
|
routers,
|
|
6413
|
-
byAmountIn,
|
|
6414
6484
|
slippage,
|
|
6415
6485
|
txb,
|
|
6416
6486
|
partner,
|
|
6417
|
-
isMergeTragetCoin,
|
|
6418
6487
|
refreshAllCoins,
|
|
6419
6488
|
payDeepFeeAmount
|
|
6420
6489
|
} = params;
|
|
6421
|
-
const
|
|
6490
|
+
const routerData = Array.isArray(routers) ? routers : routers.routes;
|
|
6491
|
+
const fromCoinType = routerData[0].path[0].from;
|
|
6422
6492
|
let fromCoins = yield this.getCoins(fromCoinType, refreshAllCoins);
|
|
6423
|
-
const targetCoinType =
|
|
6424
|
-
const amountIn =
|
|
6493
|
+
const targetCoinType = routerData[0].path[routerData[0].path.length - 1].target;
|
|
6494
|
+
const amountIn = routerData.reduce(
|
|
6425
6495
|
(acc, router) => acc.add(router.amountIn),
|
|
6426
6496
|
new import_bn5.default(0)
|
|
6427
6497
|
);
|
|
6428
|
-
const amountOut =
|
|
6498
|
+
const amountOut = routerData.reduce(
|
|
6429
6499
|
(acc, router) => acc.add(router.amountOut),
|
|
6430
6500
|
new import_bn5.default(0)
|
|
6431
6501
|
);
|
|
6502
|
+
const byAmountIn = isBuilderFastRouterSwapParams(params) ? params.byAmountIn : params.routers.byAmountIn;
|
|
6432
6503
|
const amountLimit = CalculateAmountLimit(
|
|
6433
6504
|
byAmountIn ? amountOut : amountIn,
|
|
6434
6505
|
byAmountIn,
|
|
@@ -6451,16 +6522,27 @@ var AggregatorClient10 = class {
|
|
|
6451
6522
|
this.deepbookv3DeepFeeType()
|
|
6452
6523
|
).targetCoin;
|
|
6453
6524
|
}
|
|
6454
|
-
const
|
|
6455
|
-
routers,
|
|
6525
|
+
const routerSwapParams = isBuilderFastRouterSwapParams(params) ? {
|
|
6526
|
+
routers: routerData,
|
|
6456
6527
|
inputCoin: buildFromCoinRes.targetCoin,
|
|
6457
6528
|
slippage,
|
|
6458
6529
|
byAmountIn,
|
|
6459
6530
|
txb,
|
|
6460
6531
|
partner,
|
|
6461
6532
|
deepbookv3DeepFee: deepCoin
|
|
6462
|
-
}
|
|
6463
|
-
|
|
6533
|
+
} : {
|
|
6534
|
+
routers: params.routers,
|
|
6535
|
+
inputCoin: buildFromCoinRes.targetCoin,
|
|
6536
|
+
slippage,
|
|
6537
|
+
byAmountIn,
|
|
6538
|
+
txb,
|
|
6539
|
+
partner,
|
|
6540
|
+
deepbookv3DeepFee: deepCoin
|
|
6541
|
+
};
|
|
6542
|
+
const targetCoin = yield this.routerSwap(routerSwapParams);
|
|
6543
|
+
if (CoinUtils.isSuiCoin(targetCoinType)) {
|
|
6544
|
+
txb.mergeCoins(txb.gas, [targetCoin]);
|
|
6545
|
+
} else {
|
|
6464
6546
|
let targetCoins = yield this.getCoins(targetCoinType, refreshAllCoins);
|
|
6465
6547
|
const targetCoinRes = buildInputCoin(
|
|
6466
6548
|
txb,
|
|
@@ -6468,21 +6550,22 @@ var AggregatorClient10 = class {
|
|
|
6468
6550
|
BigInt(0),
|
|
6469
6551
|
targetCoinType
|
|
6470
6552
|
);
|
|
6553
|
+
const packages = isBuilderFastRouterSwapParams(params) ? void 0 : params.routers.packages;
|
|
6554
|
+
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(this.publishedAtV2(), packages);
|
|
6471
6555
|
txb.mergeCoins(targetCoinRes.targetCoin, [targetCoin]);
|
|
6472
6556
|
if (targetCoinRes.isMintZeroCoin) {
|
|
6473
6557
|
this.transferOrDestoryCoin(
|
|
6474
6558
|
txb,
|
|
6475
6559
|
targetCoinRes.targetCoin,
|
|
6476
|
-
targetCoinType
|
|
6560
|
+
targetCoinType,
|
|
6561
|
+
aggregatorV2PublishedAt
|
|
6477
6562
|
);
|
|
6478
6563
|
}
|
|
6479
|
-
} else {
|
|
6480
|
-
this.transferOrDestoryCoin(txb, targetCoin, targetCoinType);
|
|
6481
6564
|
}
|
|
6482
6565
|
});
|
|
6483
6566
|
}
|
|
6484
6567
|
// Include cetus、deepbookv2、flowxv2 & v3、kriyav2 & v3、turbos、aftermath、haedal、afsui、volo、bluemove
|
|
6485
|
-
|
|
6568
|
+
publishedAtV2() {
|
|
6486
6569
|
if (this.env === 0 /* Mainnet */) {
|
|
6487
6570
|
return "0x3fb42ddf908af45f9fc3c59eab227888ff24ba2e137b3b55bf80920fd47e11af";
|
|
6488
6571
|
} else {
|
|
@@ -6490,9 +6573,9 @@ var AggregatorClient10 = class {
|
|
|
6490
6573
|
}
|
|
6491
6574
|
}
|
|
6492
6575
|
// Include deepbookv3, scallop, bluefin
|
|
6493
|
-
|
|
6576
|
+
publishedAtV2Extend() {
|
|
6494
6577
|
if (this.env === 0 /* Mainnet */) {
|
|
6495
|
-
return "
|
|
6578
|
+
return "0xf2fcea41dc217385019828375764fa06d9bd25e8e4726ba1962680849fb8d613";
|
|
6496
6579
|
} else {
|
|
6497
6580
|
return "0xabb6a81c8a216828e317719e06125de5bb2cb0fe8f9916ff8c023ca5be224c78";
|
|
6498
6581
|
}
|
|
@@ -6504,14 +6587,14 @@ var AggregatorClient10 = class {
|
|
|
6504
6587
|
return "0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP";
|
|
6505
6588
|
}
|
|
6506
6589
|
}
|
|
6507
|
-
transferOrDestoryCoin(txb, coin, coinType) {
|
|
6590
|
+
transferOrDestoryCoin(txb, coin, coinType, aggregatorV2PublishedAt) {
|
|
6508
6591
|
txb.moveCall({
|
|
6509
|
-
target: `${
|
|
6592
|
+
target: `${aggregatorV2PublishedAt}::utils::transfer_or_destroy_coin`,
|
|
6510
6593
|
typeArguments: [coinType],
|
|
6511
6594
|
arguments: [coin]
|
|
6512
6595
|
});
|
|
6513
6596
|
}
|
|
6514
|
-
checkCoinThresholdAndMergeCoin(txb, coins, coinType, amountLimit) {
|
|
6597
|
+
checkCoinThresholdAndMergeCoin(txb, coins, coinType, amountLimit, aggregatorV2PublishedAt) {
|
|
6515
6598
|
let targetCoin = coins[0];
|
|
6516
6599
|
if (coins.length > 1) {
|
|
6517
6600
|
let vec = txb.makeMoveVec({ elements: coins.slice(1) });
|
|
@@ -6523,7 +6606,7 @@ var AggregatorClient10 = class {
|
|
|
6523
6606
|
targetCoin = coins[0];
|
|
6524
6607
|
}
|
|
6525
6608
|
txb.moveCall({
|
|
6526
|
-
target: `${
|
|
6609
|
+
target: `${aggregatorV2PublishedAt}::utils::check_coin_threshold`,
|
|
6527
6610
|
typeArguments: [coinType],
|
|
6528
6611
|
arguments: [targetCoin, txb.pure.u64(amountLimit.toString())]
|
|
6529
6612
|
});
|
|
@@ -6561,10 +6644,14 @@ var AggregatorClient10 = class {
|
|
|
6561
6644
|
return new Scallop(this.env);
|
|
6562
6645
|
case SUILEND:
|
|
6563
6646
|
return new Suilend(this.env);
|
|
6647
|
+
case SPRINGSUI:
|
|
6648
|
+
return new Suilend(this.env);
|
|
6564
6649
|
case BLUEFIN:
|
|
6565
6650
|
return new Bluefin(this.env);
|
|
6566
6651
|
case HAEDALPMM:
|
|
6567
6652
|
return new HaedalPmm(this.env, this.client);
|
|
6653
|
+
case ALPHAFI:
|
|
6654
|
+
return new Alphafi(this.env);
|
|
6568
6655
|
default:
|
|
6569
6656
|
throw new Error(`Unsupported dex ${provider}`);
|
|
6570
6657
|
}
|
|
@@ -6612,7 +6699,7 @@ var AggregatorClient10 = class {
|
|
|
6612
6699
|
});
|
|
6613
6700
|
}
|
|
6614
6701
|
};
|
|
6615
|
-
function parseRouterResponse(data) {
|
|
6702
|
+
function parseRouterResponse(data, byAmountIn) {
|
|
6616
6703
|
let totalDeepFee = 0;
|
|
6617
6704
|
for (const route of data.routes) {
|
|
6618
6705
|
for (const path of route.path) {
|
|
@@ -6621,9 +6708,17 @@ function parseRouterResponse(data) {
|
|
|
6621
6708
|
}
|
|
6622
6709
|
}
|
|
6623
6710
|
}
|
|
6711
|
+
let packages = void 0;
|
|
6712
|
+
if (data.packages != null) {
|
|
6713
|
+
packages = /* @__PURE__ */ new Map();
|
|
6714
|
+
for (const [key, value] of Object.entries(data.packages)) {
|
|
6715
|
+
packages.set(key, value);
|
|
6716
|
+
}
|
|
6717
|
+
}
|
|
6624
6718
|
let routerData = {
|
|
6625
6719
|
amountIn: new import_bn5.default(data.amount_in.toString()),
|
|
6626
6720
|
amountOut: new import_bn5.default(data.amount_out.toString()),
|
|
6721
|
+
byAmountIn,
|
|
6627
6722
|
insufficientLiquidity: false,
|
|
6628
6723
|
routes: data.routes.map((route) => {
|
|
6629
6724
|
return {
|
|
@@ -6663,13 +6758,30 @@ function parseRouterResponse(data) {
|
|
|
6663
6758
|
initialPrice: new decimal_default(route.initial_price.toString())
|
|
6664
6759
|
};
|
|
6665
6760
|
}),
|
|
6666
|
-
totalDeepFee
|
|
6761
|
+
totalDeepFee,
|
|
6762
|
+
packages
|
|
6667
6763
|
};
|
|
6668
6764
|
return routerData;
|
|
6669
6765
|
}
|
|
6670
6766
|
|
|
6671
6767
|
// src/transaction/index.ts
|
|
6672
6768
|
var CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
|
|
6769
|
+
var AGGREGATOR_V2 = "aggregator_v2";
|
|
6770
|
+
var AGGREGATOR_V2_EXTEND = "aggregator_v2_extend";
|
|
6771
|
+
function getAggregatorV2PublishedAt(aggregatorV2PublishedAt, packages) {
|
|
6772
|
+
var _a;
|
|
6773
|
+
if (packages instanceof Map) {
|
|
6774
|
+
return (_a = packages.get(AGGREGATOR_V2)) != null ? _a : aggregatorV2PublishedAt;
|
|
6775
|
+
}
|
|
6776
|
+
return aggregatorV2PublishedAt;
|
|
6777
|
+
}
|
|
6778
|
+
function getAggregatorV2ExtendPublishedAt(aggregatorV2ExtendPublishedAt, packages) {
|
|
6779
|
+
var _a;
|
|
6780
|
+
if (packages instanceof Map) {
|
|
6781
|
+
return (_a = packages.get(AGGREGATOR_V2_EXTEND)) != null ? _a : aggregatorV2ExtendPublishedAt;
|
|
6782
|
+
}
|
|
6783
|
+
return aggregatorV2ExtendPublishedAt;
|
|
6784
|
+
}
|
|
6673
6785
|
|
|
6674
6786
|
// src/utils/msafe.ts
|
|
6675
6787
|
var import_bn6 = __toESM(require_bn());
|
|
@@ -6721,6 +6833,7 @@ function getRouterResult(endpoint, params) {
|
|
|
6721
6833
|
amountIn: ZERO,
|
|
6722
6834
|
amountOut: ZERO,
|
|
6723
6835
|
routes: [],
|
|
6836
|
+
byAmountIn: params.byAmountIn,
|
|
6724
6837
|
insufficientLiquidity: false,
|
|
6725
6838
|
error: {
|
|
6726
6839
|
code: 10001 /* NumberTooLarge */,
|
|
@@ -6737,6 +6850,7 @@ function getRouterResult(endpoint, params) {
|
|
|
6737
6850
|
amountIn: ZERO,
|
|
6738
6851
|
amountOut: ZERO,
|
|
6739
6852
|
routes: [],
|
|
6853
|
+
byAmountIn: params.byAmountIn,
|
|
6740
6854
|
insufficientLiquidity,
|
|
6741
6855
|
error: {
|
|
6742
6856
|
code: 10004 /* HoneyPot */,
|
|
@@ -6747,7 +6861,7 @@ function getRouterResult(endpoint, params) {
|
|
|
6747
6861
|
};
|
|
6748
6862
|
}
|
|
6749
6863
|
if (data.data != null) {
|
|
6750
|
-
const res = parseRouterResponse(data.data);
|
|
6864
|
+
const res = parseRouterResponse(data.data, params.byAmountIn);
|
|
6751
6865
|
return res;
|
|
6752
6866
|
}
|
|
6753
6867
|
return {
|
|
@@ -6755,6 +6869,7 @@ function getRouterResult(endpoint, params) {
|
|
|
6755
6869
|
amountOut: ZERO,
|
|
6756
6870
|
routes: [],
|
|
6757
6871
|
insufficientLiquidity,
|
|
6872
|
+
byAmountIn: params.byAmountIn,
|
|
6758
6873
|
error: {
|
|
6759
6874
|
code: 10003 /* InsufficientLiquidity */,
|
|
6760
6875
|
msg: getAggregatorServerErrorMessage(
|
|
@@ -6798,7 +6913,7 @@ function getRouter(endpoint, params) {
|
|
|
6798
6913
|
url += `&providers=${providers.join(",")}`;
|
|
6799
6914
|
}
|
|
6800
6915
|
}
|
|
6801
|
-
url += "&v=
|
|
6916
|
+
url += "&v=1000319";
|
|
6802
6917
|
const response = yield fetch(url);
|
|
6803
6918
|
return response;
|
|
6804
6919
|
} catch (error) {
|
|
@@ -6890,7 +7005,10 @@ decimal.js/decimal.mjs:
|
|
|
6890
7005
|
|
|
6891
7006
|
exports.AFSUI = AFSUI;
|
|
6892
7007
|
exports.AFTERMATH = AFTERMATH;
|
|
6893
|
-
exports.
|
|
7008
|
+
exports.AGGREGATOR_V2 = AGGREGATOR_V2;
|
|
7009
|
+
exports.AGGREGATOR_V2_EXTEND = AGGREGATOR_V2_EXTEND;
|
|
7010
|
+
exports.ALPHAFI = ALPHAFI;
|
|
7011
|
+
exports.AggregatorClient = AggregatorClient19;
|
|
6894
7012
|
exports.BLUEFIN = BLUEFIN;
|
|
6895
7013
|
exports.BLUEMOVE = BLUEMOVE;
|
|
6896
7014
|
exports.CETUS = CETUS;
|
|
@@ -6907,6 +7025,7 @@ exports.KRIYA = KRIYA;
|
|
|
6907
7025
|
exports.KRIYAV3 = KRIYAV3;
|
|
6908
7026
|
exports.ONE = ONE;
|
|
6909
7027
|
exports.SCALLOP = SCALLOP;
|
|
7028
|
+
exports.SPRINGSUI = SPRINGSUI;
|
|
6910
7029
|
exports.SUILEND = SUILEND;
|
|
6911
7030
|
exports.TEN_POW_NINE = TEN_POW_NINE;
|
|
6912
7031
|
exports.TURBOS = TURBOS;
|
|
@@ -6926,6 +7045,8 @@ exports.dealWithFastRouterSwapParamsForMsafe = dealWithFastRouterSwapParamsForMs
|
|
|
6926
7045
|
exports.extractAddressFromType = extractAddressFromType;
|
|
6927
7046
|
exports.extractStructTagFromType = extractStructTagFromType;
|
|
6928
7047
|
exports.fixSuiObjectId = fixSuiObjectId;
|
|
7048
|
+
exports.getAggregatorV2ExtendPublishedAt = getAggregatorV2ExtendPublishedAt;
|
|
7049
|
+
exports.getAggregatorV2PublishedAt = getAggregatorV2PublishedAt;
|
|
6929
7050
|
exports.getDeepbookV3Config = getDeepbookV3Config;
|
|
6930
7051
|
exports.getRouterResult = getRouterResult;
|
|
6931
7052
|
exports.isSortedSymbols = isSortedSymbols;
|