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

Safer use of slot0.currentTick #334

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

saucepoint
Copy link
Contributor

@saucepoint saucepoint commented Feb 5, 2025

Closes #317, #322


Safely retrieve "current tick" by converting it from the spot price sqrtPriceX96

As described in Cetora M02, and reference v4-core test

slot0.tick is decremented by one when zeroForOne trades push to a sqrtPriceLimit equal to a tick boundary of an LP position. This off-by-one error was problematic in Doppler when swapping to LOWER_SLUG.tickLower as well as some tick-delta calculations.

Its an extreme edge case, but the fix is quite simple so did it anyway

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.

Unsafe use of slot0.tick when calculating tickDeltas
1 participant