From 0586669ba9dbb92821cfe9ff9151285c6701f5bf Mon Sep 17 00:00:00 2001 From: ChefMist <133624774+ChefMist@users.noreply.github.com> Date: Fri, 6 Dec 2024 15:29:14 +0800 Subject: [PATCH 1/3] feat: audit follow ups --- src/base/Dispatcher.sol | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/base/Dispatcher.sol b/src/base/Dispatcher.sol index f6bfaf0..6b4aca4 100755 --- a/src/base/Dispatcher.sol +++ b/src/base/Dispatcher.sol @@ -50,8 +50,10 @@ abstract contract Dispatcher is /// @notice Decodes and executes the given command with the given inputs /// @param commandType The command type to execute - /// @param inputs The inputs to execute the command with - /// @dev 2 masks are used to enable use of a nested-if statement in execution for efficiency reasons + /// @param inputs The inputs to execute the command with. + /// @dev inputs must be ABI encoded using abi.encode() to ensure proper padding. WARNING: Direct calldata + // manipulation or abi.encodePacked() can result in incorrect data reads. + /// @dev 2 masks are used to enable use of a nested-if statement in execution for efficiency reasons /// @return success True on success of the command, false on failure /// @return output The outputs or error messages, if any, from the command function dispatch(bytes1 commandType, bytes calldata inputs) internal returns (bool success, bytes memory output) { @@ -284,6 +286,8 @@ abstract contract Dispatcher is (success, output) = address(V3_POSITION_MANAGER).call(inputs); return (success, output); } else if (command == Commands.V4_CL_INITIALIZE_POOL) { + // equivalent: abi.decode(inputs, (PoolKey, uint160)) where PoolKey is + // (Currency currency0, Currency currency1, IHooks hooks, IPoolManager poolManager, uint24 fee, bytes32 parameters) PoolKey calldata poolKey; uint160 sqrtPriceX96; assembly { @@ -293,6 +297,8 @@ abstract contract Dispatcher is (success, output) = address(clPoolManager).call(abi.encodeCall(ICLPoolManager.initialize, (poolKey, sqrtPriceX96))); } else if (command == Commands.V4_BIN_INITIALIZE_POOL) { + // equivalent: abi.decode(inputs, (PoolKey, uint24)) where PoolKey is + // (Currency currency0, Currency currency1, IHooks hooks, IPoolManager poolManager, uint24 fee, bytes32 parameters) PoolKey calldata poolKey; uint24 activeId; assembly { From 02e18856f4158a729b4969e5726faa35b588f210 Mon Sep 17 00:00:00 2001 From: ChefMist <133624774+ChefMist@users.noreply.github.com> Date: Fri, 6 Dec 2024 15:30:57 +0800 Subject: [PATCH 2/3] forge fmt --- src/base/Dispatcher.sol | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/base/Dispatcher.sol b/src/base/Dispatcher.sol index 6b4aca4..5911f42 100755 --- a/src/base/Dispatcher.sol +++ b/src/base/Dispatcher.sol @@ -50,10 +50,10 @@ abstract contract Dispatcher is /// @notice Decodes and executes the given command with the given inputs /// @param commandType The command type to execute - /// @param inputs The inputs to execute the command with. - /// @dev inputs must be ABI encoded using abi.encode() to ensure proper padding. WARNING: Direct calldata - // manipulation or abi.encodePacked() can result in incorrect data reads. - /// @dev 2 masks are used to enable use of a nested-if statement in execution for efficiency reasons + /// @param inputs The inputs to execute the command with. + /// @dev inputs must be ABI encoded using abi.encode() to ensure proper padding. WARNING: Direct calldata + // manipulation or abi.encodePacked() can result in incorrect data reads. + /// @dev 2 masks are used to enable use of a nested-if statement in execution for efficiency reasons /// @return success True on success of the command, false on failure /// @return output The outputs or error messages, if any, from the command function dispatch(bytes1 commandType, bytes calldata inputs) internal returns (bool success, bytes memory output) { @@ -286,7 +286,7 @@ abstract contract Dispatcher is (success, output) = address(V3_POSITION_MANAGER).call(inputs); return (success, output); } else if (command == Commands.V4_CL_INITIALIZE_POOL) { - // equivalent: abi.decode(inputs, (PoolKey, uint160)) where PoolKey is + // equivalent: abi.decode(inputs, (PoolKey, uint160)) where PoolKey is // (Currency currency0, Currency currency1, IHooks hooks, IPoolManager poolManager, uint24 fee, bytes32 parameters) PoolKey calldata poolKey; uint160 sqrtPriceX96; @@ -297,7 +297,7 @@ abstract contract Dispatcher is (success, output) = address(clPoolManager).call(abi.encodeCall(ICLPoolManager.initialize, (poolKey, sqrtPriceX96))); } else if (command == Commands.V4_BIN_INITIALIZE_POOL) { - // equivalent: abi.decode(inputs, (PoolKey, uint24)) where PoolKey is + // equivalent: abi.decode(inputs, (PoolKey, uint24)) where PoolKey is // (Currency currency0, Currency currency1, IHooks hooks, IPoolManager poolManager, uint24 fee, bytes32 parameters) PoolKey calldata poolKey; uint24 activeId; From 4d604cb84539db8c113b63f1400ea378276f2bab Mon Sep 17 00:00:00 2001 From: ChefMist <133624774+ChefMist@users.noreply.github.com> Date: Fri, 6 Dec 2024 15:33:08 +0800 Subject: [PATCH 3/3] cleaner comment --- src/base/Dispatcher.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base/Dispatcher.sol b/src/base/Dispatcher.sol index 5911f42..cade62c 100755 --- a/src/base/Dispatcher.sol +++ b/src/base/Dispatcher.sol @@ -50,7 +50,7 @@ abstract contract Dispatcher is /// @notice Decodes and executes the given command with the given inputs /// @param commandType The command type to execute - /// @param inputs The inputs to execute the command with. + /// @param inputs The inputs to execute the command with /// @dev inputs must be ABI encoded using abi.encode() to ensure proper padding. WARNING: Direct calldata // manipulation or abi.encodePacked() can result in incorrect data reads. /// @dev 2 masks are used to enable use of a nested-if statement in execution for efficiency reasons