Skip to content

test: add fee growth direction assertions (closes #606)#1017

Open
PrazwalR wants to merge 1 commit intoUniswap:mainfrom
PrazwalR:fix/fee-growth-direction-tests
Open

test: add fee growth direction assertions (closes #606)#1017
PrazwalR wants to merge 1 commit intoUniswap:mainfrom
PrazwalR:fix/fee-growth-direction-tests

Conversation

@PrazwalR
Copy link
Copy Markdown

@PrazwalR PrazwalR commented Mar 5, 2026

Closes #606

Problem

Flipping zeroForOne in the fee growth global storage assignment (Pool.sol:445-449) does not cause any existing test to fail.
This means incorrect fee accounting direction could go undetected.

Solution

Added FeeGrowthDirection.t.sol with tests asserting that after a single-direction swap, feeGrowthGlobal increases only for the input token's tracker, while the other remains zero.

Test Coverage

Test Scenario
zeroForOne_exactInput Basic directional check
oneForZero_exactInput Opposite direction
zeroForOne_exactOutput Exact-output variant
oneForZero_exactOutput Exact-output variant
bidirectional_independent Both directions, trackers remain independent
withTickCrossing_zeroForOne Swap crosses initialized ticks
withTickCrossing_oneForZero Swap crosses initialized ticks
fuzz_feeGrowthDirection 1000-run fuzz over direction + amount
native_zeroForOne ETH pool swap
native_oneForZero ETH pool swap

Verification

Flipping !zeroForOnezeroForOne at Pool.sol:445 causes all 10 tests to fail immediately, confirming the tests detect incorrect fee growth direction.

Copilot AI review requested due to automatic review settings March 5, 2026 18:12
@PrazwalR PrazwalR requested a review from a team as a code owner March 5, 2026 18:12
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

Flipping zeroForOne before fee indices assignment in Pool.swap doesn't cause the tests to fail

2 participants