From 51be189f3df31108ee40a5fb8b1257a0afdc3d80 Mon Sep 17 00:00:00 2001 From: ChefMist <133624774+ChefMist@users.noreply.github.com> Date: Fri, 13 Sep 2024 10:07:48 +0800 Subject: [PATCH] feat: move invalidCommandType revert out of if-else --- ...wapTest#test_stableSwap_ExactInput0For1.snap | 2 +- ...wapTest#test_stableSwap_ExactInput1For0.snap | 2 +- .../UniversalRouterBytecodeSize.snap | 2 +- ...st#test_v4CLPositionmanager_Mint_Native.snap | 2 +- ...st_v4BinPositionmanager_BinAddLiquidity.snap | 2 +- ...nPositionmanager_BinAddLiquidity_Native.snap | 2 +- ...ationTest#test_v4CLPositionmanager_Mint.snap | 2 +- src/base/Dispatcher.sol | 17 +++++------------ 8 files changed, 12 insertions(+), 19 deletions(-) diff --git a/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput0For1.snap b/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput0For1.snap index 0386c0a..612ad57 100644 --- a/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput0For1.snap +++ b/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput0For1.snap @@ -1 +1 @@ -193198 \ No newline at end of file +193207 \ No newline at end of file diff --git a/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput1For0.snap b/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput1For0.snap index c823d60..eae79b6 100644 --- a/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput1For0.snap +++ b/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput1For0.snap @@ -1 +1 @@ -192654 \ No newline at end of file +192663 \ No newline at end of file diff --git a/.forge-snapshots/UniversalRouterBytecodeSize.snap b/.forge-snapshots/UniversalRouterBytecodeSize.snap index 4cdd517..3657f89 100644 --- a/.forge-snapshots/UniversalRouterBytecodeSize.snap +++ b/.forge-snapshots/UniversalRouterBytecodeSize.snap @@ -1 +1 @@ -24108 \ No newline at end of file +24168 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap b/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap index 43f8a2a..e39cb60 100644 --- a/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap +++ b/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap @@ -1 +1 @@ -559336 \ No newline at end of file +559351 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap index 1c644c8..25ae5d9 100644 --- a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap +++ b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap @@ -1 +1 @@ -594165 \ No newline at end of file +594181 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap index 6c91c9a..496ea9a 100644 --- a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap +++ b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap @@ -1 +1 @@ -569991 \ No newline at end of file +570007 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap b/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap index fff8307..23dd0ab 100644 --- a/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap +++ b/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap @@ -1 +1 @@ -583518 \ No newline at end of file +583533 \ No newline at end of file diff --git a/src/base/Dispatcher.sol b/src/base/Dispatcher.sol index 58e98b6..029e8b9 100755 --- a/src/base/Dispatcher.sol +++ b/src/base/Dispatcher.sol @@ -157,10 +157,8 @@ abstract contract Dispatcher is } Payments.payPortion(token, map(recipient), bips); return (success, output); - } else { - // placeholder area for command 0x07 - revert InvalidCommandType(command); } + // placeholder area for command 0x07 } else { // 0x08 <= command < 0x10 if (command == Commands.V2_SWAP_EXACT_IN) { @@ -248,10 +246,8 @@ abstract contract Dispatcher is success = (ERC20(token).balanceOf(owner) >= minBalance); if (!success) output = abi.encodePacked(BalanceTooLow.selector); return (success, output); - } else { - // placeholder area for command 0x0f - revert InvalidCommandType(command); } + // placeholder area for command 0x0f } } else { // 0x10 <= command < 0x21 @@ -306,10 +302,8 @@ abstract contract Dispatcher is // do not permit or approve this contract over a v4 position or someone could use this command to decrease, burn, or transfer your position (success, output) = address(V4_BIN_POSITION_MANAGER).call{value: address(this).balance}(inputs); return (success, output); - } else { - // placeholder area for commands 0x15-0x20 - revert InvalidCommandType(command); } + // placeholder area for commands 0x15-0x20 } } else { // 0x21 <= command @@ -356,11 +350,10 @@ abstract contract Dispatcher is uint256 amountIn = stableSwapExactOutputAmountIn(amountOut, amountInMax, path, flag); stableSwapExactOutput(map(recipient), amountIn, amountOut, path, flag, payer); return (success, output); - } else { - // placeholder area for commands 0x24-0x3f - revert InvalidCommandType(command); } + // placeholder area for commands 0x24-0x3f } + revert InvalidCommandType(command); } /// @notice Calculates the recipient address for a command