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

tick spacing cannot be TickMath.MAX_TICK due to overflow/underflow in the tick bitmap #64

Closed
moodysalem opened this issue Apr 26, 2022 · 2 comments · Fixed by #54
Closed
Labels
bug Something isn't working p0 Very important to fix

Comments

@moodysalem
Copy link
Contributor

https://github.com/Uniswap/core-next/blob/718cb055823bf68dfb34b2c90d8517b3e1f0f2b1/contracts/libraries/TickBitmap.sol#L64

this calculation can result in 255 * TickMath.MAX_TICK
TickMath.MAX_TICK = 887272 = ~2^19.75 (takes 20 bits) so this overflows the int24 container since 255 is another 8 bits

@moodysalem
Copy link
Contributor Author

moodysalem commented Apr 26, 2022

the max safe value is type(int16).max = 32767 which corresponds to a 1.0001^32767 = 26.5x price movement

this can be limited in the initialize call of pool manager

@moodysalem moodysalem added bug Something isn't working p0 Very important to fix labels Apr 26, 2022
@moodysalem moodysalem changed the title TickMath.MAX_TICK cannot be tick spacing due to overflow/underflow in the tick bitmap tick spacing cannot be TickMath.MAX_TICK due to overflow/underflow in the tick bitmap Apr 26, 2022
@moodysalem
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p0 Very important to fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant