@cetusprotocol/aggregator-sdk 0.13.1 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.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;
@@ -331,6 +337,7 @@ type RouterData = {
331
337
  byAmountIn: boolean;
332
338
  routes: Router[];
333
339
  insufficientLiquidity: boolean;
340
+ deviationRatio: number;
334
341
  packages?: Map<string, string>;
335
342
  totalDeepFee?: number;
336
343
  error?: RouterError;
@@ -366,4 +373,4 @@ declare enum Env {
366
373
  Testnet = 1
367
374
  }
368
375
 
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 };
376
+ 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;
@@ -331,6 +337,7 @@ type RouterData = {
331
337
  byAmountIn: boolean;
332
338
  routes: Router[];
333
339
  insufficientLiquidity: boolean;
340
+ deviationRatio: number;
334
341
  packages?: Map<string, string>;
335
342
  totalDeepFee?: number;
336
343
  error?: RouterError;
@@ -366,4 +373,4 @@ declare enum Env {
366
373
  Testnet = 1
367
374
  }
368
375
 
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 };
376
+ 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
@@ -5896,6 +5896,7 @@ function swapInPools(client, params, sender, env) {
5896
5896
  const routeData = {
5897
5897
  amountIn,
5898
5898
  amountOut: new import_bn4.BN((_d = event.amount_out) != null ? _d : 0),
5899
+ deviationRatio: 0,
5899
5900
  routes: [
5900
5901
  {
5901
5902
  path: [
@@ -6788,6 +6789,87 @@ var Magma = class {
6788
6789
  }
6789
6790
  };
6790
6791
 
6792
+ // src/transaction/sevenk.ts
6793
+ var Sevenk = class {
6794
+ constructor(env, pythPriceIDs) {
6795
+ if (env === 1 /* Testnet */) {
6796
+ throw new Error("Sevenk is not supported on testnet");
6797
+ }
6798
+ this.pythPriceIDs = pythPriceIDs;
6799
+ this.oraclePublishedAt = "0x8c36ea167c5e6da8c3d60b4fc897416105dcb986471bd81cfbfd38720a4487c0";
6800
+ }
6801
+ swap(client, txb, path, inputCoin, packages) {
6802
+ return __async(this, null, function* () {
6803
+ const { direction, from, target } = path;
6804
+ const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
6805
+ let coinAPriceSeed;
6806
+ let coinBPriceSeed;
6807
+ let coinAOracleId;
6808
+ let coinBOracleId;
6809
+ let lpCapType;
6810
+ if (path.extendedDetails == null) {
6811
+ throw new Error("Extended details not supported haedal pmm");
6812
+ } else {
6813
+ if (!path.extendedDetails.sevenkCoinAPriceSeed || !path.extendedDetails.sevenkCoinBPriceSeed || !path.extendedDetails.sevenkCoinAOracleId || !path.extendedDetails.sevenkCoinBOracleId || !path.extendedDetails.sevenkLPCapType) {
6814
+ throw new Error("Base price seed or quote price seed not supported");
6815
+ }
6816
+ coinAPriceSeed = path.extendedDetails.sevenkCoinAPriceSeed;
6817
+ coinBPriceSeed = path.extendedDetails.sevenkCoinBPriceSeed;
6818
+ coinAOracleId = path.extendedDetails.sevenkCoinAOracleId;
6819
+ coinBOracleId = path.extendedDetails.sevenkCoinBOracleId;
6820
+ lpCapType = path.extendedDetails.sevenkLPCapType;
6821
+ }
6822
+ const coinAPriceInfoObjectId = this.pythPriceIDs.get(coinAPriceSeed);
6823
+ const coinBPriceInfoObjectId = this.pythPriceIDs.get(coinBPriceSeed);
6824
+ if (!coinAPriceInfoObjectId || !coinBPriceInfoObjectId) {
6825
+ throw new Error(
6826
+ "Base price info object id or quote price info object id not found"
6827
+ );
6828
+ }
6829
+ const holder = txb.moveCall({
6830
+ target: `${this.oraclePublishedAt}::oracle::new_holder`,
6831
+ typeArguments: [],
6832
+ arguments: []
6833
+ });
6834
+ txb.moveCall({
6835
+ target: `${this.oraclePublishedAt}::pyth::get_price`,
6836
+ typeArguments: [],
6837
+ arguments: [
6838
+ txb.object(coinAOracleId),
6839
+ holder,
6840
+ txb.object(coinAPriceInfoObjectId),
6841
+ txb.object(CLOCK_ADDRESS)
6842
+ ]
6843
+ });
6844
+ txb.moveCall({
6845
+ target: `${this.oraclePublishedAt}::pyth::get_price`,
6846
+ typeArguments: [],
6847
+ arguments: [
6848
+ txb.object(coinBOracleId),
6849
+ holder,
6850
+ txb.object(coinBPriceInfoObjectId),
6851
+ txb.object(CLOCK_ADDRESS)
6852
+ ]
6853
+ });
6854
+ const args = [
6855
+ txb.object(path.id),
6856
+ holder,
6857
+ inputCoin
6858
+ ];
6859
+ const publishedAt = getAggregatorV2Extend2PublishedAt(
6860
+ client.publishedAtV2Extend2(),
6861
+ packages
6862
+ );
6863
+ const res = txb.moveCall({
6864
+ target: `${publishedAt}::sevenk::${func}`,
6865
+ typeArguments: [coinAType, coinBType, lpCapType],
6866
+ arguments: args
6867
+ });
6868
+ return res;
6869
+ });
6870
+ }
6871
+ };
6872
+
6791
6873
  // src/client.ts
6792
6874
  var CETUS = "CETUS";
6793
6875
  var DEEPBOOKV2 = "DEEPBOOK";
@@ -6816,6 +6898,7 @@ var STEAMM_OMM = "STEAMM_OMM";
6816
6898
  var MOMENTUM = "MOMENTUM";
6817
6899
  var STEAMM_OMM_V2 = "STEAMM_OMM_V2";
6818
6900
  var MAGMA = "MAGMA";
6901
+ var SEVENK = "SEVENK";
6819
6902
  var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
6820
6903
  var ALL_DEXES = [
6821
6904
  CETUS,
@@ -6843,7 +6926,8 @@ var ALL_DEXES = [
6843
6926
  MOMENTUM,
6844
6927
  STEAMM_OMM,
6845
6928
  STEAMM_OMM_V2,
6846
- MAGMA
6929
+ MAGMA,
6930
+ SEVENK
6847
6931
  ];
6848
6932
  function isBuilderRouterSwapParams(params) {
6849
6933
  return Array.isArray(params.routers);
@@ -7390,7 +7474,7 @@ var _AggregatorClient = class _AggregatorClient {
7390
7474
  // Include cetus、deepbookv2、flowxv2 & v3、kriyav2 & v3、turbos、aftermath、haedal、afsui、volo、bluemove
7391
7475
  publishedAtV2() {
7392
7476
  if (this.env === 0 /* Mainnet */) {
7393
- return "0x47a7b90756fba96fe649c2aaa10ec60dec6b8cb8545573d621310072721133aa";
7477
+ return "0x8ae871505a80d8bf6bf9c05906cda6edfeea460c85bebe2e26a4313f5e67874a";
7394
7478
  } else {
7395
7479
  return "0x52eae33adeb44de55cfb3f281d4cc9e02d976181c0952f5323648b5717b33934";
7396
7480
  }
@@ -7398,14 +7482,14 @@ var _AggregatorClient = class _AggregatorClient {
7398
7482
  // Include deepbookv3, scallop, bluefin
7399
7483
  publishedAtV2Extend() {
7400
7484
  if (this.env === 0 /* Mainnet */) {
7401
- return "0x8093d002bba575f1378b0da206a8df1fc55c4b5b3718752304f1b67a505d2be4";
7485
+ return "0x8a2f7a5b20665eeccc79de3aa37c3b6c473eca233ada1e1cd4678ec07d4d4073";
7402
7486
  } else {
7403
7487
  return "0xabb6a81c8a216828e317719e06125de5bb2cb0fe8f9916ff8c023ca5be224c78";
7404
7488
  }
7405
7489
  }
7406
7490
  publishedAtV2Extend2() {
7407
7491
  if (this.env === 0 /* Mainnet */) {
7408
- return "0xc40b43f0aa4ba5a4d71e39770265d3698d0e6dcfd846b7d7c443207f4e919e04";
7492
+ return "0x5cb7499fc49c2642310e24a4ecffdbee00133f97e80e2b45bca90c64d55de880";
7409
7493
  } else {
7410
7494
  return "0x0";
7411
7495
  }
@@ -7516,6 +7600,8 @@ var _AggregatorClient = class _AggregatorClient {
7516
7600
  return new SteammOmmV2(this.env, pythPriceIDs);
7517
7601
  case MAGMA:
7518
7602
  return new Magma(this.env);
7603
+ case SEVENK:
7604
+ return new Sevenk(this.env, pythPriceIDs);
7519
7605
  default:
7520
7606
  throw new Error(`Unsupported dex ${provider}`);
7521
7607
  }
@@ -7611,7 +7697,7 @@ _AggregatorClient.CONFIG = {
7611
7697
  pythStateId: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8"
7612
7698
  }
7613
7699
  };
7614
- var AggregatorClient27 = _AggregatorClient;
7700
+ var AggregatorClient28 = _AggregatorClient;
7615
7701
  function findPythPriceIDs(routes) {
7616
7702
  const priceIDs = /* @__PURE__ */ new Set();
7617
7703
  for (const route of routes) {
@@ -7646,6 +7732,14 @@ function findPythPriceIDs(routes) {
7646
7732
  priceIDs.add(path.extendedDetails.steammOraclePythPriceSeedB);
7647
7733
  }
7648
7734
  }
7735
+ if (path.provider === SEVENK) {
7736
+ if (path.extendedDetails && path.extendedDetails.sevenkCoinAPriceSeed) {
7737
+ priceIDs.add(path.extendedDetails.sevenkCoinAPriceSeed);
7738
+ }
7739
+ if (path.extendedDetails && path.extendedDetails.sevenkCoinBPriceSeed) {
7740
+ priceIDs.add(path.extendedDetails.sevenkCoinBPriceSeed);
7741
+ }
7742
+ }
7649
7743
  }
7650
7744
  }
7651
7745
  return Array.from(priceIDs);
@@ -7669,18 +7763,19 @@ function parseRouterResponse(data, byAmountIn) {
7669
7763
  let routerData = {
7670
7764
  amountIn: new import_bn5.default(data.amount_in.toString()),
7671
7765
  amountOut: new import_bn5.default(data.amount_out.toString()),
7766
+ deviationRatio: data.deviation_ratio ? Number(data.deviation_ratio) : 0,
7672
7767
  byAmountIn,
7673
7768
  insufficientLiquidity: false,
7674
7769
  routes: data.routes.map((route) => {
7675
7770
  return {
7676
7771
  path: route.path.map((path) => {
7677
- 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;
7772
+ 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;
7678
7773
  let version;
7679
7774
  if (path.provider === AFTERMATH) {
7680
7775
  version = path.extended_details.aftermath_pool_flatness === 0 ? "v2" : "v3";
7681
7776
  }
7682
7777
  let extendedDetails;
7683
- 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) {
7778
+ 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) {
7684
7779
  extendedDetails = {
7685
7780
  aftermathLpSupplyType: (_a = path.extended_details) == null ? void 0 : _a.aftermath_lp_supply_type,
7686
7781
  turbosFeeType: (_b = path.extended_details) == null ? void 0 : _b.turbos_fee_type,
@@ -7711,7 +7806,12 @@ function parseRouterResponse(data, byAmountIn) {
7711
7806
  obricCoinAPriceSeed: (_A = path.extended_details) == null ? void 0 : _A.obric_coin_a_price_seed,
7712
7807
  obricCoinBPriceSeed: (_B = path.extended_details) == null ? void 0 : _B.obric_coin_b_price_seed,
7713
7808
  obricCoinAPriceId: (_C = path.extended_details) == null ? void 0 : _C.obric_coin_a_price_id,
7714
- obricCoinBPriceId: (_D = path.extended_details) == null ? void 0 : _D.obric_coin_b_price_id
7809
+ obricCoinBPriceId: (_D = path.extended_details) == null ? void 0 : _D.obric_coin_b_price_id,
7810
+ sevenkCoinAPriceSeed: (_E = path.extended_details) == null ? void 0 : _E.sevenk_coin_a_price_seed,
7811
+ sevenkCoinBPriceSeed: (_F = path.extended_details) == null ? void 0 : _F.sevenk_coin_b_price_seed,
7812
+ sevenkCoinAOracleId: (_G = path.extended_details) == null ? void 0 : _G.sevenk_oracle_config_a,
7813
+ sevenkCoinBOracleId: (_H = path.extended_details) == null ? void 0 : _H.sevenk_oracle_config_b,
7814
+ sevenkLPCapType: (_I = path.extended_details) == null ? void 0 : _I.sevenk_lp_cap_type
7715
7815
  };
7716
7816
  }
7717
7817
  return {
@@ -7808,7 +7908,7 @@ function processEndpoint(endpoint) {
7808
7908
 
7809
7909
  // src/api.ts
7810
7910
  var import_bn7 = __toESM(require_bn());
7811
- var SDK_VERSION = 1001300;
7911
+ var SDK_VERSION = 1001400;
7812
7912
  function getRouterResult(endpoint, apiKey, params, overlayFee, overlayFeeReceiver) {
7813
7913
  return __async(this, null, function* () {
7814
7914
  let response;
@@ -7831,6 +7931,7 @@ function getRouterResult(endpoint, apiKey, params, overlayFee, overlayFeeReceive
7831
7931
  routes: [],
7832
7932
  byAmountIn: params.byAmountIn,
7833
7933
  insufficientLiquidity: false,
7934
+ deviationRatio: 0,
7834
7935
  error: {
7835
7936
  code: errorCode,
7836
7937
  msg: getAggregatorServerErrorMessage(errorCode)
@@ -7846,6 +7947,7 @@ function getRouterResult(endpoint, apiKey, params, overlayFee, overlayFeeReceive
7846
7947
  routes: [],
7847
7948
  byAmountIn: params.byAmountIn,
7848
7949
  insufficientLiquidity,
7950
+ deviationRatio: 0,
7849
7951
  error: {
7850
7952
  code: 10004 /* HoneyPot */,
7851
7953
  msg: getAggregatorServerErrorMessage(
@@ -7875,6 +7977,7 @@ function getRouterResult(endpoint, apiKey, params, overlayFee, overlayFeeReceive
7875
7977
  routes: [],
7876
7978
  insufficientLiquidity,
7877
7979
  byAmountIn: params.byAmountIn,
7980
+ deviationRatio: 0,
7878
7981
  error: {
7879
7982
  code: 10003 /* InsufficientLiquidity */,
7880
7983
  msg: getAggregatorServerErrorMessage(
@@ -8019,7 +8122,7 @@ exports.AGGREGATOR_V2_EXTEND = AGGREGATOR_V2_EXTEND;
8019
8122
  exports.AGGREGATOR_V2_EXTEND2 = AGGREGATOR_V2_EXTEND2;
8020
8123
  exports.ALL_DEXES = ALL_DEXES;
8021
8124
  exports.ALPHAFI = ALPHAFI;
8022
- exports.AggregatorClient = AggregatorClient27;
8125
+ exports.AggregatorClient = AggregatorClient28;
8023
8126
  exports.BLUEFIN = BLUEFIN;
8024
8127
  exports.BLUEMOVE = BLUEMOVE;
8025
8128
  exports.CETUS = CETUS;
@@ -8041,6 +8144,7 @@ exports.MOMENTUM = MOMENTUM;
8041
8144
  exports.OBRIC = OBRIC;
8042
8145
  exports.ONE = ONE;
8043
8146
  exports.SCALLOP = SCALLOP;
8147
+ exports.SEVENK = SEVENK;
8044
8148
  exports.SPRINGSUI = SPRINGSUI;
8045
8149
  exports.STEAMM = STEAMM;
8046
8150
  exports.STEAMM_OMM = STEAMM_OMM;
package/dist/index.mjs CHANGED
@@ -5890,6 +5890,7 @@ function swapInPools(client, params, sender, env) {
5890
5890
  const routeData = {
5891
5891
  amountIn,
5892
5892
  amountOut: new import_bn4.BN((_d = event.amount_out) != null ? _d : 0),
5893
+ deviationRatio: 0,
5893
5894
  routes: [
5894
5895
  {
5895
5896
  path: [
@@ -6782,6 +6783,87 @@ var Magma = class {
6782
6783
  }
6783
6784
  };
6784
6785
 
6786
+ // src/transaction/sevenk.ts
6787
+ var Sevenk = class {
6788
+ constructor(env, pythPriceIDs) {
6789
+ if (env === 1 /* Testnet */) {
6790
+ throw new Error("Sevenk is not supported on testnet");
6791
+ }
6792
+ this.pythPriceIDs = pythPriceIDs;
6793
+ this.oraclePublishedAt = "0x8c36ea167c5e6da8c3d60b4fc897416105dcb986471bd81cfbfd38720a4487c0";
6794
+ }
6795
+ swap(client, txb, path, inputCoin, packages) {
6796
+ return __async(this, null, function* () {
6797
+ const { direction, from, target } = path;
6798
+ const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
6799
+ let coinAPriceSeed;
6800
+ let coinBPriceSeed;
6801
+ let coinAOracleId;
6802
+ let coinBOracleId;
6803
+ let lpCapType;
6804
+ if (path.extendedDetails == null) {
6805
+ throw new Error("Extended details not supported haedal pmm");
6806
+ } else {
6807
+ if (!path.extendedDetails.sevenkCoinAPriceSeed || !path.extendedDetails.sevenkCoinBPriceSeed || !path.extendedDetails.sevenkCoinAOracleId || !path.extendedDetails.sevenkCoinBOracleId || !path.extendedDetails.sevenkLPCapType) {
6808
+ throw new Error("Base price seed or quote price seed not supported");
6809
+ }
6810
+ coinAPriceSeed = path.extendedDetails.sevenkCoinAPriceSeed;
6811
+ coinBPriceSeed = path.extendedDetails.sevenkCoinBPriceSeed;
6812
+ coinAOracleId = path.extendedDetails.sevenkCoinAOracleId;
6813
+ coinBOracleId = path.extendedDetails.sevenkCoinBOracleId;
6814
+ lpCapType = path.extendedDetails.sevenkLPCapType;
6815
+ }
6816
+ const coinAPriceInfoObjectId = this.pythPriceIDs.get(coinAPriceSeed);
6817
+ const coinBPriceInfoObjectId = this.pythPriceIDs.get(coinBPriceSeed);
6818
+ if (!coinAPriceInfoObjectId || !coinBPriceInfoObjectId) {
6819
+ throw new Error(
6820
+ "Base price info object id or quote price info object id not found"
6821
+ );
6822
+ }
6823
+ const holder = txb.moveCall({
6824
+ target: `${this.oraclePublishedAt}::oracle::new_holder`,
6825
+ typeArguments: [],
6826
+ arguments: []
6827
+ });
6828
+ txb.moveCall({
6829
+ target: `${this.oraclePublishedAt}::pyth::get_price`,
6830
+ typeArguments: [],
6831
+ arguments: [
6832
+ txb.object(coinAOracleId),
6833
+ holder,
6834
+ txb.object(coinAPriceInfoObjectId),
6835
+ txb.object(CLOCK_ADDRESS)
6836
+ ]
6837
+ });
6838
+ txb.moveCall({
6839
+ target: `${this.oraclePublishedAt}::pyth::get_price`,
6840
+ typeArguments: [],
6841
+ arguments: [
6842
+ txb.object(coinBOracleId),
6843
+ holder,
6844
+ txb.object(coinBPriceInfoObjectId),
6845
+ txb.object(CLOCK_ADDRESS)
6846
+ ]
6847
+ });
6848
+ const args = [
6849
+ txb.object(path.id),
6850
+ holder,
6851
+ inputCoin
6852
+ ];
6853
+ const publishedAt = getAggregatorV2Extend2PublishedAt(
6854
+ client.publishedAtV2Extend2(),
6855
+ packages
6856
+ );
6857
+ const res = txb.moveCall({
6858
+ target: `${publishedAt}::sevenk::${func}`,
6859
+ typeArguments: [coinAType, coinBType, lpCapType],
6860
+ arguments: args
6861
+ });
6862
+ return res;
6863
+ });
6864
+ }
6865
+ };
6866
+
6785
6867
  // src/client.ts
6786
6868
  var CETUS = "CETUS";
6787
6869
  var DEEPBOOKV2 = "DEEPBOOK";
@@ -6810,6 +6892,7 @@ var STEAMM_OMM = "STEAMM_OMM";
6810
6892
  var MOMENTUM = "MOMENTUM";
6811
6893
  var STEAMM_OMM_V2 = "STEAMM_OMM_V2";
6812
6894
  var MAGMA = "MAGMA";
6895
+ var SEVENK = "SEVENK";
6813
6896
  var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
6814
6897
  var ALL_DEXES = [
6815
6898
  CETUS,
@@ -6837,7 +6920,8 @@ var ALL_DEXES = [
6837
6920
  MOMENTUM,
6838
6921
  STEAMM_OMM,
6839
6922
  STEAMM_OMM_V2,
6840
- MAGMA
6923
+ MAGMA,
6924
+ SEVENK
6841
6925
  ];
6842
6926
  function isBuilderRouterSwapParams(params) {
6843
6927
  return Array.isArray(params.routers);
@@ -7384,7 +7468,7 @@ var _AggregatorClient = class _AggregatorClient {
7384
7468
  // Include cetus、deepbookv2、flowxv2 & v3、kriyav2 & v3、turbos、aftermath、haedal、afsui、volo、bluemove
7385
7469
  publishedAtV2() {
7386
7470
  if (this.env === 0 /* Mainnet */) {
7387
- return "0x47a7b90756fba96fe649c2aaa10ec60dec6b8cb8545573d621310072721133aa";
7471
+ return "0x8ae871505a80d8bf6bf9c05906cda6edfeea460c85bebe2e26a4313f5e67874a";
7388
7472
  } else {
7389
7473
  return "0x52eae33adeb44de55cfb3f281d4cc9e02d976181c0952f5323648b5717b33934";
7390
7474
  }
@@ -7392,14 +7476,14 @@ var _AggregatorClient = class _AggregatorClient {
7392
7476
  // Include deepbookv3, scallop, bluefin
7393
7477
  publishedAtV2Extend() {
7394
7478
  if (this.env === 0 /* Mainnet */) {
7395
- return "0x8093d002bba575f1378b0da206a8df1fc55c4b5b3718752304f1b67a505d2be4";
7479
+ return "0x8a2f7a5b20665eeccc79de3aa37c3b6c473eca233ada1e1cd4678ec07d4d4073";
7396
7480
  } else {
7397
7481
  return "0xabb6a81c8a216828e317719e06125de5bb2cb0fe8f9916ff8c023ca5be224c78";
7398
7482
  }
7399
7483
  }
7400
7484
  publishedAtV2Extend2() {
7401
7485
  if (this.env === 0 /* Mainnet */) {
7402
- return "0xc40b43f0aa4ba5a4d71e39770265d3698d0e6dcfd846b7d7c443207f4e919e04";
7486
+ return "0x5cb7499fc49c2642310e24a4ecffdbee00133f97e80e2b45bca90c64d55de880";
7403
7487
  } else {
7404
7488
  return "0x0";
7405
7489
  }
@@ -7510,6 +7594,8 @@ var _AggregatorClient = class _AggregatorClient {
7510
7594
  return new SteammOmmV2(this.env, pythPriceIDs);
7511
7595
  case MAGMA:
7512
7596
  return new Magma(this.env);
7597
+ case SEVENK:
7598
+ return new Sevenk(this.env, pythPriceIDs);
7513
7599
  default:
7514
7600
  throw new Error(`Unsupported dex ${provider}`);
7515
7601
  }
@@ -7605,7 +7691,7 @@ _AggregatorClient.CONFIG = {
7605
7691
  pythStateId: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8"
7606
7692
  }
7607
7693
  };
7608
- var AggregatorClient27 = _AggregatorClient;
7694
+ var AggregatorClient28 = _AggregatorClient;
7609
7695
  function findPythPriceIDs(routes) {
7610
7696
  const priceIDs = /* @__PURE__ */ new Set();
7611
7697
  for (const route of routes) {
@@ -7640,6 +7726,14 @@ function findPythPriceIDs(routes) {
7640
7726
  priceIDs.add(path.extendedDetails.steammOraclePythPriceSeedB);
7641
7727
  }
7642
7728
  }
7729
+ if (path.provider === SEVENK) {
7730
+ if (path.extendedDetails && path.extendedDetails.sevenkCoinAPriceSeed) {
7731
+ priceIDs.add(path.extendedDetails.sevenkCoinAPriceSeed);
7732
+ }
7733
+ if (path.extendedDetails && path.extendedDetails.sevenkCoinBPriceSeed) {
7734
+ priceIDs.add(path.extendedDetails.sevenkCoinBPriceSeed);
7735
+ }
7736
+ }
7643
7737
  }
7644
7738
  }
7645
7739
  return Array.from(priceIDs);
@@ -7663,18 +7757,19 @@ function parseRouterResponse(data, byAmountIn) {
7663
7757
  let routerData = {
7664
7758
  amountIn: new import_bn5.default(data.amount_in.toString()),
7665
7759
  amountOut: new import_bn5.default(data.amount_out.toString()),
7760
+ deviationRatio: data.deviation_ratio ? Number(data.deviation_ratio) : 0,
7666
7761
  byAmountIn,
7667
7762
  insufficientLiquidity: false,
7668
7763
  routes: data.routes.map((route) => {
7669
7764
  return {
7670
7765
  path: route.path.map((path) => {
7671
- 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;
7766
+ 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;
7672
7767
  let version;
7673
7768
  if (path.provider === AFTERMATH) {
7674
7769
  version = path.extended_details.aftermath_pool_flatness === 0 ? "v2" : "v3";
7675
7770
  }
7676
7771
  let extendedDetails;
7677
- 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) {
7772
+ 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) {
7678
7773
  extendedDetails = {
7679
7774
  aftermathLpSupplyType: (_a = path.extended_details) == null ? void 0 : _a.aftermath_lp_supply_type,
7680
7775
  turbosFeeType: (_b = path.extended_details) == null ? void 0 : _b.turbos_fee_type,
@@ -7705,7 +7800,12 @@ function parseRouterResponse(data, byAmountIn) {
7705
7800
  obricCoinAPriceSeed: (_A = path.extended_details) == null ? void 0 : _A.obric_coin_a_price_seed,
7706
7801
  obricCoinBPriceSeed: (_B = path.extended_details) == null ? void 0 : _B.obric_coin_b_price_seed,
7707
7802
  obricCoinAPriceId: (_C = path.extended_details) == null ? void 0 : _C.obric_coin_a_price_id,
7708
- obricCoinBPriceId: (_D = path.extended_details) == null ? void 0 : _D.obric_coin_b_price_id
7803
+ obricCoinBPriceId: (_D = path.extended_details) == null ? void 0 : _D.obric_coin_b_price_id,
7804
+ sevenkCoinAPriceSeed: (_E = path.extended_details) == null ? void 0 : _E.sevenk_coin_a_price_seed,
7805
+ sevenkCoinBPriceSeed: (_F = path.extended_details) == null ? void 0 : _F.sevenk_coin_b_price_seed,
7806
+ sevenkCoinAOracleId: (_G = path.extended_details) == null ? void 0 : _G.sevenk_oracle_config_a,
7807
+ sevenkCoinBOracleId: (_H = path.extended_details) == null ? void 0 : _H.sevenk_oracle_config_b,
7808
+ sevenkLPCapType: (_I = path.extended_details) == null ? void 0 : _I.sevenk_lp_cap_type
7709
7809
  };
7710
7810
  }
7711
7811
  return {
@@ -7802,7 +7902,7 @@ function processEndpoint(endpoint) {
7802
7902
 
7803
7903
  // src/api.ts
7804
7904
  var import_bn7 = __toESM(require_bn());
7805
- var SDK_VERSION = 1001300;
7905
+ var SDK_VERSION = 1001400;
7806
7906
  function getRouterResult(endpoint, apiKey, params, overlayFee, overlayFeeReceiver) {
7807
7907
  return __async(this, null, function* () {
7808
7908
  let response;
@@ -7825,6 +7925,7 @@ function getRouterResult(endpoint, apiKey, params, overlayFee, overlayFeeReceive
7825
7925
  routes: [],
7826
7926
  byAmountIn: params.byAmountIn,
7827
7927
  insufficientLiquidity: false,
7928
+ deviationRatio: 0,
7828
7929
  error: {
7829
7930
  code: errorCode,
7830
7931
  msg: getAggregatorServerErrorMessage(errorCode)
@@ -7840,6 +7941,7 @@ function getRouterResult(endpoint, apiKey, params, overlayFee, overlayFeeReceive
7840
7941
  routes: [],
7841
7942
  byAmountIn: params.byAmountIn,
7842
7943
  insufficientLiquidity,
7944
+ deviationRatio: 0,
7843
7945
  error: {
7844
7946
  code: 10004 /* HoneyPot */,
7845
7947
  msg: getAggregatorServerErrorMessage(
@@ -7869,6 +7971,7 @@ function getRouterResult(endpoint, apiKey, params, overlayFee, overlayFeeReceive
7869
7971
  routes: [],
7870
7972
  insufficientLiquidity,
7871
7973
  byAmountIn: params.byAmountIn,
7974
+ deviationRatio: 0,
7872
7975
  error: {
7873
7976
  code: 10003 /* InsufficientLiquidity */,
7874
7977
  msg: getAggregatorServerErrorMessage(
@@ -8006,4 +8109,4 @@ decimal.js/decimal.mjs:
8006
8109
  *)
8007
8110
  */
8008
8111
 
8009
- 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 };
8112
+ 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.1",
3
+ "version": "0.14.1",
4
4
  "sideEffects": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",