-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Allow Hook contract to call beforeInitialize
and afterInitialize
hooks
#636
Comments
In what case would you want another call back to the hook? We see this as an optimization for when hooks already have control to finish executing anything before then finishing any further action on the pool manager, in which case there is no need to call back again into the hook |
So it is less that we are calling back into the hook and more that we are making the initial call to So as a bit of a code example that may be able to explain this better:
We are registering a collection against an existing ERC721 and creating an underlying ERC20. We then want to ensure that the sqrtPriceX96 that is provided is not erroneous as this could essentially be initialized by anyone. We use the We could bypass this issue by creating an external contract and giving this unique call rights in the This could potentially just be an incorrect approach to achieve our required logic, and happy to be lead down a better path, but it seems like preventing the hook contract from calling itself is potentially not what the initial PR intended to do, but instead wanting to prevent recursive hook calls? |
If someone is initializing the pool through a function on your hook you should be able to do any necessary enforcement before initialize is called (meaning no callback is required & our optimization works for your case). The alternative is that someone initializes the pool directly by calling initialize on the pool manager, in which case the hook would be triggered in beforeInitialize and you can then perform any extra checks. Either case will work and in case 1) you don't need to re-enter the hook inside initialize because you should have already done any necessary checks before initialize is called on the pool manager. Am I understanding your case correctly? If not please lmk what I'm missing! |
You were 100% right. I hadn't thought about that approach and maybe coded myself into a corner. I can just initialize directly and prevent external calls through |
Component
Pool Actions (swap, modifyLiquidity, donate, take, settle, mint)
Describe the suggested feature and problem it solves.
Last month a PR was added that prevented hook calls from being made when they were called from within the hook contract themselves:
8a4ebb0#diff-ff33f731a6fff1d6a1c4bdde67f734199c88a742966c3942a4fac5ab9be7c07fR99
This was then later slightly refactored in the
PoolManager
to create the modifiernoSelfCall
:11aa1f5#diff-ff33f731a6fff1d6a1c4bdde67f734199c88a742966c3942a4fac5ab9be7c07fR106-R111
This means that the hook contract can no longer call its own functions.
I can see why this would be beneficial for swap calls and other functions, and would assume that this is to prevent recursive entry.
My suggestion, however, is that we remove the modifier from
beforeInitialize
andafterInitialize
as the previous implementation allow for the hook contract to have control over who, how and when the pool could be initialized. I also don't see the harm in removing it from all functions, though I am more than happy to be proved wrong there.This may be a selfish case, but I feel that platforms should have this level of control of initialization, if not across all functions.
Describe the desired implementation.
My desired implementation would simply be to remove the
noSelfCall
modifier from at least the initialization hooks.Describe alternatives.
No response
Additional context.
No response
The text was updated successfully, but these errors were encountered: