From 9b8175aff993e3c2d55653082e4df32ba4d9d27f Mon Sep 17 00:00:00 2001 From: royvardhan Date: Sat, 15 Feb 2025 01:01:16 +0530 Subject: [PATCH] chore: cleanup --- foundry/interfaces/ICallback.sol | 2 -- foundry/src/Dispatcher.sol | 3 +-- foundry/src/TychoRouter.sol | 8 ++++---- foundry/src/executors/UniswapV3Executor.sol | 1 - foundry/test/Constants.sol | 1 + foundry/test/TychoRouterTestSetup.sol | 2 +- foundry/test/executors/UniswapV3Executor.t.sol | 3 +-- 7 files changed, 8 insertions(+), 12 deletions(-) diff --git a/foundry/interfaces/ICallback.sol b/foundry/interfaces/ICallback.sol index 38decfa..e71527e 100644 --- a/foundry/interfaces/ICallback.sol +++ b/foundry/interfaces/ICallback.sol @@ -2,8 +2,6 @@ pragma solidity ^0.8.26; interface ICallback { - error UnauthorizedCaller(string exchange, address sender); - function handleCallback( bytes calldata data ) external returns (bytes memory result); diff --git a/foundry/src/Dispatcher.sol b/foundry/src/Dispatcher.sol index d2a9128..b0a69c1 100644 --- a/foundry/src/Dispatcher.sol +++ b/foundry/src/Dispatcher.sol @@ -3,7 +3,6 @@ pragma solidity ^0.8.26; import "@interfaces/IExecutor.sol"; import "@interfaces/ICallback.sol"; -import "forge-std/console.sol"; error Dispatcher__UnapprovedExecutor(); error Dispatcher__NonContractExecutor(); @@ -83,7 +82,7 @@ contract Dispatcher { } function _handleCallback(bytes4 selector, bytes memory data) internal { - // Access the last 20 bytes of the bytes memory data using assembly + // Using assembly to access the last 20 bytes of the bytes memory data address executor; // slither-disable-next-line assembly assembly { diff --git a/foundry/src/TychoRouter.sol b/foundry/src/TychoRouter.sol index 5c26097..f26fa7c 100644 --- a/foundry/src/TychoRouter.sol +++ b/foundry/src/TychoRouter.sol @@ -227,10 +227,10 @@ contract TychoRouter is * This function will static call a verifier contract and should revert if the * caller is not a pool. */ - // fallback() external { - // bytes4 selector = bytes4(msg.data[:4]); - // _handleCallback(selector, msg.data[4:]); - // } + fallback() external { + bytes4 selector = bytes4(msg.data[:4]); + _handleCallback(selector, msg.data[4:]); + } /** * @dev Pauses the contract diff --git a/foundry/src/executors/UniswapV3Executor.sol b/foundry/src/executors/UniswapV3Executor.sol index 02e8769..74ff0e4 100644 --- a/foundry/src/executors/UniswapV3Executor.sol +++ b/foundry/src/executors/UniswapV3Executor.sol @@ -6,7 +6,6 @@ import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol"; import "@uniswap/v3-updated/CallbackValidationV2.sol"; import "@interfaces/ICallback.sol"; -import "forge-std/console.sol"; error UniswapV3Executor__InvalidDataLength(); error UniswapV3Executor__InvalidFactory(); diff --git a/foundry/test/Constants.sol b/foundry/test/Constants.sol index ba8fbef..3b742f0 100644 --- a/foundry/test/Constants.sol +++ b/foundry/test/Constants.sol @@ -38,6 +38,7 @@ contract Constants is Test { address USDC_WBTC_POOL = 0x004375Dff511095CC5A197A54140a24eFEF3A416; // uniswap v3 + address USV3_FACTORY = 0x1F98431c8aD98523631AE4a59f267346ea31F984; address DAI_WETH_USV3 = 0xC2e9F25Be6257c210d7Adf0D4Cd6E3E881ba25f8; /** diff --git a/foundry/test/TychoRouterTestSetup.sol b/foundry/test/TychoRouterTestSetup.sol index ef913fd..6c99be8 100644 --- a/foundry/test/TychoRouterTestSetup.sol +++ b/foundry/test/TychoRouterTestSetup.sol @@ -47,7 +47,7 @@ contract TychoRouterTestSetup is Test, Constants { vm.createSelectFork(vm.rpcUrl("mainnet"), forkBlock); vm.startPrank(ADMIN); - address factoryV3 = address(0x1F98431c8aD98523631AE4a59f267346ea31F984); + address factoryV3 = USV3_FACTORY; address poolManagerAddress = 0x000000000004444c5dc75cB358380D2e3dE08A90; IPoolManager poolManager = IPoolManager(poolManagerAddress); tychoRouter = diff --git a/foundry/test/executors/UniswapV3Executor.t.sol b/foundry/test/executors/UniswapV3Executor.t.sol index fc14a5a..e9a9f57 100644 --- a/foundry/test/executors/UniswapV3Executor.t.sol +++ b/foundry/test/executors/UniswapV3Executor.t.sol @@ -30,13 +30,12 @@ contract UniswapV3ExecutorTest is Test, Constants { UniswapV3ExecutorExposed uniswapV3Exposed; IERC20 WETH = IERC20(WETH_ADDR); IERC20 DAI = IERC20(DAI_ADDR); - address factory = 0x1F98431c8aD98523631AE4a59f267346ea31F984; function setUp() public { uint256 forkBlock = 17323404; vm.createSelectFork(vm.rpcUrl("mainnet"), forkBlock); - uniswapV3Exposed = new UniswapV3ExecutorExposed(factory); + uniswapV3Exposed = new UniswapV3ExecutorExposed(USV3_FACTORY); } function testDecodeParams() public view {