@cetusprotocol/aggregator-sdk 0.0.0-experimental-20240819211521 → 0.0.0-experimental-20240822182903

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 CHANGED
@@ -67,6 +67,9 @@ declare const FLOWXV2 = "FLOWX";
67
67
  declare const KRIYAV3 = "KRIYAV3";
68
68
  declare const TURBOS = "TURBOS";
69
69
  declare const AFTERMATH = "AFTERMATH";
70
+ declare const HAEDAL = "HAEDAL";
71
+ declare const VOLO = "VOLO";
72
+ declare const AFSUI = "AFSUI";
70
73
  type BuildRouterSwapParams = {
71
74
  routers: Router[];
72
75
  byAmountIn: boolean;
@@ -264,4 +267,4 @@ declare enum Env {
264
267
  Testnet = 1
265
268
  }
266
269
 
267
- export { AFTERMATH, AFTERMATH_MODULE, AggregatorClient, type AggregatorResponse, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CETUS_MODULE, CETUS_PUBLISHED_AT, CHECK_COINS_THRESHOLD_FUNC, CLOCK_ADDRESS, CoinInfoAddress, CoinStoreAddress, DEEPBOOKV2, DEEPBOOK_CLOB_V2_MODULE, DEEPBOOK_CUSTODIAN_V2_MODULE, DEEPBOOK_MODULE, DEEPBOOK_PACKAGE_ID, DEEPBOOK_PUBLISHED_AT, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWX_AMM_MODULE, type FindRouterParams, FlashSwapA2BFunc, FlashSwapB2AFunc, FlashSwapFunc, FlashSwapWithPartnerA2BFunc, FlashSwapWithPartnerB2AFunc, FlashSwapWithPartnerFunc, JOIN_FUNC, KRIYA, KRIYAV3, KRIYA_MODULE, MAINNET_AFTERMATH_INSURANCE_FUND_ID, MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, MAINNET_AFTERMATH_REFERRAL_VAULT_ID, MAINNET_AFTERMATH_REGISTRY_ID, MAINNET_AFTERMATH_TREASURY_ID, MAINNET_CETUS_GLOBAL_CONFIG_ID, MAINNET_FLOWX_AMM_CONTAINER_ID, ONE, PAY_MODULE, POOL_MODULT, type Path, REPAY_FLASH_SWAP_A2B_FUNC, REPAY_FLASH_SWAP_B2A_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC, RepayFalshSwapFunc, RepayFlashSwapWithPartnerFunc, type Router, type RouterData, type RouterError, SWAP_A2B_FUNC, SWAP_B2A_FUNC, SuiZeroCoinFn, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, TESTNET_AFTERMATH_INSURANCE_FUND_ID, TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, TESTNET_AFTERMATH_REFERRAL_VAULT_ID, TESTNET_AFTERMATH_REGISTRY_ID, TESTNET_AFTERMATH_TREASURY_ID, TESTNET_CETUS_GLOBAL_CONFIG_ID, TESTNET_FLOWX_AMM_CONTAINER_ID, TRANSFER_ACCOUNT_CAP, TRANSFER_OR_DESTORY_COIN_FUNC, TURBOS, TURBOS_MODULE, TURBOS_VERSIONED, TWO, U128, U64_MAX, U64_MAX_BN, UTILS_MODULE, ZERO, composeType, createTarget, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId };
270
+ export { AFSUI, AFTERMATH, AFTERMATH_MODULE, AggregatorClient, type AggregatorResponse, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CETUS_MODULE, CETUS_PUBLISHED_AT, CHECK_COINS_THRESHOLD_FUNC, CLOCK_ADDRESS, CoinInfoAddress, CoinStoreAddress, DEEPBOOKV2, DEEPBOOK_CLOB_V2_MODULE, DEEPBOOK_CUSTODIAN_V2_MODULE, DEEPBOOK_MODULE, DEEPBOOK_PACKAGE_ID, DEEPBOOK_PUBLISHED_AT, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWX_AMM_MODULE, type FindRouterParams, FlashSwapA2BFunc, FlashSwapB2AFunc, FlashSwapFunc, FlashSwapWithPartnerA2BFunc, FlashSwapWithPartnerB2AFunc, FlashSwapWithPartnerFunc, HAEDAL, JOIN_FUNC, KRIYA, KRIYAV3, KRIYA_MODULE, MAINNET_AFTERMATH_INSURANCE_FUND_ID, MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, MAINNET_AFTERMATH_REFERRAL_VAULT_ID, MAINNET_AFTERMATH_REGISTRY_ID, MAINNET_AFTERMATH_TREASURY_ID, MAINNET_CETUS_GLOBAL_CONFIG_ID, MAINNET_FLOWX_AMM_CONTAINER_ID, ONE, PAY_MODULE, POOL_MODULT, type Path, REPAY_FLASH_SWAP_A2B_FUNC, REPAY_FLASH_SWAP_B2A_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC, RepayFalshSwapFunc, RepayFlashSwapWithPartnerFunc, type Router, type RouterData, type RouterError, SWAP_A2B_FUNC, SWAP_B2A_FUNC, SuiZeroCoinFn, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, TESTNET_AFTERMATH_INSURANCE_FUND_ID, TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, TESTNET_AFTERMATH_REFERRAL_VAULT_ID, TESTNET_AFTERMATH_REGISTRY_ID, TESTNET_AFTERMATH_TREASURY_ID, TESTNET_CETUS_GLOBAL_CONFIG_ID, TESTNET_FLOWX_AMM_CONTAINER_ID, TRANSFER_ACCOUNT_CAP, TRANSFER_OR_DESTORY_COIN_FUNC, TURBOS, TURBOS_MODULE, TURBOS_VERSIONED, TWO, U128, U64_MAX, U64_MAX_BN, UTILS_MODULE, VOLO, ZERO, composeType, createTarget, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId };
package/dist/index.d.ts CHANGED
@@ -67,6 +67,9 @@ declare const FLOWXV2 = "FLOWX";
67
67
  declare const KRIYAV3 = "KRIYAV3";
68
68
  declare const TURBOS = "TURBOS";
69
69
  declare const AFTERMATH = "AFTERMATH";
70
+ declare const HAEDAL = "HAEDAL";
71
+ declare const VOLO = "VOLO";
72
+ declare const AFSUI = "AFSUI";
70
73
  type BuildRouterSwapParams = {
71
74
  routers: Router[];
72
75
  byAmountIn: boolean;
@@ -264,4 +267,4 @@ declare enum Env {
264
267
  Testnet = 1
265
268
  }
266
269
 
267
- export { AFTERMATH, AFTERMATH_MODULE, AggregatorClient, type AggregatorResponse, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CETUS_MODULE, CETUS_PUBLISHED_AT, CHECK_COINS_THRESHOLD_FUNC, CLOCK_ADDRESS, CoinInfoAddress, CoinStoreAddress, DEEPBOOKV2, DEEPBOOK_CLOB_V2_MODULE, DEEPBOOK_CUSTODIAN_V2_MODULE, DEEPBOOK_MODULE, DEEPBOOK_PACKAGE_ID, DEEPBOOK_PUBLISHED_AT, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWX_AMM_MODULE, type FindRouterParams, FlashSwapA2BFunc, FlashSwapB2AFunc, FlashSwapFunc, FlashSwapWithPartnerA2BFunc, FlashSwapWithPartnerB2AFunc, FlashSwapWithPartnerFunc, JOIN_FUNC, KRIYA, KRIYAV3, KRIYA_MODULE, MAINNET_AFTERMATH_INSURANCE_FUND_ID, MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, MAINNET_AFTERMATH_REFERRAL_VAULT_ID, MAINNET_AFTERMATH_REGISTRY_ID, MAINNET_AFTERMATH_TREASURY_ID, MAINNET_CETUS_GLOBAL_CONFIG_ID, MAINNET_FLOWX_AMM_CONTAINER_ID, ONE, PAY_MODULE, POOL_MODULT, type Path, REPAY_FLASH_SWAP_A2B_FUNC, REPAY_FLASH_SWAP_B2A_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC, RepayFalshSwapFunc, RepayFlashSwapWithPartnerFunc, type Router, type RouterData, type RouterError, SWAP_A2B_FUNC, SWAP_B2A_FUNC, SuiZeroCoinFn, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, TESTNET_AFTERMATH_INSURANCE_FUND_ID, TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, TESTNET_AFTERMATH_REFERRAL_VAULT_ID, TESTNET_AFTERMATH_REGISTRY_ID, TESTNET_AFTERMATH_TREASURY_ID, TESTNET_CETUS_GLOBAL_CONFIG_ID, TESTNET_FLOWX_AMM_CONTAINER_ID, TRANSFER_ACCOUNT_CAP, TRANSFER_OR_DESTORY_COIN_FUNC, TURBOS, TURBOS_MODULE, TURBOS_VERSIONED, TWO, U128, U64_MAX, U64_MAX_BN, UTILS_MODULE, ZERO, composeType, createTarget, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId };
270
+ export { AFSUI, AFTERMATH, AFTERMATH_MODULE, AggregatorClient, type AggregatorResponse, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CETUS_MODULE, CETUS_PUBLISHED_AT, CHECK_COINS_THRESHOLD_FUNC, CLOCK_ADDRESS, CoinInfoAddress, CoinStoreAddress, DEEPBOOKV2, DEEPBOOK_CLOB_V2_MODULE, DEEPBOOK_CUSTODIAN_V2_MODULE, DEEPBOOK_MODULE, DEEPBOOK_PACKAGE_ID, DEEPBOOK_PUBLISHED_AT, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWX_AMM_MODULE, type FindRouterParams, FlashSwapA2BFunc, FlashSwapB2AFunc, FlashSwapFunc, FlashSwapWithPartnerA2BFunc, FlashSwapWithPartnerB2AFunc, FlashSwapWithPartnerFunc, HAEDAL, JOIN_FUNC, KRIYA, KRIYAV3, KRIYA_MODULE, MAINNET_AFTERMATH_INSURANCE_FUND_ID, MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, MAINNET_AFTERMATH_REFERRAL_VAULT_ID, MAINNET_AFTERMATH_REGISTRY_ID, MAINNET_AFTERMATH_TREASURY_ID, MAINNET_CETUS_GLOBAL_CONFIG_ID, MAINNET_FLOWX_AMM_CONTAINER_ID, ONE, PAY_MODULE, POOL_MODULT, type Path, REPAY_FLASH_SWAP_A2B_FUNC, REPAY_FLASH_SWAP_B2A_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC, RepayFalshSwapFunc, RepayFlashSwapWithPartnerFunc, type Router, type RouterData, type RouterError, SWAP_A2B_FUNC, SWAP_B2A_FUNC, SuiZeroCoinFn, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, TESTNET_AFTERMATH_INSURANCE_FUND_ID, TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, TESTNET_AFTERMATH_REFERRAL_VAULT_ID, TESTNET_AFTERMATH_REGISTRY_ID, TESTNET_AFTERMATH_TREASURY_ID, TESTNET_CETUS_GLOBAL_CONFIG_ID, TESTNET_FLOWX_AMM_CONTAINER_ID, TRANSFER_ACCOUNT_CAP, TRANSFER_OR_DESTORY_COIN_FUNC, TURBOS, TURBOS_MODULE, TURBOS_VERSIONED, TWO, U128, U64_MAX, U64_MAX_BN, UTILS_MODULE, VOLO, ZERO, composeType, createTarget, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId };
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  var utils = require('@mysten/sui/utils');
4
4
  var transactions = require('@mysten/sui/transactions');
5
+ var utils$1 = require('@mysten/sui/dist/cjs/utils');
5
6
 
6
7
  var __create = Object.create;
7
8
  var __defProp = Object.defineProperty;
@@ -5814,6 +5815,7 @@ function swapInPools(client, params, sender) {
5814
5815
  }
5815
5816
  }
5816
5817
  const event = valueData[tempIndex].parsedJson.data;
5818
+ console.log("event", JSON.stringify(event, null, 2));
5817
5819
  const currentSqrtPrice = event.step_results[0].current_sqrt_price;
5818
5820
  const [decimalA, decimalB] = yield Promise.all([
5819
5821
  client.getCoinMetadata({ coinType: coinA }).then((metadata) => metadata == null ? void 0 : metadata.decimals),
@@ -5842,9 +5844,9 @@ function swapInPools(client, params, sender) {
5842
5844
  provider: "CETUS",
5843
5845
  from: fromCoin,
5844
5846
  target: targetCoin,
5845
- feeRate: 0,
5846
- amountIn: 0,
5847
- amountOut: 0
5847
+ feeRate: event.fee_rate,
5848
+ amountIn: event.amount_in,
5849
+ amountOut: event.amount_out
5848
5850
  }
5849
5851
  ],
5850
5852
  amountIn: new import_bn4.BN((_d = event.amount_in) != null ? _d : 0),
@@ -5889,6 +5891,99 @@ var KriyaV3 = class {
5889
5891
  });
5890
5892
  }
