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