@cetusprotocol/aggregator-sdk 0.3.16 → 0.3.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.d.mts +33 -11
- package/dist/index.d.ts +33 -11
- package/dist/index.js +209 -89
- package/dist/index.mjs +204 -89
- package/dist/src/api.d.ts +2 -0
- package/dist/src/client.d.ts +25 -9
- package/dist/src/transaction/afsui.d.ts +1 -1
- package/dist/src/transaction/aftermath.d.ts +1 -1
- package/dist/src/transaction/alphafi.d.ts +7 -0
- package/dist/src/transaction/bluefin.d.ts +1 -1
- package/dist/src/transaction/bluemove.d.ts +1 -1
- package/dist/src/transaction/cetus.d.ts +3 -3
- package/dist/src/transaction/deepbook_v2.d.ts +1 -1
- package/dist/src/transaction/deepbook_v3.d.ts +1 -1
- package/dist/src/transaction/flowx_v2.d.ts +1 -1
- package/dist/src/transaction/flowx_v3.d.ts +1 -1
- package/dist/src/transaction/haedal.d.ts +1 -1
- package/dist/src/transaction/haedal_pmm.d.ts +1 -1
- package/dist/src/transaction/index.d.ts +5 -1
- package/dist/src/transaction/kriya_v2.d.ts +1 -1
- package/dist/src/transaction/kriya_v3.d.ts +1 -1
- package/dist/src/transaction/scallop.d.ts +1 -1
- package/dist/src/transaction/suilend.d.ts +1 -2
- package/dist/src/transaction/turbos.d.ts +1 -1
- package/dist/src/transaction/volo.d.ts +1 -1
- package/package.json +1 -1
- package/src/api.ts +7 -3
- package/src/client.ts +129 -42
- package/src/transaction/afsui.ts +6 -3
- package/src/transaction/aftermath.ts +6 -3
- package/src/transaction/alphafi.ts +50 -0
- package/src/transaction/bluefin.ts +6 -3
- package/src/transaction/bluemove.ts +5 -4
- package/src/transaction/cetus.ts +13 -7
- package/src/transaction/deepbook_v2.ts +5 -4
- package/src/transaction/deepbook_v3.ts +5 -3
- package/src/transaction/flowx_v2.ts +5 -4
- package/src/transaction/flowx_v3.ts +5 -3
- package/src/transaction/haedal.ts +5 -3
- package/src/transaction/haedal_pmm.ts +5 -3
- package/src/transaction/index.ts +20 -1
- package/src/transaction/kriya_v2.ts +5 -4
- package/src/transaction/kriya_v3.ts +5 -4
- package/src/transaction/scallop.ts +5 -4
- package/src/transaction/suilend.ts +6 -10
- package/src/transaction/swap.ts +1 -0
- package/src/transaction/turbos.ts +5 -4
- package/src/transaction/volo.ts +5 -3
- package/src/utils/coin.ts +20 -8
- package/tests/router.test.ts +15 -22
package/dist/index.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) {
|
|
@@ -5708,8 +5726,11 @@ function buildInputCoin(txb, allCoins, amount, coinType) {
|
|
|
5708
5726
|
mergedCoin.map((coin) => txb.object(coin))
|
|
5709
5727
|
);
|
|
5710
5728
|
}
|
|
5729
|
+
const targetCoin = txb.splitCoins(txb.object(masterCoin), [
|
|
5730
|
+
txb.pure.u64(amount.toString())
|
|
5731
|
+
]);
|
|
5711
5732
|
return {
|
|
5712
|
-
targetCoin
|
|
5733
|
+
targetCoin,
|
|
5713
5734
|
isMintZeroCoin: false,
|
|
5714
5735
|
targetCoinAmount: Number(amount.toString())
|
|
5715
5736
|
};
|
|
@@ -5894,7 +5915,8 @@ function swapInPools(client, params, sender, env) {
|
|
|
5894
5915
|
initialPrice
|
|
5895
5916
|
}
|
|
5896
5917
|
],
|
|
5897
|
-
insufficientLiquidity: false
|
|
5918
|
+
insufficientLiquidity: false,
|
|
5919
|
+
byAmountIn: params.byAmountIn
|
|
5898
5920
|
};
|
|
5899
5921
|
const result = {
|
|
5900
5922
|
isExceed: event.is_exceed,
|
|
@@ -5911,7 +5933,7 @@ var Haedal = class {
|
|
|
5911
5933
|
throw new Error("Haedal only supported on mainnet");
|
|
5912
5934
|
}
|
|
5913
5935
|
}
|
|
5914
|
-
swap(client, txb, path, inputCoin) {
|
|
5936
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
5915
5937
|
return __async(this, null, function* () {
|
|
5916
5938
|
const { direction } = path;
|
|
5917
5939
|
if (!direction) {
|
|
@@ -5919,8 +5941,9 @@ var Haedal = class {
|
|
|
5919
5941
|
}
|
|
5920
5942
|
const func = "swap_a2b";
|
|
5921
5943
|
const args = [txb.object(path.id), txb.object("0x5"), inputCoin];
|
|
5944
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5922
5945
|
const res = txb.moveCall({
|
|
5923
|
-
target: `${
|
|
5946
|
+
target: `${publishedAt}::haedal::${func}`,
|
|
5924
5947
|
typeArguments: [],
|
|
5925
5948
|
arguments: args
|
|
5926
5949
|
});
|
|
@@ -5940,7 +5963,7 @@ var Afsui = class {
|
|
|
5940
5963
|
this.referVault = "0x4ce9a19b594599536c53edb25d22532f82f18038dc8ef618afd00fbbfb9845ef";
|
|
5941
5964
|
this.validator = "0xd30018ec3f5ff1a3c75656abf927a87d7f0529e6dc89c7ddd1bd27ecb05e3db2";
|
|
5942
5965
|
}
|
|
5943
|
-
swap(client, txb, path, inputCoin) {
|
|
5966
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
5944
5967
|
return __async(this, null, function* () {
|
|
5945
5968
|
const { direction } = path;
|
|
5946
5969
|
if (!direction) {
|
|
@@ -5955,8 +5978,9 @@ var Afsui = class {
|
|
|
5955
5978
|
txb.object(this.validator),
|
|
5956
5979
|
inputCoin
|
|
5957
5980
|
];
|
|
5981
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5958
5982
|
const res = txb.moveCall({
|
|
5959
|
-
target: `${
|
|
5983
|
+
target: `${publishedAt}::afsui::${func}`,
|
|
5960
5984
|
typeArguments: [],
|
|
5961
5985
|
arguments: args
|
|
5962
5986
|
});
|
|
@@ -5974,7 +5998,7 @@ var Volo = class {
|
|
|
5974
5998
|
this.nativePool = "0x7fa2faa111b8c65bea48a23049bfd81ca8f971a262d981dcd9a17c3825cb5baf";
|
|
5975
5999
|
this.metadata = "0x680cd26af32b2bde8d3361e804c53ec1d1cfe24c7f039eb7f549e8dfde389a60";
|
|
5976
6000
|
}
|
|
5977
|
-
swap(client, txb, path, inputCoin) {
|
|
6001
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
5978
6002
|
return __async(this, null, function* () {
|
|
5979
6003
|
const { direction } = path;
|
|
5980
6004
|
if (!direction) {
|
|
@@ -5987,8 +6011,9 @@ var Volo = class {
|
|
|
5987
6011
|
txb.object("0x5"),
|
|
5988
6012
|
inputCoin
|
|
5989
6013
|
];
|
|
6014
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5990
6015
|
const res = txb.moveCall({
|
|
5991
|
-
target: `${
|
|
6016
|
+
target: `${publishedAt}::volo::${func}`,
|
|
5992
6017
|
typeArguments: [],
|
|
5993
6018
|
arguments: args
|
|
5994
6019
|
});
|
|
@@ -6005,13 +6030,14 @@ var Bluemove = class {
|
|
|
6005
6030
|
}
|
|
6006
6031
|
this.dexInfo = "0x3f2d9f724f4a1ce5e71676448dc452be9a6243dac9c5b975a588c8c867066e92";
|
|
6007
6032
|
}
|
|
6008
|
-
swap(client, txb, path, inputCoin) {
|
|
6033
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6009
6034
|
return __async(this, null, function* () {
|
|
6010
6035
|
const { direction, from, target } = path;
|
|
6011
6036
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
6012
6037
|
const args = [txb.object(this.dexInfo), inputCoin];
|
|
6038
|
+
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
6013
6039
|
const res = txb.moveCall({
|
|
6014
|
-
target: `${
|
|
6040
|
+
target: `${publishedAt}::bluemove::${func}`,
|
|
6015
6041
|
typeArguments: [coinAType, coinBType],
|
|
6016
6042
|
arguments: args
|
|
6017
6043
|
});
|
|
@@ -6025,7 +6051,7 @@ var DeepbookV3 = class {
|
|
|
6025
6051
|
constructor(env) {
|
|
6026
6052
|
this.deepbookV3Config = env === 0 /* Mainnet */ ? "0xe4099d0cda04f3aa80028fac91a9b3dbe50d08f2ff42aa2c29473926e34ca48c" : "0xe19b5d072346cae83a037d4e3c8492068a74410a74e5830b3a68012db38296aa";
|
|
6027
6053
|
}
|
|
6028
|
-
swap(client, txb, path, inputCoin, deepbookv3DeepFee) {
|
|
6054
|
+
swap(client, txb, path, inputCoin, packages, deepbookv3DeepFee) {
|
|
6029
6055
|
return __async(this, null, function* () {
|
|
6030
6056
|
const { direction, from, target } = path;
|
|
6031
6057
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
@@ -6042,8 +6068,9 @@ var DeepbookV3 = class {
|
|
|
6042
6068
|
deepFee,
|
|
6043
6069
|
txb.object(CLOCK_ADDRESS)
|
|
6044
6070
|
];
|
|
6071
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
|
|
6045
6072
|
const res = txb.moveCall({
|
|
6046
|
-
target: `${
|
|
6073
|
+
target: `${publishedAt}::deepbookv3::${func}`,
|
|
6047
6074
|
typeArguments: [coinAType, coinBType],
|
|
6048
6075
|
arguments: args
|
|
6049
6076
|
});
|
|
@@ -6061,7 +6088,7 @@ var Scallop = class {
|
|
|
6061
6088
|
this.version = env === 0 /* Mainnet */ ? "0x07871c4b3c847a0f674510d4978d5cf6f960452795e8ff6f189fd2088a3f6ac7" : "0x0";
|
|
6062
6089
|
this.market = env === 0 /* Mainnet */ ? "0xa757975255146dc9686aa823b7838b507f315d704f428cbadad2f4ea061939d9" : "0x0";
|
|
6063
6090
|
}
|
|
6064
|
-
swap(client, txb, path, inputCoin) {
|
|
6091
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6065
6092
|
return __async(this, null, function* () {
|
|
6066
6093
|
const { direction, from, target } = path;
|
|
6067
6094
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", from, target];
|
|
@@ -6079,8 +6106,9 @@ var Scallop = class {
|
|
|
6079
6106
|
inputCoin,
|
|
6080
6107
|
txb.object(CLOCK_ADDRESS)
|
|
6081
6108
|
];
|
|
6109
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
|
|
6082
6110
|
const res = txb.moveCall({
|
|
6083
|
-
target: `${
|
|
6111
|
+
target: `${publishedAt}::scallop::${func}`,
|
|
6084
6112
|
typeArguments: [coinAType, coinBType],
|
|
6085
6113
|
arguments: args
|
|
6086
6114
|
});
|
|
@@ -6095,20 +6123,20 @@ var Suilend = class {
|
|
|
6095
6123
|
if (env !== 0 /* Mainnet */) {
|
|
6096
6124
|
throw new Error("Suilend only supported on mainnet");
|
|
6097
6125
|
}
|
|
6098
|
-
this.liquid_staking_pool = env === 0 /* Mainnet */ ? "0x15eda7330c8f99c30e430b4d82fd7ab2af3ead4ae17046fcb224aa9bad394f6b" : "0x0";
|
|
6099
6126
|
this.sui_system_state = env === 0 /* Mainnet */ ? "0x0000000000000000000000000000000000000000000000000000000000000005" : "0x0";
|
|
6100
6127
|
}
|
|
6101
|
-
swap(client, txb, path, inputCoin) {
|
|
6128
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6102
6129
|
return __async(this, null, function* () {
|
|
6103
6130
|
const { direction, from, target } = path;
|
|
6104
6131
|
const [func, springCoinType] = direction ? ["swap_a2b", target] : ["swap_b2a", from];
|
|
6105
6132
|
const args = [
|
|
6106
|
-
txb.object(
|
|
6133
|
+
txb.object(path.id),
|
|
6107
6134
|
txb.object(this.sui_system_state),
|
|
6108
6135
|
inputCoin
|
|
6109
6136
|
];
|
|
6137
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
|
|
6110
6138
|
const res = txb.moveCall({
|
|
6111
|
-
target: `${
|
|
6139
|
+
target: `${publishedAt}::suilend::${func}`,
|
|
6112
6140
|
typeArguments: [springCoinType],
|
|
6113
6141
|
arguments: args
|
|
6114
6142
|
});
|
|
@@ -6125,7 +6153,7 @@ var Bluefin = class {
|
|
|
6125
6153
|
}
|
|
6126
6154
|
this.globalConfig = "0x03db251ba509a8d5d8777b6338836082335d93eecbdd09a11e190a1cff51c352";
|
|
6127
6155
|
}
|
|
6128
|
-
swap(client, txb, path, inputCoin) {
|
|
6156
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6129
6157
|
return __async(this, null, function* () {
|
|
6130
6158
|
const { direction, from, target } = path;
|
|
6131
6159
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
@@ -6135,8 +6163,9 @@ var Bluefin = class {
|
|
|
6135
6163
|
inputCoin,
|
|
6136
6164
|
txb.object(CLOCK_ADDRESS)
|
|
6137
6165
|
];
|
|
6166
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
|
|
6138
6167
|
const res = txb.moveCall({
|
|
6139
|
-
target: `${
|
|
6168
|
+
target: `${publishedAt}::bluefin::${func}`,
|
|
6140
6169
|
typeArguments: [coinAType, coinBType],
|
|
6141
6170
|
arguments: args
|
|
6142
6171
|
});
|
|
@@ -6158,7 +6187,7 @@ var HaedalPmm = class {
|
|
|
6158
6187
|
this.pythClient = new pythSuiJs.SuiPythClient(suiClient, pythStateId, wormholeStateId);
|
|
6159
6188
|
}
|
|
6160
6189
|
}
|
|
6161
|
-
swap(client, txb, path, inputCoin) {
|
|
6190
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6162
6191
|
return __async(this, null, function* () {
|
|
6163
6192
|
const { direction, from, target } = path;
|
|
6164
6193
|
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
@@ -6183,8 +6212,9 @@ var HaedalPmm = class {
|
|
|
6183
6212
|
inputCoin,
|
|
6184
6213
|
txb.object(CLOCK_ADDRESS)
|
|
6185
6214
|
];
|
|
6215
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
|
|
6186
6216
|
const res = txb.moveCall({
|
|
6187
|
-
target: `${
|
|
6217
|
+
target: `${publishedAt}::haedalpmm::${func}`,
|
|
6188
6218
|
typeArguments: [coinAType, coinBType],
|
|
6189
6219
|
arguments: args
|
|
6190
6220
|
});
|
|
@@ -6193,6 +6223,34 @@ var HaedalPmm = class {
|
|
|
6193
6223
|
}
|
|
6194
6224
|
};
|
|
6195
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
|
+
|
|
6196
6254
|
// src/client.ts
|
|
6197
6255
|
var CETUS = "CETUS";
|
|
6198
6256
|
var DEEPBOOKV2 = "DEEPBOOK";
|
|
@@ -6211,8 +6269,15 @@ var SCALLOP = "SCALLOP";
|
|
|
6211
6269
|
var SUILEND = "SUILEND";
|
|
6212
6270
|
var BLUEFIN = "BLUEFIN";
|
|
6213
6271
|
var HAEDALPMM = "HAEDALPMM";
|
|
6272
|
+
var ALPHAFI = "ALPHAFI";
|
|
6214
6273
|
var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
6215
|
-
|
|
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 {
|
|
6216
6281
|
constructor(endpoint, signer, client$1, env) {
|
|
6217
6282
|
this.endpoint = endpoint ? processEndpoint(endpoint) : DEFAULT_ENDPOINT;
|
|
6218
6283
|
this.client = client$1 || new client.SuiClient({ url: client.getFullnodeUrl("mainnet") });
|
|
@@ -6262,7 +6327,7 @@ var AggregatorClient10 = class {
|
|
|
6262
6327
|
return getRouterResult(this.endpoint, params);
|
|
6263
6328
|
});
|
|
6264
6329
|
}
|
|
6265
|
-
expectInputSwap(txb, inputCoin, routers, amountOutLimit, partner, deepbookv3DeepFee) {
|
|
6330
|
+
expectInputSwap(txb, inputCoin, routers, amountOutLimit, partner, deepbookv3DeepFee, packages) {
|
|
6266
6331
|
return __async(this, null, function* () {
|
|
6267
6332
|
if (routers.length === 0) {
|
|
6268
6333
|
throw new Error("No router found");
|
|
@@ -6279,26 +6344,29 @@ var AggregatorClient10 = class {
|
|
|
6279
6344
|
let nextCoin = inputCoins[i];
|
|
6280
6345
|
for (const path of routers[i].path) {
|
|
6281
6346
|
const dex = this.newDex(path.provider, partner);
|
|
6282
|
-
nextCoin = yield dex.swap(this, txb, path, nextCoin, deepbookv3DeepFee);
|
|
6347
|
+
nextCoin = yield dex.swap(this, txb, path, nextCoin, packages, deepbookv3DeepFee);
|
|
6283
6348
|
}
|
|
6284
6349
|
outputCoins.push(nextCoin);
|
|
6285
6350
|
}
|
|
6286
|
-
this.
|
|
6351
|
+
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(this.publishedAtV2(), packages);
|
|
6352
|
+
this.transferOrDestoryCoin(txb, inputCoin, inputCoinType, this.publishedAtV2());
|
|
6287
6353
|
const mergedTargetCointhis = this.checkCoinThresholdAndMergeCoin(
|
|
6288
6354
|
txb,
|
|
6289
6355
|
outputCoins,
|
|
6290
6356
|
outputCoinType,
|
|
6291
|
-
amountOutLimit
|
|
6357
|
+
amountOutLimit,
|
|
6358
|
+
aggregatorV2PublishedAt
|
|
6292
6359
|
);
|
|
6293
6360
|
return mergedTargetCointhis;
|
|
6294
6361
|
});
|
|
6295
6362
|
}
|
|
6296
|
-
expectOutputSwap(txb, inputCoin, routers, partner) {
|
|
6363
|
+
expectOutputSwap(txb, inputCoin, routers, partner, packages) {
|
|
6297
6364
|
return __async(this, null, function* () {
|
|
6298
6365
|
const returnCoins = [];
|
|
6299
6366
|
const receipts = [];
|
|
6300
6367
|
const targetCoins = [];
|
|
6301
6368
|
const dex = new Cetus(this.env, partner);
|
|
6369
|
+
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(this.publishedAtV2(), packages);
|
|
6302
6370
|
for (let i = 0; i < routers.length; i++) {
|
|
6303
6371
|
const router = routers[i];
|
|
6304
6372
|
for (let j = router.path.length - 1; j >= 0; j--) {
|
|
@@ -6321,7 +6389,7 @@ var AggregatorClient10 = class {
|
|
|
6321
6389
|
if (j === 0) {
|
|
6322
6390
|
inputCoin = repayResult;
|
|
6323
6391
|
} else {
|
|
6324
|
-
this.transferOrDestoryCoin(txb, repayResult, path.from);
|
|
6392
|
+
this.transferOrDestoryCoin(txb, repayResult, path.from, aggregatorV2PublishedAt);
|
|
6325
6393
|
}
|
|
6326
6394
|
if (j === router.path.length - 1) {
|
|
6327
6395
|
targetCoins.push(nextRepayCoin);
|
|
@@ -6329,7 +6397,7 @@ var AggregatorClient10 = class {
|
|
|
6329
6397
|
}
|
|
6330
6398
|
}
|
|
6331
6399
|
const inputCoinType = routers[0].path[0].from;
|
|
6332
|
-
this.transferOrDestoryCoin(txb, inputCoin, inputCoinType);
|
|
6400
|
+
this.transferOrDestoryCoin(txb, inputCoin, inputCoinType, aggregatorV2PublishedAt);
|
|
6333
6401
|
if (targetCoins.length > 1) {
|
|
6334
6402
|
const vec = txb.makeMoveVec({ elements: targetCoins.slice(1) });
|
|
6335
6403
|
txb.moveCall({
|
|
@@ -6359,16 +6427,17 @@ var AggregatorClient10 = class {
|
|
|
6359
6427
|
routers,
|
|
6360
6428
|
inputCoin,
|
|
6361
6429
|
slippage,
|
|
6362
|
-
byAmountIn,
|
|
6363
6430
|
txb,
|
|
6364
6431
|
partner,
|
|
6365
6432
|
deepbookv3DeepFee
|
|
6366
6433
|
} = params;
|
|
6367
|
-
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(
|
|
6368
6437
|
(acc, router) => acc.add(router.amountIn),
|
|
6369
6438
|
new import_bn5.default(0)
|
|
6370
6439
|
);
|
|
6371
|
-
const amountOut =
|
|
6440
|
+
const amountOut = routerData.reduce(
|
|
6372
6441
|
(acc, router) => acc.add(router.amountOut),
|
|
6373
6442
|
new import_bn5.default(0)
|
|
6374
6443
|
);
|
|
@@ -6377,25 +6446,29 @@ var AggregatorClient10 = class {
|
|
|
6377
6446
|
byAmountIn,
|
|
6378
6447
|
slippage
|
|
6379
6448
|
);
|
|
6449
|
+
const packages = isBuilderRouterSwapParams(params) ? void 0 : params.routers.packages;
|
|
6450
|
+
console.log("packages11", packages);
|
|
6451
|
+
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(this.publishedAtV2(), packages);
|
|
6380
6452
|
if (byAmountIn) {
|
|
6381
6453
|
const targetCoin2 = yield this.expectInputSwap(
|
|
6382
6454
|
txb,
|
|
6383
6455
|
inputCoin,
|
|
6384
|
-
|
|
6456
|
+
routerData,
|
|
6385
6457
|
amountLimit,
|
|
6386
6458
|
partner,
|
|
6387
|
-
deepbookv3DeepFee
|
|
6459
|
+
deepbookv3DeepFee,
|
|
6460
|
+
packages
|
|
6388
6461
|
);
|
|
6389
6462
|
return targetCoin2;
|
|
6390
6463
|
}
|
|
6391
6464
|
const splitedInputCoins = txb.splitCoins(inputCoin, [
|
|
6392
6465
|
amountLimit.toString()
|
|
6393
6466
|
]);
|
|
6394
|
-
this.transferOrDestoryCoin(txb, inputCoin,
|
|
6467
|
+
this.transferOrDestoryCoin(txb, inputCoin, routerData[0].path[0].from, aggregatorV2PublishedAt);
|
|
6395
6468
|
const targetCoin = yield this.expectOutputSwap(
|
|
6396
6469
|
txb,
|
|
6397
6470
|
splitedInputCoins[0],
|
|
6398
|
-
|
|
6471
|
+
routerData,
|
|
6399
6472
|
partner
|
|
6400
6473
|
);
|
|
6401
6474
|
return targetCoin;
|
|
@@ -6407,25 +6480,25 @@ var AggregatorClient10 = class {
|
|
|
6407
6480
|
return __async(this, null, function* () {
|
|
6408
6481
|
const {
|
|
6409
6482
|
routers,
|
|
6410
|
-
byAmountIn,
|
|
6411
6483
|
slippage,
|
|
6412
6484
|
txb,
|
|
6413
6485
|
partner,
|
|
6414
|
-
isMergeTragetCoin,
|
|
6415
6486
|
refreshAllCoins,
|
|
6416
6487
|
payDeepFeeAmount
|
|
6417
6488
|
} = params;
|
|
6418
|
-
const
|
|
6489
|
+
const routerData = Array.isArray(routers) ? routers : routers.routes;
|
|
6490
|
+
const fromCoinType = routerData[0].path[0].from;
|
|
6419
6491
|
let fromCoins = yield this.getCoins(fromCoinType, refreshAllCoins);
|
|
6420
|
-
const targetCoinType =
|
|
6421
|
-
const amountIn =
|
|
6492
|
+
const targetCoinType = routerData[0].path[routerData[0].path.length - 1].target;
|
|
6493
|
+
const amountIn = routerData.reduce(
|
|
6422
6494
|
(acc, router) => acc.add(router.amountIn),
|
|
6423
6495
|
new import_bn5.default(0)
|
|
6424
6496
|
);
|
|
6425
|
-
const amountOut =
|
|
6497
|
+
const amountOut = routerData.reduce(
|
|
6426
6498
|
(acc, router) => acc.add(router.amountOut),
|
|
6427
6499
|
new import_bn5.default(0)
|
|
6428
6500
|
);
|
|
6501
|
+
const byAmountIn = isBuilderFastRouterSwapParams(params) ? params.byAmountIn : params.routers.byAmountIn;
|
|
6429
6502
|
const amountLimit = CalculateAmountLimit(
|
|
6430
6503
|
byAmountIn ? amountOut : amountIn,
|
|
6431
6504
|
byAmountIn,
|
|
@@ -6448,16 +6521,27 @@ var AggregatorClient10 = class {
|
|
|
6448
6521
|
this.deepbookv3DeepFeeType()
|
|
6449
6522
|
).targetCoin;
|
|
6450
6523
|
}
|
|
6451
|
-
const
|
|
6452
|
-
routers,
|
|
6524
|
+
const routerSwapParams = isBuilderFastRouterSwapParams(params) ? {
|
|
6525
|
+
routers: routerData,
|
|
6453
6526
|
inputCoin: buildFromCoinRes.targetCoin,
|
|
6454
6527
|
slippage,
|
|
6455
6528
|
byAmountIn,
|
|
6456
6529
|
txb,
|
|
6457
6530
|
partner,
|
|
6458
6531
|
deepbookv3DeepFee: deepCoin
|
|
6459
|
-
}
|
|
6460
|
-
|
|
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 {
|
|
6461
6545
|
let targetCoins = yield this.getCoins(targetCoinType, refreshAllCoins);
|
|
6462
6546
|
const targetCoinRes = buildInputCoin(
|
|
6463
6547
|
txb,
|
|
@@ -6465,21 +6549,22 @@ var AggregatorClient10 = class {
|
|
|
6465
6549
|
BigInt(0),
|
|
6466
6550
|
targetCoinType
|
|
6467
6551
|
);
|
|
6552
|
+
const packages = isBuilderFastRouterSwapParams(params) ? void 0 : params.routers.packages;
|
|
6553
|
+
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(this.publishedAtV2(), packages);
|
|
6468
6554
|
txb.mergeCoins(targetCoinRes.targetCoin, [targetCoin]);
|
|
6469
6555
|
if (targetCoinRes.isMintZeroCoin) {
|
|
6470
6556
|
this.transferOrDestoryCoin(
|
|
6471
6557
|
txb,
|
|
6472
6558
|
targetCoinRes.targetCoin,
|
|
6473
|
-
targetCoinType
|
|
6559
|
+
targetCoinType,
|
|
6560
|
+
aggregatorV2PublishedAt
|
|
6474
6561
|
);
|
|
6475
6562
|
}
|
|
6476
|
-
} else {
|
|
6477
|
-
this.transferOrDestoryCoin(txb, targetCoin, targetCoinType);
|
|
6478
6563
|
}
|
|
6479
6564
|
});
|
|
6480
6565
|
}
|
|
6481
6566
|
// Include cetus、deepbookv2、flowxv2 & v3、kriyav2 & v3、turbos、aftermath、haedal、afsui、volo、bluemove
|
|
6482
|
-
|
|
6567
|
+
publishedAtV2() {
|
|
6483
6568
|
if (this.env === 0 /* Mainnet */) {
|
|
6484
6569
|
return "0x3fb42ddf908af45f9fc3c59eab227888ff24ba2e137b3b55bf80920fd47e11af";
|
|
6485
6570
|
} else {
|
|
@@ -6487,9 +6572,9 @@ var AggregatorClient10 = class {
|
|
|
6487
6572
|
}
|
|
6488
6573
|
}
|
|
6489
6574
|
// Include deepbookv3, scallop, bluefin
|
|
6490
|
-
|
|
6575
|
+
publishedAtV2Extend() {
|
|
6491
6576
|
if (this.env === 0 /* Mainnet */) {
|
|
6492
|
-
return "
|
|
6577
|
+
return "0xf2fcea41dc217385019828375764fa06d9bd25e8e4726ba1962680849fb8d613";
|
|
6493
6578
|
} else {
|
|
6494
6579
|
return "0xabb6a81c8a216828e317719e06125de5bb2cb0fe8f9916ff8c023ca5be224c78";
|
|
6495
6580
|
}
|
|
@@ -6501,14 +6586,14 @@ var AggregatorClient10 = class {
|
|
|
6501
6586
|
return "0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP";
|
|
6502
6587
|
}
|
|
6503
6588
|
}
|
|
6504
|
-
transferOrDestoryCoin(txb, coin, coinType) {
|
|
6589
|
+
transferOrDestoryCoin(txb, coin, coinType, aggregatorV2PublishedAt) {
|
|
6505
6590
|
txb.moveCall({
|
|
6506
|
-
target: `${
|
|
6591
|
+
target: `${aggregatorV2PublishedAt}::utils::transfer_or_destroy_coin`,
|
|
6507
6592
|
typeArguments: [coinType],
|
|
6508
6593
|
arguments: [coin]
|
|
6509
6594
|
});
|
|
6510
6595
|
}
|
|
6511
|
-
checkCoinThresholdAndMergeCoin(txb, coins, coinType, amountLimit) {
|
|
6596
|
+
checkCoinThresholdAndMergeCoin(txb, coins, coinType, amountLimit, aggregatorV2PublishedAt) {
|
|
6512
6597
|
let targetCoin = coins[0];
|
|
6513
6598
|
if (coins.length > 1) {
|
|
6514
6599
|
let vec = txb.makeMoveVec({ elements: coins.slice(1) });
|
|
@@ -6520,7 +6605,7 @@ var AggregatorClient10 = class {
|
|
|
6520
6605
|
targetCoin = coins[0];
|
|
6521
6606
|
}
|
|
6522
6607
|
txb.moveCall({
|
|
6523
|
-
target: `${
|
|
6608
|
+
target: `${aggregatorV2PublishedAt}::utils::check_coin_threshold`,
|
|
6524
6609
|
typeArguments: [coinType],
|
|
6525
6610
|
arguments: [targetCoin, txb.pure.u64(amountLimit.toString())]
|
|
6526
6611
|
});
|
|
@@ -6562,6 +6647,8 @@ var AggregatorClient10 = class {
|
|
|
6562
6647
|
return new Bluefin(this.env);
|
|
6563
6648
|
case HAEDALPMM:
|
|
6564
6649
|
return new HaedalPmm(this.env, this.client);
|
|
6650
|
+
case ALPHAFI:
|
|
6651
|
+
return new Alphafi(this.env);
|
|
6565
6652
|
default:
|
|
6566
6653
|
throw new Error(`Unsupported dex ${provider}`);
|
|
6567
6654
|
}
|
|
@@ -6609,7 +6696,7 @@ var AggregatorClient10 = class {
|
|
|
6609
6696
|
});
|
|
6610
6697
|
}
|
|
6611
6698
|
};
|
|
6612
|
-
function parseRouterResponse(data) {
|
|
6699
|
+
function parseRouterResponse(data, byAmountIn) {
|
|
6613
6700
|
let totalDeepFee = 0;
|
|
6614
6701
|
for (const route of data.routes) {
|
|
6615
6702
|
for (const path of route.path) {
|
|
@@ -6618,9 +6705,17 @@ function parseRouterResponse(data) {
|
|
|
6618
6705
|
}
|
|
6619
6706
|
}
|
|
6620
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
|
+
}
|
|
6621
6715
|
let routerData = {
|
|
6622
6716
|
amountIn: new import_bn5.default(data.amount_in.toString()),
|
|
6623
6717
|
amountOut: new import_bn5.default(data.amount_out.toString()),
|
|
6718
|
+
byAmountIn,
|
|
6624
6719
|
insufficientLiquidity: false,
|
|
6625
6720
|
routes: data.routes.map((route) => {
|
|
6626
6721
|
return {
|
|
@@ -6660,13 +6755,30 @@ function parseRouterResponse(data) {
|
|
|
6660
6755
|
initialPrice: new decimal_default(route.initial_price.toString())
|
|
6661
6756
|
};
|
|
6662
6757
|
}),
|
|
6663
|
-
totalDeepFee
|
|
6758
|
+
totalDeepFee,
|
|
6759
|
+
packages
|
|
6664
6760
|
};
|
|
6665
6761
|
return routerData;
|
|
6666
6762
|
}
|
|
6667
6763
|
|
|
6668
6764
|
// src/transaction/index.ts
|
|
6669
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
|
+
}
|
|
6670
6782
|
|
|
6671
6783
|
// src/utils/msafe.ts
|
|
6672
6784
|
var import_bn6 = __toESM(require_bn());
|
|
@@ -6718,6 +6830,7 @@ function getRouterResult(endpoint, params) {
|
|
|
6718
6830
|
amountIn: ZERO,
|
|
6719
6831
|
amountOut: ZERO,
|
|
6720
6832
|
routes: [],
|
|
6833
|
+
byAmountIn: params.byAmountIn,
|
|
6721
6834
|
insufficientLiquidity: false,
|
|
6722
6835
|
error: {
|
|
6723
6836
|
code: 10001 /* NumberTooLarge */,
|
|
@@ -6734,6 +6847,7 @@ function getRouterResult(endpoint, params) {
|
|
|
6734
6847
|
amountIn: ZERO,
|
|
6735
6848
|
amountOut: ZERO,
|
|
6736
6849
|
routes: [],
|
|
6850
|
+
byAmountIn: params.byAmountIn,
|
|
6737
6851
|
insufficientLiquidity,
|
|
6738
6852
|
error: {
|
|
6739
6853
|
code: 10004 /* HoneyPot */,
|
|
@@ -6744,7 +6858,7 @@ function getRouterResult(endpoint, params) {
|
|
|
6744
6858
|
};
|
|
6745
6859
|
}
|
|
6746
6860
|
if (data.data != null) {
|
|
6747
|
-
const res = parseRouterResponse(data.data);
|
|
6861
|
+
const res = parseRouterResponse(data.data, params.byAmountIn);
|
|
6748
6862
|
return res;
|
|
6749
6863
|
}
|
|
6750
6864
|
return {
|
|
@@ -6752,6 +6866,7 @@ function getRouterResult(endpoint, params) {
|
|
|
6752
6866
|
amountOut: ZERO,
|
|
6753
6867
|
routes: [],
|
|
6754
6868
|
insufficientLiquidity,
|
|
6869
|
+
byAmountIn: params.byAmountIn,
|
|
6755
6870
|
error: {
|
|
6756
6871
|
code: 10003 /* InsufficientLiquidity */,
|
|
6757
6872
|
msg: getAggregatorServerErrorMessage(
|
|
@@ -6795,7 +6910,7 @@ function getRouter(endpoint, params) {
|
|
|
6795
6910
|
url += `&providers=${providers.join(",")}`;
|
|
6796
6911
|
}
|
|
6797
6912
|
}
|
|
6798
|
-
url += "&v=
|
|
6913
|
+
url += "&v=1000318";
|
|
6799
6914
|
const response = yield fetch(url);
|
|
6800
6915
|
return response;
|
|
6801
6916
|
} catch (error) {
|
|
@@ -6887,7 +7002,10 @@ decimal.js/decimal.mjs:
|
|
|
6887
7002
|
|
|
6888
7003
|
exports.AFSUI = AFSUI;
|
|
6889
7004
|
exports.AFTERMATH = AFTERMATH;
|
|
6890
|
-
exports.
|
|
7005
|
+
exports.AGGREGATOR_V2 = AGGREGATOR_V2;
|
|
7006
|
+
exports.AGGREGATOR_V2_EXTEND = AGGREGATOR_V2_EXTEND;
|
|
7007
|
+
exports.ALPHAFI = ALPHAFI;
|
|
7008
|
+
exports.AggregatorClient = AggregatorClient19;
|
|
6891
7009
|
exports.BLUEFIN = BLUEFIN;
|
|
6892
7010
|
exports.BLUEMOVE = BLUEMOVE;
|
|
6893
7011
|
exports.CETUS = CETUS;
|
|
@@ -6923,6 +7041,8 @@ exports.dealWithFastRouterSwapParamsForMsafe = dealWithFastRouterSwapParamsForMs
|
|
|
6923
7041
|
exports.extractAddressFromType = extractAddressFromType;
|
|
6924
7042
|
exports.extractStructTagFromType = extractStructTagFromType;
|
|
6925
7043
|
exports.fixSuiObjectId = fixSuiObjectId;
|
|
7044
|
+
exports.getAggregatorV2ExtendPublishedAt = getAggregatorV2ExtendPublishedAt;
|
|
7045
|
+
exports.getAggregatorV2PublishedAt = getAggregatorV2PublishedAt;
|
|
6926
7046
|
exports.getDeepbookV3Config = getDeepbookV3Config;
|
|
6927
7047
|
exports.getRouterResult = getRouterResult;
|
|
6928
7048
|
exports.isSortedSymbols = isSortedSymbols;
|