@ring-protocol/universal-router-sdk 0.1.38 → 0.1.39
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 +13 -3
- 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 +13 -3
- package/dist/universal-router-sdk.esm.js.map +1 -1
- package/package.json +1 -1
|
@@ -883,15 +883,20 @@ var UniswapTrade = /*#__PURE__*/function () {
|
|
|
883
883
|
var fwWETH = FEW_WRAPPED_NATIVE_CURRENCY[this.trade.inputAmount.currency.wrapped.chainId];
|
|
884
884
|
// for exactOutput swaps with native input or that perform an inputToken transition (wrap or unwrap)
|
|
885
885
|
// we need to send back the change to the user
|
|
886
|
+
// Chains without few wrapped native (e.g. X Layer 196, MegaETH 4326) use WETH-only path; only use fwWETH when defined
|
|
886
887
|
if (this.trade.tradeType === TradeType.EXACT_OUTPUT || riskOfPartialFill(this.trade)) {
|
|
887
888
|
if (this.inputRequiresWrap) {
|
|
888
|
-
|
|
889
|
+
if (fwWETH) {
|
|
890
|
+
planner.addCommand(CommandType.UNWRAP_FEW_TOKEN, [fwWETH.address, ROUTER_AS_RECIPIENT, '0']);
|
|
891
|
+
}
|
|
889
892
|
planner.addCommand(CommandType.UNWRAP_WETH, [this.options.recipient, 0]);
|
|
890
893
|
planner.addCommand(CommandType.SWEEP, [ETH_ADDRESS, this.options.recipient, 0]);
|
|
891
894
|
} else if (this.inputRequiresUnwrap) {
|
|
892
895
|
planner.addCommand(CommandType.WRAP_ETH, [this.options.recipient, CONTRACT_BALANCE]);
|
|
893
896
|
} else if (this.trade.inputAmount.currency.isNative) {
|
|
894
|
-
|
|
897
|
+
if (fwWETH) {
|
|
898
|
+
planner.addCommand(CommandType.UNWRAP_FEW_TOKEN, [fwWETH.address, ROUTER_AS_RECIPIENT, '0']);
|
|
899
|
+
}
|
|
895
900
|
planner.addCommand(CommandType.UNWRAP_WETH, [SENDER_AS_RECIPIENT, 0]);
|
|
896
901
|
// must refund extra native currency sent along for native v4 trades (no input transition)
|
|
897
902
|
planner.addCommand(CommandType.SWEEP, [ETH_ADDRESS, this.options.recipient, 0]);
|
|
@@ -1021,7 +1026,12 @@ function addRingV2Swap(planner, _ref, tradeType, options, payerIsUser, routerMus
|
|
|
1021
1026
|
var fewOutputToken = getFewTokenFromOriginalToken(trade.outputAmount.currency.wrapped, trade.outputAmount.currency.chainId);
|
|
1022
1027
|
var fwWETH = FEW_WRAPPED_NATIVE_CURRENCY[trade.inputAmount.currency.wrapped.chainId];
|
|
1023
1028
|
if (outputAmount.currency.isNative) {
|
|
1024
|
-
|
|
1029
|
+
// Chains without few wrapped native (e.g. X Layer 196, MegaETH 4326): unwrap WETH to native instead of fwWETH
|
|
1030
|
+
if (fwWETH) {
|
|
1031
|
+
planner.addCommand(CommandType.UNWRAP_FEW_TOKEN, [fwWETH.address, ROUTER_AS_RECIPIENT, trade.minimumAmountOut(options.slippageTolerance).quotient.toString()]);
|
|
1032
|
+
} else {
|
|
1033
|
+
planner.addCommand(CommandType.UNWRAP_WETH, [options.recipient, trade.minimumAmountOut(options.slippageTolerance).quotient.toString()]);
|
|
1034
|
+
}
|
|
1025
1035
|
} else {
|
|
1026
1036
|
if (isFewToken(route.pathInput.wrapped) && isFewToken(route.pathOutput.wrapped)) {
|
|
1027
1037
|
planner.addCommand(CommandType.UNWRAP_FEW_TOKEN, [fewOutputToken.address, SENDER_AS_RECIPIENT, trade.minimumAmountOut(options.slippageTolerance).quotient.toString()]);
|