@gearbox-protocol/sdk 1.12.1 → 1.12.2

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.
@@ -54,7 +54,7 @@ var PathFinder = /** @class */ (function () {
54
54
  }
55
55
  PathFinder.prototype.findAllSwaps = function (creditAccount, swapOperation, tokenIn, tokenOut, amount, slippage) {
56
56
  return __awaiter(this, void 0, void 0, function () {
57
- var swapTask, results;
57
+ var swapTask, results, unique;
58
58
  return __generator(this, function (_a) {
59
59
  switch (_a.label) {
60
60
  case 0:
@@ -72,10 +72,17 @@ var PathFinder = /** @class */ (function () {
72
72
  return [4 /*yield*/, this.pathFinder.callStatic.findAllSwaps(swapTask)];
73
73
  case 1:
74
74
  results = _a.sent();
75
- return [2 /*return*/, results.map(function (r) { return ({
75
+ unique = {};
76
+ results.forEach(function (r) {
77
+ var key = "".concat(r.amount.toHexString()).concat(r.calls
78
+ .map(function (c) { return "".concat(c.target.toLowerCase()).concat(c.callData); })
79
+ .join("-"));
80
+ unique[key] = {
76
81
  amount: ethers_1.BigNumber.from(r.amount),
77
82
  calls: r.calls,
78
- }); })];
83
+ };
84
+ });
85
+ return [2 /*return*/, Object.values(unique)];
79
86
  }
80
87
  });
81
88
  });
@@ -87,9 +94,6 @@ var PathFinder = /** @class */ (function () {
87
94
  switch (_a.label) {
88
95
  case 0:
89
96
  tokenInAddr = token_1.tokenDataByNetwork[this.network][tokenIn] || tokenIn;
90
- if (creditAccount.balances[tokenInAddr.toLowerCase()].lt(amount)) {
91
- throw new Error("Not enough balance for token ".concat(tokenIn));
92
- }
93
97
  return [4 /*yield*/, this.pathFinder.callStatic.findOneTokenPath(tokenInAddr, amount, token_1.tokenDataByNetwork[this.network][tokenOut] || tokenOut, creditAccount.addr, this._connectors, slippage)];
94
98
  case 1:
95
99
  result = _a.sent();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "1.12.1",
3
+ "version": "1.12.2",
4
4
  "description": "Gearbox SDK",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",