@cetusprotocol/aggregator-sdk 0.10.0 → 0.11.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
@@ -6821,7 +6821,9 @@ var _AggregatorClient = class _AggregatorClient {
6821
6821
  if (!pythUrls.includes("https://hermes.pyth.network")) {
6822
6822
  pythUrls.push("https://hermes.pyth.network");
6823
6823
  }
6824
- const connections = pythUrls.map((url) => new pythSuiJs.SuiPriceServiceConnection(url, { timeout: 3e3 }));
6824
+ const connections = pythUrls.map(
6825
+ (url) => new pythSuiJs.SuiPriceServiceConnection(url, { timeout: 3e3 })
6826
+ );
6825
6827
  return connections;
6826
6828
  }
6827
6829
  getCoins(coinType, refresh = true) {
@@ -6868,7 +6870,13 @@ var _AggregatorClient = class _AggregatorClient {
6868
6870
  }
6869
6871
  findRouters(params) {
6870
6872
  return __async(this, null, function* () {
6871
- return getRouterResult(this.endpoint, this.apiKey, params, this.overlayFeeRate, this.overlayFeeReceiver);
6873
+ return getRouterResult(
6874
+ this.endpoint,
6875
+ this.apiKey,
6876
+ params,
6877
+ this.overlayFeeRate,
6878
+ this.overlayFeeReceiver
6879
+ );
6872
6880
  });
6873
6881
  }
6874
6882
  executeFlexibleInputSwap(txb, inputCoin, routers, expectedAmountOut, amountLimit, pythPriceIDs, partner, deepbookv3DeepFee, packages) {
@@ -6882,7 +6890,9 @@ var _AggregatorClient = class _AggregatorClient {
6882
6890
  if (routers[i].path.length === 0) {
6883
6891
  throw new Error("Empty path");
6884
6892
  }
6885
- const splitCoin = txb.splitCoins(inputCoin, [routers[i].amountIn.toString()]);
6893
+ const splitCoin = txb.splitCoins(inputCoin, [
6894
+ routers[i].amountIn.toString()
6895
+ ]);
6886
6896
  let nextCoin = splitCoin[0];
6887
6897
  for (const path of routers[i].path) {
6888
6898
  const dex = this.newDex(path.provider, pythPriceIDs, partner);
@@ -7059,7 +7069,9 @@ var _AggregatorClient = class _AggregatorClient {
7059
7069
  return __async(this, null, function* () {
7060
7070
  const { routers, inputCoin, slippage, txb, deepbookv3DeepFee, partner } = params;
7061
7071
  if (slippage > 1 || slippage < 0) {
7062
- throw new Error("Invalid slippage value. Must be between 0 and 1 (e.g., 0.01 represents 1% slippage)");
7072
+ throw new Error(
7073
+ "Invalid slippage value. Must be between 0 and 1 (e.g., 0.01 represents 1% slippage)"
7074
+ );
7063
7075
  }
7064
7076
  const routerData = Array.isArray(routers) ? routers : routers.routes;
7065
7077
  const byAmountIn = isBuilderRouterSwapParams(params) ? params.byAmountIn : params.routers.byAmountIn;
@@ -7108,9 +7120,7 @@ var _AggregatorClient = class _AggregatorClient {
7108
7120
  return targetCoin2;
7109
7121
  }
7110
7122
  if (this.overlayFeeRate > 0 && this.overlayFeeReceiver !== "0x0") {
7111
- const overlayFeeCoin = txb.splitCoins(inputCoin, [
7112
- overlayFee.toString()
7113
- ]);
7123
+ const overlayFeeCoin = txb.splitCoins(inputCoin, [overlayFee.toString()]);
7114
7124
  txb.transferObjects([overlayFeeCoin], this.overlayFeeReceiver);
7115
7125
  }
7116
7126
  const splitedInputCoins = txb.splitCoins(inputCoin, [
@@ -7147,9 +7157,13 @@ var _AggregatorClient = class _AggregatorClient {
7147
7157
  let overlayFee = 0;
7148
7158
  if (this.overlayFeeRate > 0 && this.overlayFeeReceiver !== "0x0") {
7149
7159
  if (byAmountIn) {
7150
- overlayFee = Number(amountOut.mul(new import_bn5.default(this.overlayFeeRate)).div(new import_bn5.default(1e6)).toString());
7160
+ overlayFee = Number(
7161
+ amountOut.mul(new import_bn5.default(this.overlayFeeRate)).div(new import_bn5.default(1e6)).toString()
7162
+ );
7151
7163
  } else {
7152
- overlayFee = Number(amountIn.mul(new import_bn5.default(this.overlayFeeRate)).div(new import_bn5.default(1e6)).toString());
7164
+ overlayFee = Number(
7165
+ amountIn.mul(new import_bn5.default(this.overlayFeeRate)).div(new import_bn5.default(1e6)).toString()
7166
+ );
7153
7167
  }
7154
7168
  }
7155
7169
  const expectedAmountOut = byAmountIn ? amountOut.sub(new import_bn5.default(overlayFee)) : amountOut;
@@ -7213,9 +7227,13 @@ var _AggregatorClient = class _AggregatorClient {
7213
7227
  let overlayFee = 0;
7214
7228
  if (this.overlayFeeRate > 0 && this.overlayFeeReceiver !== "0x0") {
7215
7229
  if (byAmountIn) {
7216
- overlayFee = Number(amountOut.mul(new import_bn5.default(this.overlayFeeRate)).div(new import_bn5.default(1e6)).toString());
7230
+ overlayFee = Number(
7231
+ amountOut.mul(new import_bn5.default(this.overlayFeeRate)).div(new import_bn5.default(1e6)).toString()
7232
+ );
7217
7233
  } else {
7218
- overlayFee = Number(amountIn.mul(new import_bn5.default(this.overlayFeeRate)).div(new import_bn5.default(1e6)).toString());
7234
+ overlayFee = Number(
7235
+ amountIn.mul(new import_bn5.default(this.overlayFeeRate)).div(new import_bn5.default(1e6)).toString()
7236
+ );
7219
7237
  }
7220
7238
  }
7221
7239
  const expectedAmountOut = byAmountIn ? amountOut.sub(new import_bn5.default(overlayFee)) : amountOut;
@@ -7290,7 +7308,7 @@ var _AggregatorClient = class _AggregatorClient {
7290
7308
  // Include cetus、deepbookv2、flowxv2 & v3、kriyav2 & v3、turbos、aftermath、haedal、afsui、volo、bluemove
7291
7309
  publishedAtV2() {
7292
7310
  if (this.env === 0 /* Mainnet */) {
7293
- return "0x3864c7c59a4889fec05d1aae4bc9dba5a0e0940594b424fbed44cb3f6ac4c032";
7311
+ return "0x51966dc1d9d3e6d85aed55aa87eb9e78e928b4e74b4844a15ef7e3dfb5af3bae";
7294
7312
  } else {
7295
7313
  return "0x52eae33adeb44de55cfb3f281d4cc9e02d976181c0952f5323648b5717b33934";
7296
7314
  }
@@ -7298,14 +7316,14 @@ var _AggregatorClient = class _AggregatorClient {
7298
7316
  // Include deepbookv3, scallop, bluefin
7299
7317
  publishedAtV2Extend() {
7300
7318
  if (this.env === 0 /* Mainnet */) {
7301
- return "0xa2fe8e900d719813fee1ffaea14d5a2b5516a4d15b75f14aa0cf27c531c20ae3";
7319
+ return "0x7cdd26c4aa40c990d5ca780e0919b2de796be9bb41fba461d133bfacb0f677bc";
7302
7320
  } else {
7303
7321
  return "0xabb6a81c8a216828e317719e06125de5bb2cb0fe8f9916ff8c023ca5be224c78";
7304
7322
  }
7305
7323
  }
7306
7324
  publishedAtV2Extend2() {
7307
7325
  if (this.env === 0 /* Mainnet */) {
7308
- return "0xed2b71968fb6b74c2161bad4c98561c28c69ce82df2cb3707c3b8bc947f2162d";
7326
+ return "0x186d6d71cedd341ad744e40873cc1513ac539ffac860d0c3ebd27ec5da63d9ba";
7309
7327
  } else {
7310
7328
  return "0x0";
7311
7329
  }
@@ -7487,7 +7505,9 @@ var _AggregatorClient = class _AggregatorClient {
7487
7505
  priceIDs
7488
7506
  );
7489
7507
  } catch (e) {
7490
- throw new Error(`All Pyth price nodes are unavailable. Cannot fetch price data. Please switch to or add new available Pyth nodes in the pythUrls parameter when initializing AggregatorClient, for example: new AggregatorClient({ pythUrls: ["https://your-pyth-node-url"] }). Detailed error: ${e}`);
7508
+ throw new Error(
7509
+ `All Pyth price nodes are unavailable. Cannot fetch price data. Please switch to or add new available Pyth nodes in the pythUrls parameter when initializing AggregatorClient, for example: new AggregatorClient({ pythUrls: ["https://your-pyth-node-url"] }). Detailed error: ${e}`
7510
+ );
7491
7511
  }
7492
7512
  let priceInfoObjectIdsMap = /* @__PURE__ */ new Map();
7493
7513
  for (let i = 0; i < priceIDs.length; i++) {
@@ -7704,7 +7724,7 @@ function processEndpoint(endpoint) {
7704
7724
 
7705
7725
  // src/api.ts
7706
7726
  var import_bn7 = __toESM(require_bn());
7707
- var SDK_VERSION = 1001e3;
7727
+ var SDK_VERSION = 1001100;
7708
7728
  function getRouterResult(endpoint, apiKey, params, overlayFee, overlayFeeReceiver) {
7709
7729
  return __async(this, null, function* () {
7710
7730
  let response;
package/dist/index.mjs CHANGED
@@ -6819,7 +6819,9 @@ var _AggregatorClient = class _AggregatorClient {
6819
6819
  if (!pythUrls.includes("https://hermes.pyth.network")) {
6820
6820
  pythUrls.push("https://hermes.pyth.network");
6821
6821
  }
6822
- const connections = pythUrls.map((url) => new SuiPriceServiceConnection(url, { timeout: 3e3 }));
6822
+ const connections = pythUrls.map(
6823
+ (url) => new SuiPriceServiceConnection(url, { timeout: 3e3 })
6824
+ );
6823
6825
  return connections;
6824
6826
  }
6825
6827
  getCoins(coinType, refresh = true) {
@@ -6866,7 +6868,13 @@ var _AggregatorClient = class _AggregatorClient {
6866
6868
  }
6867
6869
  findRouters(params) {
6868
6870
  return __async(this, null, function* () {
6869
- return getRouterResult(this.endpoint, this.apiKey, params, this.overlayFeeRate, this.overlayFeeReceiver);
6871
+ return getRouterResult(
6872
+ this.endpoint,
6873
+ this.apiKey,
6874
+ params,
6875
+ this.overlayFeeRate,
6876
+ this.overlayFeeReceiver
6877
+ );
6870
6878
  });
6871
6879
  }
6872
6880
  executeFlexibleInputSwap(txb, inputCoin, routers, expectedAmountOut, amountLimit, pythPriceIDs, partner, deepbookv3DeepFee, packages) {
@@ -6880,7 +6888,9 @@ var _AggregatorClient = class _AggregatorClient {
6880
6888
  if (routers[i].path.length === 0) {
6881
6889
  throw new Error("Empty path");
6882
6890
  }
6883
- const splitCoin = txb.splitCoins(inputCoin, [routers[i].amountIn.toString()]);
6891
+ const splitCoin = txb.splitCoins(inputCoin, [
6892
+ routers[i].amountIn.toString()
6893
+ ]);
6884
6894
  let nextCoin = splitCoin[0];
6885
6895
  for (const path of routers[i].path) {
6886
6896
  const dex = this.newDex(path.provider, pythPriceIDs, partner);
@@ -7057,7 +7067,9 @@ var _AggregatorClient = class _AggregatorClient {
7057
7067
  return __async(this, null, function* () {
7058
7068
  const { routers, inputCoin, slippage, txb, deepbookv3DeepFee, partner } = params;
7059
7069
  if (slippage > 1 || slippage < 0) {
7060
- throw new Error("Invalid slippage value. Must be between 0 and 1 (e.g., 0.01 represents 1% slippage)");
7070
+ throw new Error(
7071
+ "Invalid slippage value. Must be between 0 and 1 (e.g., 0.01 represents 1% slippage)"
7072
+ );
7061
7073
  }
7062
7074
  const routerData = Array.isArray(routers) ? routers : routers.routes;
7063
7075
  const byAmountIn = isBuilderRouterSwapParams(params) ? params.byAmountIn : params.routers.byAmountIn;
@@ -7106,9 +7118,7 @@ var _AggregatorClient = class _AggregatorClient {
7106
7118
  return targetCoin2;
7107
7119
  }
7108
7120
  if (this.overlayFeeRate > 0 && this.overlayFeeReceiver !== "0x0") {
7109
- const overlayFeeCoin = txb.splitCoins(inputCoin, [
7110
- overlayFee.toString()
7111
- ]);
7121
+ const overlayFeeCoin = txb.splitCoins(inputCoin, [overlayFee.toString()]);
7112
7122
  txb.transferObjects([overlayFeeCoin], this.overlayFeeReceiver);
7113
7123
  }
7114
7124
  const splitedInputCoins = txb.splitCoins(inputCoin, [
@@ -7145,9 +7155,13 @@ var _AggregatorClient = class _AggregatorClient {
7145
7155
  let overlayFee = 0;
7146
7156
  if (this.overlayFeeRate > 0 && this.overlayFeeReceiver !== "0x0") {
7147
7157
  if (byAmountIn) {
7148
- overlayFee = Number(amountOut.mul(new import_bn5.default(this.overlayFeeRate)).div(new import_bn5.default(1e6)).toString());
7158
+ overlayFee = Number(
7159
+ amountOut.mul(new import_bn5.default(this.overlayFeeRate)).div(new import_bn5.default(1e6)).toString()
7160
+ );
7149
7161
  } else {
7150
- overlayFee = Number(amountIn.mul(new import_bn5.default(this.overlayFeeRate)).div(new import_bn5.default(1e6)).toString());
7162
+ overlayFee = Number(
7163
+ amountIn.mul(new import_bn5.default(this.overlayFeeRate)).div(new import_bn5.default(1e6)).toString()
7164
+ );
7151
7165
  }
7152
7166
  }
7153
7167
  const expectedAmountOut = byAmountIn ? amountOut.sub(new import_bn5.default(overlayFee)) : amountOut;
@@ -7211,9 +7225,13 @@ var _AggregatorClient = class _AggregatorClient {
7211
7225
  let overlayFee = 0;
7212
7226
  if (this.overlayFeeRate > 0 && this.overlayFeeReceiver !== "0x0") {
7213
7227
  if (byAmountIn) {
7214
- overlayFee = Number(amountOut.mul(new import_bn5.default(this.overlayFeeRate)).div(new import_bn5.default(1e6)).toString());
7228
+ overlayFee = Number(
7229
+ amountOut.mul(new import_bn5.default(this.overlayFeeRate)).div(new import_bn5.default(1e6)).toString()
7230
+ );
7215
7231
  } else {
7216
- overlayFee = Number(amountIn.mul(new import_bn5.default(this.overlayFeeRate)).div(new import_bn5.default(1e6)).toString());
7232
+ overlayFee = Number(
7233
+ amountIn.mul(new import_bn5.default(this.overlayFeeRate)).div(new import_bn5.default(1e6)).toString()
7234
+ );
7217
7235
  }
7218
7236
  }
7219
7237
  const expectedAmountOut = byAmountIn ? amountOut.sub(new import_bn5.default(overlayFee)) : amountOut;
@@ -7288,7 +7306,7 @@ var _AggregatorClient = class _AggregatorClient {
7288
7306
  // Include cetus、deepbookv2、flowxv2 & v3、kriyav2 & v3、turbos、aftermath、haedal、afsui、volo、bluemove
7289
7307
  publishedAtV2() {
7290
7308
  if (this.env === 0 /* Mainnet */) {
7291
- return "0x3864c7c59a4889fec05d1aae4bc9dba5a0e0940594b424fbed44cb3f6ac4c032";
7309
+ return "0x51966dc1d9d3e6d85aed55aa87eb9e78e928b4e74b4844a15ef7e3dfb5af3bae";
7292
7310
  } else {
7293
7311
  return "0x52eae33adeb44de55cfb3f281d4cc9e02d976181c0952f5323648b5717b33934";
7294
7312
  }
@@ -7296,14 +7314,14 @@ var _AggregatorClient = class _AggregatorClient {
7296
7314
  // Include deepbookv3, scallop, bluefin
7297
7315
  publishedAtV2Extend() {
7298
7316
  if (this.env === 0 /* Mainnet */) {
7299
- return "0xa2fe8e900d719813fee1ffaea14d5a2b5516a4d15b75f14aa0cf27c531c20ae3";
7317
+ return "0x7cdd26c4aa40c990d5ca780e0919b2de796be9bb41fba461d133bfacb0f677bc";
7300
7318
  } else {
7301
7319
  return "0xabb6a81c8a216828e317719e06125de5bb2cb0fe8f9916ff8c023ca5be224c78";
7302
7320
  }
7303
7321
  }
7304
7322
  publishedAtV2Extend2() {
7305
7323
  if (this.env === 0 /* Mainnet */) {
7306
- return "0xed2b71968fb6b74c2161bad4c98561c28c69ce82df2cb3707c3b8bc947f2162d";
7324
+ return "0x186d6d71cedd341ad744e40873cc1513ac539ffac860d0c3ebd27ec5da63d9ba";
7307
7325
  } else {
7308
7326
  return "0x0";
7309
7327
  }
@@ -7485,7 +7503,9 @@ var _AggregatorClient = class _AggregatorClient {
7485
7503
  priceIDs
7486
7504
  );
7487
7505
  } catch (e) {
7488
- throw new Error(`All Pyth price nodes are unavailable. Cannot fetch price data. Please switch to or add new available Pyth nodes in the pythUrls parameter when initializing AggregatorClient, for example: new AggregatorClient({ pythUrls: ["https://your-pyth-node-url"] }). Detailed error: ${e}`);
7506
+ throw new Error(
7507
+ `All Pyth price nodes are unavailable. Cannot fetch price data. Please switch to or add new available Pyth nodes in the pythUrls parameter when initializing AggregatorClient, for example: new AggregatorClient({ pythUrls: ["https://your-pyth-node-url"] }). Detailed error: ${e}`
7508
+ );
7489
7509
  }
7490
7510
  let priceInfoObjectIdsMap = /* @__PURE__ */ new Map();
7491
7511
  for (let i = 0; i < priceIDs.length; i++) {
@@ -7702,7 +7722,7 @@ function processEndpoint(endpoint) {
7702
7722
 
7703
7723
  // src/api.ts
7704
7724
  var import_bn7 = __toESM(require_bn());
7705
- var SDK_VERSION = 1001e3;
7725
+ var SDK_VERSION = 1001100;
7706
7726
  function getRouterResult(endpoint, apiKey, params, overlayFee, overlayFeeReceiver) {
7707
7727
  return __async(this, null, function* () {
7708
7728
  let response;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cetusprotocol/aggregator-sdk",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "sideEffects": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",