Submitted by hickuphh3
secondsPerLiquidity is updated as such: secondsPerLiquidity += uint160((diff << 128) / liquidity); where diff = timestamp - uint256(lastObservation). Hence, whenever liquidity changes, secondsPerLiquidity should be updated prior to the change.
In particular, this affects the mint() and burn() functions, in the case where liquidity changes when lowerTick <= currentTick < upperTick.
In fact, the latest secondsPerLiquidity value should be calculated and used in Ticks.insert(). For comparison, notice how UniswapV3 fetches the latest value by calling observations.observeSingle() in its _updatePosition() function.
The secondsPerLiquidity increment logic should be applied prior to liquidity addition in mint() and removal in burn().
sarangparikh22 (Sushi) disputed:
alcueca (judge) commented:
sarangparikh22 (Sushi) confirmed:
