fix position calculation

This commit is contained in:
johba 2025-09-23 11:46:57 +02:00
parent 548fd006c1
commit af031877a5
2 changed files with 18 additions and 3 deletions

View file

@ -139,6 +139,20 @@ contract LiquidityManagerTest is UniSwapHelper {
token0isWeth = _token0isWeth;
}
function testRecenterUsesAvailableEthWhenToken0IsWeth() public {
deployProtocolWithTokenOrder(true);
vm.deal(address(lm), 1 ether);
uint256 initialEthBudget = address(lm).balance;
assertEq(initialEthBudget, 1 ether, "precondition");
vm.prank(RECENTER_CALLER);
lm.recenter();
uint256 remainingEthBudget = address(lm).balance + weth.balanceOf(address(lm));
assertLe(remainingEthBudget, initialEthBudget, "should not overdraw ETH budget");
}
/// @notice Recenter with intelligent error handling for extreme price conditions
/// @param last Whether this is the last attempt (affects error handling)
function recenterWithErrorHandling(bool last) internal {