@cetusprotocol/aggregator-sdk 0.13.0 → 0.14.0

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
@@ -88,6 +88,7 @@ declare const STEAMM_OMM = "STEAMM_OMM";
88
88
  declare const MOMENTUM = "MOMENTUM";
89
89
  declare const STEAMM_OMM_V2 = "STEAMM_OMM_V2";
90
90
  declare const MAGMA = "MAGMA";
91
+ declare const SEVENK = "SEVENK";
91
92
  declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
92
93
  declare const ALL_DEXES: string[];
93
94
  type BuildRouterSwapParams = {
@@ -302,6 +303,11 @@ type ExtendedDetails = {
302
303
  obricCoinBPriceSeed?: string;
303
304
  obricCoinAPriceId?: string;
304
305
  obricCoinBPriceId?: string;
306
+ sevenkCoinAPriceSeed?: string;
307
+ sevenkCoinBPriceSeed?: string;
308
+ sevenkCoinAOracleId?: string;
309
+ sevenkCoinBOracleId?: string;
310
+ sevenkLPCapType?: string;
305
311
  };
306
312
  type Path = {
307
313
  id: string;
@@ -366,4 +372,4 @@ declare enum Env {
366
372
  Testnet = 1
367
373
  }
368
374
 
369
- export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, AGGREGATOR_V2_EXTEND2, ALL_DEXES, ALPHAFI, AggregatorClient, type AggregatorClientParams, 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, HAWAL, KRIYA, KRIYAV3, MAGMA, METASTABLE, MOMENTUM, OBRIC, ONE, type Path, type PreSwapLpChangeParams, type Router, type RouterData, type RouterError, SCALLOP, SPRINGSUI, STEAMM, STEAMM_OMM, STEAMM_OMM_V2, 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, getAggregatorV2Extend2PublishedAt, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getAllProviders, getDeepbookV3Config, getProvidersExcluding, getProvidersIncluding, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
375
+ export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, AGGREGATOR_V2_EXTEND2, ALL_DEXES, ALPHAFI, AggregatorClient, type AggregatorClientParams, 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, HAWAL, KRIYA, KRIYAV3, MAGMA, METASTABLE, MOMENTUM, OBRIC, ONE, type Path, type PreSwapLpChangeParams, type Router, type RouterData, type RouterError, SCALLOP, SEVENK, SPRINGSUI, STEAMM, STEAMM_OMM, STEAMM_OMM_V2, 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, getAggregatorV2Extend2PublishedAt, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getAllProviders, getDeepbookV3Config, getProvidersExcluding, getProvidersIncluding, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
package/dist/index.d.ts CHANGED
@@ -88,6 +88,7 @@ declare const STEAMM_OMM = "STEAMM_OMM";
88
88
  declare const MOMENTUM = "MOMENTUM";
89
89
  declare const STEAMM_OMM_V2 = "STEAMM_OMM_V2";
90
90
  declare const MAGMA = "MAGMA";
91
+ declare const SEVENK = "SEVENK";
91
92
  declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
92
93
  declare const ALL_DEXES: string[];
93
94
  type BuildRouterSwapParams = {
@@ -302,6 +303,11 @@ type ExtendedDetails = {
302
303
  obricCoinBPriceSeed?: string;
303
304
  obricCoinAPriceId?: string;
304
305
  obricCoinBPriceId?: string;
306
+ sevenkCoinAPriceSeed?: string;
307
+ sevenkCoinBPriceSeed?: string;
308
+ sevenkCoinAOracleId?: string;
309
+ sevenkCoinBOracleId?: string;
310
+ sevenkLPCapType?: string;
305
311
  };
306
312
  type Path = {
307
313
  id: string;
@@ -366,4 +372,4 @@ declare enum Env {
366
372
  Testnet = 1
367
373
  }
368
374
 
369
- export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, AGGREGATOR_V2_EXTEND2, ALL_DEXES, ALPHAFI, AggregatorClient, type AggregatorClientParams, 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, HAWAL, KRIYA, KRIYAV3, MAGMA, METASTABLE, MOMENTUM, OBRIC, ONE, type Path, type PreSwapLpChangeParams, type Router, type RouterData, type RouterError, SCALLOP, SPRINGSUI, STEAMM, STEAMM_OMM, STEAMM_OMM_V2, 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, getAggregatorV2Extend2PublishedAt, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getAllProviders, getDeepbookV3Config, getProvidersExcluding, getProvidersIncluding, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
375
+ export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, AGGREGATOR_V2_EXTEND2, ALL_DEXES, ALPHAFI, AggregatorClient, type AggregatorClientParams, 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, HAWAL, KRIYA, KRIYAV3, MAGMA, METASTABLE, MOMENTUM, OBRIC, ONE, type Path, type PreSwapLpChangeParams, type Router, type RouterData, type RouterError, SCALLOP, SEVENK, SPRINGSUI, STEAMM, STEAMM_OMM, STEAMM_OMM_V2, 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, getAggregatorV2Extend2PublishedAt, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getAllProviders, getDeepbookV3Config, getProvidersExcluding, getProvidersIncluding, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
package/dist/index.js CHANGED
@@ -4,6 +4,11 @@ var client = require('@mysten/sui/client');
4
4
  var utils = require('@mysten/sui/utils');
5
5
  var transactions = require('@mysten/sui/transactions');
6
6
  var pythSuiJs = require('@pythnetwork/pyth-sui-js');
7
+ var JSONbig = require('json-bigint');
8
+
9
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
+
11
+ var JSONbig__default = /*#__PURE__*/_interopDefault(JSONbig);
7
12
 
8
13
  var __create = Object.create;
9
14
  var __defProp = Object.defineProperty;
@@ -6783,6 +6788,87 @@ var Magma = class {
6783
6788
  }
6784
6789
  };
6785
6790
 
6791
+ // src/transaction/sevenk.ts
6792
+ var Sevenk = class {
6793
+ constructor(env, pythPriceIDs) {
6794
+ if (env === 1 /* Testnet */) {
6795
+ throw new Error("Sevenk is not supported on testnet");
6796
+ }
6797
+ this.pythPriceIDs = pythPriceIDs;
6798
+ this.oraclePublishedAt = "0x8c36ea167c5e6da8c3d60b4fc897416105dcb986471bd81cfbfd38720a4487c0";
6799
+ }
6800
+ swap(client, txb, path, inputCoin, packages) {
6801
+ return __async(this, null, function* () {
6802
+ const { direction, from, target } = path;
6803
+ const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
6804
+ let coinAPriceSeed;
6805
+ let coinBPriceSeed;
6806
+ let coinAOracleId;
6807
+ let coinBOracleId;
6808
+ let lpCapType;
6809
+ if (path.extendedDetails == null) {
6810
+ throw new Error("Extended details not supported haedal pmm");
6811
+ } else {
6812
+ if (!path.extendedDetails.sevenkCoinAPriceSeed || !path.extendedDetails.sevenkCoinBPriceSeed || !path.extendedDetails.sevenkCoinAOracleId || !path.extendedDetails.sevenkCoinBOracleId || !path.extendedDetails.sevenkLPCapType) {
6813
+ throw new Error("Base price seed or quote price seed not supported");
6814
+ }
6815
+ coinAPriceSeed = path.extendedDetails.sevenkCoinAPriceSeed;
6816
+ coinBPriceSeed = path.extendedDetails.sevenkCoinBPriceSeed;
6817
+ coinAOracleId = path.extendedDetails.sevenkCoinAOracleId;
6818
+ coinBOracleId = path.extendedDetails.sevenkCoinBOracleId;
6819
+ lpCapType = path.extendedDetails.sevenkLPCapType;
6820
+ }
6821
+ const coinAPriceInfoObjectId = this.pythPriceIDs.get(coinAPriceSeed);
6822
+ const coinBPriceInfoObjectId = this.pythPriceIDs.get(coinBPriceSeed);
6823
+ if (!coinAPriceInfoObjectId || !coinBPriceInfoObjectId) {
6824
+ throw new Error(
6825
+ "Base price info object id or quote price info object id not found"
6826
+ );
6827
+ }
6828
+ const holder = txb.moveCall({
6829
+ target: `${this.oraclePublishedAt}::oracle::new_holder`,
6830
+ typeArguments: [],
6831
+ arguments: []
6832
+ });
6833
+ txb.moveCall({
6834
+ target: `${this.oraclePublishedAt}::pyth::get_price`,
6835
+ typeArguments: [],
6836
+ arguments: [
6837
+ txb.object(coinAOracleId),
6838
+ holder,
6839
+ txb.object(coinAPriceInfoObjectId),
6840
+ txb.object(CLOCK_ADDRESS)
6841
+ ]
6842
+ });
6843
+ txb.moveCall({
6844
+ target: `${this.oraclePublishedAt}::pyth::get_price`,
6845
+ typeArguments: [],
6846
+ arguments: [
6847
+ txb.object(coinBOracleId),
6848
+ holder,
6849
+ txb.object(coinBPriceInfoObjectId),
6850
+ txb.object(CLOCK_ADDRESS)
6851
+ ]
6852
+ });
6853
+ const args = [
6854
+ txb.object(path.id),
6855
+ holder,
6856
+ inputCoin
6857
+ ];
6858
+ const publishedAt = getAggregatorV2Extend2PublishedAt(
6859
+ client.publishedAtV2Extend2(),
6860
+ packages
6861
+ );
6862
+ const res = txb.moveCall({
6863
+ target: `${publishedAt}::sevenk::${func}`,
6864
+ typeArguments: [coinAType, coinBType, lpCapType],
6865
+ arguments: args
6866
+ });
6867
+ return res;
6868
+ });
6869
+ }
6870
+ };
6871
+
6786
6872
  // src/client.ts
6787
6873
  var CETUS = "CETUS";
6788
6874
  var DEEPBOOKV2 = "DEEPBOOK";
@@ -6811,6 +6897,7 @@ var STEAMM_OMM = "STEAMM_OMM";
6811
6897
  var MOMENTUM = "MOMENTUM";
6812
6898
  var STEAMM_OMM_V2 = "STEAMM_OMM_V2";
6813
6899
  var MAGMA = "MAGMA";
6900
+ var SEVENK = "SEVENK";
6814
6901
  var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
6815
6902
  var ALL_DEXES = [
6816
6903
  CETUS,
@@ -6838,7 +6925,8 @@ var ALL_DEXES = [
6838
6925
  MOMENTUM,
6839
6926
  STEAMM_OMM,
6840
6927
  STEAMM_OMM_V2,
6841
- MAGMA
6928
+ MAGMA,
6929
+ SEVENK
6842
6930
  ];
6843
6931
  function isBuilderRouterSwapParams(params) {
6844
6932
  return Array.isArray(params.routers);
@@ -7069,10 +7157,18 @@ var _AggregatorClient = class _AggregatorClient {
7069
7157
  );
7070
7158
  for (let i = 0; i < routers.length; i++) {
7071
7159
  const router = routers[i];
7072
- let amount_arg = txb.pure.u64(router.amountOut.toString());
7160
+ let amount_arg = txb.pure.u64(
7161
+ router.amountOut.toString()
7162
+ );
7073
7163
  for (let j = router.path.length - 1; j >= 0; j--) {
7074
7164
  const path = router.path[j];
7075
- const flashSwapResult = dex.flash_swap(this, txb, path, amount_arg, false);
7165
+ const flashSwapResult = dex.flash_swap(
7166
+ this,
7167
+ txb,
7168
+ path,
7169
+ amount_arg,
7170
+ false
7171
+ );
7076
7172
  amount_arg = flashSwapResult.payAmount;
7077
7173
  returnCoins.unshift(flashSwapResult.targetCoin);
7078
7174
  receipts.unshift(flashSwapResult.flashReceipt);
@@ -7377,7 +7473,7 @@ var _AggregatorClient = class _AggregatorClient {
7377
7473
  // Include cetus、deepbookv2、flowxv2 & v3、kriyav2 & v3、turbos、aftermath、haedal、afsui、volo、bluemove
7378
7474
  publishedAtV2() {
7379
7475
  if (this.env === 0 /* Mainnet */) {
7380
- return "0x47a7b90756fba96fe649c2aaa10ec60dec6b8cb8545573d621310072721133aa";
7476
+ return "0x8ae871505a80d8bf6bf9c05906cda6edfeea460c85bebe2e26a4313f5e67874a";
7381
7477
  } else {
7382
7478
  return "0x52eae33adeb44de55cfb3f281d4cc9e02d976181c0952f5323648b5717b33934";
7383
7479
  }
@@ -7385,14 +7481,14 @@ var _AggregatorClient = class _AggregatorClient {
7385
7481
  // Include deepbookv3, scallop, bluefin
7386
7482
  publishedAtV2Extend() {
7387
7483
  if (this.env === 0 /* Mainnet */) {
7388
- return "0x8093d002bba575f1378b0da206a8df1fc55c4b5b3718752304f1b67a505d2be4";
7484
+ return "0x8a2f7a5b20665eeccc79de3aa37c3b6c473eca233ada1e1cd4678ec07d4d4073";
7389
7485
  } else {
7390
7486
  return "0xabb6a81c8a216828e317719e06125de5bb2cb0fe8f9916ff8c023ca5be224c78";
7391
7487
  }
7392
7488
  }
7393
7489
  publishedAtV2Extend2() {
7394
7490
  if (this.env === 0 /* Mainnet */) {
7395
- return "0xc40b43f0aa4ba5a4d71e39770265d3698d0e6dcfd846b7d7c443207f4e919e04";
7491
+ return "0x5cb7499fc49c2642310e24a4ecffdbee00133f97e80e2b45bca90c64d55de880";
7396
7492
  } else {
7397
7493
  return "0x0";
7398
7494
  }
@@ -7503,6 +7599,8 @@ var _AggregatorClient = class _AggregatorClient {
7503
7599
  return new SteammOmmV2(this.env, pythPriceIDs);
7504
7600
  case MAGMA:
7505
7601
  return new Magma(this.env);
7602
+ case SEVENK:
7603
+ return new Sevenk(this.env, pythPriceIDs);
7506
7604
  default:
7507
7605
  throw new Error(`Unsupported dex ${provider}`);
7508
7606
  }
@@ -7598,7 +7696,7 @@ _AggregatorClient.CONFIG = {
7598
7696
  pythStateId: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8"
7599
7697
  }
7600
7698
  };
7601
- var AggregatorClient27 = _AggregatorClient;
7699
+ var AggregatorClient28 = _AggregatorClient;
7602
7700
  function findPythPriceIDs(routes) {
7603
7701
  const priceIDs = /* @__PURE__ */ new Set();
7604
7702
  for (const route of routes) {
@@ -7633,6 +7731,14 @@ function findPythPriceIDs(routes) {
7633
7731
  priceIDs.add(path.extendedDetails.steammOraclePythPriceSeedB);
7634
7732
  }
7635
7733
  }
7734
+ if (path.provider === SEVENK) {
7735
+ if (path.extendedDetails && path.extendedDetails.sevenkCoinAPriceSeed) {
7736
+ priceIDs.add(path.extendedDetails.sevenkCoinAPriceSeed);
7737
+ }
7738
+ if (path.extendedDetails && path.extendedDetails.sevenkCoinBPriceSeed) {
7739
+ priceIDs.add(path.extendedDetails.sevenkCoinBPriceSeed);
7740
+ }
7741
+ }
7636
7742
  }
7637
7743
  }
7638
7744
  return Array.from(priceIDs);
@@ -7661,13 +7767,13 @@ function parseRouterResponse(data, byAmountIn) {
7661
7767
  routes: data.routes.map((route) => {
7662
7768
  return {
7663
7769
  path: route.path.map((path) => {
7664
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D;
7770
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I;
7665
7771
  let version;
7666
7772
  if (path.provider === AFTERMATH) {
7667
7773
  version = path.extended_details.aftermath_pool_flatness === 0 ? "v2" : "v3";
7668
7774
  }
7669
7775
  let extendedDetails;
7670
- if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS || path.provider === DEEPBOOKV3 || path.provider === SCALLOP || path.provider === HAEDALPMM || path.provider === METASTABLE || path.provider === OBRIC || path.provider === STEAMM || path.provider === STEAMM_OMM || path.provider === STEAMM_OMM_V2) {
7776
+ if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS || path.provider === DEEPBOOKV3 || path.provider === SCALLOP || path.provider === HAEDALPMM || path.provider === METASTABLE || path.provider === OBRIC || path.provider === STEAMM || path.provider === STEAMM_OMM || path.provider === STEAMM_OMM_V2 || path.provider === SEVENK) {
7671
7777
  extendedDetails = {
7672
7778
  aftermathLpSupplyType: (_a = path.extended_details) == null ? void 0 : _a.aftermath_lp_supply_type,
7673
7779
  turbosFeeType: (_b = path.extended_details) == null ? void 0 : _b.turbos_fee_type,
@@ -7698,7 +7804,12 @@ function parseRouterResponse(data, byAmountIn) {
7698
7804
  obricCoinAPriceSeed: (_A = path.extended_details) == null ? void 0 : _A.obric_coin_a_price_seed,
7699
7805
  obricCoinBPriceSeed: (_B = path.extended_details) == null ? void 0 : _B.obric_coin_b_price_seed,
7700
7806
  obricCoinAPriceId: (_C = path.extended_details) == null ? void 0 : _C.obric_coin_a_price_id,
7701
- obricCoinBPriceId: (_D = path.extended_details) == null ? void 0 : _D.obric_coin_b_price_id
7807
+ obricCoinBPriceId: (_D = path.extended_details) == null ? void 0 : _D.obric_coin_b_price_id,
7808
+ sevenkCoinAPriceSeed: (_E = path.extended_details) == null ? void 0 : _E.sevenk_coin_a_price_seed,
7809
+ sevenkCoinBPriceSeed: (_F = path.extended_details) == null ? void 0 : _F.sevenk_coin_b_price_seed,
7810
+ sevenkCoinAOracleId: (_G = path.extended_details) == null ? void 0 : _G.sevenk_oracle_config_a,
7811
+ sevenkCoinBOracleId: (_H = path.extended_details) == null ? void 0 : _H.sevenk_oracle_config_b,
7812
+ sevenkLPCapType: (_I = path.extended_details) == null ? void 0 : _I.sevenk_lp_cap_type
7702
7813
  };
7703
7814
  }
7704
7815
  return {
@@ -7795,7 +7906,7 @@ function processEndpoint(endpoint) {
7795
7906
 
7796
7907
  // src/api.ts
7797
7908
  var import_bn7 = __toESM(require_bn());
7798
- var SDK_VERSION = 1001300;
7909
+ var SDK_VERSION = 1001400;
7799
7910
  function getRouterResult(endpoint, apiKey, params, overlayFee, overlayFeeReceiver) {
7800
7911
  return __async(this, null, function* () {
7801
7912
  let response;
@@ -7824,7 +7935,7 @@ function getRouterResult(endpoint, apiKey, params, overlayFee, overlayFeeReceive
7824
7935
  }
7825
7936
  };
7826
7937
  }
7827
- const data = yield response.json();
7938
+ const data = JSONbig__default.default.parse(yield response.text());
7828
7939
  const insufficientLiquidity = data.msg === "liquidity is not enough";
7829
7940
  if (data.msg && data.msg.indexOf("HoneyPot scam") > -1) {
7830
7941
  return {
@@ -8006,7 +8117,7 @@ exports.AGGREGATOR_V2_EXTEND = AGGREGATOR_V2_EXTEND;
8006
8117
  exports.AGGREGATOR_V2_EXTEND2 = AGGREGATOR_V2_EXTEND2;
8007
8118
  exports.ALL_DEXES = ALL_DEXES;
8008
8119
  exports.ALPHAFI = ALPHAFI;
8009
- exports.AggregatorClient = AggregatorClient27;
8120
+ exports.AggregatorClient = AggregatorClient28;
8010
8121
  exports.BLUEFIN = BLUEFIN;
8011
8122
  exports.BLUEMOVE = BLUEMOVE;
8012
8123
  exports.CETUS = CETUS;
@@ -8028,6 +8139,7 @@ exports.MOMENTUM = MOMENTUM;
8028
8139
  exports.OBRIC = OBRIC;
8029
8140
  exports.ONE = ONE;
8030
8141
  exports.SCALLOP = SCALLOP;
8142
+ exports.SEVENK = SEVENK;
8031
8143
  exports.SPRINGSUI = SPRINGSUI;
8032
8144
  exports.STEAMM = STEAMM;
8033
8145
  exports.STEAMM_OMM = STEAMM_OMM;
package/dist/index.mjs CHANGED
@@ -2,6 +2,7 @@ import { SuiClient, getFullnodeUrl } from '@mysten/sui/client';
2
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 { SuiPythClient, SuiPriceServiceConnection } from '@pythnetwork/pyth-sui-js';
5
+ import JSONbig from 'json-bigint';
5
6
 
6
7
  var __create = Object.create;
7
8
  var __defProp = Object.defineProperty;
@@ -6781,6 +6782,87 @@ var Magma = class {
6781
6782
  }
6782
6783
  };
6783
6784
 
6785
+ // src/transaction/sevenk.ts
6786
+ var Sevenk = class {
6787
+ constructor(env, pythPriceIDs) {
6788
+ if (env === 1 /* Testnet */) {
6789
+ throw new Error("Sevenk is not supported on testnet");
6790
+ }
6791
+ this.pythPriceIDs = pythPriceIDs;
6792
+ this.oraclePublishedAt = "0x8c36ea167c5e6da8c3d60b4fc897416105dcb986471bd81cfbfd38720a4487c0";
6793
+ }
6794
+ swap(client, txb, path, inputCoin, packages) {
6795
+ return __async(this, null, function* () {
6796
+ const { direction, from, target } = path;
6797
+ const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
6798
+ let coinAPriceSeed;
6799
+ let coinBPriceSeed;
6800
+ let coinAOracleId;
6801
+ let coinBOracleId;
6802
+ let lpCapType;
6803
+ if (path.extendedDetails == null) {
6804
+ throw new Error("Extended details not supported haedal pmm");
6805
+ } else {
6806
+ if (!path.extendedDetails.sevenkCoinAPriceSeed || !path.extendedDetails.sevenkCoinBPriceSeed || !path.extendedDetails.sevenkCoinAOracleId || !path.extendedDetails.sevenkCoinBOracleId || !path.extendedDetails.sevenkLPCapType) {
6807
+ throw new Error("Base price seed or quote price seed not supported");
6808
+ }
6809
+ coinAPriceSeed = path.extendedDetails.sevenkCoinAPriceSeed;
6810
+ coinBPriceSeed = path.extendedDetails.sevenkCoinBPriceSeed;
6811
+ coinAOracleId = path.extendedDetails.sevenkCoinAOracleId;
6812
+ coinBOracleId = path.extendedDetails.sevenkCoinBOracleId;
6813
+ lpCapType = path.extendedDetails.sevenkLPCapType;
6814
+ }
6815
+ const coinAPriceInfoObjectId = this.pythPriceIDs.get(coinAPriceSeed);
6816
+ const coinBPriceInfoObjectId = this.pythPriceIDs.get(coinBPriceSeed);
6817
+ if (!coinAPriceInfoObjectId || !coinBPriceInfoObjectId) {
6818
+ throw new Error(
6819
+ "Base price info object id or quote price info object id not found"
6820
+ );
6821
+ }
6822
+ const holder = txb.moveCall({
6823
+ target: `${this.oraclePublishedAt}::oracle::new_holder`,
6824
+ typeArguments: [],
6825
+ arguments: []
6826
+ });
6827
+ txb.moveCall({
6828
+ target: `${this.oraclePublishedAt}::pyth::get_price`,
6829
+ typeArguments: [],
6830
+ arguments: [
6831
+ txb.object(coinAOracleId),
6832
+ holder,
6833
+ txb.object(coinAPriceInfoObjectId),
6834
+ txb.object(CLOCK_ADDRESS)
6835
+ ]
6836
+ });
6837
+ txb.moveCall({
6838
+ target: `${this.oraclePublishedAt}::pyth::get_price`,
6839
+ typeArguments: [],
6840
+ arguments: [
6841
+ txb.object(coinBOracleId),
6842
+ holder,
6843
+ txb.object(coinBPriceInfoObjectId),
6844
+ txb.object(CLOCK_ADDRESS)
6845
+ ]
6846
+ });
6847
+ const args = [
6848
+ txb.object(path.id),
6849
+ holder,
6850
+ inputCoin
6851
+ ];
6852
+ const publishedAt = getAggregatorV2Extend2PublishedAt(
6853
+ client.publishedAtV2Extend2(),
6854
+ packages
6855
+ );
6856
+ const res = txb.moveCall({
6857
+ target: `${publishedAt}::sevenk::${func}`,
6858
+ typeArguments: [coinAType, coinBType, lpCapType],
6859
+ arguments: args
6860
+ });
6861
+ return res;
6862
+ });
6863
+ }
6864
+ };
6865
+
6784
6866
  // src/client.ts
6785
6867
  var CETUS = "CETUS";
6786
6868
  var DEEPBOOKV2 = "DEEPBOOK";
@@ -6809,6 +6891,7 @@ var STEAMM_OMM = "STEAMM_OMM";
6809
6891
  var MOMENTUM = "MOMENTUM";
6810
6892
  var STEAMM_OMM_V2 = "STEAMM_OMM_V2";
6811
6893
  var MAGMA = "MAGMA";
6894
+ var SEVENK = "SEVENK";
6812
6895
  var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
6813
6896
  var ALL_DEXES = [
6814
6897
  CETUS,
@@ -6836,7 +6919,8 @@ var ALL_DEXES = [
6836
6919
  MOMENTUM,
6837
6920
  STEAMM_OMM,
6838
6921
  STEAMM_OMM_V2,
6839
- MAGMA
6922
+ MAGMA,
6923
+ SEVENK
6840
6924
  ];
6841
6925
  function isBuilderRouterSwapParams(params) {
6842
6926
  return Array.isArray(params.routers);
@@ -7067,10 +7151,18 @@ var _AggregatorClient = class _AggregatorClient {
7067
7151
  );
7068
7152
  for (let i = 0; i < routers.length; i++) {
7069
7153
  const router = routers[i];
7070
- let amount_arg = txb.pure.u64(router.amountOut.toString());
7154
+ let amount_arg = txb.pure.u64(
7155
+ router.amountOut.toString()
7156
+ );
7071
7157
  for (let j = router.path.length - 1; j >= 0; j--) {
7072
7158
  const path = router.path[j];
7073
- const flashSwapResult = dex.flash_swap(this, txb, path, amount_arg, false);
7159
+ const flashSwapResult = dex.flash_swap(
7160
+ this,
7161
+ txb,
7162
+ path,
7163
+ amount_arg,
7164
+ false
7165
+ );
7074
7166
  amount_arg = flashSwapResult.payAmount;
7075
7167
  returnCoins.unshift(flashSwapResult.targetCoin);
7076
7168
  receipts.unshift(flashSwapResult.flashReceipt);
@@ -7375,7 +7467,7 @@ var _AggregatorClient = class _AggregatorClient {
7375
7467
  // Include cetus、deepbookv2、flowxv2 & v3、kriyav2 & v3、turbos、aftermath、haedal、afsui、volo、bluemove
7376
7468
  publishedAtV2() {
7377
7469
  if (this.env === 0 /* Mainnet */) {
7378
- return "0x47a7b90756fba96fe649c2aaa10ec60dec6b8cb8545573d621310072721133aa";
7470
+ return "0x8ae871505a80d8bf6bf9c05906cda6edfeea460c85bebe2e26a4313f5e67874a";
7379
7471
  } else {
7380
7472
  return "0x52eae33adeb44de55cfb3f281d4cc9e02d976181c0952f5323648b5717b33934";
7381
7473
  }
@@ -7383,14 +7475,14 @@ var _AggregatorClient = class _AggregatorClient {
7383
7475
  // Include deepbookv3, scallop, bluefin
7384
7476
  publishedAtV2Extend() {
7385
7477
  if (this.env === 0 /* Mainnet */) {
7386
- return "0x8093d002bba575f1378b0da206a8df1fc55c4b5b3718752304f1b67a505d2be4";
7478
+ return "0x8a2f7a5b20665eeccc79de3aa37c3b6c473eca233ada1e1cd4678ec07d4d4073";
7387
7479
  } else {
7388
7480
  return "0xabb6a81c8a216828e317719e06125de5bb2cb0fe8f9916ff8c023ca5be224c78";
7389
7481
  }
7390
7482
  }
7391
7483
  publishedAtV2Extend2() {
7392
7484
  if (this.env === 0 /* Mainnet */) {
7393
- return "0xc40b43f0aa4ba5a4d71e39770265d3698d0e6dcfd846b7d7c443207f4e919e04";
7485
+ return "0x5cb7499fc49c2642310e24a4ecffdbee00133f97e80e2b45bca90c64d55de880";
7394
7486
  } else {
7395
7487
  return "0x0";
7396
7488
  }
@@ -7501,6 +7593,8 @@ var _AggregatorClient = class _AggregatorClient {
7501
7593
  return new SteammOmmV2(this.env, pythPriceIDs);
7502
7594
  case MAGMA:
7503
7595
  return new Magma(this.env);
7596
+ case SEVENK:
7597
+ return new Sevenk(this.env, pythPriceIDs);
7504
7598
  default:
7505
7599
  throw new Error(`Unsupported dex ${provider}`);
7506
7600
  }
@@ -7596,7 +7690,7 @@ _AggregatorClient.CONFIG = {
7596
7690
  pythStateId: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8"
7597
7691
  }
7598
7692
  };
7599
- var AggregatorClient27 = _AggregatorClient;
7693
+ var AggregatorClient28 = _AggregatorClient;
7600
7694
  function findPythPriceIDs(routes) {
7601
7695
  const priceIDs = /* @__PURE__ */ new Set();
7602
7696
  for (const route of routes) {
@@ -7631,6 +7725,14 @@ function findPythPriceIDs(routes) {
7631
7725
  priceIDs.add(path.extendedDetails.steammOraclePythPriceSeedB);
7632
7726
  }
7633
7727
  }
7728
+ if (path.provider === SEVENK) {
7729
+ if (path.extendedDetails && path.extendedDetails.sevenkCoinAPriceSeed) {
7730
+ priceIDs.add(path.extendedDetails.sevenkCoinAPriceSeed);
7731
+ }
7732
+ if (path.extendedDetails && path.extendedDetails.sevenkCoinBPriceSeed) {
7733
+ priceIDs.add(path.extendedDetails.sevenkCoinBPriceSeed);
7734
+ }
7735
+ }
7634
7736
  }
7635
7737
  }
7636
7738
  return Array.from(priceIDs);
@@ -7659,13 +7761,13 @@ function parseRouterResponse(data, byAmountIn) {
7659
7761
  routes: data.routes.map((route) => {
7660
7762
  return {
7661
7763
  path: route.path.map((path) => {
7662
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D;
7764
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I;
7663
7765
  let version;
7664
7766
  if (path.provider === AFTERMATH) {
7665
7767
  version = path.extended_details.aftermath_pool_flatness === 0 ? "v2" : "v3";
7666
7768
  }
7667
7769
  let extendedDetails;
7668
- if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS || path.provider === DEEPBOOKV3 || path.provider === SCALLOP || path.provider === HAEDALPMM || path.provider === METASTABLE || path.provider === OBRIC || path.provider === STEAMM || path.provider === STEAMM_OMM || path.provider === STEAMM_OMM_V2) {
7770
+ if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS || path.provider === DEEPBOOKV3 || path.provider === SCALLOP || path.provider === HAEDALPMM || path.provider === METASTABLE || path.provider === OBRIC || path.provider === STEAMM || path.provider === STEAMM_OMM || path.provider === STEAMM_OMM_V2 || path.provider === SEVENK) {
7669
7771
  extendedDetails = {
7670
7772
  aftermathLpSupplyType: (_a = path.extended_details) == null ? void 0 : _a.aftermath_lp_supply_type,
7671
7773
  turbosFeeType: (_b = path.extended_details) == null ? void 0 : _b.turbos_fee_type,
@@ -7696,7 +7798,12 @@ function parseRouterResponse(data, byAmountIn) {
7696
7798
  obricCoinAPriceSeed: (_A = path.extended_details) == null ? void 0 : _A.obric_coin_a_price_seed,
7697
7799
  obricCoinBPriceSeed: (_B = path.extended_details) == null ? void 0 : _B.obric_coin_b_price_seed,
7698
7800
  obricCoinAPriceId: (_C = path.extended_details) == null ? void 0 : _C.obric_coin_a_price_id,
7699
- obricCoinBPriceId: (_D = path.extended_details) == null ? void 0 : _D.obric_coin_b_price_id
7801
+ obricCoinBPriceId: (_D = path.extended_details) == null ? void 0 : _D.obric_coin_b_price_id,
7802
+ sevenkCoinAPriceSeed: (_E = path.extended_details) == null ? void 0 : _E.sevenk_coin_a_price_seed,
7803
+ sevenkCoinBPriceSeed: (_F = path.extended_details) == null ? void 0 : _F.sevenk_coin_b_price_seed,
7804
+ sevenkCoinAOracleId: (_G = path.extended_details) == null ? void 0 : _G.sevenk_oracle_config_a,
7805
+ sevenkCoinBOracleId: (_H = path.extended_details) == null ? void 0 : _H.sevenk_oracle_config_b,
7806
+ sevenkLPCapType: (_I = path.extended_details) == null ? void 0 : _I.sevenk_lp_cap_type
7700
7807
  };
7701
7808
  }
7702
7809
  return {
@@ -7793,7 +7900,7 @@ function processEndpoint(endpoint) {
7793
7900
 
7794
7901
  // src/api.ts
7795
7902
  var import_bn7 = __toESM(require_bn());
7796
- var SDK_VERSION = 1001300;
7903
+ var SDK_VERSION = 1001400;
7797
7904
  function getRouterResult(endpoint, apiKey, params, overlayFee, overlayFeeReceiver) {
7798
7905
  return __async(this, null, function* () {
7799
7906
  let response;
@@ -7822,7 +7929,7 @@ function getRouterResult(endpoint, apiKey, params, overlayFee, overlayFeeReceive
7822
7929
  }
7823
7930
  };
7824
7931
  }
7825
- const data = yield response.json();
7932
+ const data = JSONbig.parse(yield response.text());
7826
7933
  const insufficientLiquidity = data.msg === "liquidity is not enough";
7827
7934
  if (data.msg && data.msg.indexOf("HoneyPot scam") > -1) {
7828
7935
  return {
@@ -7997,4 +8104,4 @@ decimal.js/decimal.mjs:
7997
8104
  *)
7998
8105
  */
7999
8106
 
8000
- export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, AGGREGATOR_V2_EXTEND2, ALL_DEXES, ALPHAFI, AggregatorClient27 as AggregatorClient, BLUEFIN, BLUEMOVE, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, Env, FLOWXV2, FLOWXV3, HAEDAL, HAEDALPMM, HAWAL, KRIYA, KRIYAV3, MAGMA, METASTABLE, MOMENTUM, OBRIC, ONE, SCALLOP, SPRINGSUI, STEAMM, STEAMM_OMM, STEAMM_OMM_V2, 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, getAggregatorV2Extend2PublishedAt, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getAllProviders, getDeepbookV3Config, getProvidersExcluding, getProvidersIncluding, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
8107
+ export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, AGGREGATOR_V2_EXTEND2, ALL_DEXES, ALPHAFI, AggregatorClient28 as AggregatorClient, BLUEFIN, BLUEMOVE, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, Env, FLOWXV2, FLOWXV3, HAEDAL, HAEDALPMM, HAWAL, KRIYA, KRIYAV3, MAGMA, METASTABLE, MOMENTUM, OBRIC, ONE, SCALLOP, SEVENK, SPRINGSUI, STEAMM, STEAMM_OMM, STEAMM_OMM_V2, 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, getAggregatorV2Extend2PublishedAt, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getAllProviders, getDeepbookV3Config, getProvidersExcluding, getProvidersIncluding, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cetusprotocol/aggregator-sdk",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "sideEffects": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -30,13 +30,15 @@
30
30
  "@mysten/sui": "^1.6.0",
31
31
  "@pythnetwork/pyth-sui-js": "^2.1.0",
32
32
  "@types/jest": "^29.5.12",
33
+ "@types/json-bigint": "^1.0.4",
33
34
  "@types/node": "^20.12.12",
34
35
  "babel-jest": "^29.7.0",
35
36
  "bip39": "^3.1.0",
36
37
  "dotenv": "^16.4.5",
37
38
  "jest": "^29.7.0",
39
+ "json-bigint": "^1.0.0",
38
40
  "node-fetch": "^3.3.2",
39
41
  "ts-jest": "^29.1.3",
40
- "typescript": "^5.4.5"
42
+ "typescript": "^5.0.0"
41
43
  }
42
44
  }