@uniswap/router-sdk 1.10.0 → 1.11.1
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/entities/trade.d.ts +9 -9
- package/dist/router-sdk.cjs.development.js +125 -96
- package/dist/router-sdk.cjs.development.js.map +1 -1
- package/dist/router-sdk.cjs.production.min.js +1 -1
- package/dist/router-sdk.cjs.production.min.js.map +1 -1
- package/dist/router-sdk.esm.js +126 -97
- package/dist/router-sdk.esm.js.map +1 -1
- package/dist/utils/isValidTokenPath.d.ts +7 -0
- package/package.json +3 -2
package/dist/entities/trade.d.ts
CHANGED
|
@@ -18,28 +18,28 @@ export declare class Trade<TInput extends Currency, TOutput extends Currency, TT
|
|
|
18
18
|
inputAmount: CurrencyAmount<TInput>;
|
|
19
19
|
outputAmount: CurrencyAmount<TOutput>;
|
|
20
20
|
}[];
|
|
21
|
-
constructor({ v2Routes, v3Routes, v4Routes,
|
|
22
|
-
v2Routes
|
|
21
|
+
constructor({ v2Routes, v3Routes, v4Routes, mixedRoutes, tradeType, }: {
|
|
22
|
+
v2Routes?: {
|
|
23
23
|
routev2: V2RouteSDK<TInput, TOutput>;
|
|
24
24
|
inputAmount: CurrencyAmount<TInput>;
|
|
25
25
|
outputAmount: CurrencyAmount<TOutput>;
|
|
26
26
|
}[];
|
|
27
|
-
v3Routes
|
|
27
|
+
v3Routes?: {
|
|
28
28
|
routev3: V3RouteSDK<TInput, TOutput>;
|
|
29
29
|
inputAmount: CurrencyAmount<TInput>;
|
|
30
30
|
outputAmount: CurrencyAmount<TOutput>;
|
|
31
31
|
}[];
|
|
32
|
-
v4Routes
|
|
32
|
+
v4Routes?: {
|
|
33
33
|
routev4: V4RouteSDK<TInput, TOutput>;
|
|
34
34
|
inputAmount: CurrencyAmount<TInput>;
|
|
35
35
|
outputAmount: CurrencyAmount<TOutput>;
|
|
36
36
|
}[];
|
|
37
|
-
tradeType: TTradeType;
|
|
38
37
|
mixedRoutes?: {
|
|
39
38
|
mixedRoute: MixedRouteSDK<TInput, TOutput>;
|
|
40
39
|
inputAmount: CurrencyAmount<TInput>;
|
|
41
40
|
outputAmount: CurrencyAmount<TOutput>;
|
|
42
41
|
}[];
|
|
42
|
+
tradeType: TTradeType;
|
|
43
43
|
});
|
|
44
44
|
get inputAmount(): CurrencyAmount<TInput>;
|
|
45
45
|
get outputAmount(): CurrencyAmount<TOutput>;
|
|
@@ -91,12 +91,12 @@ export declare class Trade<TInput extends Currency, TOutput extends Currency, TT
|
|
|
91
91
|
}[], v3Routes: {
|
|
92
92
|
routev3: V3RouteSDK<TInput, TOutput>;
|
|
93
93
|
amount: TTradeType extends TradeType.EXACT_INPUT ? CurrencyAmount<TInput> : CurrencyAmount<TOutput>;
|
|
94
|
-
}[], v4Routes: {
|
|
95
|
-
routev4: V4RouteSDK<TInput, TOutput>;
|
|
96
|
-
amount: TTradeType extends TradeType.EXACT_INPUT ? CurrencyAmount<TInput> : CurrencyAmount<TOutput>;
|
|
97
94
|
}[], tradeType: TTradeType, mixedRoutes?: {
|
|
98
95
|
mixedRoute: MixedRouteSDK<TInput, TOutput>;
|
|
99
96
|
amount: TTradeType extends TradeType.EXACT_INPUT ? CurrencyAmount<TInput> : CurrencyAmount<TOutput>;
|
|
97
|
+
}[], v4Routes?: {
|
|
98
|
+
routev4: V4RouteSDK<TInput, TOutput>;
|
|
99
|
+
amount: TTradeType extends TradeType.EXACT_INPUT ? CurrencyAmount<TInput> : CurrencyAmount<TOutput>;
|
|
100
100
|
}[]): Promise<Trade<TInput, TOutput, TTradeType>>;
|
|
101
|
-
static fromRoute<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(route: V2RouteSDK<TInput, TOutput> | V3RouteSDK<TInput, TOutput> | MixedRouteSDK<TInput, TOutput>, amount: TTradeType extends TradeType.EXACT_INPUT ? CurrencyAmount<TInput> : CurrencyAmount<TOutput>, tradeType: TTradeType): Promise<Trade<TInput, TOutput, TTradeType>>;
|
|
101
|
+
static fromRoute<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(route: V2RouteSDK<TInput, TOutput> | V3RouteSDK<TInput, TOutput> | V4RouteSDK<TInput, TOutput> | MixedRouteSDK<TInput, TOutput>, amount: TTradeType extends TradeType.EXACT_INPUT ? CurrencyAmount<TInput> : CurrencyAmount<TOutput>, tradeType: TTradeType): Promise<Trade<TInput, TOutput, TTradeType>>;
|
|
102
102
|
}
|
|
@@ -622,6 +622,21 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
|
622
622
|
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
623
623
|
}
|
|
624
624
|
|
|
625
|
+
function isValidTokenPath(prevPool, currentPool, inputToken) {
|
|
626
|
+
if (currentPool.involvesToken(inputToken)) return true;
|
|
627
|
+
// throw if both v4 pools, native/wrapped tokens not interchangeable in v4
|
|
628
|
+
if (prevPool instanceof v4Sdk.Pool && currentPool instanceof v4Sdk.Pool) return false;
|
|
629
|
+
// v2/v3 --> v4 valid if v2/v3 output is the wrapped version of the v4 pool native currency
|
|
630
|
+
if (currentPool instanceof v4Sdk.Pool) {
|
|
631
|
+
if (currentPool.token0.wrapped.equals(inputToken) || currentPool.token1.wrapped.equals(inputToken)) return true;
|
|
632
|
+
}
|
|
633
|
+
// v4 --> v2/v3 valid if v4 output is the native version of the v2/v3 wrapped token
|
|
634
|
+
if (prevPool instanceof v4Sdk.Pool) {
|
|
635
|
+
if (currentPool.involvesToken(inputToken.wrapped)) return true;
|
|
636
|
+
}
|
|
637
|
+
return false;
|
|
638
|
+
}
|
|
639
|
+
|
|
625
640
|
/**
|
|
626
641
|
* Represents a list of pools or pairs through which a swap can occur
|
|
627
642
|
* @template TInput The input token
|
|
@@ -658,14 +673,14 @@ var MixedRouteSDK = /*#__PURE__*/function () {
|
|
|
658
673
|
* Normalizes token0-token1 order and selects the next token/fee step to add to the path
|
|
659
674
|
* */
|
|
660
675
|
var tokenPath = [this.adjustedInput];
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
var
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
tokenPath.push(
|
|
676
|
+
pools[0].token0.equals(this.adjustedInput) ? tokenPath.push(pools[0].token1) : tokenPath.push(pools[0].token0);
|
|
677
|
+
for (var i = 1; i < pools.length; i++) {
|
|
678
|
+
var prevPool = pools[i - 1];
|
|
679
|
+
var pool = pools[i];
|
|
680
|
+
var inputToken = tokenPath[i];
|
|
681
|
+
var outputToken = pool.token0.wrapped.equals(inputToken.wrapped) ? pool.token1 : pool.token0;
|
|
682
|
+
!isValidTokenPath(prevPool, pool, inputToken) ? invariant(false, 'PATH') : void 0;
|
|
683
|
+
tokenPath.push(outputToken);
|
|
669
684
|
}
|
|
670
685
|
this.pools = pools;
|
|
671
686
|
this.path = tokenPath;
|
|
@@ -716,32 +731,41 @@ function _getOutputAmount() {
|
|
|
716
731
|
while (1) switch (_context.prev = _context.next) {
|
|
717
732
|
case 0:
|
|
718
733
|
if (!(pool instanceof v4Sdk.Pool)) {
|
|
719
|
-
_context.next =
|
|
734
|
+
_context.next = 13;
|
|
720
735
|
break;
|
|
721
736
|
}
|
|
722
737
|
if (!pool.involvesCurrency(amountIn.currency)) {
|
|
723
|
-
_context.next =
|
|
738
|
+
_context.next = 5;
|
|
724
739
|
break;
|
|
725
740
|
}
|
|
726
741
|
_context.next = 4;
|
|
727
742
|
return pool.getOutputAmount(amountIn);
|
|
728
743
|
case 4:
|
|
729
744
|
return _context.abrupt("return", _context.sent);
|
|
730
|
-
case
|
|
731
|
-
if (!pool.
|
|
732
|
-
_context.next =
|
|
745
|
+
case 5:
|
|
746
|
+
if (!pool.token0.wrapped.equals(amountIn.currency)) {
|
|
747
|
+
_context.next = 9;
|
|
733
748
|
break;
|
|
734
749
|
}
|
|
735
|
-
_context.next =
|
|
736
|
-
return pool.getOutputAmount(amountIn.
|
|
737
|
-
case
|
|
750
|
+
_context.next = 8;
|
|
751
|
+
return pool.getOutputAmount(sdkCore.CurrencyAmount.fromRawAmount(pool.token0, amountIn.quotient));
|
|
752
|
+
case 8:
|
|
753
|
+
return _context.abrupt("return", _context.sent);
|
|
754
|
+
case 9:
|
|
755
|
+
if (!pool.token1.wrapped.equals(amountIn.currency)) {
|
|
756
|
+
_context.next = 13;
|
|
757
|
+
break;
|
|
758
|
+
}
|
|
759
|
+
_context.next = 12;
|
|
760
|
+
return pool.getOutputAmount(sdkCore.CurrencyAmount.fromRawAmount(pool.token1, amountIn.quotient));
|
|
761
|
+
case 12:
|
|
738
762
|
return _context.abrupt("return", _context.sent);
|
|
739
|
-
case 11:
|
|
740
|
-
_context.next = 13;
|
|
741
|
-
return pool.getOutputAmount(amountIn.wrapped);
|
|
742
763
|
case 13:
|
|
764
|
+
_context.next = 15;
|
|
765
|
+
return pool.getOutputAmount(amountIn.wrapped);
|
|
766
|
+
case 15:
|
|
743
767
|
return _context.abrupt("return", _context.sent);
|
|
744
|
-
case
|
|
768
|
+
case 16:
|
|
745
769
|
case "end":
|
|
746
770
|
return _context.stop();
|
|
747
771
|
}
|
|
@@ -1336,48 +1360,65 @@ var MixedRoute = /*#__PURE__*/function (_MixedRouteSDK) {
|
|
|
1336
1360
|
var Trade = /*#__PURE__*/function () {
|
|
1337
1361
|
// construct a trade across v2 and v3 routes from pre-computed amounts
|
|
1338
1362
|
function Trade(_ref) {
|
|
1339
|
-
var v2Routes = _ref.v2Routes,
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1363
|
+
var _ref$v2Routes = _ref.v2Routes,
|
|
1364
|
+
v2Routes = _ref$v2Routes === void 0 ? [] : _ref$v2Routes,
|
|
1365
|
+
_ref$v3Routes = _ref.v3Routes,
|
|
1366
|
+
v3Routes = _ref$v3Routes === void 0 ? [] : _ref$v3Routes,
|
|
1367
|
+
_ref$v4Routes = _ref.v4Routes,
|
|
1368
|
+
v4Routes = _ref$v4Routes === void 0 ? [] : _ref$v4Routes,
|
|
1369
|
+
_ref$mixedRoutes = _ref.mixedRoutes,
|
|
1370
|
+
mixedRoutes = _ref$mixedRoutes === void 0 ? [] : _ref$mixedRoutes,
|
|
1371
|
+
tradeType = _ref.tradeType;
|
|
1344
1372
|
this.swaps = [];
|
|
1345
1373
|
this.routes = [];
|
|
1346
1374
|
// wrap v2 routes
|
|
1347
1375
|
for (var _iterator = _createForOfIteratorHelperLoose(v2Routes), _step; !(_step = _iterator()).done;) {
|
|
1348
1376
|
var _step$value = _step.value,
|
|
1349
1377
|
routev2 = _step$value.routev2,
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
var
|
|
1353
|
-
this.routes.push(
|
|
1378
|
+
inputAmount = _step$value.inputAmount,
|
|
1379
|
+
outputAmount = _step$value.outputAmount;
|
|
1380
|
+
var route = new RouteV2(routev2);
|
|
1381
|
+
this.routes.push(route);
|
|
1354
1382
|
this.swaps.push({
|
|
1355
|
-
route:
|
|
1356
|
-
inputAmount:
|
|
1357
|
-
outputAmount:
|
|
1383
|
+
route: route,
|
|
1384
|
+
inputAmount: inputAmount,
|
|
1385
|
+
outputAmount: outputAmount
|
|
1358
1386
|
});
|
|
1359
1387
|
}
|
|
1360
1388
|
// wrap v3 routes
|
|
1361
1389
|
for (var _iterator2 = _createForOfIteratorHelperLoose(v3Routes), _step2; !(_step2 = _iterator2()).done;) {
|
|
1362
1390
|
var _step2$value = _step2.value,
|
|
1363
1391
|
routev3 = _step2$value.routev3,
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
var
|
|
1367
|
-
this.routes.push(
|
|
1392
|
+
_inputAmount = _step2$value.inputAmount,
|
|
1393
|
+
_outputAmount = _step2$value.outputAmount;
|
|
1394
|
+
var _route = new RouteV3(routev3);
|
|
1395
|
+
this.routes.push(_route);
|
|
1368
1396
|
this.swaps.push({
|
|
1369
|
-
route:
|
|
1370
|
-
inputAmount:
|
|
1371
|
-
outputAmount:
|
|
1397
|
+
route: _route,
|
|
1398
|
+
inputAmount: _inputAmount,
|
|
1399
|
+
outputAmount: _outputAmount
|
|
1372
1400
|
});
|
|
1373
1401
|
}
|
|
1374
1402
|
// wrap v4 routes
|
|
1375
1403
|
for (var _iterator3 = _createForOfIteratorHelperLoose(v4Routes), _step3; !(_step3 = _iterator3()).done;) {
|
|
1376
1404
|
var _step3$value = _step3.value,
|
|
1377
1405
|
routev4 = _step3$value.routev4,
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
var
|
|
1406
|
+
_inputAmount2 = _step3$value.inputAmount,
|
|
1407
|
+
_outputAmount2 = _step3$value.outputAmount;
|
|
1408
|
+
var _route2 = new RouteV4(routev4);
|
|
1409
|
+
this.routes.push(_route2);
|
|
1410
|
+
this.swaps.push({
|
|
1411
|
+
route: _route2,
|
|
1412
|
+
inputAmount: _inputAmount2,
|
|
1413
|
+
outputAmount: _outputAmount2
|
|
1414
|
+
});
|
|
1415
|
+
}
|
|
1416
|
+
for (var _iterator4 = _createForOfIteratorHelperLoose(mixedRoutes), _step4; !(_step4 = _iterator4()).done;) {
|
|
1417
|
+
var _step4$value = _step4.value,
|
|
1418
|
+
mixedRoute = _step4$value.mixedRoute,
|
|
1419
|
+
_inputAmount3 = _step4$value.inputAmount,
|
|
1420
|
+
_outputAmount3 = _step4$value.outputAmount;
|
|
1421
|
+
var _route3 = new MixedRoute(mixedRoute);
|
|
1381
1422
|
this.routes.push(_route3);
|
|
1382
1423
|
this.swaps.push({
|
|
1383
1424
|
route: _route3,
|
|
@@ -1385,22 +1426,6 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1385
1426
|
outputAmount: _outputAmount3
|
|
1386
1427
|
});
|
|
1387
1428
|
}
|
|
1388
|
-
// wrap mixedRoutes
|
|
1389
|
-
if (mixedRoutes) {
|
|
1390
|
-
for (var _iterator4 = _createForOfIteratorHelperLoose(mixedRoutes), _step4; !(_step4 = _iterator4()).done;) {
|
|
1391
|
-
var _step4$value = _step4.value,
|
|
1392
|
-
mixedRoute = _step4$value.mixedRoute,
|
|
1393
|
-
inputAmount = _step4$value.inputAmount,
|
|
1394
|
-
outputAmount = _step4$value.outputAmount;
|
|
1395
|
-
var route = new MixedRoute(mixedRoute);
|
|
1396
|
-
this.routes.push(route);
|
|
1397
|
-
this.swaps.push({
|
|
1398
|
-
route: route,
|
|
1399
|
-
inputAmount: inputAmount,
|
|
1400
|
-
outputAmount: outputAmount
|
|
1401
|
-
});
|
|
1402
|
-
}
|
|
1403
|
-
}
|
|
1404
1429
|
if (this.swaps.length === 0) {
|
|
1405
1430
|
throw new Error('No routes provided when calling Trade constructor');
|
|
1406
1431
|
}
|
|
@@ -1486,8 +1511,8 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1486
1511
|
return new sdkCore.Price(this.inputAmount.currency, this.outputAmount.currency, this.maximumAmountIn(slippageTolerance).quotient, this.minimumAmountOut(slippageTolerance).quotient);
|
|
1487
1512
|
};
|
|
1488
1513
|
Trade.fromRoutes = /*#__PURE__*/function () {
|
|
1489
|
-
var _fromRoutes = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(v2Routes, v3Routes,
|
|
1490
|
-
var populatedV2Routes, populatedV3Routes, populatedV4Routes, populatedMixedRoutes, _iterator7, _step7, _step7$value, routev2,
|
|
1514
|
+
var _fromRoutes = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(v2Routes, v3Routes, tradeType, mixedRoutes, v4Routes) {
|
|
1515
|
+
var populatedV2Routes, populatedV3Routes, populatedV4Routes, populatedMixedRoutes, _iterator7, _step7, _step7$value, routev2, _amount2, v2Trade, _inputAmount5, _outputAmount5, _iterator8, _step8, _step8$value, routev3, _amount3, v3Trade, _inputAmount6, _outputAmount6, _iterator9, _step9, _step9$value, routev4, amount, v4Trade, inputAmount, outputAmount, _iterator10, _step10, _step10$value, mixedRoute, _amount, mixedRouteTrade, _inputAmount4, _outputAmount4;
|
|
1491
1516
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1492
1517
|
while (1) switch (_context.prev = _context.next) {
|
|
1493
1518
|
case 0:
|
|
@@ -1496,13 +1521,13 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1496
1521
|
populatedV4Routes = [];
|
|
1497
1522
|
populatedMixedRoutes = [];
|
|
1498
1523
|
for (_iterator7 = _createForOfIteratorHelperLoose(v2Routes); !(_step7 = _iterator7()).done;) {
|
|
1499
|
-
_step7$value = _step7.value, routev2 = _step7$value.routev2,
|
|
1500
|
-
v2Trade = new v2Sdk.Trade(routev2,
|
|
1501
|
-
|
|
1524
|
+
_step7$value = _step7.value, routev2 = _step7$value.routev2, _amount2 = _step7$value.amount;
|
|
1525
|
+
v2Trade = new v2Sdk.Trade(routev2, _amount2, tradeType);
|
|
1526
|
+
_inputAmount5 = v2Trade.inputAmount, _outputAmount5 = v2Trade.outputAmount;
|
|
1502
1527
|
populatedV2Routes.push({
|
|
1503
1528
|
routev2: routev2,
|
|
1504
|
-
inputAmount:
|
|
1505
|
-
outputAmount:
|
|
1529
|
+
inputAmount: _inputAmount5,
|
|
1530
|
+
outputAmount: _outputAmount5
|
|
1506
1531
|
});
|
|
1507
1532
|
}
|
|
1508
1533
|
_iterator8 = _createForOfIteratorHelperLoose(v3Routes);
|
|
@@ -1511,67 +1536,71 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1511
1536
|
_context.next = 15;
|
|
1512
1537
|
break;
|
|
1513
1538
|
}
|
|
1514
|
-
_step8$value = _step8.value, routev3 = _step8$value.routev3,
|
|
1539
|
+
_step8$value = _step8.value, routev3 = _step8$value.routev3, _amount3 = _step8$value.amount;
|
|
1515
1540
|
_context.next = 10;
|
|
1516
|
-
return v3Sdk.Trade.fromRoute(routev3,
|
|
1541
|
+
return v3Sdk.Trade.fromRoute(routev3, _amount3, tradeType);
|
|
1517
1542
|
case 10:
|
|
1518
1543
|
v3Trade = _context.sent;
|
|
1519
|
-
|
|
1544
|
+
_inputAmount6 = v3Trade.inputAmount, _outputAmount6 = v3Trade.outputAmount;
|
|
1520
1545
|
populatedV3Routes.push({
|
|
1521
1546
|
routev3: routev3,
|
|
1522
|
-
inputAmount:
|
|
1523
|
-
outputAmount:
|
|
1547
|
+
inputAmount: _inputAmount6,
|
|
1548
|
+
outputAmount: _outputAmount6
|
|
1524
1549
|
});
|
|
1525
1550
|
case 13:
|
|
1526
1551
|
_context.next = 6;
|
|
1527
1552
|
break;
|
|
1528
1553
|
case 15:
|
|
1554
|
+
if (!v4Routes) {
|
|
1555
|
+
_context.next = 26;
|
|
1556
|
+
break;
|
|
1557
|
+
}
|
|
1529
1558
|
_iterator9 = _createForOfIteratorHelperLoose(v4Routes);
|
|
1530
|
-
case
|
|
1559
|
+
case 17:
|
|
1531
1560
|
if ((_step9 = _iterator9()).done) {
|
|
1532
|
-
_context.next =
|
|
1561
|
+
_context.next = 26;
|
|
1533
1562
|
break;
|
|
1534
1563
|
}
|
|
1535
|
-
_step9$value = _step9.value, routev4 = _step9$value.routev4,
|
|
1536
|
-
_context.next =
|
|
1537
|
-
return v4Sdk.Trade.fromRoute(routev4,
|
|
1538
|
-
case
|
|
1564
|
+
_step9$value = _step9.value, routev4 = _step9$value.routev4, amount = _step9$value.amount;
|
|
1565
|
+
_context.next = 21;
|
|
1566
|
+
return v4Sdk.Trade.fromRoute(routev4, amount, tradeType);
|
|
1567
|
+
case 21:
|
|
1539
1568
|
v4Trade = _context.sent;
|
|
1540
|
-
|
|
1569
|
+
inputAmount = v4Trade.inputAmount, outputAmount = v4Trade.outputAmount;
|
|
1541
1570
|
populatedV4Routes.push({
|
|
1542
1571
|
routev4: routev4,
|
|
1543
|
-
inputAmount:
|
|
1544
|
-
outputAmount:
|
|
1572
|
+
inputAmount: inputAmount,
|
|
1573
|
+
outputAmount: outputAmount
|
|
1545
1574
|
});
|
|
1546
|
-
case
|
|
1547
|
-
_context.next =
|
|
1575
|
+
case 24:
|
|
1576
|
+
_context.next = 17;
|
|
1548
1577
|
break;
|
|
1549
|
-
case
|
|
1578
|
+
case 26:
|
|
1550
1579
|
if (!mixedRoutes) {
|
|
1551
|
-
_context.next =
|
|
1580
|
+
_context.next = 37;
|
|
1552
1581
|
break;
|
|
1553
1582
|
}
|
|
1554
1583
|
_iterator10 = _createForOfIteratorHelperLoose(mixedRoutes);
|
|
1555
|
-
case
|
|
1584
|
+
case 28:
|
|
1556
1585
|
if ((_step10 = _iterator10()).done) {
|
|
1557
|
-
_context.next =
|
|
1586
|
+
_context.next = 37;
|
|
1558
1587
|
break;
|
|
1559
1588
|
}
|
|
1560
|
-
_step10$value = _step10.value, mixedRoute = _step10$value.mixedRoute,
|
|
1561
|
-
_context.next =
|
|
1562
|
-
return MixedRouteTrade.fromRoute(mixedRoute,
|
|
1563
|
-
case
|
|
1589
|
+
_step10$value = _step10.value, mixedRoute = _step10$value.mixedRoute, _amount = _step10$value.amount;
|
|
1590
|
+
_context.next = 32;
|
|
1591
|
+
return MixedRouteTrade.fromRoute(mixedRoute, _amount, tradeType);
|
|
1592
|
+
case 32:
|
|
1564
1593
|
mixedRouteTrade = _context.sent;
|
|
1565
|
-
|
|
1594
|
+
_inputAmount4 = mixedRouteTrade.inputAmount, _outputAmount4 = mixedRouteTrade.outputAmount;
|
|
1566
1595
|
populatedMixedRoutes.push({
|
|
1567
1596
|
mixedRoute: mixedRoute,
|
|
1568
|
-
inputAmount:
|
|
1569
|
-
outputAmount:
|
|
1597
|
+
inputAmount: _inputAmount4,
|
|
1598
|
+
outputAmount: _outputAmount4
|
|
1570
1599
|
});
|
|
1571
|
-
case
|
|
1572
|
-
_context.next =
|
|
1600
|
+
case 35:
|
|
1601
|
+
_context.next = 28;
|
|
1573
1602
|
break;
|
|
1574
|
-
case
|
|
1603
|
+
case 37:
|
|
1575
1604
|
return _context.abrupt("return", new Trade({
|
|
1576
1605
|
v2Routes: populatedV2Routes,
|
|
1577
1606
|
v3Routes: populatedV3Routes,
|
|
@@ -1579,7 +1608,7 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1579
1608
|
mixedRoutes: populatedMixedRoutes,
|
|
1580
1609
|
tradeType: tradeType
|
|
1581
1610
|
}));
|
|
1582
|
-
case
|
|
1611
|
+
case 38:
|
|
1583
1612
|
case "end":
|
|
1584
1613
|
return _context.stop();
|
|
1585
1614
|
}
|