refactor: update unwrapEth to only check 0 amount

This commit is contained in:
royvardhan
2025-02-26 20:49:19 +05:30
parent 6b57e81afc
commit 353861f738

View File

@@ -56,6 +56,7 @@ import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol";
// ✷✷✷✷✷✷ ✷✷✷✷✷ ✷✷✷✷✷✷✷✷ ✷✷✷✷✷✷ ✷✷✷✷✷✷ ✷✷✷✷✷✷✷✷ // ✷✷✷✷✷✷ ✷✷✷✷✷ ✷✷✷✷✷✷✷✷ ✷✷✷✷✷✷ ✷✷✷✷✷✷ ✷✷✷✷✷✷✷✷
error TychoRouter__AddressZero(); error TychoRouter__AddressZero();
error TychoRouter__AmountZero();
error TychoRouter__EmptySwaps(); error TychoRouter__EmptySwaps();
error TychoRouter__NegativeSlippage(uint256 amount, uint256 minAmount); error TychoRouter__NegativeSlippage(uint256 amount, uint256 minAmount);
error TychoRouter__AmountInNotFullySpent(uint256 leftoverAmount); error TychoRouter__AmountInNotFullySpent(uint256 leftoverAmount);
@@ -440,13 +441,14 @@ contract TychoRouter is AccessControl, Dispatcher, Pausable, ReentrancyGuard {
* @param amount of WETH to unwrap. * @param amount of WETH to unwrap.
*/ */
function _unwrapETH(uint256 amount) internal { function _unwrapETH(uint256 amount) internal {
uint256 unwrapAmount = if (amount == 0) {
amount == 0 ? _weth.balanceOf(address(this)) : amount; revert TychoRouter__AmountZero();
_weth.withdraw(unwrapAmount); }
_weth.withdraw(amount);
} }
/** /**
* @dev Allows this contract to receive native token * @dev Allows this contract to receive native token from contracts
*/ */
receive() external payable { receive() external payable {
require(msg.sender.code.length != 0); require(msg.sender.code.length != 0);