-
Notifications
You must be signed in to change notification settings - Fork 491
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
try-catch-initialize #397
try-catch-initialize #397
Conversation
src/base/PoolInitializer.sol
Outdated
function initializePool(PoolKey calldata key, uint160 sqrtPriceX96) external payable returns (int24) { | ||
return poolManager.initialize(key, sqrtPriceX96); | ||
try poolManager.initialize(key, sqrtPriceX96) returns (int24) {} catch {} |
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.
i think if you want to return the tick (if we care) then you have to do like
try poolManager.initialize(key, sqrtPriceX96) returns (int24 tick) {
return tick;
} catch {
return 0;
}
i think it currently never returns something
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.
or you could remove the return parameter
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.
or you could name the return parameter of initializePool
to tick
and then do
try poolManager.initialize(key, sqrtPriceX96) returns (int24 _tick) {
tick = _tick;
} catch {}
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.
happy with any of those 3 solutions :)
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.
hm actually you dont want to return 0
on failure because thats a valid tick too 😆 i'm pushing a suggestion
Related Issue
Which issue does this pull request resolve?
Description of changes