Skip to content

Commit

Permalink
Improve coments
Browse files Browse the repository at this point in the history
  • Loading branch information
hensha256 committed Oct 17, 2024
1 parent 5bc8881 commit b6f402a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions contracts/base/Dispatcher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,12 @@ abstract contract Dispatcher is Payments, V2SwapRouter, V3SwapRouter, V4SwapRout
}
(success, output) =
address(poolManager).call(abi.encodeCall(IPoolManager.initialize, (poolKey, sqrtPriceX96)));
} else if (command == Commands.V4_POSITION_CALL) {
} else if (command == Commands.V4_POSITION_MANAGER_CALL) {
// should only call modifyLiquidities() to mint
_checkV4PositionManagerCall(inputs);
(success, output) = address(V4_POSITION_MANAGER).call{value: address(this).balance}(inputs);
} else {
// placeholder area for commands 0x13-0x20
// placeholder area for commands 0x15-0x20
revert InvalidCommandType(command);
}
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/libraries/Commands.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ library Commands {
uint256 constant V3_POSITION_MANAGER_PERMIT = 0x11;
uint256 constant V3_POSITION_MANAGER_CALL = 0x12;
uint256 constant V4_INITIALIZE_POOL = 0x13;
uint256 constant V4_POSITION_CALL = 0x14;
uint256 constant V4_POSITION_MANAGER_CALL = 0x14;
// COMMAND_PLACEHOLDER = 0x15 -> 0x20

// Command Types where 0x21<=value<=0x3f
Expand Down
9 changes: 7 additions & 2 deletions contracts/modules/V3ToV4Migrator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ abstract contract V3ToV4Migrator is MigratorImmutables {
}

/// @dev check that the v4 position manager call is a safe call
/// of the position-altering Actions, we only allow Actions.MINT
/// this is because, if a user could be tricked into approving the UniversalRouter for
/// their position, an attacker could take their fees, or drain their entire position
function _checkV4PositionManagerCall(bytes calldata inputs) internal view {
bytes4 selector;
assembly {
Expand All @@ -39,9 +42,11 @@ abstract contract V3ToV4Migrator is MigratorImmutables {
revert InvalidAction(selector);
}

// slice is `abi.encode(bytes unlockData, uint256 deadline)`
bytes calldata slice = inputs[4:];
// first bytes(0) extracts the unlockData parameter from modifyLiquidities
// second bytes(0) extracts the actions parameter from unlockData
// the first bytes(0) extracts the unlockData parameter from modifyLiquidities
// unlockData = `abi.encode(bytes actions, bytes[] params)`
// the second bytes(0) extracts the actions parameter from unlockData
bytes calldata actions = slice.toBytes(0).toBytes(0);

uint256 numActions = actions.length;
Expand Down

0 comments on commit b6f402a

Please sign in to comment.