step.initialized not checked in pool swap function
bzpassersby opened this issue ยท 1 comments
Thanks for the great work! But I see that in the swap
function (milestone 5) in the pool contract, there is no checking on whether step.nextTick
returned by nextInitializedTickWithinOneWord
is initialized or not. Neither was this checked before invoking ticks. cross()
later in the same function. This means that whenever a tick is crossed from the next word, regardless of whether the tick is bound for a liquidity position or not, the state of the tick is rewritten, this will cost a lot of gas, right?
I think the step.nextTick
s state of initialization needs to be checked before invoking 'ticks.cross()', unless there is some reason I missed? Also from Uniswapv3 white paper, it says '๐๐ is only needed for ticks that are used as either the lower or
upper bound for at least one position. As a result, for efficiency, ๐๐ is
not initialized (and thus does not need to be updated when crossed)
until a position is created that has that tick as one of its bounds.'
Thank you!