Skip to content
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

Merged
merged 6 commits into from
Nov 23, 2024
Merged

try-catch-initialize #397

merged 6 commits into from
Nov 23, 2024

Conversation

snreynolds
Copy link
Member

Related Issue

Which issue does this pull request resolve?

Description of changes

hensha256
hensha256 previously approved these changes Nov 22, 2024
function initializePool(PoolKey calldata key, uint160 sqrtPriceX96) external payable returns (int24) {
return poolManager.initialize(key, sqrtPriceX96);
try poolManager.initialize(key, sqrtPriceX96) returns (int24) {} catch {}
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor

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 {}

Copy link
Contributor

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 :)

Copy link
Contributor

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

hensha256
hensha256 previously approved these changes Nov 22, 2024
hensha256
hensha256 previously approved these changes Nov 22, 2024
@hensha256 hensha256 merged commit bf39426 into main Nov 23, 2024
3 checks passed
@hensha256 hensha256 deleted the 87-try-catch branch November 23, 2024 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants