@cetusprotocol/aggregator-sdk 1.0.2 → 1.1.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.js CHANGED
@@ -3426,7 +3426,7 @@ var AGGREGATOR_V3_CONFIG = {
3426
3426
  };
3427
3427
 
3428
3428
  // src/api.ts
3429
- var SDK_VERSION = 1010001;
3429
+ var SDK_VERSION = 1010003;
3430
3430
  function parseRouterResponse(data, byAmountIn) {
3431
3431
  let packages = /* @__PURE__ */ new Map();
3432
3432
  if (data.packages) {
@@ -6663,51 +6663,6 @@ var ScallopRouter = class {
6663
6663
  });
6664
6664
  }
6665
6665
  };
6666
- var SuilendRouter = class {
6667
- constructor(env) {
6668
- if (env !== 0 /* Mainnet */) {
6669
- throw new Error("Suilend only supported on mainnet");
6670
- }
6671
- this.obligationKey = "0x9ce2b3f03d4e5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c";
6672
- this.lendingMarket = "0xadf4c5e0f4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2";
6673
- }
6674
- swap(txb, flattenedPath, swapContext, _extends) {
6675
- const swapData = this.prepareSwapData(flattenedPath);
6676
- this.executeSwapContract(txb, swapData, swapContext);
6677
- }
6678
- prepareSwapData(flattenedPath) {
6679
- const path = flattenedPath.path;
6680
- if (flattenedPath.path.publishedAt == null) {
6681
- throw new Error("Suilend not set publishedAt");
6682
- }
6683
- const [coinAType, coinBType] = path.direction ? [path.from, path.target] : [path.target, path.from];
6684
- const amountIn = flattenedPath.isLastUseOfIntermediateToken ? AGGREGATOR_V3_CONFIG.MAX_AMOUNT_IN : path.amountIn;
6685
- return {
6686
- coinAType,
6687
- coinBType,
6688
- direction: path.direction,
6689
- amountIn,
6690
- publishedAt: path.publishedAt,
6691
- poolId: path.id
6692
- };
6693
- }
6694
- executeSwapContract(txb, swapData, swapContext) {
6695
- const args = [
6696
- swapContext,
6697
- txb.object(this.obligationKey),
6698
- txb.object(this.lendingMarket),
6699
- txb.object(swapData.poolId),
6700
- txb.pure.bool(swapData.direction),
6701
- txb.pure.u64(swapData.amountIn),
6702
- txb.object(utils.SUI_CLOCK_OBJECT_ID)
6703
- ];
6704
- txb.moveCall({
6705
- target: `${swapData.publishedAt}::suilend::swap`,
6706
- typeArguments: [swapData.coinAType, swapData.coinBType],
6707
- arguments: args
6708
- });
6709
- }
6710
- };
6711
6666
 
6712
6667
  // src/movecall/springsui.ts
6713
6668
  var SpringsuiRouter = class {
@@ -7954,13 +7909,21 @@ var dealWithFastRouterSwapParamsForMsafe = (data) => {
7954
7909
  const result = __spreadProps(__spreadValues({}, data), {
7955
7910
  amountIn: (_a = data == null ? void 0 : data.amountIn) == null ? void 0 : _a.toString(),
7956
7911
  amountOut: (_b = data == null ? void 0 : data.amountIn) == null ? void 0 : _b.toString(),
7957
- routes: (_c = data == null ? void 0 : data.routes) == null ? void 0 : _c.map((item) => {
7958
- var _a2, _b2, _c2;
7959
- return __spreadProps(__spreadValues({}, item), {
7912
+ paths: (_c = data == null ? void 0 : data.paths) == null ? void 0 : _c.map((item) => {
7913
+ var _a2, _b2, _c2, _d, _e, _f;
7914
+ const info = __spreadProps(__spreadValues({}, item), {
7960
7915
  amountIn: (_a2 = item == null ? void 0 : item.amountIn) == null ? void 0 : _a2.toString(),
7961
- amountOut: (_b2 = item == null ? void 0 : item.amountOut) == null ? void 0 : _b2.toString(),
7962
- initialPrice: (_c2 = item == null ? void 0 : item.initialPrice) == null ? void 0 : _c2.toString()
7916
+ amountOut: (_b2 = item == null ? void 0 : item.amountOut) == null ? void 0 : _b2.toString()
7963
7917
  });
7918
+ if (item == null ? void 0 : item.initialPrice) {
7919
+ info["initialPrice"] = (_c2 = item == null ? void 0 : item.initialPrice) == null ? void 0 : _c2.toString();
7920
+ }
7921
+ if ((_d = item == null ? void 0 : item.extendedDetails) == null ? void 0 : _d.after_sqrt_price) {
7922
+ info["extendedDetails"] = {
7923
+ after_sqrt_price: (_f = (_e = item == null ? void 0 : item.extendedDetails) == null ? void 0 : _e.afterSqrtPrice) == null ? void 0 : _f.toString()
7924
+ };
7925
+ }
7926
+ return info;
7964
7927
  })
7965
7928
  });
7966
7929
  return result;
@@ -7970,13 +7933,18 @@ var restituteMsafeFastRouterSwapParams = (data) => {
7970
7933
  const result = __spreadProps(__spreadValues({}, data), {
7971
7934
  amountIn: new import_bn5.default(data == null ? void 0 : data.amountIn),
7972
7935
  amountOut: new import_bn5.default(data == null ? void 0 : data.amountIn),
7973
- routes: (_a = data == null ? void 0 : data.routes) == null ? void 0 : _a.map((item) => {
7974
- var _a2;
7975
- return __spreadProps(__spreadValues({}, item), {
7976
- amountIn: new import_bn5.default(item == null ? void 0 : item.amountIn),
7977
- amountOut: new import_bn5.default(item == null ? void 0 : item.amountOut),
7978
- initialPrice: new decimal_default((_a2 = item == null ? void 0 : item.initialPrice) == null ? void 0 : _a2.toString())
7979
- });
7936
+ paths: (_a = data == null ? void 0 : data.paths) == null ? void 0 : _a.map((item) => {
7937
+ var _a2, _b, _c, _d;
7938
+ const info = __spreadValues({}, item);
7939
+ if (item == null ? void 0 : item.initialPrice) {
7940
+ info["initialPrice"] = new decimal_default((_a2 = item == null ? void 0 : item.initialPrice) == null ? void 0 : _a2.toString());
7941
+ }
7942
+ if ((_b = item == null ? void 0 : item.extendedDetails) == null ? void 0 : _b.after_sqrt_price) {
7943
+ info["extendedDetails"] = {
7944
+ after_sqrt_price: new decimal_default((_d = (_c = item == null ? void 0 : item.extendedDetails) == null ? void 0 : _c.after_sqrt_price) == null ? void 0 : _d.toString())
7945
+ };
7946
+ }
7947
+ return info;
7980
7948
  })
7981
7949
  });
7982
7950
  return result;
@@ -8360,7 +8328,7 @@ var _AggregatorClient = class _AggregatorClient {
8360
8328
  case SCALLOP:
8361
8329
  return new ScallopRouter(this.env);
8362
8330
  case SUILEND:
8363
- return new SuilendRouter(this.env);
8331
+ return new SpringsuiRouter(this.env);
8364
8332
  case SPRINGSUI:
8365
8333
  return new SpringsuiRouter(this.env);
8366
8334
  case HAEDALPMM:
package/dist/index.mjs CHANGED
@@ -3420,7 +3420,7 @@ var AGGREGATOR_V3_CONFIG = {
3420
3420
  };
3421
3421
 
3422
3422
  // src/api.ts
3423
- var SDK_VERSION = 1010001;
3423
+ var SDK_VERSION = 1010003;
3424
3424
  function parseRouterResponse(data, byAmountIn) {
3425
3425
  let packages = /* @__PURE__ */ new Map();
3426
3426
  if (data.packages) {
@@ -6657,51 +6657,6 @@ var ScallopRouter = class {
6657
6657
  });
6658
6658
  }
6659
6659
  };
6660
- var SuilendRouter = class {
6661
- constructor(env) {
6662
- if (env !== 0 /* Mainnet */) {
6663
- throw new Error("Suilend only supported on mainnet");
6664
- }
6665
- this.obligationKey = "0x9ce2b3f03d4e5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c";
6666
- this.lendingMarket = "0xadf4c5e0f4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2";
6667
- }
6668
- swap(txb, flattenedPath, swapContext, _extends) {
6669
- const swapData = this.prepareSwapData(flattenedPath);
6670
- this.executeSwapContract(txb, swapData, swapContext);
6671
- }
6672
- prepareSwapData(flattenedPath) {
6673
- const path = flattenedPath.path;
6674
- if (flattenedPath.path.publishedAt == null) {
6675
- throw new Error("Suilend not set publishedAt");
6676
- }
6677
- const [coinAType, coinBType] = path.direction ? [path.from, path.target] : [path.target, path.from];
6678
- const amountIn = flattenedPath.isLastUseOfIntermediateToken ? AGGREGATOR_V3_CONFIG.MAX_AMOUNT_IN : path.amountIn;
6679
- return {
6680
- coinAType,
6681
- coinBType,
6682
- direction: path.direction,
6683
- amountIn,
6684
- publishedAt: path.publishedAt,
6685
- poolId: path.id
6686
- };
6687
- }
6688
- executeSwapContract(txb, swapData, swapContext) {
6689
- const args = [
6690
- swapContext,
6691
- txb.object(this.obligationKey),
6692
- txb.object(this.lendingMarket),
6693
- txb.object(swapData.poolId),
6694
- txb.pure.bool(swapData.direction),
6695
- txb.pure.u64(swapData.amountIn),
6696
- txb.object(SUI_CLOCK_OBJECT_ID)
6697
- ];
6698
- txb.moveCall({
6699
- target: `${swapData.publishedAt}::suilend::swap`,
6700
- typeArguments: [swapData.coinAType, swapData.coinBType],
6701
- arguments: args
6702
- });
6703
- }
6704
- };
6705
6660
 
6706
6661
  // src/movecall/springsui.ts
6707
6662
  var SpringsuiRouter = class {
@@ -7948,13 +7903,21 @@ var dealWithFastRouterSwapParamsForMsafe = (data) => {
7948
7903
  const result = __spreadProps(__spreadValues({}, data), {
7949
7904
  amountIn: (_a = data == null ? void 0 : data.amountIn) == null ? void 0 : _a.toString(),
7950
7905
  amountOut: (_b = data == null ? void 0 : data.amountIn) == null ? void 0 : _b.toString(),
7951
- routes: (_c = data == null ? void 0 : data.routes) == null ? void 0 : _c.map((item) => {
7952
- var _a2, _b2, _c2;
7953
- return __spreadProps(__spreadValues({}, item), {
7906
+ paths: (_c = data == null ? void 0 : data.paths) == null ? void 0 : _c.map((item) => {
7907
+ var _a2, _b2, _c2, _d, _e, _f;
7908
+ const info = __spreadProps(__spreadValues({}, item), {
7954
7909
  amountIn: (_a2 = item == null ? void 0 : item.amountIn) == null ? void 0 : _a2.toString(),
7955
- amountOut: (_b2 = item == null ? void 0 : item.amountOut) == null ? void 0 : _b2.toString(),
7956
- initialPrice: (_c2 = item == null ? void 0 : item.initialPrice) == null ? void 0 : _c2.toString()
7910
+ amountOut: (_b2 = item == null ? void 0 : item.amountOut) == null ? void 0 : _b2.toString()
7957
7911
  });
7912
+ if (item == null ? void 0 : item.initialPrice) {
7913
+ info["initialPrice"] = (_c2 = item == null ? void 0 : item.initialPrice) == null ? void 0 : _c2.toString();
7914
+ }
7915
+ if ((_d = item == null ? void 0 : item.extendedDetails) == null ? void 0 : _d.after_sqrt_price) {
7916
+ info["extendedDetails"] = {
7917
+ after_sqrt_price: (_f = (_e = item == null ? void 0 : item.extendedDetails) == null ? void 0 : _e.afterSqrtPrice) == null ? void 0 : _f.toString()
7918
+ };
7919
+ }
7920
+ return info;
7958
7921
  })
7959
7922
  });
7960
7923
  return result;
@@ -7964,13 +7927,18 @@ var restituteMsafeFastRouterSwapParams = (data) => {
7964
7927
  const result = __spreadProps(__spreadValues({}, data), {
7965
7928
  amountIn: new import_bn5.default(data == null ? void 0 : data.amountIn),
7966
7929
  amountOut: new import_bn5.default(data == null ? void 0 : data.amountIn),
7967
- routes: (_a = data == null ? void 0 : data.routes) == null ? void 0 : _a.map((item) => {
7968
- var _a2;
7969
- return __spreadProps(__spreadValues({}, item), {
7970
- amountIn: new import_bn5.default(item == null ? void 0 : item.amountIn),
7971
- amountOut: new import_bn5.default(item == null ? void 0 : item.amountOut),
7972
- initialPrice: new decimal_default((_a2 = item == null ? void 0 : item.initialPrice) == null ? void 0 : _a2.toString())
7973
- });
7930
+ paths: (_a = data == null ? void 0 : data.paths) == null ? void 0 : _a.map((item) => {
7931
+ var _a2, _b, _c, _d;
7932
+ const info = __spreadValues({}, item);
7933
+ if (item == null ? void 0 : item.initialPrice) {
7934
+ info["initialPrice"] = new decimal_default((_a2 = item == null ? void 0 : item.initialPrice) == null ? void 0 : _a2.toString());
7935
+ }
7936
+ if ((_b = item == null ? void 0 : item.extendedDetails) == null ? void 0 : _b.after_sqrt_price) {
7937
+ info["extendedDetails"] = {
7938
+ after_sqrt_price: new decimal_default((_d = (_c = item == null ? void 0 : item.extendedDetails) == null ? void 0 : _c.after_sqrt_price) == null ? void 0 : _d.toString())
7939
+ };
7940
+ }
7941
+ return info;
7974
7942
  })
7975
7943
  });
7976
7944
  return result;
@@ -8354,7 +8322,7 @@ var _AggregatorClient = class _AggregatorClient {
8354
8322
  case SCALLOP:
8355
8323
  return new ScallopRouter(this.env);
8356
8324
  case SUILEND:
8357
- return new SuilendRouter(this.env);
8325
+ return new SpringsuiRouter(this.env);
8358
8326
  case SPRINGSUI:
8359
8327
  return new SpringsuiRouter(this.env);
8360
8328
  case HAEDALPMM:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cetusprotocol/aggregator-sdk",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "sideEffects": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",