@uniswap/universal-router-sdk 3.0.1 → 3.0.3
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/universal-router-sdk.cjs.development.js +7 -5
- package/dist/universal-router-sdk.cjs.development.js.map +1 -1
- package/dist/universal-router-sdk.cjs.production.min.js +1 -1
- package/dist/universal-router-sdk.cjs.production.min.js.map +1 -1
- package/dist/universal-router-sdk.esm.js +7 -5
- package/dist/universal-router-sdk.esm.js.map +1 -1
- package/dist/utils/constants.d.ts +2 -2
- package/package.json +1 -1
|
@@ -216,8 +216,8 @@ function createCommand(type, parameters) {
|
|
|
216
216
|
var _routerConfigs, _routerConfigs2, _routerConfigs3, _routerConfigs4, _routerConfigs5, _routerConfigs6, _routerConfigs7, _routerConfigs8, _routerConfigs9, _routerConfigs10, _routerConfigs11, _routerConfigs12, _routerConfigs13, _routerConfigs14, _routerConfigs15, _routerConfigs16, _routerConfigs17, _routerConfigs18, _CHAIN_CONFIGS;
|
|
217
217
|
var UniversalRouterVersion;
|
|
218
218
|
(function (UniversalRouterVersion) {
|
|
219
|
-
UniversalRouterVersion[
|
|
220
|
-
UniversalRouterVersion[
|
|
219
|
+
UniversalRouterVersion["V1_2"] = "1.2";
|
|
220
|
+
UniversalRouterVersion["V2_0"] = "2.0";
|
|
221
221
|
})(UniversalRouterVersion || (UniversalRouterVersion = {}));
|
|
222
222
|
var WETH_NOT_SUPPORTED_ON_CHAIN = '0x0000000000000000000000000000000000000000';
|
|
223
223
|
// Todo: Change `CHAIN_CONFIGS` to pull the UR address with v4
|
|
@@ -513,7 +513,9 @@ function addV2Swap(planner, _ref, tradeType, options, payerIsUser, routerMustCus
|
|
|
513
513
|
if (tradeType == TradeType.EXACT_INPUT) {
|
|
514
514
|
planner.addCommand(CommandType.V2_SWAP_EXACT_IN, [
|
|
515
515
|
// if native, we have to unwrap so keep in the router for now
|
|
516
|
-
routerMustCustody ? ROUTER_AS_RECIPIENT : options.recipient, trade.maximumAmountIn(options.slippageTolerance).quotient.toString(),
|
|
516
|
+
routerMustCustody ? ROUTER_AS_RECIPIENT : options.recipient, trade.maximumAmountIn(options.slippageTolerance).quotient.toString(),
|
|
517
|
+
// if router will custody funds, we do aggregated slippage check from router
|
|
518
|
+
routerMustCustody ? 0 : trade.minimumAmountOut(options.slippageTolerance).quotient.toString(), route.path.map(function (token) {
|
|
517
519
|
return token.wrapped.address;
|
|
518
520
|
}), payerIsUser]);
|
|
519
521
|
} else if (tradeType == TradeType.EXACT_OUTPUT) {
|
|
@@ -535,7 +537,7 @@ function addV3Swap(planner, _ref2, tradeType, options, payerIsUser, routerMustCu
|
|
|
535
537
|
});
|
|
536
538
|
var path = encodeRouteToPath(route, trade.tradeType === TradeType.EXACT_OUTPUT);
|
|
537
539
|
if (tradeType == TradeType.EXACT_INPUT) {
|
|
538
|
-
planner.addCommand(CommandType.V3_SWAP_EXACT_IN, [routerMustCustody ? ROUTER_AS_RECIPIENT : options.recipient, trade.maximumAmountIn(options.slippageTolerance).quotient.toString(), trade.minimumAmountOut(options.slippageTolerance).quotient.toString(), path, payerIsUser]);
|
|
540
|
+
planner.addCommand(CommandType.V3_SWAP_EXACT_IN, [routerMustCustody ? ROUTER_AS_RECIPIENT : options.recipient, trade.maximumAmountIn(options.slippageTolerance).quotient.toString(), routerMustCustody ? 0 : trade.minimumAmountOut(options.slippageTolerance).quotient.toString(), path, payerIsUser]);
|
|
539
541
|
} else if (tradeType == TradeType.EXACT_OUTPUT) {
|
|
540
542
|
planner.addCommand(CommandType.V3_SWAP_EXACT_OUT, [routerMustCustody ? ROUTER_AS_RECIPIENT : options.recipient, trade.minimumAmountOut(options.slippageTolerance).quotient.toString(), trade.maximumAmountIn(options.slippageTolerance).quotient.toString(), path, payerIsUser]);
|
|
541
543
|
}
|
|
@@ -563,7 +565,7 @@ function addMixedSwap(planner, swap, tradeType, options, payerIsUser, routerMust
|
|
|
563
565
|
tradeType: tradeType
|
|
564
566
|
});
|
|
565
567
|
var amountIn = trade.maximumAmountIn(options.slippageTolerance, inputAmount).quotient.toString();
|
|
566
|
-
var amountOut = trade.minimumAmountOut(options.slippageTolerance, outputAmount).quotient.toString();
|
|
568
|
+
var amountOut = routerMustCustody ? 0 : trade.minimumAmountOut(options.slippageTolerance, outputAmount).quotient.toString();
|
|
567
569
|
// logic from
|
|
568
570
|
// https://github.com/Uniswap/router-sdk/blob/d8eed164e6c79519983844ca8b6a3fc24ebcb8f8/src/swapRouter.ts#L276
|
|
569
571
|
var sections = partitionMixedRouteByProtocol(route);
|