@cetusprotocol/aggregator-sdk 0.0.0-experimental-20250625194009 → 0.0.0-experimental-20250626105736

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
@@ -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;
@@ -7069,10 +7074,18 @@ var _AggregatorClient = class _AggregatorClient {
7069
7074
  );
7070
7075
  for (let i = 0; i < routers.length; i++) {
7071
7076
  const router = routers[i];
7072
- let amount_arg = txb.pure.u64(router.amountOut.toString());
7077
+ let amount_arg = txb.pure.u64(
7078
+ router.amountOut.toString()
7079
+ );
7073
7080
  for (let j = router.path.length - 1; j >= 0; j--) {
7074
7081
  const path = router.path[j];
7075
- const flashSwapResult = dex.flash_swap(this, txb, path, amount_arg, false);
7082
+ const flashSwapResult = dex.flash_swap(
7083
+ this,
7084
+ txb,
7085
+ path,
7086
+ amount_arg,
7087
+ false
7088
+ );
7076
7089
  amount_arg = flashSwapResult.payAmount;
7077
7090
  returnCoins.unshift(flashSwapResult.targetCoin);
7078
7091
  receipts.unshift(flashSwapResult.flashReceipt);
@@ -7392,7 +7405,7 @@ var _AggregatorClient = class _AggregatorClient {
7392
7405
  }
7393
7406
  publishedAtV2Extend2() {
7394
7407
  if (this.env === 0 /* Mainnet */) {
7395
- return "0x96356d1cfc7a4dec5bc0171f085ddaf1f650b1c6c412f209518d496c8ffed212";
7408
+ return "0xc40b43f0aa4ba5a4d71e39770265d3698d0e6dcfd846b7d7c443207f4e919e04";
7396
7409
  } else {
7397
7410
  return "0x0";
7398
7411
  }
@@ -7714,8 +7727,8 @@ function parseRouterResponse(data, byAmountIn) {
7714
7727
  version
7715
7728
  };
7716
7729
  }),
7717
- amountIn: new import_bn5.default(BigInt(route.amount_in).toString()),
7718
- amountOut: new import_bn5.default(BigInt(route.amount_out).toString()),
7730
+ amountIn: new import_bn5.default(route.amount_in.toString()),
7731
+ amountOut: new import_bn5.default(route.amount_out.toString()),
7719
7732
  initialPrice: new decimal_default(route.initial_price.toString())
7720
7733
  };
7721
7734
  }),
@@ -7824,34 +7837,7 @@ function getRouterResult(endpoint, apiKey, params, overlayFee, overlayFeeReceive
7824
7837
  }
7825
7838
  };
7826
7839
  }
7827
- console.log("sdk getRouterResult \u{1F680} ~ response:", response);
7828
- const test = yield response.text().then((text) => {
7829
- const bigNumbers = [];
7830
- const regex = /"([^"]+)"\s*:\s*(\d{16,})/g;
7831
- const matches = text.matchAll(regex);
7832
- for (const match of matches) {
7833
- const key = match[1];
7834
- const value = match[2];
7835
- if (value.length > 15) {
7836
- bigNumbers.push({ key, value });
7837
- }
7838
- }
7839
- let safeText = text;
7840
- bigNumbers.forEach(({ key, value }) => {
7841
- safeText = safeText.replace(`"${key}":${value}`, `"${key}":"${value}"`);
7842
- });
7843
- const data2 = JSON.parse(safeText);
7844
- console.log("\u5B89\u5168\u89E3\u6790\u7684\u6570\u636E:", data2);
7845
- return data2;
7846
- });
7847
- console.log("sdk getRouterResult \u{1F680} ~ test:", test);
7848
- const blob = yield response.blob().then((blob2) => blob2.text()).then((rawText) => {
7849
- console.log("sdk getRouterResult\u539F\u59CB\u54CD\u5E94\u6587\u672C:", rawText);
7850
- return rawText;
7851
- });
7852
- console.log("sdk getRouterResult \u{1F680} ~ blob:", blob);
7853
- const data = yield response.json();
7854
- console.log("sdk getRouterResult \u{1F680} ~ data:", data);
7840
+ const data = JSONbig__default.default.parse(yield response.text());
7855
7841
  const insufficientLiquidity = data.msg === "liquidity is not enough";
