@cetusprotocol/aggregator-sdk 0.12.0 → 0.12.1

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.js CHANGED
@@ -5274,15 +5274,14 @@ var Cetus = class {
5274
5274
  this.globalConfig = env === 0 /* Mainnet */ ? "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f" : "0x9774e359588ead122af1c7e7f64e14ade261cfeecdb5d0eb4a5b3b4c8ab8bd3e";
5275
5275
  this.partner = partner != null ? partner : env === 0 /* Mainnet */ ? "0x639b5e433da31739e800cd085f356e64cae222966d0f1b11bd9dc76b322ff58b" : "0x1f5fa5c820f40d43fc47815ad06d95e40a1942ff72a732a92e8ef4aa8cde70a5";
5276
5276
  }
5277
- flash_swap(client, txb, path, by_amount_in, packages) {
5277
+ flash_swap(client, txb, path, amount_arg, by_amount_in, packages) {
5278
5278
  const { direction, from, target } = path;
5279
5279
  const [func, coinAType, coinBType] = direction ? ["flash_swap_a2b", from, target] : ["flash_swap_b2a", target, from];
5280
- let amount = by_amount_in ? path.amountIn : path.amountOut;
5281
5280
  const args = [
5282
5281
  txb.object(this.globalConfig),
5283
5282
  txb.object(path.id),
5284
5283
  txb.object(this.partner),
5285
- txb.pure.u64(amount),
5284
+ amount_arg,
5286
5285
  txb.pure.bool(by_amount_in),
5287
5286
  txb.object(CLOCK_ADDRESS)
5288
5287
  ];
@@ -7039,9 +7038,11 @@ var _AggregatorClient = class _AggregatorClient {
7039
7038
  );
7040
7039
  for (let i = 0; i < routers.length; i++) {
7041
7040
  const router = routers[i];
7041
+ let amount_arg = txb.pure.u64(router.amountOut.toString());
7042
7042
  for (let j = router.path.length - 1; j >= 0; j--) {
7043
7043
  const path = router.path[j];
7044
- const flashSwapResult = dex.flash_swap(this, txb, path, false);
7044
+ const flashSwapResult = dex.flash_swap(this, txb, path, amount_arg, false);
7045
+ amount_arg = flashSwapResult.payAmount;
7045
7046
  returnCoins.unshift(flashSwapResult.targetCoin);
7046
7047
  receipts.unshift(flashSwapResult.flashReceipt);
7047
7048
  }
@@ -7279,6 +7280,7 @@ var _AggregatorClient = class _AggregatorClient {
7279
7280
  byAmountIn,
7280
7281
  slippage
7281
7282
  );
7283
+ console.log("amountLimit", amountLimit.toString());
7282
7284
  const amount = byAmountIn ? expectedAmountIn : amountLimit;
7283
7285
  const buildFromCoinRes = buildInputCoin(
7284
7286
  txb,
@@ -7760,7 +7762,7 @@ function processEndpoint(endpoint) {
7760
7762
 
7761
7763
  // src/api.ts
7762
7764
  var import_bn7 = __toESM(require_bn());
7763
- var SDK_VERSION = 1001200;
7765
+ var SDK_VERSION = 1001201;
7764
7766
  function getRouterResult(endpoint, apiKey, params, overlayFee, overlayFeeReceiver) {
7765
7767
  return __async(this, null, function* () {
7766
7768
  let response;
package/dist/index.mjs CHANGED
@@ -5272,15 +5272,14 @@ var Cetus = class {
5272
5272
  this.globalConfig = env === 0 /* Mainnet */ ? "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f" : "0x9774e359588ead122af1c7e7f64e14ade261cfeecdb5d0eb4a5b3b4c8ab8bd3e";
5273
5273
  this.partner = partner != null ? partner : env === 0 /* Mainnet */ ? "0x639b5e433da31739e800cd085f356e64cae222966d0f1b11bd9dc76b322ff58b" : "0x1f5fa5c820f40d43fc47815ad06d95e40a1942ff72a732a92e8ef4aa8cde70a5";
5274
5274
  }
5275
- flash_swap(client, txb, path, by_amount_in, packages) {
5275
+ flash_swap(client, txb, path, amount_arg, by_amount_in, packages) {
5276
5276
  const { direction, from, target } = path;
5277
5277
  const [func, coinAType, coinBType] = direction ? ["flash_swap_a2b", from, target] : ["flash_swap_b2a", target, from];
5278
- let amount = by_amount_in ? path.amountIn : path.amountOut;
5279
5278
  const args = [
5280
5279
  txb.object(this.globalConfig),
5281
5280
  txb.object(path.id),
5282
5281
  txb.object(this.partner),
5283
- txb.pure.u64(amount),
5282
+ amount_arg,
5284
5283
  txb.pure.bool(by_amount_in),
5285
5284
  txb.object(CLOCK_ADDRESS)
5286
5285
  ];
@@ -7037,9 +7036,11 @@ var _AggregatorClient = class _AggregatorClient {
7037
7036
  );
7038
7037
  for (let i = 0; i < routers.length; i++) {
7039
7038
  const router = routers[i];
7039
+ let amount_arg = txb.pure.u64(router.amountOut.toString());
7040
7040
  for (let j = router.path.length - 1; j >= 0; j--) {
7041
7041
  const path = router.path[j];
7042
- const flashSwapResult = dex.flash_swap(this, txb, path, false);
7042
+ const flashSwapResult = dex.flash_swap(this, txb, path, amount_arg, false);
7043
+ amount_arg = flashSwapResult.payAmount;
7043
7044
  returnCoins.unshift(flashSwapResult.targetCoin);
7044
7045
  receipts.unshift(flashSwapResult.flashReceipt);
7045
7046
  }
@@ -7277,6 +7278,7 @@ var _AggregatorClient = class _AggregatorClient {
7277
7278
  byAmountIn,
7278
7279
  slippage
7279
7280
  );
7281
+ console.log("amountLimit", amountLimit.toString());
7280
7282
  const amount = byAmountIn ? expectedAmountIn : amountLimit;
7281
7283
  const buildFromCoinRes = buildInputCoin(
7282
7284
  txb,
@@ -7758,7 +7760,7 @@ function processEndpoint(endpoint) {
7758
7760
 
7759
7761
  // src/api.ts
7760
7762
  var import_bn7 = __toESM(require_bn());
7761
- var SDK_VERSION = 1001200;
7763
+ var SDK_VERSION = 1001201;
7762
7764
  function getRouterResult(endpoint, apiKey, params, overlayFee, overlayFeeReceiver) {
7763
7765
  return __async(this, null, function* () {
7764
7766
  let response;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cetusprotocol/aggregator-sdk",
3
- "version": "0.12.0",
3
+ "version": "0.12.1",
4
4
  "sideEffects": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",