@uniswap/router-sdk 1.10.0 → 1.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/entities/trade.d.ts +9 -9
- package/dist/router-sdk.cjs.development.js +81 -76
- 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 +81 -76
- package/dist/router-sdk.esm.js.map +1 -1
- package/package.json +3 -2
package/dist/router-sdk.esm.js
CHANGED
|
@@ -1332,48 +1332,65 @@ var MixedRoute = /*#__PURE__*/function (_MixedRouteSDK) {
|
|
|
1332
1332
|
var Trade = /*#__PURE__*/function () {
|
|
1333
1333
|
// construct a trade across v2 and v3 routes from pre-computed amounts
|
|
1334
1334
|
function Trade(_ref) {
|
|
1335
|
-
var v2Routes = _ref.v2Routes,
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1335
|
+
var _ref$v2Routes = _ref.v2Routes,
|
|
1336
|
+
v2Routes = _ref$v2Routes === void 0 ? [] : _ref$v2Routes,
|
|
1337
|
+
_ref$v3Routes = _ref.v3Routes,
|
|
1338
|
+
v3Routes = _ref$v3Routes === void 0 ? [] : _ref$v3Routes,
|
|
1339
|
+
_ref$v4Routes = _ref.v4Routes,
|
|
1340
|
+
v4Routes = _ref$v4Routes === void 0 ? [] : _ref$v4Routes,
|
|
1341
|
+
_ref$mixedRoutes = _ref.mixedRoutes,
|
|
1342
|
+
mixedRoutes = _ref$mixedRoutes === void 0 ? [] : _ref$mixedRoutes,
|
|
1343
|
+
tradeType = _ref.tradeType;
|
|
1340
1344
|
this.swaps = [];
|
|
1341
1345
|
this.routes = [];
|
|
1342
1346
|
// wrap v2 routes
|
|
1343
1347
|
for (var _iterator = _createForOfIteratorHelperLoose(v2Routes), _step; !(_step = _iterator()).done;) {
|
|
1344
1348
|
var _step$value = _step.value,
|
|
1345
1349
|
routev2 = _step$value.routev2,
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
var
|
|
1349
|
-
this.routes.push(
|
|
1350
|
+
inputAmount = _step$value.inputAmount,
|
|
1351
|
+
outputAmount = _step$value.outputAmount;
|
|
1352
|
+
var route = new RouteV2(routev2);
|
|
1353
|
+
this.routes.push(route);
|
|
1350
1354
|
this.swaps.push({
|
|
1351
|
-
route:
|
|
1352
|
-
inputAmount:
|
|
1353
|
-
outputAmount:
|
|
1355
|
+
route: route,
|
|
1356
|
+
inputAmount: inputAmount,
|
|
1357
|
+
outputAmount: outputAmount
|
|
1354
1358
|
});
|
|
1355
1359
|
}
|
|
1356
1360
|
// wrap v3 routes
|
|
1357
1361
|
for (var _iterator2 = _createForOfIteratorHelperLoose(v3Routes), _step2; !(_step2 = _iterator2()).done;) {
|
|
1358
1362
|
var _step2$value = _step2.value,
|
|
1359
1363
|
routev3 = _step2$value.routev3,
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
var
|
|
1363
|
-
this.routes.push(
|
|
1364
|
+
_inputAmount = _step2$value.inputAmount,
|
|
1365
|
+
_outputAmount = _step2$value.outputAmount;
|
|
1366
|
+
var _route = new RouteV3(routev3);
|
|
1367
|
+
this.routes.push(_route);
|
|
1364
1368
|
this.swaps.push({
|
|
1365
|
-
route:
|
|
1366
|
-
inputAmount:
|
|
1367
|
-
outputAmount:
|
|
1369
|
+
route: _route,
|
|
1370
|
+
inputAmount: _inputAmount,
|
|
1371
|
+
outputAmount: _outputAmount
|
|
1368
1372
|
});
|
|
1369
1373
|
}
|
|
1370
1374
|
// wrap v4 routes
|
|
1371
1375
|
for (var _iterator3 = _createForOfIteratorHelperLoose(v4Routes), _step3; !(_step3 = _iterator3()).done;) {
|
|
1372
1376
|
var _step3$value = _step3.value,
|
|
1373
1377
|
routev4 = _step3$value.routev4,
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
var
|
|
1378
|
+
_inputAmount2 = _step3$value.inputAmount,
|
|
1379
|
+
_outputAmount2 = _step3$value.outputAmount;
|
|
1380
|
+
var _route2 = new RouteV4(routev4);
|
|
1381
|
+
this.routes.push(_route2);
|
|
1382
|
+
this.swaps.push({
|
|
1383
|
+
route: _route2,
|
|
1384
|
+
inputAmount: _inputAmount2,
|
|
1385
|
+
outputAmount: _outputAmount2
|
|
1386
|
+
});
|
|
1387
|
+
}
|
|
1388
|
+
for (var _iterator4 = _createForOfIteratorHelperLoose(mixedRoutes), _step4; !(_step4 = _iterator4()).done;) {
|
|
1389
|
+
var _step4$value = _step4.value,
|
|
1390
|
+
mixedRoute = _step4$value.mixedRoute,
|
|
1391
|
+
_inputAmount3 = _step4$value.inputAmount,
|
|
1392
|
+
_outputAmount3 = _step4$value.outputAmount;
|
|
1393
|
+
var _route3 = new MixedRoute(mixedRoute);
|
|
1377
1394
|
this.routes.push(_route3);
|
|
1378
1395
|
this.swaps.push({
|
|
1379
1396
|
route: _route3,
|
|
@@ -1381,22 +1398,6 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1381
1398
|
outputAmount: _outputAmount3
|
|
1382
1399
|
});
|
|
1383
1400
|
}
|
|
1384
|
-
// wrap mixedRoutes
|
|
1385
|
-
if (mixedRoutes) {
|
|
1386
|
-
for (var _iterator4 = _createForOfIteratorHelperLoose(mixedRoutes), _step4; !(_step4 = _iterator4()).done;) {
|
|
1387
|
-
var _step4$value = _step4.value,
|
|
1388
|
-
mixedRoute = _step4$value.mixedRoute,
|
|
1389
|
-
inputAmount = _step4$value.inputAmount,
|
|
1390
|
-
outputAmount = _step4$value.outputAmount;
|
|
1391
|
-
var route = new MixedRoute(mixedRoute);
|
|
1392
|
-
this.routes.push(route);
|
|
1393
|
-
this.swaps.push({
|
|
1394
|
-
route: route,
|
|
1395
|
-
inputAmount: inputAmount,
|
|
1396
|
-
outputAmount: outputAmount
|
|
1397
|
-
});
|
|
1398
|
-
}
|
|
1399
|
-
}
|
|
1400
1401
|
if (this.swaps.length === 0) {
|
|
1401
1402
|
throw new Error('No routes provided when calling Trade constructor');
|
|
1402
1403
|
}
|
|
@@ -1482,8 +1483,8 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1482
1483
|
return new Price(this.inputAmount.currency, this.outputAmount.currency, this.maximumAmountIn(slippageTolerance).quotient, this.minimumAmountOut(slippageTolerance).quotient);
|
|
1483
1484
|
};
|
|
1484
1485
|
Trade.fromRoutes = /*#__PURE__*/function () {
|
|
1485
|
-
var _fromRoutes = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(v2Routes, v3Routes,
|
|
1486
|
-
var populatedV2Routes, populatedV3Routes, populatedV4Routes, populatedMixedRoutes, _iterator7, _step7, _step7$value, routev2,
|
|
1486
|
+
var _fromRoutes = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(v2Routes, v3Routes, tradeType, mixedRoutes, v4Routes) {
|
|
1487
|
+
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;
|
|
1487
1488
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1488
1489
|
while (1) switch (_context.prev = _context.next) {
|
|
1489
1490
|
case 0:
|
|
@@ -1492,13 +1493,13 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1492
1493
|
populatedV4Routes = [];
|
|
1493
1494
|
populatedMixedRoutes = [];
|
|
1494
1495
|
for (_iterator7 = _createForOfIteratorHelperLoose(v2Routes); !(_step7 = _iterator7()).done;) {
|
|
1495
|
-
_step7$value = _step7.value, routev2 = _step7$value.routev2,
|
|
1496
|
-
v2Trade = new Trade$3(routev2,
|
|
1497
|
-
|
|
1496
|
+
_step7$value = _step7.value, routev2 = _step7$value.routev2, _amount2 = _step7$value.amount;
|
|
1497
|
+
v2Trade = new Trade$3(routev2, _amount2, tradeType);
|
|
1498
|
+
_inputAmount5 = v2Trade.inputAmount, _outputAmount5 = v2Trade.outputAmount;
|
|
1498
1499
|
populatedV2Routes.push({
|
|
1499
1500
|
routev2: routev2,
|
|
1500
|
-
inputAmount:
|
|
1501
|
-
outputAmount:
|
|
1501
|
+
inputAmount: _inputAmount5,
|
|
1502
|
+
outputAmount: _outputAmount5
|
|
1502
1503
|
});
|
|
1503
1504
|
}
|
|
1504
1505
|
_iterator8 = _createForOfIteratorHelperLoose(v3Routes);
|
|
@@ -1507,67 +1508,71 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1507
1508
|
_context.next = 15;
|
|
1508
1509
|
break;
|
|
1509
1510
|
}
|
|
1510
|
-
_step8$value = _step8.value, routev3 = _step8$value.routev3,
|
|
1511
|
+
_step8$value = _step8.value, routev3 = _step8$value.routev3, _amount3 = _step8$value.amount;
|
|
1511
1512
|
_context.next = 10;
|
|
1512
|
-
return Trade$2.fromRoute(routev3,
|
|
1513
|
+
return Trade$2.fromRoute(routev3, _amount3, tradeType);
|
|
1513
1514
|
case 10:
|
|
1514
1515
|
v3Trade = _context.sent;
|
|
1515
|
-
|
|
1516
|
+
_inputAmount6 = v3Trade.inputAmount, _outputAmount6 = v3Trade.outputAmount;
|
|
1516
1517
|
populatedV3Routes.push({
|
|
1517
1518
|
routev3: routev3,
|
|
1518
|
-
inputAmount:
|
|
1519
|
-
outputAmount:
|
|
1519
|
+
inputAmount: _inputAmount6,
|
|
1520
|
+
outputAmount: _outputAmount6
|
|
1520
1521
|
});
|
|
1521
1522
|
case 13:
|
|
1522
1523
|
_context.next = 6;
|
|
1523
1524
|
break;
|
|
1524
1525
|
case 15:
|
|
1526
|
+
if (!v4Routes) {
|
|
1527
|
+
_context.next = 26;
|
|
1528
|
+
break;
|
|
1529
|
+
}
|
|
1525
1530
|
_iterator9 = _createForOfIteratorHelperLoose(v4Routes);
|
|
1526
|
-
case
|
|
1531
|
+
case 17:
|
|
1527
1532
|
if ((_step9 = _iterator9()).done) {
|
|
1528
|
-
_context.next =
|
|
1533
|
+
_context.next = 26;
|
|
1529
1534
|
break;
|
|
1530
1535
|
}
|
|
1531
|
-
_step9$value = _step9.value, routev4 = _step9$value.routev4,
|
|
1532
|
-
_context.next =
|
|
1533
|
-
return Trade$1.fromRoute(routev4,
|
|
1534
|
-
case
|
|
1536
|
+
_step9$value = _step9.value, routev4 = _step9$value.routev4, amount = _step9$value.amount;
|
|
1537
|
+
_context.next = 21;
|
|
1538
|
+
return Trade$1.fromRoute(routev4, amount, tradeType);
|
|
1539
|
+
case 21:
|
|
1535
1540
|
v4Trade = _context.sent;
|
|
1536
|
-
|
|
1541
|
+
inputAmount = v4Trade.inputAmount, outputAmount = v4Trade.outputAmount;
|
|
1537
1542
|
populatedV4Routes.push({
|
|
1538
1543
|
routev4: routev4,
|
|
1539
|
-
inputAmount:
|
|
1540
|
-
outputAmount:
|
|
1544
|
+
inputAmount: inputAmount,
|
|
1545
|
+
outputAmount: outputAmount
|
|
1541
1546
|
});
|
|
1542
|
-
case
|
|
1543
|
-
_context.next =
|
|
1547
|
+
case 24:
|
|
1548
|
+
_context.next = 17;
|
|
1544
1549
|
break;
|
|
1545
|
-
case
|
|
1550
|
+
case 26:
|
|
1546
1551
|
if (!mixedRoutes) {
|
|
1547
|
-
_context.next =
|
|
1552
|
+
_context.next = 37;
|
|
1548
1553
|
break;
|
|
1549
1554
|
}
|
|
1550
1555
|
_iterator10 = _createForOfIteratorHelperLoose(mixedRoutes);
|
|
1551
|
-
case
|
|
1556
|
+
case 28:
|
|
1552
1557
|
if ((_step10 = _iterator10()).done) {
|
|
1553
|
-
_context.next =
|
|
1558
|
+
_context.next = 37;
|
|
1554
1559
|
break;
|
|
1555
1560
|
}
|
|
1556
|
-
_step10$value = _step10.value, mixedRoute = _step10$value.mixedRoute,
|
|
1557
|
-
_context.next =
|
|
1558
|
-
return MixedRouteTrade.fromRoute(mixedRoute,
|
|
1559
|
-
case
|
|
1561
|
+
_step10$value = _step10.value, mixedRoute = _step10$value.mixedRoute, _amount = _step10$value.amount;
|
|
1562
|
+
_context.next = 32;
|
|
1563
|
+
return MixedRouteTrade.fromRoute(mixedRoute, _amount, tradeType);
|
|
1564
|
+
case 32:
|
|
1560
1565
|
mixedRouteTrade = _context.sent;
|
|
1561
|
-
|
|
1566
|
+
_inputAmount4 = mixedRouteTrade.inputAmount, _outputAmount4 = mixedRouteTrade.outputAmount;
|
|
1562
1567
|
populatedMixedRoutes.push({
|
|
1563
1568
|
mixedRoute: mixedRoute,
|
|
1564
|
-
inputAmount:
|
|
1565
|
-
outputAmount:
|
|
1569
|
+
inputAmount: _inputAmount4,
|
|
1570
|
+
outputAmount: _outputAmount4
|
|
1566
1571
|
});
|
|
1567
|
-
case
|
|
1568
|
-
_context.next =
|
|
1572
|
+
case 35:
|
|
1573
|
+
_context.next = 28;
|
|
1569
1574
|
break;
|
|
1570
|
-
case
|
|
1575
|
+
case 37:
|
|
1571
1576
|
return _context.abrupt("return", new Trade({
|
|
1572
1577
|
v2Routes: populatedV2Routes,
|
|
1573
1578
|
v3Routes: populatedV3Routes,
|
|
@@ -1575,7 +1580,7 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1575
1580
|
mixedRoutes: populatedMixedRoutes,
|
|
1576
1581
|
tradeType: tradeType
|
|
1577
1582
|
}));
|
|
1578
|
-
case
|
|
1583
|
+
case 38:
|
|
1579
1584
|
case "end":
|
|
1580
1585
|
return _context.stop();
|
|
1581
1586
|
}
|