fix: Dead code branch: lastRecenterTick==0 with cumulativeVolume>0 (#568)
Remove unreachable else branch in VWAP recording logic. The branch was only reachable if lastRecenterTick==0 and cumulativeVolume>0, which requires tick==0 on the very first recenter — virtually impossible on a live pool. Collapse else-if into else and delete the corresponding testVWAPElseBranch test that exercised the path via vm.store. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
b34e26eb70
commit
b8f5ed9411
2 changed files with 1 additions and 31 deletions
|
|
@ -1084,33 +1084,6 @@ contract LiquidityManagerTest is UniSwapHelper {
|
|||
assertGt(anchorLiq, 0, "ANCHOR position should have been created with fallback params");
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice VWAP else branch: cumulativeVolume > 0 AND lastRecenterTick == 0
|
||||
* Reached by re-deploying a fresh LM (lastRecenterTick = 0) and setting
|
||||
* cumulativeVolume via vm.store before the first recenter.
|
||||
*/
|
||||
function testVWAPElseBranch() public {
|
||||
// Re-deploy fresh protocol so lastRecenterTick starts at 0
|
||||
deployProtocolWithTokenOrder(DEFAULT_TOKEN0_IS_WETH);
|
||||
|
||||
// Preconditions: fresh LM has lastRecenterTick == 0 and cumulativeVolume == 0
|
||||
assertEq(lm.lastRecenterTick(), 0, "precondition: lastRecenterTick must be 0");
|
||||
assertEq(lm.cumulativeVolume(), 0, "precondition: cumulativeVolume must be 0");
|
||||
|
||||
// Set cumulativeVolume to non-zero (storage slot 1 in VWAPTracker).
|
||||
// This creates the state: cumulativeVolume > 0 AND lastRecenterTick == 0,
|
||||
// which triggers the else branch (line 170) on the first recenter.
|
||||
vm.store(address(lm), bytes32(uint256(1)), bytes32(uint256(1e18)));
|
||||
assertEq(lm.cumulativeVolume(), 1e18, "cumulativeVolume should be 1e18 after vm.store");
|
||||
|
||||
// Call recenter — hits the else branch, sets lastRecenterTick, then sets positions
|
||||
vm.prank(RECENTER_CALLER);
|
||||
lm.recenter();
|
||||
|
||||
// Verify lastRecenterTick was updated from the recenter
|
||||
assertTrue(lm.lastRecenterTick() != 0, "lastRecenterTick should have been updated after recenter");
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice When feeDestination == address(lm), recenter must not transfer fees externally
|
||||
* and _getOutstandingSupply must not double-subtract LM-held KRK.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue