-
Notifications
You must be signed in to change notification settings - Fork 977
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Tests for maxUsableTick and minUsableTick Functions #526
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left some comments 🙏
function test_maxUsableTick_equalsMinUsableTick_fuzz(int24 tickSpacing) public { | ||
tickSpacing = int24(bound(tickSpacing, TickMath.MIN_TICK_SPACING, TickMath.MAX_TICK_SPACING)); | ||
vm.assume(tickSpacing != 0); | ||
|
||
assertEq(-tickMath.minUsableTick(tickSpacing), tickMath.maxUsableTick(tickSpacing)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hensha256 resolving this suggestion from @aadams on my previous PR
#468 (comment)
function test_maxUsableTick_shouldMatchExpectedMaxTickGivenSpacing_fuzz(int24 tickSpacing) public { | ||
tickSpacing = int24(bound(tickSpacing, TickMath.MIN_TICK_SPACING, TickMath.MAX_TICK_SPACING)); | ||
vm.assume(tickSpacing != 0); | ||
|
||
int24 expectedMaxTick = (MAX_TICK / tickSpacing) * tickSpacing; | ||
assertEq(tickMath.maxUsableTick(tickSpacing), expectedMaxTick); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hensha256 Using bound
instead of vm.assume and using TickMath.MIN_TICK_SPACING
and TickMath.MAX_TICK_SPACING
instead of MIN_TICK
and MAX_TICK
@hensha256 @aadams Following up on the stale PR: #468
This commit introduces tests for the newly added utility functions
maxUsableTick
andminUsableTick
in the TickMath library.Added tests to check the min and max usable ticks in the
TickMath
library.Added 2 tests to check tick spacings for popular fee tiers.
Added 2 fuzzing tests.
Added 2 tests to check revert of min/max tick on 0.