-
Notifications
You must be signed in to change notification settings - Fork 530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move BaseHook to new utils directory #438
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in favor of the change,
BUT in this tidy-up PR, it makes sense to change BaseHook
to inherit ImmutableState
instead
Only |
@gretzke we should decorate the hook functions with a as much as I hate repeating code, the modifier lives in SafeCallback which we shouldnt change; so we'll need to redefine the modifier in BaseHook? |
If someone overrides the hook function they also override the function modifier, because the functions are reverting anyways right now we could not have it there. If we want to ensure the modifier is not overwritten accidentally, we should split the functions into two: -function beforeInitialize(address, PoolKey calldata, uint160) external virtual returns (bytes4) {
- revert HookNotImplemented();
-}
+function beforeInitialize(address sender, PoolKey calldata key, uint160 sqrtPriceX96) external returns (bytes4) {
+ return _beforeInitialize(sender, key, sqrtPriceX96);
+}
+
+function _beforeInitialize(address sender, PoolKey calldata key, uint160 sqrtPriceX96) internal virtual returns (bytes4)
+ revert HookNotImplemented();
+} This ensures that the external function cannot be overwritten and is always protected |
do we still need the |
I'm pro moving the modifier to ImmutableState... 👀 @saucepoint interested in your reason that we cant? just because of code freeze? And yeah I think I'm pro adding the modifier and then adding internal functions to baseHook.sol. We follow that same pattern in SafeCallback too. |
yeah, if were not careful -- we might end up deploying a version of posm with different bytecode than whats currently in the wild |
bytecode for positionmanager did not change after my implementation, feel free to double check |
src/base/ImmutableState.sol
Outdated
@@ -10,6 +10,15 @@ contract ImmutableState is IImmutableState { | |||
/// @inheritdoc IImmutableState | |||
IPoolManager public immutable poolManager; | |||
|
|||
/// @notice Thrown when calling unlockCallback where the caller is not PoolManager |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not only thrown when calling unlockCallBack since its also being called elsewhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pushed a change here, in the future, could you suggest a change instead? e.g.,
/// @notice Thrown when calling unlockCallback where the caller is not PoolManager | |
/// @notice Thrown when the caller is not PoolManager |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah forgot again! my bad!
@hensha256 @dianakocsis @gretzke with this change, might need to update the V4 hook docs here -- https://docs.uniswap.org/contracts/v4/guides/hooks/your-first-hook as it uses Also if you guys could tag the commit that works with |
Note, the |
Related Issue
Which issue does this pull request resolve?
Description of changes