Skip to content

Test/mint slippage revert rollback#522

Open
anxbt wants to merge 2 commits into
Uniswap:mainfrom
anxbt:test/mint-slippage-revert-rollback
Open

Test/mint slippage revert rollback#522
anxbt wants to merge 2 commits into
Uniswap:mainfrom
anxbt:test/mint-slippage-revert-rollback

Conversation

@anxbt

@anxbt anxbt commented Apr 8, 2026

Copy link
Copy Markdown

Related Issue

Which issue does this pull request resolve?

Description of changes

  • Fixed the amount1 slippage revert test to use the correct delta field in line 655
  • Added/updated slippage revert coverage for minting when both max token inputs are set below required amounts.
  • Added explanatory comments clarifying test intent and why the revert is expected.
  • Added rollback assertions after revert to confirm:
  • no new position NFT is minted (next token id unchanged)
  • caller balances remain unchanged for both currencies

Copilot AI review requested due to automatic review settings April 8, 2026 10:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates PositionManager slippage-revert tests to correctly assert token deltas/balances and adds a mint slippage revert test that verifies full state rollback (no NFT minted, balances unchanged) after a revert.

Changes:

  • Fix decrease-liquidity slippage revert test to use delta.amount1() for amount1 slippage bounds.
  • Fix burn/transfer test to snapshot currency1 balance (was incorrectly reading currency0 twice).
  • Implement test_mint_slippageRevert with revert expectation plus rollback assertions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}

function test_mint_slippageRevert() public {}
function test_mint_slippageRevert() public {

Copilot AI Apr 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New test name test_mint_slippageRevert breaks the underscore naming pattern used throughout this file (e.g., test_mint_slippage_revertAmount0, test_decreaseLiquidity_slippage_revertAmount1). Renaming to match the existing test_<action>_<scenario> convention will make the test suite easier to scan and search.

Suggested change
function test_mint_slippageRevert() public {
function test_mint_slippage_revert() public {

Copilot uses AI. Check for mistakes.
Comment on lines +993 to +1007
// 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)
)

Copilot AI Apr 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says the slippage limits are "too strict by 1 wei", but the code sets amount0Max/amount1Max to amount0 - 1 wei / amount1 - 1 wei while the revert expectation indicates the requested amount is amount0 + 1 wei. If the intent is “1 wei below required” (per PR description and the earlier test_mint_slippage_exactDoesNotRevert behavior), consider using amount0/amount1 as the max values (or update the comment to reflect the actual gap).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants