diff --git a/foundry/src/TychoRouter.sol b/foundry/src/TychoRouter.sol index c26e8cb..844507e 100644 --- a/foundry/src/TychoRouter.sol +++ b/foundry/src/TychoRouter.sol @@ -450,7 +450,8 @@ contract TychoRouter is { require(data.length >= 20, "Invalid data length"); bytes4 selector = bytes4(data[data.length - 4:]); - address executor = address(uint160(bytes20(data[data.length - 24:data.length - 4]))); + address executor = + address(uint160(bytes20(data[data.length - 24:data.length - 4]))); bytes memory protocolData = data[:data.length - 24]; if (!executors[executor]) { diff --git a/foundry/src/executors/UniswapV4Executor.sol b/foundry/src/executors/UniswapV4Executor.sol index 545729a..57fe796 100644 --- a/foundry/src/executors/UniswapV4Executor.sol +++ b/foundry/src/executors/UniswapV4Executor.sol @@ -75,7 +75,6 @@ contract UniswapV4Executor is IExecutor, V4Router { params[1] = abi.encode(key.currency0, amountIn); params[2] = abi.encode(key.currency1, amountOutMin); swapData = abi.encode(actions, params); - } else { PathKey[] memory path = new PathKey[](pools.length); for (uint256 i = 0; i < pools.length; i++) { @@ -109,8 +108,8 @@ contract UniswapV4Executor is IExecutor, V4Router { params[2] = abi.encode(Currency.wrap(tokenOut), amountOutMin); swapData = abi.encode(actions, params); } - bytes memory fullData = - abi.encodePacked( swapData, callbackExecutor, callbackSelector); + bytes memory fullData = + abi.encodePacked(swapData, callbackExecutor, callbackSelector); uint256 tokenOutBalanceBefore; tokenOutBalanceBefore = tokenOut == address(0) @@ -132,11 +131,12 @@ contract UniswapV4Executor is IExecutor, V4Router { // necessary to convert bytes memory to bytes calldata function executeActions(bytes memory unlockData) public { + // slither-disable-next-line unused-return poolManager.unlock(unlockData); } function _decodeData(bytes calldata data) - public + internal pure returns ( address tokenIn, @@ -148,7 +148,7 @@ contract UniswapV4Executor is IExecutor, V4Router { UniswapV4Pool[] memory pools ) { - if(data.length < 123) { + if (data.length < 123) { revert UniswapV4Executor__InvalidDataLength(); } @@ -168,6 +168,7 @@ contract UniswapV4Executor is IExecutor, V4Router { uint24 fee; int24 tickSpacing; + // slither-disable-next-line assembly assembly { intermediaryToken := mload(add(poolsData, add(offset, 20))) fee := shr(232, mload(add(poolsData, add(offset, 52)))) @@ -178,10 +179,7 @@ contract UniswapV4Executor is IExecutor, V4Router { } } - function _pay(Currency token, address payer, uint256 amount) - internal - override - { + function _pay(Currency token, address, uint256 amount) internal override { IERC20(Currency.unwrap(token)).safeTransfer( address(poolManager), amount ); diff --git a/foundry/test/executors/UniswapV4Executor.t.sol b/foundry/test/executors/UniswapV4Executor.t.sol index c9afd56..e35b676 100644 --- a/foundry/test/executors/UniswapV4Executor.t.sol +++ b/foundry/test/executors/UniswapV4Executor.t.sol @@ -104,10 +104,10 @@ contract UniswapV4ExecutorTest is Test, Constants { deal(USDE_ADDR, address(uniswapV4Exposed), amountIn); uint256 usdeBalanceBeforePool = USDE.balanceOf(poolManager); uint256 usdeBalanceBeforeSwapExecutor = - USDE.balanceOf(address(uniswapV4Exposed)); + USDE.balanceOf(address(uniswapV4Exposed)); UniswapV4Executor.UniswapV4Pool[] memory pools = - new UniswapV4Executor.UniswapV4Pool[](1); + new UniswapV4Executor.UniswapV4Pool[](1); pools[0] = UniswapV4Executor.UniswapV4Pool({ intermediaryToken: USDT_ADDR, fee: uint24(100), @@ -139,11 +139,10 @@ contract UniswapV4ExecutorTest is Test, Constants { deal(USDE_ADDR, address(uniswapV4Exposed), amountIn); uint256 usdeBalanceBeforePool = USDE.balanceOf(poolManager); uint256 usdeBalanceBeforeSwapExecutor = - USDE.balanceOf(address(uniswapV4Exposed)); - + USDE.balanceOf(address(uniswapV4Exposed)); UniswapV4Executor.UniswapV4Pool[] memory pools = - new UniswapV4Executor.UniswapV4Pool[](2); + new UniswapV4Executor.UniswapV4Pool[](2); pools[0] = UniswapV4Executor.UniswapV4Pool({ intermediaryToken: USDT_ADDR, fee: uint24(100), @@ -171,7 +170,8 @@ contract UniswapV4ExecutorTest is Test, Constants { USDE.balanceOf(address(uniswapV4Exposed)), usdeBalanceBeforeSwapExecutor - amountIn ); - assertTrue(IERC20(WBTC_ADDR).balanceOf(address(uniswapV4Exposed)) == amountOut); + assertTrue( + IERC20(WBTC_ADDR).balanceOf(address(uniswapV4Exposed)) == amountOut + ); } - }