Skip to content

Commit

Permalink
fix: Extra ETH to avoid (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
fb-alexcq authored May 20, 2024
1 parent 49cef6d commit bf6b509
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion contracts/WooPPV3/WooRouterV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,11 @@ contract WooRouterV3 is IWooRouterV3, Ownable, ReentrancyGuard {

// Step 1: transfer the source tokens to WooRouterV3
if (isFromETH) {
require(fromAmount <= msg.value, "WooRouterV3: fromAmount_INVALID");
require(fromAmount == msg.value, "WooRouterV3: !msg.value");
IWETH(WETH).deposit{value: msg.value}();
TransferHelper.safeTransfer(WETH, address(wooPP), fromAmount);
} else {
require(0 == msg.value, "WooRouterV3: !msg.value");
TransferHelper.safeTransferFrom(fromToken, msg.sender, address(wooPP), fromAmount);
}

Expand Down
3 changes: 2 additions & 1 deletion contracts/WooRouterV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,11 @@ contract WooRouterV2 is IWooRouterV2, Ownable, ReentrancyGuard {

// Step 1: transfer the source tokens to WooRouter
if (isFromETH) {
require(fromAmount <= msg.value, "WooRouter: fromAmount_INVALID");
require(fromAmount == msg.value, "WooRouter: !msg.value");
IWETH(WETH).deposit{value: msg.value}();
TransferHelper.safeTransfer(WETH, address(wooPool), fromAmount);
} else {
require(0 == msg.value, "WooRouter: !msg.value");
TransferHelper.safeTransferFrom(fromToken, msg.sender, address(wooPool), fromAmount);
}

Expand Down

0 comments on commit bf6b509

Please sign in to comment.