Skip to content

Commit

Permalink
feat: move invalidCommandType revert out of if-else
Browse files Browse the repository at this point in the history
  • Loading branch information
ChefMist committed Sep 13, 2024
1 parent cc2d2e2 commit 51be189
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
193198
193207
Original file line number Diff line number Diff line change
@@ -1 +1 @@
192654
192663
2 changes: 1 addition & 1 deletion .forge-snapshots/UniversalRouterBytecodeSize.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24108
24168
Original file line number Diff line number Diff line change
@@ -1 +1 @@
559336
559351
Original file line number Diff line number Diff line change
@@ -1 +1 @@
594165
594181
Original file line number Diff line number Diff line change
@@ -1 +1 @@
569991
570007
Original file line number Diff line number Diff line change
@@ -1 +1 @@
583518
583533
17 changes: 5 additions & 12 deletions src/base/Dispatcher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 51be189

Please sign in to comment.