7856
7842
  if (data.msg && data.msg.indexOf("HoneyPot scam") > -1) {
7857
7843
  return {
@@ -7870,7 +7856,6 @@ function getRouterResult(endpoint, apiKey, params, overlayFee, overlayFeeReceive
7870
7856
  }
7871
7857
  if (data.data != null) {
7872
7858
  const res = parseRouterResponse(data.data, params.byAmountIn);
7873
- console.log("sdk getRouterResult parseRouterResponse \u{1F680} ~ res:", res);
7874
7859
  if (overlayFee > 0 && overlayFeeReceiver !== "0x0") {
7875
7860
  if (params.byAmountIn) {
7876
7861
  const overlayFeeAmount = res.amountOut.mul(new import_bn7.default(overlayFee)).div(new import_bn7.default(1e6));
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;
@@ -7067,10 +7068,18 @@ var _AggregatorClient = class _AggregatorClient {
7067
7068
  );
7068
7069
  for (let i = 0; i < routers.length; i++) {
7069
7070
  const router = routers[i];
7070
- let amount_arg = txb.pure.u64(router.amountOut.toString());
7071
+ let amount_arg = txb.pure.u64(
7072
+ router.amountOut.toString()
7073
+ );
7071
7074
  for (let j = router.path.length - 1; j >= 0; j--) {
7072
7075
  const path = router.path[j];
7073
- const flashSwapResult = dex.flash_swap(this, txb, path, amount_arg, false);
7076
+ const flashSwapResult = dex.flash_swap(
7077
+ this,
7078
+ txb,
7079
+ path,
7080
+ amount_arg,
7081
+ false
7082
+ );
7074
7083
  amount_arg = flashSwapResult.payAmount;
7075
7084
  returnCoins.unshift(flashSwapResult.targetCoin);
7076
7085
  receipts.unshift(flashSwapResult.flashReceipt);
@@ -7390,7 +7399,7 @@ var _AggregatorClient = class _AggregatorClient {
7390
7399
  }
7391
7400
  publishedAtV2Extend2() {
7392
7401
  if (this.env === 0 /* Mainnet */) {
7393
- return "0x96356d1cfc7a4dec5bc0171f085ddaf1f650b1c6c412f209518d496c8ffed212";
7402
+ return "0xc40b43f0aa4ba5a4d71e39770265d3698d0e6dcfd846b7d7c443207f4e919e04";
7394
7403
  } else {
7395
7404
  return "0x0";
7396
7405
  }
@@ -7712,8 +7721,8 @@ function parseRouterResponse(data, byAmountIn) {
7712
7721
  version
7713
7722
  };
7714
7723
  }),
7715
- amountIn: new import_bn5.default(BigInt(route.amount_in).toString()),
7716
- amountOut: new import_bn5.default(BigInt(route.amount_out).toString()),
7724
+ amountIn: new import_bn5.default(route.amount_in.toString()),
7725
+ amountOut: new import_bn5.default(route.amount_out.toString()),
7717
7726
  initialPrice: new decimal_default(route.initial_price.toString())
7718
7727
  };
7719
7728
  }),
@@ -7822,34 +7831,7 @@ function getRouterResult(endpoint, apiKey, params, overlayFee, overlayFeeReceive
7822
7831
  }
7823
7832
  };
7824
7833
  }
7825
- console.log("sdk getRouterResult \u{1F680} ~ response:", response);
7826
- const test = yield response.text().then((text) => {
7827
- const bigNumbers = [];
7828
- const regex = /"([^"]+)"\s*:\s*(\d{16,})/g;
7829
- const matches = text.matchAll(regex);
7830
- for (const match of matches) {
7831
- const key = match[1];
7832
- const value = match[2];
7833
- if (value.length > 15) {
7834
- bigNumbers.push({ key, value });
7835
- }
7836
- }
7837
- let safeText = text;
7838
- bigNumbers.forEach(({ key, value }) => {
7839
- safeText = safeText.replace(`"${key}":${value}`, `"${key}":"${value}"`);
7840
- });
7841
- const data2 = JSON.parse(safeText);
7842
- console.log("\u5B89\u5168\u89E3\u6790\u7684\u6570\u636E:", data2);
7843
- return data2;
7844
- });
7845
- console.log("sdk getRouterResult \u{1F680} ~ test:", test);
7846
- const blob = yield response.blob().then((blob2) => blob2.text()).then((rawText) => {
7847
- console.log("sdk getRouterResult\u539F\u59CB\u54CD\u5E94\u6587\u672C:", rawText);
7848
- return rawText;
7849
- });
7850
- console.log("sdk getRouterResult \u{1F680} ~ blob:", blob);
7851
- const data = yield response.json();
7852
- console.log("sdk getRouterResult \u{1F680} ~ data:", data);
7834
+ const data = JSONbig.parse(yield response.text());
7853
7835
  const insufficientLiquidity = data.msg === "liquidity is not enough";
7854
7836
  if (data.msg && data.msg.indexOf("HoneyPot scam") > -1) {
7855
7837
  return {
@@ -7868,7 +7850,6 @@ function getRouterResult(endpoint, apiKey, params, overlayFee, overlayFeeReceive
7868
7850
  }
7869
7851
  if (data.data != null) {
7870
7852
  const res = parseRouterResponse(data.data, params.byAmountIn);
7871
- console.log("sdk getRouterResult parseRouterResponse \u{1F680} ~ res:", res);
7872
7853
  if (overlayFee > 0 && overlayFeeReceiver !== "0x0") {
7873
7854
  if (params.byAmountIn) {
7874
7855
  const overlayFeeAmount = res.amountOut.mul(new import_bn7.default(overlayFee)).div(new import_bn7.default(1e6));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cetusprotocol/aggregator-sdk",
3
- "version": "0.0.0-experimental-20250625194009",
3
+ "version": "0.0.0-experimental-20250626105736",
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
  }