@cetusprotocol/aggregator-sdk 0.3.23 → 0.3.25

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
@@ -79,6 +79,7 @@ declare const BLUEFIN = "BLUEFIN";
79
79
  declare const HAEDALPMM = "HAEDALPMM";
80
80
  declare const ALPHAFI = "ALPHAFI";
81
81
  declare const SPRINGSUI = "SPRINGSUI";
82
+ declare const STEAMM = "STEAMM";
82
83
  declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
83
84
  type BuildRouterSwapParams = {
84
85
  routers: Router[];
@@ -157,7 +158,7 @@ declare class AggregatorClient {
157
158
  declare function findPythPriceIDs(routes: Router[]): string[];
158
159
  declare function parseRouterResponse(data: any, byAmountIn: boolean): RouterData;
159
160
 
160
- declare const CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
161
+ declare const CLOCK_ADDRESS: string;
161
162
  declare const AGGREGATOR_V2 = "aggregator_v2";
162
163
  declare const AGGREGATOR_V2_EXTEND = "aggregator_v2_extend";
163
164
  declare function getAggregatorV2PublishedAt(aggregatorV2PublishedAt: string, packages?: Map<string, string> | Record<string, string>): string;
@@ -235,6 +236,13 @@ type ExtendedDetails = {
235
236
  scallopScoinTreasury?: string;
236
237
  haedalPmmBasePriceSeed?: string;
237
238
  haedalPmmQuotePriceSeed?: string;
239
+ steammBankA?: string;
240
+ steammBankB?: string;
241
+ steammLendingMarket?: string;
242
+ steammLendingMarketType?: string;
243
+ steammBCoinAType?: string;
244
+ steammBCoinBType?: string;
245
+ steammLPToken?: string;
238
246
  };
239
247
  type Path = {
240
248
  id: string;
@@ -298,4 +306,4 @@ declare enum Env {
298
306
  Testnet = 1
299
307
  }
300
308
 
301
- export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI, AggregatorClient, type AggregatorResponse, BLUEFIN, BLUEMOVE, type BuildCoinResult, type BuildFastRouterSwapParams, type BuildFastRouterSwapParamsV2, type BuildRouterSwapParams, type BuildRouterSwapParamsV2, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, HAEDALPMM, KRIYA, KRIYAV3, ONE, type Path, type PreSwapLpChangeParams, type Router, type RouterData, type RouterError, SCALLOP, SPRINGSUI, SUILEND, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, buildInputCoin, checkInvalidSuiAddress, compareCoins, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, findPythPriceIDs, fixSuiObjectId, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
309
+ export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI, AggregatorClient, type AggregatorResponse, BLUEFIN, BLUEMOVE, type BuildCoinResult, type BuildFastRouterSwapParams, type BuildFastRouterSwapParamsV2, type BuildRouterSwapParams, type BuildRouterSwapParamsV2, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, HAEDALPMM, KRIYA, KRIYAV3, ONE, type Path, type PreSwapLpChangeParams, type Router, type RouterData, type RouterError, SCALLOP, SPRINGSUI, STEAMM, SUILEND, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, buildInputCoin, checkInvalidSuiAddress, compareCoins, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, findPythPriceIDs, fixSuiObjectId, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
package/dist/index.d.ts CHANGED
@@ -79,6 +79,7 @@ declare const BLUEFIN = "BLUEFIN";
79
79
  declare const HAEDALPMM = "HAEDALPMM";
80
80
  declare const ALPHAFI = "ALPHAFI";
81
81
  declare const SPRINGSUI = "SPRINGSUI";
82
+ declare const STEAMM = "STEAMM";
82
83
  declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
83
84
  type BuildRouterSwapParams = {
84
85
  routers: Router[];
@@ -157,7 +158,7 @@ declare class AggregatorClient {
157
158
  declare function findPythPriceIDs(routes: Router[]): string[];
158
159
  declare function parseRouterResponse(data: any, byAmountIn: boolean): RouterData;
159
160
 
160
- declare const CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
161
+ declare const CLOCK_ADDRESS: string;
161
162
  declare const AGGREGATOR_V2 = "aggregator_v2";
162
163
  declare const AGGREGATOR_V2_EXTEND = "aggregator_v2_extend";
163
164
  declare function getAggregatorV2PublishedAt(aggregatorV2PublishedAt: string, packages?: Map<string, string> | Record<string, string>): string;
@@ -235,6 +236,13 @@ type ExtendedDetails = {
235
236
  scallopScoinTreasury?: string;
236
237
  haedalPmmBasePriceSeed?: string;
237
238
  haedalPmmQuotePriceSeed?: string;
239
+ steammBankA?: string;
240
+ steammBankB?: string;
241
+ steammLendingMarket?: string;
242
+ steammLendingMarketType?: string;
243
+ steammBCoinAType?: string;
244
+ steammBCoinBType?: string;
245
+ steammLPToken?: string;
238
246
  };
239
247
  type Path = {
240
248
  id: string;
@@ -298,4 +306,4 @@ declare enum Env {
298
306
  Testnet = 1
299
307
  }
300
308
 
301
- export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI, AggregatorClient, type AggregatorResponse, BLUEFIN, BLUEMOVE, type BuildCoinResult, type BuildFastRouterSwapParams, type BuildFastRouterSwapParamsV2, type BuildRouterSwapParams, type BuildRouterSwapParamsV2, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, HAEDALPMM, KRIYA, KRIYAV3, ONE, type Path, type PreSwapLpChangeParams, type Router, type RouterData, type RouterError, SCALLOP, SPRINGSUI, SUILEND, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, buildInputCoin, checkInvalidSuiAddress, compareCoins, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, findPythPriceIDs, fixSuiObjectId, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
309
+ export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI, AggregatorClient, type AggregatorResponse, BLUEFIN, BLUEMOVE, type BuildCoinResult, type BuildFastRouterSwapParams, type BuildFastRouterSwapParamsV2, type BuildRouterSwapParams, type BuildRouterSwapParamsV2, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, HAEDALPMM, KRIYA, KRIYAV3, ONE, type Path, type PreSwapLpChangeParams, type Router, type RouterData, type RouterError, SCALLOP, SPRINGSUI, STEAMM, SUILEND, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, buildInputCoin, checkInvalidSuiAddress, compareCoins, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, findPythPriceIDs, fixSuiObjectId, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
package/dist/index.js CHANGED
@@ -6246,6 +6246,70 @@ var Alphafi = class {
6246
6246
  });
6247
6247
  }
6248
6248
  };
6249
+
6250
+ // src/transaction/steamm.ts
6251
+ var Steamm = class {
6252
+ constructor(env) {
6253
+ if (env !== 0 /* Mainnet */) {
6254
+ throw new Error("Steamm only supported on mainnet");
6255
+ }
6256
+ }
6257
+ swap(client, txb, path, inputCoin, packages) {
6258
+ return __async(this, null, function* () {
6259
+ const { direction, from, target } = path;
6260
+ const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
6261
+ if (path.extendedDetails == null) {
6262
+ throw new Error("Extended details not supported");
6263
+ } else {
6264
+ if (path.extendedDetails.steammBankA == null) {
6265
+ throw new Error("Steamm bank a type not supported");
6266
+ }
6267
+ if (path.extendedDetails.steammBankB == null) {
6268
+ throw new Error("Steamm bank b type not supported");
6269
+ }
6270
+ if (path.extendedDetails.steammLendingMarket == null) {
6271
+ throw new Error("Steamm lending market not supported");
6272
+ }
6273
+ if (path.extendedDetails.steammLendingMarketType == null) {
6274
+ throw new Error("Steamm lending market type not supported");
6275
+ }
6276
+ if (path.extendedDetails.steammBCoinAType == null) {
6277
+ throw new Error("Steamm b coin a type not supported");
6278
+ }
6279
+ if (path.extendedDetails.steammBCoinBType == null) {
6280
+ throw new Error("Steamm b coin b type not supported");
6281
+ }
6282
+ if (path.extendedDetails.steammLPToken == null) {
6283
+ throw new Error("Steamm lp token not supported");
6284
+ }
6285
+ }
6286
+ const args = [
6287
+ txb.object(path.id),
6288
+ txb.object(path.extendedDetails.steammBankA),
6289
+ txb.object(path.extendedDetails.steammBankB),
6290
+ txb.object(path.extendedDetails.steammLendingMarket),
6291
+ inputCoin,
6292
+ txb.object(CLOCK_ADDRESS)
6293
+ ];
6294
+ const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
6295
+ const res = txb.moveCall({
6296
+ target: `${publishedAt}::steammfe::${func}`,
6297
+ typeArguments: [
6298
+ path.extendedDetails.steammLendingMarketType,
6299
+ coinAType,
6300
+ coinBType,
6301
+ path.extendedDetails.steammBCoinAType,
6302
+ path.extendedDetails.steammBCoinBType,
6303
+ path.extendedDetails.steammLPToken
6304
+ ],
6305
+ arguments: args
6306
+ });
6307
+ return res;
6308
+ });
6309
+ }
6310
+ };
6311
+
6312
+ // src/client.ts
6249
6313
  var CETUS = "CETUS";
6250
6314
  var DEEPBOOKV2 = "DEEPBOOK";
6251
6315
  var KRIYA = "KRIYA";
@@ -6265,6 +6329,7 @@ var BLUEFIN = "BLUEFIN";
6265
6329
  var HAEDALPMM = "HAEDALPMM";
6266
6330
  var ALPHAFI = "ALPHAFI";
6267
6331
  var SPRINGSUI = "SPRINGSUI";
6332
+ var STEAMM = "STEAMM";
6268
6333
  var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
6269
6334
  function isBuilderRouterSwapParams(params) {
6270
6335
  return Array.isArray(params.routers);
@@ -6610,7 +6675,7 @@ var _AggregatorClient = class _AggregatorClient {
6610
6675
  // Include deepbookv3, scallop, bluefin
6611
6676
  publishedAtV2Extend() {
6612
6677
  if (this.env === 0 /* Mainnet */) {
6613
- return "0xf2fcea41dc217385019828375764fa06d9bd25e8e4726ba1962680849fb8d613";
6678
+ return "0xa2d8a4279d69d8fec04b2fea8852d0d467d3cc0d39c5890180d439ae7a9953ed";
6614
6679
  } else {
6615
6680
  return "0xabb6a81c8a216828e317719e06125de5bb2cb0fe8f9916ff8c023ca5be224c78";
6616
6681
  }
@@ -6687,6 +6752,8 @@ var _AggregatorClient = class _AggregatorClient {
6687
6752
  return new HaedalPmm(this.env, pythPriceIDs);
6688
6753
  case ALPHAFI:
6689
6754
  return new Alphafi(this.env);
6755
+ case STEAMM:
6756
+ return new Steamm(this.env);
6690
6757
  default:
6691
6758
  throw new Error(`Unsupported dex ${provider}`);
6692
6759
  }
@@ -6794,7 +6861,7 @@ _AggregatorClient.CONFIG = {
6794
6861
  pythStateId: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8"
6795
6862
  }
6796
6863
  };
6797
- var AggregatorClient19 = _AggregatorClient;
6864
+ var AggregatorClient20 = _AggregatorClient;
6798
6865
  function findPythPriceIDs(routes) {
6799
6866
  const priceIDs = /* @__PURE__ */ new Set();
6800
6867
  for (const route of routes) {
@@ -6833,13 +6900,13 @@ function parseRouterResponse(data, byAmountIn) {
6833
6900
  routes: data.routes.map((route) => {
6834
6901
  return {
6835
6902
  path: route.path.map((path) => {
6836
- var _a, _b, _c, _d, _e, _f, _g;
6903
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
6837
6904
  let version;
6838
6905
  if (path.provider === AFTERMATH) {
6839
6906
  version = path.extended_details.aftermath_pool_flatness === 0 ? "v2" : "v3";
6840
6907
  }
6841
6908
  let extendedDetails;
6842
- if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS || path.provider === DEEPBOOKV3 || path.provider === SCALLOP || path.provider === HAEDALPMM) {
6909
+ if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS || path.provider === DEEPBOOKV3 || path.provider === SCALLOP || path.provider === HAEDALPMM || path.provider === STEAMM) {
6843
6910
  extendedDetails = {
6844
6911
  aftermathLpSupplyType: (_a = path.extended_details) == null ? void 0 : _a.aftermath_lp_supply_type,
6845
6912
  turbosFeeType: (_b = path.extended_details) == null ? void 0 : _b.turbos_fee_type,
@@ -6847,7 +6914,14 @@ function parseRouterResponse(data, byAmountIn) {
6847
6914
  deepbookv3DeepFee: (_d = path.extended_details) == null ? void 0 : _d.deepbookv3_deep_fee,
6848
6915
  scallopScoinTreasury: (_e = path.extended_details) == null ? void 0 : _e.scallop_scoin_treasury,
6849
6916
  haedalPmmBasePriceSeed: (_f = path.extended_details) == null ? void 0 : _f.haedal_pmm_base_price_seed,
6850
- haedalPmmQuotePriceSeed: (_g = path.extended_details) == null ? void 0 : _g.haedal_pmm_quote_price_seed
6917
+ haedalPmmQuotePriceSeed: (_g = path.extended_details) == null ? void 0 : _g.haedal_pmm_quote_price_seed,
6918
+ steammfeBankA: (_h = path.extended_details) == null ? void 0 : _h.steammfe_bank_a,
6919
+ steammfeBankB: (_i = path.extended_details) == null ? void 0 : _i.steammfe_bank_b,
6920
+ steammfeLendingMarket: (_j = path.extended_details) == null ? void 0 : _j.steammfe_lending_market,
6921
+ steammfeLendingMarketType: (_k = path.extended_details) == null ? void 0 : _k.steammfe_lending_market_type,
6922
+ steammfeBCoinAType: (_l = path.extended_details) == null ? void 0 : _l.steammfe_btoken_a_type,
6923
+ steammfeBCoinBType: (_m = path.extended_details) == null ? void 0 : _m.steammfe_btoken_b_type,
6924
+ steammfeLPToken: (_n = path.extended_details) == null ? void 0 : _n.steammfe_lp_token_type
6851
6925
  };
6852
6926
  }
6853
6927
  return {
@@ -6873,9 +6947,7 @@ function parseRouterResponse(data, byAmountIn) {
6873
6947
  };
6874
6948
  return routerData;
6875
6949
  }
6876
-
6877
- // src/transaction/index.ts
6878
- var CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
6950
+ var CLOCK_ADDRESS = utils.SUI_CLOCK_OBJECT_ID;
6879
6951
  var AGGREGATOR_V2 = "aggregator_v2";
6880
6952
  var AGGREGATOR_V2_EXTEND = "aggregator_v2_extend";
6881
6953
  function getAggregatorV2PublishedAt(aggregatorV2PublishedAt, packages) {
@@ -6981,6 +7053,7 @@ function getRouterResult(endpoint, params) {
6981
7053
  };
6982
7054
  }
6983
7055
  if (data.data != null) {
7056
+ console.log("data.data", JSON.stringify(data.data, null, 2));
6984
7057
  const res = parseRouterResponse(data.data, params.byAmountIn);
6985
7058
  return res;
6986
7059
  }
@@ -7033,7 +7106,7 @@ function getRouter(endpoint, params) {
7033
7106
  url += `&providers=${providers.join(",")}`;
7034
7107
  }
7035
7108
  }
7036
- url += "&v=1000323";
7109
+ url += "&v=1000325";
7037
7110
  const response = yield fetch(url);
7038
7111
  return response;
7039
7112
  } catch (error) {
@@ -7128,7 +7201,7 @@ exports.AFTERMATH = AFTERMATH;
7128
7201
  exports.AGGREGATOR_V2 = AGGREGATOR_V2;
7129
7202
  exports.AGGREGATOR_V2_EXTEND = AGGREGATOR_V2_EXTEND;
7130
7203
  exports.ALPHAFI = ALPHAFI;
7131
- exports.AggregatorClient = AggregatorClient19;
7204
+ exports.AggregatorClient = AggregatorClient20;
7132
7205
  exports.BLUEFIN = BLUEFIN;
7133
7206
  exports.BLUEMOVE = BLUEMOVE;
7134
7207
  exports.CETUS = CETUS;
@@ -7146,6 +7219,7 @@ exports.KRIYAV3 = KRIYAV3;
7146
7219
  exports.ONE = ONE;
7147
7220
  exports.SCALLOP = SCALLOP;
7148
7221
  exports.SPRINGSUI = SPRINGSUI;
7222
+ exports.STEAMM = STEAMM;
7149
7223
  exports.SUILEND = SUILEND;
7150
7224
  exports.TEN_POW_NINE = TEN_POW_NINE;
7151
7225
  exports.TURBOS = TURBOS;
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { SuiClient, getFullnodeUrl } from '@mysten/sui/client';
2
- import { normalizeSuiObjectId, SUI_FRAMEWORK_ADDRESS } from '@mysten/sui/utils';
2
+ import { normalizeSuiObjectId, SUI_CLOCK_OBJECT_ID, SUI_FRAMEWORK_ADDRESS } from '@mysten/sui/utils';
3
3
  import { Transaction } from '@mysten/sui/transactions';
4
4
  import { SuiPriceServiceConnection, SuiPythClient } from '@pythnetwork/pyth-sui-js';
5
5
 
@@ -6244,6 +6244,70 @@ var Alphafi = class {
6244
6244
  });
6245
6245
  }
6246
6246
  };
6247
+
6248
+ // src/transaction/steamm.ts
6249
+ var Steamm = class {
6250
+ constructor(env) {
6251
+ if (env !== 0 /* Mainnet */) {
6252
+ throw new Error("Steamm only supported on mainnet");
6253
+ }
6254
+ }
6255
+ swap(client, txb, path, inputCoin, packages) {
6256
+ return __async(this, null, function* () {
6257
+ const { direction, from, target } = path;
6258
+ const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
6259
+ if (path.extendedDetails == null) {
6260
+ throw new Error("Extended details not supported");
6261
+ } else {
6262
+ if (path.extendedDetails.steammBankA == null) {
6263
+ throw new Error("Steamm bank a type not supported");
6264
+ }
6265
+ if (path.extendedDetails.steammBankB == null) {
6266
+ throw new Error("Steamm bank b type not supported");
6267
+ }
6268
+ if (path.extendedDetails.steammLendingMarket == null) {
6269
+ throw new Error("Steamm lending market not supported");
6270
+ }
6271
+ if (path.extendedDetails.steammLendingMarketType == null) {
6272
+ throw new Error("Steamm lending market type not supported");
6273
+ }
6274
+ if (path.extendedDetails.steammBCoinAType == null) {
6275
+ throw new Error("Steamm b coin a type not supported");
6276
+ }
6277
+ if (path.extendedDetails.steammBCoinBType == null) {
6278
+ throw new Error("Steamm b coin b type not supported");
6279
+ }
6280
+ if (path.extendedDetails.steammLPToken == null) {
6281
+ throw new Error("Steamm lp token not supported");
6282
+ }
6283
+ }
6284
+ const args = [
6285
+ txb.object(path.id),
6286
+ txb.object(path.extendedDetails.steammBankA),
6287
+ txb.object(path.extendedDetails.steammBankB),
6288
+ txb.object(path.extendedDetails.steammLendingMarket),
6289
+ inputCoin,
6290
+ txb.object(CLOCK_ADDRESS)
6291
+ ];
6292
+ const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
6293
+ const res = txb.moveCall({
6294
+ target: `${publishedAt}::steammfe::${func}`,
6295
+ typeArguments: [
6296
+ path.extendedDetails.steammLendingMarketType,
6297
+ coinAType,
6298
+ coinBType,
6299
+ path.extendedDetails.steammBCoinAType,
6300
+ path.extendedDetails.steammBCoinBType,
6301
+ path.extendedDetails.steammLPToken
6302
+ ],
6303
+ arguments: args
6304
+ });
6305
+ return res;
6306
+ });
6307
+ }
6308
+ };
6309
+
6310
+ // src/client.ts
6247
6311
  var CETUS = "CETUS";
6248
6312
  var DEEPBOOKV2 = "DEEPBOOK";
6249
6313
  var KRIYA = "KRIYA";
@@ -6263,6 +6327,7 @@ var BLUEFIN = "BLUEFIN";
6263
6327
  var HAEDALPMM = "HAEDALPMM";
6264
6328
  var ALPHAFI = "ALPHAFI";
6265
6329
  var SPRINGSUI = "SPRINGSUI";
6330
+ var STEAMM = "STEAMM";
6266
6331
  var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
6267
6332
  function isBuilderRouterSwapParams(params) {
6268
6333
  return Array.isArray(params.routers);
@@ -6608,7 +6673,7 @@ var _AggregatorClient = class _AggregatorClient {
6608
6673
  // Include deepbookv3, scallop, bluefin
6609
6674
  publishedAtV2Extend() {
6610
6675
  if (this.env === 0 /* Mainnet */) {
6611
- return "0xf2fcea41dc217385019828375764fa06d9bd25e8e4726ba1962680849fb8d613";
6676
+ return "0xa2d8a4279d69d8fec04b2fea8852d0d467d3cc0d39c5890180d439ae7a9953ed";
6612
6677
  } else {
6613
6678
  return "0xabb6a81c8a216828e317719e06125de5bb2cb0fe8f9916ff8c023ca5be224c78";
6614
6679
  }
@@ -6685,6 +6750,8 @@ var _AggregatorClient = class _AggregatorClient {
6685
6750
  return new HaedalPmm(this.env, pythPriceIDs);
6686
6751
  case ALPHAFI:
6687
6752
  return new Alphafi(this.env);
6753
+ case STEAMM:
6754
+ return new Steamm(this.env);
6688
6755
  default:
6689
6756
  throw new Error(`Unsupported dex ${provider}`);
6690
6757
  }
@@ -6792,7 +6859,7 @@ _AggregatorClient.CONFIG = {
6792
6859
  pythStateId: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8"
6793
6860
  }
6794
6861
  };
6795
- var AggregatorClient19 = _AggregatorClient;
6862
+ var AggregatorClient20 = _AggregatorClient;
6796
6863
  function findPythPriceIDs(routes) {
6797
6864
  const priceIDs = /* @__PURE__ */ new Set();
6798
6865
  for (const route of routes) {
@@ -6831,13 +6898,13 @@ function parseRouterResponse(data, byAmountIn) {
6831
6898
  routes: data.routes.map((route) => {
6832
6899
  return {
6833
6900
  path: route.path.map((path) => {
6834
- var _a, _b, _c, _d, _e, _f, _g;
6901
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
6835
6902
  let version;
6836
6903
  if (path.provider === AFTERMATH) {
6837
6904
  version = path.extended_details.aftermath_pool_flatness === 0 ? "v2" : "v3";
6838
6905
  }
6839
6906
  let extendedDetails;
6840
- if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS || path.provider === DEEPBOOKV3 || path.provider === SCALLOP || path.provider === HAEDALPMM) {
6907
+ if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS || path.provider === DEEPBOOKV3 || path.provider === SCALLOP || path.provider === HAEDALPMM || path.provider === STEAMM) {
6841
6908
  extendedDetails = {
6842
6909
  aftermathLpSupplyType: (_a = path.extended_details) == null ? void 0 : _a.aftermath_lp_supply_type,
6843
6910
  turbosFeeType: (_b = path.extended_details) == null ? void 0 : _b.turbos_fee_type,
@@ -6845,7 +6912,14 @@ function parseRouterResponse(data, byAmountIn) {
6845
6912
  deepbookv3DeepFee: (_d = path.extended_details) == null ? void 0 : _d.deepbookv3_deep_fee,
6846
6913
  scallopScoinTreasury: (_e = path.extended_details) == null ? void 0 : _e.scallop_scoin_treasury,
6847
6914
  haedalPmmBasePriceSeed: (_f = path.extended_details) == null ? void 0 : _f.haedal_pmm_base_price_seed,
6848
- haedalPmmQuotePriceSeed: (_g = path.extended_details) == null ? void 0 : _g.haedal_pmm_quote_price_seed
6915
+ haedalPmmQuotePriceSeed: (_g = path.extended_details) == null ? void 0 : _g.haedal_pmm_quote_price_seed,
6916
+ steammfeBankA: (_h = path.extended_details) == null ? void 0 : _h.steammfe_bank_a,
6917
+ steammfeBankB: (_i = path.extended_details) == null ? void 0 : _i.steammfe_bank_b,
6918
+ steammfeLendingMarket: (_j = path.extended_details) == null ? void 0 : _j.steammfe_lending_market,
6919
+ steammfeLendingMarketType: (_k = path.extended_details) == null ? void 0 : _k.steammfe_lending_market_type,
6920
+ steammfeBCoinAType: (_l = path.extended_details) == null ? void 0 : _l.steammfe_btoken_a_type,
6921
+ steammfeBCoinBType: (_m = path.extended_details) == null ? void 0 : _m.steammfe_btoken_b_type,
6922
+ steammfeLPToken: (_n = path.extended_details) == null ? void 0 : _n.steammfe_lp_token_type
6849
6923
  };
6850
6924
  }
6851
6925
  return {
@@ -6871,9 +6945,7 @@ function parseRouterResponse(data, byAmountIn) {
6871
6945
  };
6872
6946
  return routerData;
6873
6947
  }
6874
-
6875
- // src/transaction/index.ts
6876
- var CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
6948
+ var CLOCK_ADDRESS = SUI_CLOCK_OBJECT_ID;
6877
6949
  var AGGREGATOR_V2 = "aggregator_v2";
6878
6950
  var AGGREGATOR_V2_EXTEND = "aggregator_v2_extend";
6879
6951
  function getAggregatorV2PublishedAt(aggregatorV2PublishedAt, packages) {
@@ -6979,6 +7051,7 @@ function getRouterResult(endpoint, params) {
6979
7051
  };
6980
7052
  }
6981
7053
  if (data.data != null) {
7054
+ console.log("data.data", JSON.stringify(data.data, null, 2));
6982
7055
  const res = parseRouterResponse(data.data, params.byAmountIn);
6983
7056
  return res;
6984
7057
  }
@@ -7031,7 +7104,7 @@ function getRouter(endpoint, params) {
7031
7104
  url += `&providers=${providers.join(",")}`;
7032
7105
  }
7033
7106
  }
7034
- url += "&v=1000323";
7107
+ url += "&v=1000325";
7035
7108
  const response = yield fetch(url);
7036
7109
  return response;
7037
7110
  } catch (error) {
@@ -7121,4 +7194,4 @@ decimal.js/decimal.mjs:
7121
7194
  *)
7122
7195
  */
7123
7196
 
7124
- export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI, AggregatorClient19 as AggregatorClient, BLUEFIN, BLUEMOVE, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, Env, FLOWXV2, FLOWXV3, HAEDAL, HAEDALPMM, KRIYA, KRIYAV3, ONE, SCALLOP, SPRINGSUI, SUILEND, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, buildInputCoin, checkInvalidSuiAddress, compareCoins, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, findPythPriceIDs, fixSuiObjectId, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
7197
+ export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI, AggregatorClient20 as AggregatorClient, BLUEFIN, BLUEMOVE, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, Env, FLOWXV2, FLOWXV3, HAEDAL, HAEDALPMM, KRIYA, KRIYAV3, ONE, SCALLOP, SPRINGSUI, STEAMM, SUILEND, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, buildInputCoin, checkInvalidSuiAddress, compareCoins, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, findPythPriceIDs, fixSuiObjectId, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
package/dist/src/api.d.ts CHANGED
@@ -27,6 +27,13 @@ export type ExtendedDetails = {
27
27
  scallopScoinTreasury?: string;
28
28
  haedalPmmBasePriceSeed?: string;
29
29
  haedalPmmQuotePriceSeed?: string;
30
+ steammBankA?: string;
31
+ steammBankB?: string;
32
+ steammLendingMarket?: string;
33
+ steammLendingMarketType?: string;
34
+ steammBCoinAType?: string;
35
+ steammBCoinBType?: string;
36
+ steammLPToken?: string;
30
37
  };
31
38
  export type Path = {
32
39
  id: string;
@@ -23,6 +23,7 @@ export declare const BLUEFIN = "BLUEFIN";
23
23
  export declare const HAEDALPMM = "HAEDALPMM";
24
24
  export declare const ALPHAFI = "ALPHAFI";
25
25
  export declare const SPRINGSUI = "SPRINGSUI";
26
+ export declare const STEAMM = "STEAMM";
26
27
  export declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
27
28
  export type BuildRouterSwapParams = {
28
29
  routers: Router[];
@@ -1,6 +1,6 @@
1
1
  import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
2
2
  import { AggregatorClient, Path } from "..";
3
- export declare const CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
3
+ export declare const CLOCK_ADDRESS: string;
4
4
  export declare const AGGREGATOR_V2 = "aggregator_v2";
5
5
  export declare const AGGREGATOR_V2_EXTEND = "aggregator_v2_extend";
6
6
  export declare function getAggregatorV2PublishedAt(aggregatorV2PublishedAt: string, packages?: Map<string, string> | Record<string, string>): string;
@@ -0,0 +1,6 @@
1
+ import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
2
+ import { AggregatorClient, Dex, Env, Path } from "..";
3
+ export declare class Steamm implements Dex {
4
+ constructor(env: Env);
5
+ swap(client: AggregatorClient, txb: Transaction, path: Path, inputCoin: TransactionObjectArgument, packages?: Map<string, string>): Promise<TransactionObjectArgument>;
6
+ }
@@ -0,0 +1,2 @@
1
+ import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
2
+ export declare function buildTestAccount(): Ed25519Keypair;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cetusprotocol/aggregator-sdk",
3
- "version": "0.3.23",
3
+ "version": "0.3.25",
4
4
  "sideEffects": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/api.ts CHANGED
@@ -29,14 +29,28 @@ export interface PreSwapLpChangeParams {
29
29
  }
30
30
 
31
31
  export type ExtendedDetails = {
32
+ // aftermath
32
33
  aftermathPoolFlatness?: number
33
34
  aftermathLpSupplyType?: string
35
+ // turbos
34
36
  turbosFeeType?: string
37
+ // cetus
35
38
  afterSqrtPrice?: string
39
+ // deepbookv3
36
40
  deepbookv3DeepFee?: number
41
+ // scallop
37
42
  scallopScoinTreasury?: string
43
+ // haedal
38
44
  haedalPmmBasePriceSeed?: string
39
45
  haedalPmmQuotePriceSeed?: string
46
+ // steamm
47
+ steammBankA?: string
48
+ steammBankB?: string
49
+ steammLendingMarket?: string
50
+ steammLendingMarketType?: string
51
+ steammBCoinAType?: string
52
+ steammBCoinBType?: string
53
+ steammLPToken?: string
40
54
  }
41
55
 
42
56
  export type Path = {
@@ -130,6 +144,7 @@ export async function getRouterResult(
130
144
  }
131
145
  }
132
146
  if (data.data != null) {
147
+ console.log("data.data", JSON.stringify(data.data, null, 2))
133
148
  const res = parseRouterResponse(data.data, params.byAmountIn)
134
149
  return res
135
150
  }
@@ -190,7 +205,7 @@ async function getRouter(endpoint: string, params: FindRouterParams) {
190
205
  }
191
206
 
192
207
  // set newest sdk version
193
- url += "&v=1000323"
208
+ url += "&v=1000325"
194
209
 
195
210
  const response = await fetch(url)
196
211
  return response
package/src/client.ts CHANGED
@@ -47,6 +47,7 @@ import {
47
47
  SuiPriceServiceConnection,
48
48
  SuiPythClient,
49
49
  } from "@pythnetwork/pyth-sui-js"
50
+ import { Steamm } from "./transaction/steamm"
50
51
 
51
52
  export const CETUS = "CETUS"
52
53
  export const DEEPBOOKV2 = "DEEPBOOK"
@@ -67,6 +68,7 @@ export const BLUEFIN = "BLUEFIN"
67
68
  export const HAEDALPMM = "HAEDALPMM"
68
69
  export const ALPHAFI = "ALPHAFI"
69
70
  export const SPRINGSUI = "SPRINGSUI"
71
+ export const STEAMM = "STEAMM"
70
72
  export const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2"
71
73
 
72
74
  export type BuildRouterSwapParams = {
@@ -580,9 +582,8 @@ export class AggregatorClient {
580
582
  publishedAtV2(): string {
581
583
  if (this.env === Env.Mainnet) {
582
584
  // return "0x3fb42ddf908af45f9fc3c59eab227888ff24ba2e137b3b55bf80920fd47e11af" // version 6
583
- // return "0x4069913c4953297b7f08f67f6722e3b04aa5ab2976b4e1b8a456b81590b34ab4"
584
- // return "0xf9c6f78322ed667909e05f6b42b2f5a67af6297503c905335e02a15148e9440d"
585
- return "0x2485feb9d42c7c3bcb8ecde555ad40f1b073d9fb4faf354fa2d30a0b183a23ce"
585
+ // return "0xf9c6f78322ed667909e05f6b42b2f5a67af6297503c905335e02a15148e9440d" // version 7
586
+ return "0x2485feb9d42c7c3bcb8ecde555ad40f1b073d9fb4faf354fa2d30a0b183a23ce" // version 8
586
587
  // return "0x803db8dfcc86fc1afbc7d2212bd14ec9690978ddebea0d590e01147d6b17aa06" // pre
587
588
  } else {
588
589
  // return "0x0ed287d6c3fe4962d0994ffddc1d19a15fba6a81533f3f0dcc2bbcedebce0637" // version 2
@@ -599,7 +600,8 @@ export class AggregatorClient {
599
600
  // return "0x3b6d71bdeb8ce5b06febfd3cfc29ecd60d50da729477c8b8038ecdae34541b91" // version 5, add bluefin
600
601
  // return "0x81ade554cb24a7564ca43a4bfb7381b08d9e5c5f375162c95215b696ab903502" // version 6, force upgrade scallop
601
602
  // return "0x347dd58bbd11cd82c8b386b344729717c04a998da73386e82a239cc196d5706b" // version 7
602
- return "0xf2fcea41dc217385019828375764fa06d9bd25e8e4726ba1962680849fb8d613" // version 8
603
+ // return "0xf2fcea41dc217385019828375764fa06d9bd25e8e4726ba1962680849fb8d613" // version 8
604
+ return "0xa2d8a4279d69d8fec04b2fea8852d0d467d3cc0d39c5890180d439ae7a9953ed" // version 9
603
605
  } else {
604
606
  return "0xabb6a81c8a216828e317719e06125de5bb2cb0fe8f9916ff8c023ca5be224c78"
605
607
  }
@@ -696,6 +698,8 @@ export class AggregatorClient {
696
698
  return new HaedalPmm(this.env, pythPriceIDs)
697
699
  case ALPHAFI:
698
700
  return new Alphafi(this.env)
701
+ case STEAMM:
702
+ return new Steamm(this.env)
699
703
  default:
700
704
  throw new Error(`Unsupported dex ${provider}`)
701
705
  }
@@ -845,7 +849,8 @@ export function parseRouterResponse(
845
849
  path.provider === CETUS ||
846
850
  path.provider === DEEPBOOKV3 ||
847
851
  path.provider === SCALLOP ||
848
- path.provider === HAEDALPMM
852
+ path.provider === HAEDALPMM ||
853
+ path.provider === STEAMM
849
854
  ) {
850
855
  extendedDetails = {
851
856
  aftermathLpSupplyType:
@@ -859,6 +864,13 @@ export function parseRouterResponse(
859
864
  path.extended_details?.haedal_pmm_base_price_seed,
860
865
  haedalPmmQuotePriceSeed:
861
866
  path.extended_details?.haedal_pmm_quote_price_seed,
867
+ steammfeBankA: path.extended_details?.steammfe_bank_a,
868
+ steammfeBankB: path.extended_details?.steammfe_bank_b,
869
+ steammfeLendingMarket: path.extended_details?.steammfe_lending_market,
870
+ steammfeLendingMarketType: path.extended_details?.steammfe_lending_market_type,
871
+ steammfeBCoinAType: path.extended_details?.steammfe_btoken_a_type,
872
+ steammfeBCoinBType: path.extended_details?.steammfe_btoken_b_type,
873
+ steammfeLPToken: path.extended_details?.steammfe_lp_token_type,
862
874
  }
863
875
  }
864
876
 
@@ -1,6 +1,5 @@
1
1
  import {
2
2
  Transaction,
3
- TransactionArgument,
4
3
  TransactionObjectArgument,
5
4
  } from "@mysten/sui/transactions"
6
5
  import { AggregatorClient, Dex, Env, getAggregatorV2PublishedAt, Path } from ".."
@@ -3,9 +3,9 @@ import {
3
3
  TransactionObjectArgument,
4
4
  } from "@mysten/sui/transactions"
5
5
  import { AggregatorClient, Path } from ".."
6
+ import { SUI_CLOCK_OBJECT_ID } from "@mysten/sui/utils"
6
7
 
7
- export const CLOCK_ADDRESS =
8
- "0x0000000000000000000000000000000000000000000000000000000000000006"
8
+ export const CLOCK_ADDRESS = SUI_CLOCK_OBJECT_ID
9
9
 
10
10
  export const AGGREGATOR_V2 = "aggregator_v2"
11
11
  export const AGGREGATOR_V2_EXTEND = "aggregator_v2_extend"
@@ -0,0 +1,77 @@
1
+ import {
2
+ Transaction,
3
+ TransactionObjectArgument,
4
+ } from "@mysten/sui/transactions"
5
+ import { AggregatorClient, CLOCK_ADDRESS, Dex, Env, getAggregatorV2ExtendPublishedAt, Path } from ".."
6
+
7
+ export class Steamm implements Dex {
8
+ constructor(env: Env) {
9
+ if (env !== Env.Mainnet) {
10
+ throw new Error("Steamm only supported on mainnet")
11
+ }
12
+ }
13
+
14
+ async swap(
15
+ client: AggregatorClient,
16
+ txb: Transaction,
17
+ path: Path,
18
+ inputCoin: TransactionObjectArgument,
19
+ packages?: Map<string, string>
20
+ ): Promise<TransactionObjectArgument> {
21
+ const { direction, from, target } = path
22
+
23
+ const [func, coinAType, coinBType] = direction
24
+ ? ["swap_a2b", from, target]
25
+ : ["swap_b2a", target, from]
26
+
27
+ if (path.extendedDetails == null) {
28
+ throw new Error("Extended details not supported")
29
+ } else {
30
+ if (path.extendedDetails.steammBankA == null) {
31
+ throw new Error("Steamm bank a type not supported")
32
+ }
33
+ if (path.extendedDetails.steammBankB == null) {
34
+ throw new Error("Steamm bank b type not supported")
35
+ }
36
+ if (path.extendedDetails.steammLendingMarket == null) {
37
+ throw new Error("Steamm lending market not supported")
38
+ }
39
+ if (path.extendedDetails.steammLendingMarketType == null) {
40
+ throw new Error("Steamm lending market type not supported")
41
+ }
42
+ if (path.extendedDetails.steammBCoinAType == null) {
43
+ throw new Error("Steamm b coin a type not supported")
44
+ }
45
+ if (path.extendedDetails.steammBCoinBType == null) {
46
+ throw new Error("Steamm b coin b type not supported")
47
+ }
48
+ if (path.extendedDetails.steammLPToken == null) {
49
+ throw new Error("Steamm lp token not supported")
50
+ }
51
+ }
52
+
53
+ const args = [
54
+ txb.object(path.id),
55
+ txb.object(path.extendedDetails.steammBankA),
56
+ txb.object(path.extendedDetails.steammBankB),
57
+ txb.object(path.extendedDetails.steammLendingMarket),
58
+ inputCoin,
59
+ txb.object(CLOCK_ADDRESS),
60
+ ]
61
+ const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages)
62
+ const res = txb.moveCall({
63
+ target: `${publishedAt}::steammfe::${func}`,
64
+ typeArguments: [
65
+ path.extendedDetails.steammLendingMarketType,
66
+ coinAType,
67
+ coinBType,
68
+ path.extendedDetails.steammBCoinAType,
69
+ path.extendedDetails.steammBCoinBType,
70
+ path.extendedDetails.steammLPToken,
71
+ ],
72
+ arguments: args,
73
+ }) as TransactionObjectArgument
74
+
75
+ return res
76
+ }
77
+ }
@@ -0,0 +1,124 @@
1
+ import { describe, test } from "@jest/globals"
2
+ import dotenv from "dotenv"
3
+ import { AggregatorClient } from "~/client"
4
+ import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519"
5
+ import { printTransaction } from "~/utils/transaction"
6
+ import BN from "bn.js"
7
+ import { fromB64 } from "@mysten/sui/utils"
8
+ import { SuiClient } from "@mysten/sui/client"
9
+ import { Env } from "~/index"
10
+ import { Transaction } from "@mysten/sui/transactions"
11
+
12
+ dotenv.config()
13
+
14
+ export function buildTestAccount(): Ed25519Keypair {
15
+ const mnemonics = process.env.SUI_WALLET_MNEMONICS || ""
16
+ const testAccountObject = Ed25519Keypair.deriveKeypair(mnemonics)
17
+ return testAccountObject
18
+ }
19
+
20
+ describe("Test steammfe module", () => {
21
+ let client: AggregatorClient
22
+ let keypair: Ed25519Keypair
23
+
24
+ const T_SUI = "0x2e868e44010e06c0fc925d29f35029b6ef75a50e03d997585980fb2acea45ec6::sui::SUI"
25
+ const T_USDC = "0x2e868e44010e06c0fc925d29f35029b6ef75a50e03d997585980fb2acea45ec6::usdc::USDC"
26
+
27
+ beforeAll(() => {
28
+ const fullNodeURL = process.env.SUI_RPC!
29
+ const aggregatorURL = process.env.CETUS_AGGREGATOR!
30
+ const secret = process.env.SUI_WALLET_SECRET!
31
+
32
+ if (secret) {
33
+ keypair = Ed25519Keypair.fromSecretKey(fromB64(secret).slice(1, 33))
34
+ } else {
35
+ keypair = buildTestAccount()
36
+ }
37
+
38
+ // const wallet = keypair.getPublicKey().toSuiAddress()
39
+ const wallet =
40
+ "0xb0deeb083fb5738e2d76820a3e59a284adbd56ab1b1d71d606cda8ea71cffe90"
41
+
42
+ console.log("wallet: ", wallet)
43
+
44
+ const endpoint = aggregatorURL
45
+
46
+ const suiClient = new SuiClient({
47
+ url: fullNodeURL,
48
+ })
49
+
50
+ client = new AggregatorClient(endpoint, wallet, suiClient, Env.Mainnet)
51
+ })
52
+
53
+ test("Find Routers", async () => {
54
+ const amounts = ["1000", "1000000", "100000000", "5000000000", "10000000000000"]
55
+
56
+ for (const amount of amounts) {
57
+ const res = await client.findRouters({
58
+ from: T_USDC,
59
+ target: T_SUI,
60
+ amount: new BN(amount),
61
+ byAmountIn: true,
62
+ depth: 3,
63
+ splitCount: 1,
64
+ providers: ["STEAMMFE"],
65
+ })
66
+
67
+ if (res != null) {
68
+ console.log(JSON.stringify(res, null, 2))
69
+ }
70
+ console.log("amount in", res?.amountIn.toString())
71
+ console.log("amount out", res?.amountOut.toString())
72
+ }
73
+ })
74
+
75
+ test("Build Router TX", async () => {
76
+ const amount = "100000"
77
+
78
+ const res = await client.findRouters({
79
+ from: T_USDC,
80
+ target: T_SUI,
81
+ amount: new BN(amount),
82
+ byAmountIn: true,
83
+ depth: 3,
84
+ providers: ["STEAMMFE"],
85
+ })
86
+
87
+ console.log("amount in", res?.amountIn.toString())
88
+ console.log("amount out", res?.amountOut.toString())
89
+
90
+ const txb = new Transaction()
91
+
92
+ if (res != null) {
93
+ console.log(JSON.stringify(res, null, 2))
94
+ await client.fastRouterSwap({
95
+ routers: res,
96
+ txb,
97
+ slippage: 0.01,
98
+ refreshAllCoins: true,
99
+ payDeepFeeAmount: 0,
100
+ })
101
+
102
+ txb.setSender(client.signer)
103
+ const buildTxb = await txb.build({ client: client.client })
104
+ // const buildTxb = await txb.getData()
105
+
106
+ console.log("buildTxb", buildTxb)
107
+
108
+ printTransaction(txb)
109
+
110
+ let result = await client.devInspectTransactionBlock(txb)
111
+ console.log("🚀 ~ file: router.test.ts:180 ~ test ~ result:", result)
112
+ for (const event of result.events) {
113
+ console.log("event", JSON.stringify(event, null, 2))
114
+ }
115
+
116
+ if (result.effects.status.status === "success") {
117
+ const result = await client.signAndExecuteTransaction(txb, keypair)
118
+ console.log("result", result)
119
+ } else {
120
+ console.log("result", result)
121
+ }
122
+ }
123
+ }, 600000)
124
+ })