5891
5893
  };
5894
+ var Haedal = class {
5895
+ constructor(env) {
5896
+ if (env !== 0 /* Mainnet */) {
5897
+ throw new Error("Haedal only supported on mainnet");
5898
+ }
5899
+ this.stake = "0x47b224762220393057ebf4f70501b6e657c3e56684737568439a04f80849b2ca";
5900
+ }
5901
+ swap(client, txb, path, inputCoin) {
5902
+ return __async(this, null, function* () {
5903
+ const { direction, from, target } = path;
5904
+ if (!direction) {
5905
+ throw new Error("Haedal not support b2a swap");
5906
+ }
5907
+ const [func, coinAType, coinBType] = ["swap_a2b", from, target];
5908
+ const args = [
5909
+ txb.pure.address(utils$1.SUI_SYSTEM_ADDRESS),
5910
+ txb.object(this.stake),
5911
+ inputCoin,
5912
+ txb.pure.address("0x0")
5913
+ ];
5914
+ const res = txb.moveCall({
5915
+ target: `${client.publishedAt()}::haedal::${func}`,
5916
+ typeArguments: [coinAType, coinBType],
5917
+ arguments: args
5918
+ });
5919
+ return res;
5920
+ });
5921
+ }
5922
+ };
5923
+ var Afsui = class {
5924
+ constructor(env) {
5925
+ if (env !== 0 /* Mainnet */) {
5926
+ throw new Error("Afsui only supported on mainnet");
5927
+ }
5928
+ this.stakedSuiVault = "0x2f8f6d5da7f13ea37daa397724280483ed062769813b6f31e9788e59cc88994d";
5929
+ this.safe = "0xeb685899830dd5837b47007809c76d91a098d52aabbf61e8ac467c59e5cc4610";
5930
+ this.referVault = "0x4ce9a19b594599536c53edb25d22532f82f18038dc8ef618afd00fbbfb9845ef";
5931
+ this.validator = "0xd30018ec3f5ff1a3c75656abf927a87d7f0529e6dc89c7ddd1bd27ecb05e3db2";
5932
+ }
5933
+ swap(client, txb, path, inputCoin) {
5934
+ return __async(this, null, function* () {
5935
+ const { direction, from, target } = path;
5936
+ if (!direction) {
5937
+ throw new Error("Afsui not support b2a swap");
5938
+ }
5939
+ const [func, coinAType, coinBType] = ["swap_a2b", from, target];
5940
+ const args = [
5941
+ txb.object(this.stakedSuiVault),
5942
+ txb.object(this.safe),
5943
+ txb.pure.address(utils$1.SUI_SYSTEM_ADDRESS),
5944
+ txb.object(this.referVault),
5945
+ inputCoin,
5946
+ txb.object(this.validator)
5947
+ ];
5948
+ const res = txb.moveCall({
5949
+ target: `${client.publishedAt()}::afsui::${func}`,
5950
+ typeArguments: [coinAType, coinBType],
5951
+ arguments: args
5952
+ });
5953
+ return res;
5954
+ });
5955
+ }
5956
+ };
5957
+ var Volo = class {
5958
+ constructor(env) {
5959
+ if (env !== 0 /* Mainnet */) {
5960
+ throw new Error("Volo only supported on mainnet");
5961
+ }
5962
+ this.nativePool = "0x7fa2faa111b8c65bea48a23049bfd81ca8f971a262d981dcd9a17c3825cb5baf";
5963
+ this.metadata = "0x680cd26af32b2bde8d3361e804c53ec1d1cfe24c7f039eb7f549e8dfde389a60";
5964
+ }
5965
+ swap(client, txb, path, inputCoin) {
5966
+ return __async(this, null, function* () {
5967
+ const { direction, from, target } = path;
5968
+ if (!direction) {
5969
+ throw new Error("Volo not support b2a swap");
5970
+ }
5971
+ const [func, coinAType, coinBType] = ["swap_a2b", from, target];
5972
+ const args = [
5973
+ txb.object(this.nativePool),
5974
+ txb.object(this.metadata),
5975
+ txb.pure.address(utils$1.SUI_SYSTEM_ADDRESS),
5976
+ inputCoin
5977
+ ];
5978
+ const res = txb.moveCall({
5979
+ target: `${client.publishedAt()}::volo::${func}`,
5980
+ typeArguments: [coinAType, coinBType],
5981
+ arguments: args
5982
+ });
5983
+ return res;
5984
+ });
5985
+ }
5986
+ };
5892
5987
 
5893
5988
  // src/client.ts
5894
5989
  var CETUS = "CETUS";
@@ -5898,6 +5993,9 @@ var FLOWXV2 = "FLOWX";
5898
5993
  var KRIYAV3 = "KRIYAV3";
5899
5994
  var TURBOS = "TURBOS";
5900
5995
  var AFTERMATH = "AFTERMATH";
5996
+ var HAEDAL = "HAEDAL";
5997
+ var VOLO = "VOLO";
5998
+ var AFSUI = "AFSUI";
5901
5999
  var AggregatorClient5 = class {
5902
6000
  constructor(endpoint, signer, client, env) {
5903
6001
  this.endpoint = endpoint;
@@ -6181,6 +6279,12 @@ var AggregatorClient5 = class {
6181
6279
  return new Turbos(this.env);
6182
6280
  case AFTERMATH:
6183
6281
  return new Aftermath(this.env);
6282
+ case HAEDAL:
6283
+ return new Haedal(this.env);
6284
+ case AFSUI:
6285
+ return new Afsui(this.env);
6286
+ case VOLO:
6287
+ return new Volo(this.env);
6184
6288
  default:
6185
6289
  throw new Error(`Unsupported dex ${provider}`);
6186
6290
  }
@@ -6351,6 +6455,7 @@ decimal.js/decimal.mjs:
6351
6455
  *)
6352
6456
  */
6353
6457
 
6458
+ exports.AFSUI = AFSUI;
6354
6459
  exports.AFTERMATH = AFTERMATH;
6355
6460
  exports.AFTERMATH_MODULE = AFTERMATH_MODULE;
6356
6461
  exports.AggregatorClient = AggregatorClient5;
@@ -6376,6 +6481,7 @@ exports.FlashSwapFunc = FlashSwapFunc;
6376
6481
  exports.FlashSwapWithPartnerA2BFunc = FlashSwapWithPartnerA2BFunc;
6377
6482
  exports.FlashSwapWithPartnerB2AFunc = FlashSwapWithPartnerB2AFunc;
6378
6483
  exports.FlashSwapWithPartnerFunc = FlashSwapWithPartnerFunc;
6484
+ exports.HAEDAL = HAEDAL;
6379
6485
  exports.JOIN_FUNC = JOIN_FUNC;
6380
6486
  exports.KRIYA = KRIYA;
6381
6487
  exports.KRIYAV3 = KRIYAV3;
@@ -6417,6 +6523,7 @@ exports.U128 = U128;
6417
6523
  exports.U64_MAX = U64_MAX;
6418
6524
  exports.U64_MAX_BN = U64_MAX_BN;
6419
6525
  exports.UTILS_MODULE = UTILS_MODULE;
6526
+ exports.VOLO = VOLO;
6420
6527
  exports.ZERO = ZERO;
6421
6528
  exports.composeType = composeType;
6422
6529
  exports.createTarget = createTarget;
package/dist/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { normalizeSuiObjectId, SUI_FRAMEWORK_ADDRESS } from '@mysten/sui/utils';
2
2
  import { Transaction } from '@mysten/sui/transactions';
3
+ import { SUI_SYSTEM_ADDRESS } from '@mysten/sui/dist/cjs/utils';
3
4
 
4
5
  var __create = Object.create;
5
6
  var __defProp = Object.defineProperty;
@@ -5812,6 +5813,7 @@ function swapInPools(client, params, sender) {
5812
5813
  }
5813
5814
  }
5814
5815
  const event = valueData[tempIndex].parsedJson.data;
5816
+ console.log("event", JSON.stringify(event, null, 2));
5815
5817
  const currentSqrtPrice = event.step_results[0].current_sqrt_price;
5816
5818
  const [decimalA, decimalB] = yield Promise.all([
5817
5819
  client.getCoinMetadata({ coinType: coinA }).then((metadata) => metadata == null ? void 0 : metadata.decimals),
@@ -5840,9 +5842,9 @@ function swapInPools(client, params, sender) {
5840
5842
  provider: "CETUS",
5841
5843
  from: fromCoin,
5842
5844
  target: targetCoin,
5843
- feeRate: 0,
5844
- amountIn: 0,
5845
- amountOut: 0
5845
+ feeRate: event.fee_rate,
5846
+ amountIn: event.amount_in,
5847
+ amountOut: event.amount_out
5846
5848
  }
5847
5849
  ],
5848
5850
  amountIn: new import_bn4.BN((_d = event.amount_in) != null ? _d : 0),
@@ -5887,6 +5889,99 @@ var KriyaV3 = class {
5887
5889
  });
5888
5890
  }
5889
5891
  };
5892
+ var Haedal = class {
5893
+ constructor(env) {
5894
+ if (env !== 0 /* Mainnet */) {
5895
+ throw new Error("Haedal only supported on mainnet");
5896
+ }
5897
+ this.stake = "0x47b224762220393057ebf4f70501b6e657c3e56684737568439a04f80849b2ca";
5898
+ }
5899
+ swap(client, txb, path, inputCoin) {
5900
+ return __async(this, null, function* () {
5901
+ const { direction, from, target } = path;
5902
+ if (!direction) {
5903
+ throw new Error("Haedal not support b2a swap");
5904
+ }
5905
+ const [func, coinAType, coinBType] = ["swap_a2b", from, target];
5906
+ const args = [
5907
+ txb.pure.address(SUI_SYSTEM_ADDRESS),
5908
+ txb.object(this.stake),
5909
+ inputCoin,
5910
+ txb.pure.address("0x0")
5911
+ ];
5912
+ const res = txb.moveCall({
5913
+ target: `${client.publishedAt()}::haedal::${func}`,
5914
+ typeArguments: [coinAType, coinBType],
5915
+ arguments: args
5916
+ });
5917
+ return res;
5918
+ });
5919
+ }
5920
+ };
5921
+ var Afsui = class {
5922
+ constructor(env) {
5923
+ if (env !== 0 /* Mainnet */) {
5924
+ throw new Error("Afsui only supported on mainnet");
5925
+ }
5926
+ this.stakedSuiVault = "0x2f8f6d5da7f13ea37daa397724280483ed062769813b6f31e9788e59cc88994d";
5927
+ this.safe = "0xeb685899830dd5837b47007809c76d91a098d52aabbf61e8ac467c59e5cc4610";
5928
+ this.referVault = "0x4ce9a19b594599536c53edb25d22532f82f18038dc8ef618afd00fbbfb9845ef";
5929
+ this.validator = "0xd30018ec3f5ff1a3c75656abf927a87d7f0529e6dc89c7ddd1bd27ecb05e3db2";
5930
+ }
5931
+ swap(client, txb, path, inputCoin) {
5932
+ return __async(this, null, function* () {
5933
+ const { direction, from, target } = path;
5934
+ if (!direction) {
5935
+ throw new Error("Afsui not support b2a swap");
5936
+ }
5937
+ const [func, coinAType, coinBType] = ["swap_a2b", from, target];
5938
+ const args = [
5939
+ txb.object(this.stakedSuiVault),
5940
+ txb.object(this.safe),
5941
+ txb.pure.address(SUI_SYSTEM_ADDRESS),
5942
+ txb.object(this.referVault),
5943
+ inputCoin,
5944
+ txb.object(this.validator)
5945
+ ];
5946
+ const res = txb.moveCall({
5947
+ target: `${client.publishedAt()}::afsui::${func}`,
5948
+ typeArguments: [coinAType, coinBType],
5949
+ arguments: args
5950
+ });
5951
+ return res;
5952
+ });
5953
+ }
5954
+ };
5955
+ var Volo = class {
5956
+ constructor(env) {
5957
+ if (env !== 0 /* Mainnet */) {
5958
+ throw new Error("Volo only supported on mainnet");
5959
+ }
5960
+ this.nativePool = "0x7fa2faa111b8c65bea48a23049bfd81ca8f971a262d981dcd9a17c3825cb5baf";
5961
+ this.metadata = "0x680cd26af32b2bde8d3361e804c53ec1d1cfe24c7f039eb7f549e8dfde389a60";
5962
+ }
5963
+ swap(client, txb, path, inputCoin) {
5964
+ return __async(this, null, function* () {
5965
+ const { direction, from, target } = path;
5966
+ if (!direction) {
5967
+ throw new Error("Volo not support b2a swap");
5968
+ }
5969
+ const [func, coinAType, coinBType] = ["swap_a2b", from, target];
5970
+ const args = [
5971
+ txb.object(this.nativePool),
5972
+ txb.object(this.metadata),
5973
+ txb.pure.address(SUI_SYSTEM_ADDRESS),
5974
+ inputCoin
5975
+ ];
5976
+ const res = txb.moveCall({
5977
+ target: `${client.publishedAt()}::volo::${func}`,
5978
+ typeArguments: [coinAType, coinBType],
5979
+ arguments: args
5980
+ });
5981
+ return res;
5982
+ });
5983
+ }
5984
+ };
5890
5985
 
