@cetusprotocol/aggregator-sdk 0.3.19 → 0.3.20

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
@@ -6786,24 +6786,34 @@ function getAggregatorV2ExtendPublishedAt(aggregatorV2ExtendPublishedAt, package
6786
6786
  // src/utils/msafe.ts
6787
6787
  var import_bn6 = __toESM(require_bn());
6788
6788
  var dealWithFastRouterSwapParamsForMsafe = (data) => {
6789
- const result = data.map((route) => {
6790
- return __spreadProps(__spreadValues({}, route), {
6791
- amountIn: route.amountIn.toString(),
6792
- amountOut: route.amountOut.toString(),
6793
- initialPrice: route.initialPrice.toString(),
6794
- path: route.path
6795
- });
6789
+ var _a, _b, _c;
6790
+ const result = __spreadProps(__spreadValues({}, data), {
6791
+ amountIn: (_a = data == null ? void 0 : data.amountIn) == null ? void 0 : _a.toString(),
6792
+ amountOut: (_b = data == null ? void 0 : data.amountIn) == null ? void 0 : _b.toString(),
6793
+ routes: (_c = data == null ? void 0 : data.routes) == null ? void 0 : _c.map((item) => {
6794
+ var _a2, _b2, _c2;
6795
+ return __spreadProps(__spreadValues({}, item), {
6796
+ amountIn: (_a2 = item == null ? void 0 : item.amountIn) == null ? void 0 : _a2.toString(),
6797
+ amountOut: (_b2 = item == null ? void 0 : item.amountOut) == null ? void 0 : _b2.toString(),
6798
+ initialPrice: (_c2 = item == null ? void 0 : item.initialPrice) == null ? void 0 : _c2.toString()
6799
+ });
6800
+ })
6796
6801
  });
6797
6802
  return result;
6798
6803
  };
6799
6804
  var restituteMsafeFastRouterSwapParams = (data) => {
6800
- const result = data.map((route) => {
6801
- return __spreadProps(__spreadValues({}, route), {
6802
- amountIn: new import_bn6.default(route.amountIn),
6803
- amountOut: new import_bn6.default(route.amountOut),
6804
- initialPrice: new decimal_default(route.initialPrice.toString()),
6805
- path: route.path
6806
- });
6805
+ var _a;
6806
+ const result = __spreadProps(__spreadValues({}, data), {
6807
+ amountIn: new import_bn6.default(data == null ? void 0 : data.amountIn),
6808
+ amountOut: new import_bn6.default(data == null ? void 0 : data.amountIn),
6809
+ routes: (_a = data == null ? void 0 : data.routes) == null ? void 0 : _a.map((item) => {
6810
+ var _a2;
6811
+ return __spreadProps(__spreadValues({}, item), {
6812
+ amountIn: new import_bn6.default(item == null ? void 0 : item.amountIn),
6813
+ amountOut: new import_bn6.default(item == null ? void 0 : item.amountOut),
6814
+ initialPrice: new decimal_default((_a2 = item == null ? void 0 : item.initialPrice) == null ? void 0 : _a2.toString())
6815
+ });
6816
+ })
6807
6817
  });
6808
6818
  return result;
6809
6819
  };
@@ -6913,7 +6923,7 @@ function getRouter(endpoint, params) {
6913
6923
  url += `&providers=${providers.join(",")}`;
6914
6924
  }
6915
6925
  }
6916
- url += "&v=1000319";
6926
+ url += "&v=1000320";
6917
6927
  const response = yield fetch(url);
6918
6928
  return response;
6919
6929
  } catch (error) {
package/dist/index.mjs CHANGED
@@ -6784,24 +6784,34 @@ function getAggregatorV2ExtendPublishedAt(aggregatorV2ExtendPublishedAt, package
6784
6784
  // src/utils/msafe.ts
6785
6785
  var import_bn6 = __toESM(require_bn());
6786
6786
  var dealWithFastRouterSwapParamsForMsafe = (data) => {
6787
- const result = data.map((route) => {
6788
- return __spreadProps(__spreadValues({}, route), {
6789
- amountIn: route.amountIn.toString(),
6790
- amountOut: route.amountOut.toString(),
6791
- initialPrice: route.initialPrice.toString(),
6792
- path: route.path
6793
- });
6787
+ var _a, _b, _c;
6788
+ const result = __spreadProps(__spreadValues({}, data), {
6789
+ amountIn: (_a = data == null ? void 0 : data.amountIn) == null ? void 0 : _a.toString(),
6790
+ amountOut: (_b = data == null ? void 0 : data.amountIn) == null ? void 0 : _b.toString(),
6791
+ routes: (_c = data == null ? void 0 : data.routes) == null ? void 0 : _c.map((item) => {
6792
+ var _a2, _b2, _c2;
6793
+ return __spreadProps(__spreadValues({}, item), {
6794
+ amountIn: (_a2 = item == null ? void 0 : item.amountIn) == null ? void 0 : _a2.toString(),
6795
+ amountOut: (_b2 = item == null ? void 0 : item.amountOut) == null ? void 0 : _b2.toString(),
6796
+ initialPrice: (_c2 = item == null ? void 0 : item.initialPrice) == null ? void 0 : _c2.toString()
6797
+ });
6798
+ })
6794
6799
  });
6795
6800
  return result;
6796
6801
  };
6797
6802
  var restituteMsafeFastRouterSwapParams = (data) => {
6798
- const result = data.map((route) => {
6799
- return __spreadProps(__spreadValues({}, route), {
6800
- amountIn: new import_bn6.default(route.amountIn),
6801
- amountOut: new import_bn6.default(route.amountOut),
6802
- initialPrice: new decimal_default(route.initialPrice.toString()),
6803
- path: route.path
6804
- });
6803
+ var _a;
6804
+ const result = __spreadProps(__spreadValues({}, data), {
6805
+ amountIn: new import_bn6.default(data == null ? void 0 : data.amountIn),
6806
+ amountOut: new import_bn6.default(data == null ? void 0 : data.amountIn),
6807
+ routes: (_a = data == null ? void 0 : data.routes) == null ? void 0 : _a.map((item) => {
6808
+ var _a2;
6809
+ return __spreadProps(__spreadValues({}, item), {
6810
+ amountIn: new import_bn6.default(item == null ? void 0 : item.amountIn),
6811
+ amountOut: new import_bn6.default(item == null ? void 0 : item.amountOut),
6812
+ initialPrice: new decimal_default((_a2 = item == null ? void 0 : item.initialPrice) == null ? void 0 : _a2.toString())
6813
+ });
6814
+ })
6805
6815
  });
6806
6816
  return result;
6807
6817
  };
@@ -6911,7 +6921,7 @@ function getRouter(endpoint, params) {
6911
6921
  url += `&providers=${providers.join(",")}`;
6912
6922
  }
6913
6923
  }
6914
- url += "&v=1000319";
6924
+ url += "&v=1000320";
6915
6925
  const response = yield fetch(url);
6916
6926
  return response;
6917
6927
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cetusprotocol/aggregator-sdk",
3
- "version": "0.3.19",
3
+ "version": "0.3.20",
4
4
  "sideEffects": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/api.ts CHANGED
@@ -190,7 +190,7 @@ async function getRouter(endpoint: string, params: FindRouterParams) {
190
190
  }
191
191
 
192
192
  // set newest sdk version
193
- url += "&v=1000319"
193
+ url += "&v=1000320"
194
194
 
195
195
  const response = await fetch(url)
196
196
  return response
@@ -3,29 +3,38 @@ import BN from 'bn.js'
3
3
  import Decimal from "decimal.js"
4
4
 
5
5
  export const dealWithFastRouterSwapParamsForMsafe = (data: any) => {
6
- const result =data.map((route: any) => {
6
+ const result = {
7
+ ...data,
8
+ amountIn: data?.amountIn?.toString(),
9
+ amountOut: data?.amountIn?.toString(),
10
+ routes: data?.routes?.map((item:any) => {
7
11
  return {
8
- ...route,
9
- amountIn: route.amountIn.toString(),
10
- amountOut: route.amountOut.toString(),
11
- initialPrice: route.initialPrice.toString(),
12
- path: route.path
12
+ ...item,
13
+ amountIn: item?.amountIn?.toString(),
14
+ amountOut: item?.amountOut?.toString(),
15
+ initialPrice: item?.initialPrice?.toString()
13
16
  }
14
17
  })
15
-
16
- return result
17
18
  }
18
19
 
19
- export const restituteMsafeFastRouterSwapParams = (data: any) => {
20
- const result =data.map((route: any) => {
20
+ return result
21
+ }
22
+
23
+
24
+ export const restituteMsafeFastRouterSwapParams = (data: any) => {
25
+ const result = {
26
+ ...data,
27
+ amountIn: new BN(data?.amountIn),
28
+ amountOut: new BN(data?.amountIn),
29
+ routes: data?.routes?.map((item:any) => {
21
30
  return {
22
- ...route,
23
- amountIn: new BN(route.amountIn),
24
- amountOut: new BN(route.amountOut),
25
- initialPrice: new Decimal(route.initialPrice.toString()),
26
- path: route.path
31
+ ...item,
32
+ amountIn: new BN(item?.amountIn),
33
+ amountOut: new BN(item?.amountOut),
34
+ initialPrice: new Decimal(item?.initialPrice?.toString())
27
35
  }
28
36
  })
29
-
30
- return result
31
- }
37
+ }
38
+
39
+ return result
40
+ }