From e134447dcc6d50f64b81807a5b8eb44d2ecbc2aa Mon Sep 17 00:00:00 2001 From: anxbt Date: Mon, 6 Apr 2026 10:54:22 +0530 Subject: [PATCH 1/2] fix(test): correct alice balance1 token in mint transfer burn test --- test/position-managers/PositionManager.t.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/position-managers/PositionManager.t.sol b/test/position-managers/PositionManager.t.sol index c67ff4d7e..c138fcf79 100644 --- a/test/position-managers/PositionManager.t.sol +++ b/test/position-managers/PositionManager.t.sol @@ -745,7 +745,7 @@ contract PositionManagerTest is Test, PosmTestSetup, LiquidityFuzzers { bytes memory calls = getBurnEncoded(tokenId, config, ZERO_BYTES); uint256 balance0BeforeAlice = currency0.balanceOf(alice); - uint256 balance1BeforeAlice = currency0.balanceOf(alice); + uint256 balance1BeforeAlice = currency1.balanceOf(alice); vm.prank(alice); lpm.modifyLiquidities(calls, _deadline); From f7aa1a7968c9760907be1e07ce7740fd8bcbd0da Mon Sep 17 00:00:00 2001 From: anxbt Date: Wed, 8 Apr 2026 16:14:14 +0530 Subject: [PATCH 2/2] test: strengthen mint slippage revert rollback assertions --- test/position-managers/PositionManager.t.sol | 41 +++++++++++++++++++- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/test/position-managers/PositionManager.t.sol b/test/position-managers/PositionManager.t.sol index c138fcf79..656ae1f0a 100644 --- a/test/position-managers/PositionManager.t.sol +++ b/test/position-managers/PositionManager.t.sol @@ -652,7 +652,7 @@ contract PositionManagerTest is Test, PosmTestSetup, LiquidityFuzzers { uint256 tokenId = lpm.nextTokenId(); mint(config, 1e18, ActionConstants.MSG_SENDER, ZERO_BYTES); BalanceDelta delta = getLastDelta(); - uint128 amount1Delta = uint128(-delta.amount0()); + uint128 amount1Delta = uint128(-delta.amount1()); bytes memory calls = getDecreaseEncoded(tokenId, config, 1e18, MIN_SLIPPAGE_DECREASE, amount1Delta + 1 wei, ZERO_BYTES); @@ -974,5 +974,42 @@ contract PositionManagerTest is Test, PosmTestSetup, LiquidityFuzzers { assertLt(uint256(int256(deltaDecrease.amount1())), uint256(int256(-deltaMint.amount1()))); // amount1 in the second position was greater than amount1 in the first position } - function test_mint_slippageRevert() public {} + function test_mint_slippageRevert() public { + PositionConfig memory config = PositionConfig({poolKey: key, tickLower: -120, tickUpper: 120}); + uint256 liquidity = 100e18; + + (uint256 amount0, uint256 amount1) = LiquidityAmounts.getAmountsForLiquidity( + SQRT_PRICE_1_1, + TickMath.getSqrtPriceAtTick(config.tickLower), + TickMath.getSqrtPriceAtTick(config.tickUpper), + uint128(liquidity) + ); + + // Snapshot state to prove full rollback on revert. + uint256 nextTokenIdBefore = lpm.nextTokenId(); + uint256 balance0Before = currency0.balanceOfSelf(); + uint256 balance1Before = currency1.balanceOfSelf(); + + // Make both slippage limits intentionally too strict by 1 wei. + bytes memory calls = getMintEncoded( + config, + liquidity, + uint128(amount0 - 1 wei), + uint128(amount1 - 1 wei), + ActionConstants.MSG_SENDER, + ZERO_BYTES + ); + + // Position manager checks amount0 first for this path. + vm.expectRevert( + abi.encodeWithSelector( + SlippageCheck.MaximumAmountExceeded.selector, uint128(amount0 - 1 wei), uint128(amount0 + 1 wei) + ) + ); + lpm.modifyLiquidities(calls, _deadline); + + assertEq(lpm.nextTokenId(), nextTokenIdBefore); + assertEq(currency0.balanceOfSelf(), balance0Before); + assertEq(currency1.balanceOfSelf(), balance1Before); + } }