5891
5986
  // src/client.ts
5892
5987
  var CETUS = "CETUS";
@@ -5896,6 +5991,9 @@ var FLOWXV2 = "FLOWX";
5896
5991
  var KRIYAV3 = "KRIYAV3";
5897
5992
  var TURBOS = "TURBOS";
5898
5993
  var AFTERMATH = "AFTERMATH";
5994
+ var HAEDAL = "HAEDAL";
5995
+ var VOLO = "VOLO";
5996
+ var AFSUI = "AFSUI";
5899
5997
  var AggregatorClient5 = class {
5900
5998
  constructor(endpoint, signer, client, env) {
5901
5999
  this.endpoint = endpoint;
@@ -6179,6 +6277,12 @@ var AggregatorClient5 = class {
6179
6277
  return new Turbos(this.env);
6180
6278
  case AFTERMATH:
6181
6279
  return new Aftermath(this.env);
6280
+ case HAEDAL:
6281
+ return new Haedal(this.env);
6282
+ case AFSUI:
6283
+ return new Afsui(this.env);
6284
+ case VOLO:
6285
+ return new Volo(this.env);
6182
6286
  default:
6183
6287
  throw new Error(`Unsupported dex ${provider}`);
6184
6288
  }
@@ -6349,4 +6453,4 @@ decimal.js/decimal.mjs:
6349
6453
  *)
6350
6454
  */
6351
6455
 
6352
- export { AFTERMATH, AFTERMATH_MODULE, AggregatorClient5 as AggregatorClient, CETUS, CETUS_MODULE, CETUS_PUBLISHED_AT, CHECK_COINS_THRESHOLD_FUNC, CLOCK_ADDRESS, CoinInfoAddress, CoinStoreAddress, DEEPBOOKV2, DEEPBOOK_CLOB_V2_MODULE, DEEPBOOK_CUSTODIAN_V2_MODULE, DEEPBOOK_MODULE, DEEPBOOK_PACKAGE_ID2 as DEEPBOOK_PACKAGE_ID, DEEPBOOK_PUBLISHED_AT, Env, FLOWXV2, FLOWX_AMM_MODULE, FlashSwapA2BFunc, FlashSwapB2AFunc, FlashSwapFunc, FlashSwapWithPartnerA2BFunc, FlashSwapWithPartnerB2AFunc, FlashSwapWithPartnerFunc, JOIN_FUNC, KRIYA, KRIYAV3, KRIYA_MODULE, MAINNET_AFTERMATH_INSURANCE_FUND_ID, MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, MAINNET_AFTERMATH_REFERRAL_VAULT_ID, MAINNET_AFTERMATH_REGISTRY_ID, MAINNET_AFTERMATH_TREASURY_ID, MAINNET_CETUS_GLOBAL_CONFIG_ID, MAINNET_FLOWX_AMM_CONTAINER_ID, ONE, PAY_MODULE, POOL_MODULT, REPAY_FLASH_SWAP_A2B_FUNC, REPAY_FLASH_SWAP_B2A_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC, RepayFalshSwapFunc, RepayFlashSwapWithPartnerFunc, SWAP_A2B_FUNC, SWAP_B2A_FUNC, SuiZeroCoinFn, TEN_POW_NINE, TESTNET_AFTERMATH_INSURANCE_FUND_ID, TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, TESTNET_AFTERMATH_REFERRAL_VAULT_ID, TESTNET_AFTERMATH_REGISTRY_ID, TESTNET_AFTERMATH_TREASURY_ID, TESTNET_CETUS_GLOBAL_CONFIG_ID, TESTNET_FLOWX_AMM_CONTAINER_ID, TRANSFER_ACCOUNT_CAP, TRANSFER_OR_DESTORY_COIN_FUNC, TURBOS, TURBOS_MODULE, TURBOS_VERSIONED, TWO, U128, U64_MAX, U64_MAX_BN, UTILS_MODULE, ZERO, composeType, createTarget, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId };
6456
+ export { AFSUI, AFTERMATH, AFTERMATH_MODULE, AggregatorClient5 as AggregatorClient, CETUS, CETUS_MODULE, CETUS_PUBLISHED_AT, CHECK_COINS_THRESHOLD_FUNC, CLOCK_ADDRESS, CoinInfoAddress, CoinStoreAddress, DEEPBOOKV2, DEEPBOOK_CLOB_V2_MODULE, DEEPBOOK_CUSTODIAN_V2_MODULE, DEEPBOOK_MODULE, DEEPBOOK_PACKAGE_ID2 as DEEPBOOK_PACKAGE_ID, DEEPBOOK_PUBLISHED_AT, Env, FLOWXV2, FLOWX_AMM_MODULE, FlashSwapA2BFunc, FlashSwapB2AFunc, FlashSwapFunc, FlashSwapWithPartnerA2BFunc, FlashSwapWithPartnerB2AFunc, FlashSwapWithPartnerFunc, HAEDAL, JOIN_FUNC, KRIYA, KRIYAV3, KRIYA_MODULE, MAINNET_AFTERMATH_INSURANCE_FUND_ID, MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, MAINNET_AFTERMATH_REFERRAL_VAULT_ID, MAINNET_AFTERMATH_REGISTRY_ID, MAINNET_AFTERMATH_TREASURY_ID, MAINNET_CETUS_GLOBAL_CONFIG_ID, MAINNET_FLOWX_AMM_CONTAINER_ID, ONE, PAY_MODULE, POOL_MODULT, REPAY_FLASH_SWAP_A2B_FUNC, REPAY_FLASH_SWAP_B2A_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC, RepayFalshSwapFunc, RepayFlashSwapWithPartnerFunc, SWAP_A2B_FUNC, SWAP_B2A_FUNC, SuiZeroCoinFn, TEN_POW_NINE, TESTNET_AFTERMATH_INSURANCE_FUND_ID, TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, TESTNET_AFTERMATH_REFERRAL_VAULT_ID, TESTNET_AFTERMATH_REGISTRY_ID, TESTNET_AFTERMATH_TREASURY_ID, TESTNET_CETUS_GLOBAL_CONFIG_ID, TESTNET_FLOWX_AMM_CONTAINER_ID, TRANSFER_ACCOUNT_CAP, TRANSFER_OR_DESTORY_COIN_FUNC, TURBOS, TURBOS_MODULE, TURBOS_VERSIONED, TWO, U128, U64_MAX, U64_MAX_BN, UTILS_MODULE, VOLO, ZERO, composeType, createTarget, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId };
@@ -11,6 +11,9 @@ export declare const FLOWXV2 = "FLOWX";
11
11
  export declare const KRIYAV3 = "KRIYAV3";
12
12
  export declare const TURBOS = "TURBOS";
13
13
  export declare const AFTERMATH = "AFTERMATH";
14
+ export declare const HAEDAL = "HAEDAL";
15
+ export declare const VOLO = "VOLO";
16
+ export declare const AFSUI = "AFSUI";
14
17
  export type BuildRouterSwapParams = {
15
18
  routers: Router[];
16
19
  byAmountIn: boolean;
@@ -0,0 +1,10 @@
1
+ import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
2
+ import { AggregatorClient, Dex, Env, Path } from "..";
3
+ export declare class Afsui implements Dex {
4
+ private stakedSuiVault;
5
+ private safe;
6
+ private referVault;
7
+ private validator;
8
+ constructor(env: Env);
9
+ swap(client: AggregatorClient, txb: Transaction, path: Path, inputCoin: TransactionObjectArgument): Promise<TransactionObjectArgument>;
10
+ }
@@ -0,0 +1,7 @@
1
+ import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
2
+ import { AggregatorClient, Dex, Env, Path } from "..";
3
+ export declare class Haedal implements Dex {
4
+ private stake;
5
+ constructor(env: Env);
6
+ swap(client: AggregatorClient, txb: Transaction, path: Path, inputCoin: TransactionObjectArgument): Promise<TransactionObjectArgument>;
7
+ }
@@ -0,0 +1,8 @@
1
+ import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
2
+ import { AggregatorClient, Dex, Env, Path } from "..";
3
+ export declare class Volo implements Dex {
4
+ private nativePool;
5
+ private metadata;
6
+ constructor(env: Env);
7
+ swap(client: AggregatorClient, txb: Transaction, path: Path, inputCoin: TransactionObjectArgument): Promise<TransactionObjectArgument>;
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cetusprotocol/aggregator-sdk",
3
- "version": "0.0.0-experimental-20240819211521",
3
+ "version": "0.0.0-experimental-20240822182903",
4
4
  "sideEffects": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/client.ts CHANGED
@@ -2,7 +2,6 @@ import Decimal from "decimal.js"
2
2
  import { SuiClient } from "@mysten/sui/client"
3
3
  import {
4
4
  Transaction,
5
- TransactionArgument,
6
5
  TransactionObjectArgument,
7
6
  } from "@mysten/sui/transactions"
8
7
  import { Signer } from "@mysten/sui/dist/cjs/cryptography"
@@ -28,6 +27,9 @@ import { CalculateAmountLimit } from "./math"
28
27
  import { buildInputCoin } from "./utils/coin"
29
28
  import { CoinAsset } from "./types/sui"
30
29
  import { KriyaV3 } from "./transaction/kriya_v3"
30
+ import { Haedal } from "./transaction/haedal"
31
+ import { Afsui } from "./transaction/afsui"
32
+ import { Volo } from "./transaction/volo"
31
33
 
32
34
  export const CETUS = "CETUS"
33
35
  export const DEEPBOOKV2 = "DEEPBOOK"
@@ -36,6 +38,9 @@ export const FLOWXV2 = "FLOWX"
36
38
  export const KRIYAV3 = "KRIYAV3"
37
39
  export const TURBOS = "TURBOS"
38
40
  export const AFTERMATH = "AFTERMATH"
41
+ export const HAEDAL = "HAEDAL"
42
+ export const VOLO = "VOLO"
43
+ export const AFSUI = "AFSUI"
39
44
 
40
45
  export type BuildRouterSwapParams = {
41
46
  routers: Router[]
@@ -387,6 +392,12 @@ export class AggregatorClient {
387
392
  return new Turbos(this.env)
388
393
  case AFTERMATH:
389
394
  return new Aftermath(this.env)
395
+ case HAEDAL:
396
+ return new Haedal(this.env)
397
+ case AFSUI:
398
+ return new Afsui(this.env)
399
+ case VOLO:
400
+ return new Volo(this.env)
390
401
  default:
391
402
  throw new Error(`Unsupported dex ${provider}`)
392
403
  }
@@ -0,0 +1,60 @@
1
+ import {
2
+ Transaction,
3
+ TransactionObjectArgument,
4
+ } from "@mysten/sui/transactions"
5
+ import { AggregatorClient, Dex, Env, Path } from ".."
6
+ import { SUI_SYSTEM_ADDRESS } from "@mysten/sui/dist/cjs/utils"
7
+
8
+ export class Afsui implements Dex {
9
+ private stakedSuiVault: string
10
+ private safe: string
11
+ private referVault: string
12
+ private validator: string
13
+
14
+ constructor(env: Env) {
15
+ if (env !== Env.Mainnet) {
16
+ throw new Error("Afsui only supported on mainnet")
17
+ }
18
+
19
+ this.stakedSuiVault =
20
+ "0x2f8f6d5da7f13ea37daa397724280483ed062769813b6f31e9788e59cc88994d"
21
+ this.safe =
22
+ "0xeb685899830dd5837b47007809c76d91a098d52aabbf61e8ac467c59e5cc4610"
23
+ this.referVault =
24
+ "0x4ce9a19b594599536c53edb25d22532f82f18038dc8ef618afd00fbbfb9845ef"
25
+ this.validator =
26
+ "0xd30018ec3f5ff1a3c75656abf927a87d7f0529e6dc89c7ddd1bd27ecb05e3db2"
27
+ }
28
+
29
+ async swap(
30
+ client: AggregatorClient,
31
+ txb: Transaction,
32
+ path: Path,
33
+ inputCoin: TransactionObjectArgument
34
+ ): Promise<TransactionObjectArgument> {
35
+ const { direction, from, target } = path
36
+
37
+ if (!direction) {
38
+ throw new Error("Afsui not support b2a swap")
39
+ }
40
+
41
+ const [func, coinAType, coinBType] = ["swap_a2b", from, target]
42
+
43
+ const args = [
44
+ txb.object(this.stakedSuiVault),
45
+ txb.object(this.safe),
46
+ txb.pure.address(SUI_SYSTEM_ADDRESS),
47
+ txb.object(this.referVault),
48
+ inputCoin,
49
+ txb.object(this.validator),
50
+ ]
51
+
52
+ const res = txb.moveCall({
53
+ target: `${client.publishedAt()}::afsui::${func}`,
54
+ typeArguments: [coinAType, coinBType],
55
+ arguments: args,
56
+ }) as TransactionObjectArgument
57
+
58
+ return res
59
+ }
60
+ }
@@ -0,0 +1,49 @@
1
+ import {
2
+ Transaction,
3
+ TransactionObjectArgument,
4
+ } from "@mysten/sui/transactions"
5
+ import { AggregatorClient, Dex, Env, Path } from ".."
6
+ import { SUI_SYSTEM_ADDRESS } from "@mysten/sui/dist/cjs/utils"
7
+
8
+ export class Haedal implements Dex {
9
+ private stake: string
10
+
11
+ constructor(env: Env) {
12
+ if (env !== Env.Mainnet) {
13
+ throw new Error("Haedal only supported on mainnet")
14
+ }
15
+
16
+ this.stake =
17
+ "0x47b224762220393057ebf4f70501b6e657c3e56684737568439a04f80849b2ca"
18
+ }
19
+
20
+ async swap(
21
+ client: AggregatorClient,
22
+ txb: Transaction,
23
+ path: Path,
24
+ inputCoin: TransactionObjectArgument
25
+ ): Promise<TransactionObjectArgument> {
26
+ const { direction, from, target } = path
27
+
28
+ if (!direction) {
29
+ throw new Error("Haedal not support b2a swap")
30
+ }
31
+
32
+ const [func, coinAType, coinBType] = ["swap_a2b", from, target]
33
+
34
+ const args = [
35
+ txb.pure.address(SUI_SYSTEM_ADDRESS),
36
+ txb.object(this.stake),
37
+ inputCoin,
38
+ txb.pure.address("0x0"),
39
+ ]
40
+
41
+ const res = txb.moveCall({
42
+ target: `${client.publishedAt()}::haedal::${func}`,
43
+ typeArguments: [coinAType, coinBType],
44
+ arguments: args,
45
+ }) as TransactionObjectArgument
46
+
47
+ return res
48
+ }
49
+ }
@@ -91,6 +91,8 @@ export async function swapInPools(
91
91
  }
92
92
 
93
93
  const event = valueData[tempIndex].parsedJson.data
94
+ console.log("event", JSON.stringify(event, null, 2))
95
+
94
96
  const currentSqrtPrice = event.step_results[0].current_sqrt_price
95
97
 
96
98
  const [decimalA, decimalB] = await Promise.all([
@@ -126,9 +128,9 @@ export async function swapInPools(
126
128
  provider: "CETUS",
127
129
  from: fromCoin,
128
130
  target: targetCoin,
129
- feeRate: 0,
130
- amountIn: 0,
131
- amountOut: 0,
131
+ feeRate: event.fee_rate,
132
+ amountIn: event.amount_in,
133
+ amountOut: event.amount_out,
132
134
  },
133
135
  ],
134
136
  amountIn: new BN(event.amount_in ?? 0),
@@ -0,0 +1,52 @@
1
+ import {
2
+ Transaction,
3
+ TransactionObjectArgument,
4
+ } from "@mysten/sui/transactions"
5
+ import { AggregatorClient, Dex, Env, Path } from ".."
6
+ import { SUI_SYSTEM_ADDRESS } from "@mysten/sui/dist/cjs/utils"
7
+
8
+ export class Volo implements Dex {
9
+ private nativePool: string
10
+ private metadata: string
11
+
12
+ constructor(env: Env) {
13
+ if (env !== Env.Mainnet) {
14
+ throw new Error("Volo only supported on mainnet")
15
+ }
16
+
17
+ this.nativePool =
18
+ "0x7fa2faa111b8c65bea48a23049bfd81ca8f971a262d981dcd9a17c3825cb5baf"
19
+ this.metadata =
20
+ "0x680cd26af32b2bde8d3361e804c53ec1d1cfe24c7f039eb7f549e8dfde389a60"
21
+ }
22
+
23
+ async swap(
24
+ client: AggregatorClient,
25
+ txb: Transaction,
26
+ path: Path,
27
+ inputCoin: TransactionObjectArgument
28
+ ): Promise<TransactionObjectArgument> {
29
+ const { direction, from, target } = path
30
+
31
+ if (!direction) {
32
+ throw new Error("Volo not support b2a swap")
33
+ }
34
+
35
+ const [func, coinAType, coinBType] = ["swap_a2b", from, target]
36
+
37
+ const args = [
38
+ txb.object(this.nativePool),
39
+ txb.object(this.metadata),
40
+ txb.pure.address(SUI_SYSTEM_ADDRESS),
41
+ inputCoin,
42
+ ]
43
+
44
+ const res = txb.moveCall({
45
+ target: `${client.publishedAt()}::volo::${func}`,
46
+ typeArguments: [coinAType, coinBType],
47
+ arguments: args,
48
+ }) as TransactionObjectArgument
49
+
50
+ return res
51
+ }
52
+ }
@@ -27,18 +27,11 @@ describe("router module", () => {
27
27
  const aggregatorURL = process.env.CETUS_AGGREGATOR!
28
28
  const secret = process.env.SUI_WALLET_SECRET!
29
29
 
30
- // const byte = Buffer.from(secret, "hex")
31
- // keypair = secret
32
- // ? Ed25519Keypair.fromSecretKey(u8Array.slice(1, 33))
33
- // : buildTestAccount()
34
- const byte = Buffer.from(secret, "base64")
35
- const u8Array = new Uint8Array(byte)
36
- const secretKey = fromB64(secret)
37
-
38
- // keypair = Ed25519Keypair.fromSecretKey(fromB64(secret).slice(1, 33))
39
- keypair = secret
40
- ? Ed25519Keypair.fromSecretKey(u8Array.slice(1, 33))
41
- : buildTestAccount()
30
+ if (secret) {
31
+ keypair = Ed25519Keypair.fromSecretKey(fromB64(secret).slice(1, 33))
32
+ } else {
33
+ keypair = buildTestAccount()
34
+ }
42
35
 
43
36
  const wallet = keypair.getPublicKey().toSuiAddress()
44
37
 
@@ -85,12 +78,13 @@ describe("router module", () => {
85
78
 
86
79
  test("Downgrade swap in route", async () => {
87
80
  const amount = 1000000
81
+ const byAmountIn = false
88
82
 
89
- const res = await client.swapInPools({
83
+ const res: any = await client.swapInPools({
90
84
  from: M_USDC,
91
85
  target: M_SUI,
92
86
  amount: new BN(amount),
93
- byAmountIn: true,
87
+ byAmountIn,
94
88
  pools: [
95
89
  "0xcf994611fd4c48e277ce3ffd4d4364c914af2c3cbb05f7bf6facd371de688630",
96
90
  ],
@@ -98,8 +92,20 @@ describe("router module", () => {
98
92
 
99
93
  if (res != null) {
100
94
  console.log(JSON.stringify(res, null, 2))
95
+ const txb = new Transaction()
96
+ await client.fastRouterSwap({
97
+ routers: res.routeData.routes,
98
+ byAmountIn,
99
+ txb,
100
+ slippage: 0.01,
101
+ isMergeTragetCoin: false,
102
+ refreshAllCoins: true,
103
+ })
104
+
105
+ let result = await client.devInspectTransactionBlock(txb)
106
+ console.log("🚀 ~ file: router.test.ts:114 ~ test ~ result:", result)
101
107
  }
102
- })
108
+ }, 10000)
103
109
 
104
110
  test("Find router", async () => {
105
111
  const amount = "4239267610000000000"
@@ -122,10 +128,10 @@ describe("router module", () => {
122
128
 
123
129
  test("Build router tx", async () => {
124
130
  const byAmountIn = true
125
- const amount = "10000000000"
131
+ const amount = "100000"
126
132
 
127
- const from = M_SUI
128
- const target = M_USDC
133
+ const from = M_USDC
134
+ const target = M_SUI
129
135
 
130
136
  const res = await client.findRouters({
131
137
  from,