-
Notifications
You must be signed in to change notification settings - Fork 607
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
[CL]: Increase min tick past canonical tick range #5551
Changes from all commits
4679405
f34cbaf
a9de3ef
4984fd4
8b3670d
3471bfb
1bea678
8675792
28409d2
b84aef2
bb6d2b9
aca6f22
a1b7c5c
749212c
bc6a4e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1405,89 +1405,3 @@ func (s *KeeperTestSuite) TestValidateTickRangeIsValid() { | |
}) | ||
} | ||
} | ||
|
||
func (s *KeeperTestSuite) TestRoundTickToCanonicalPriceTick() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this removed? Is there a replacement for these test vectors? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The notion of canonical price ticks no longer exist, so these vectors no longer make sense. All the test vectors added relating to the behavior in ticks surrounding the new MinTick ensure the appropriate properties hold. |
||
tests := []struct { | ||
name string | ||
lowerTick int64 | ||
upperTick int64 | ||
expectedNewLowerTick int64 | ||
expectedNewUpperTick int64 | ||
expectedError error | ||
}{ | ||
{ | ||
name: "exact upper tick for 0.000000000000000003 to exact lower tick for 0.000000000000000002", | ||
lowerTick: -161000000, | ||
expectedNewLowerTick: -161000000, | ||
upperTick: -160000000, | ||
expectedNewUpperTick: -160000000, | ||
}, | ||
{ | ||
name: "exact upper tick for 0.000000000000000003 to inexact lower tick for 0.000000000000000002", | ||
lowerTick: -161001234, | ||
expectedNewLowerTick: -161000000, | ||
upperTick: -160000000, | ||
expectedNewUpperTick: -160000000, | ||
}, | ||
{ | ||
name: "inexact upper tick for 0.000000000000000003 to exact lower tick for 0.000000000000000002", | ||
lowerTick: -161000000, | ||
expectedNewLowerTick: -161000000, | ||
upperTick: -160001234, | ||
expectedNewUpperTick: -160000000, | ||
}, | ||
{ | ||
name: "inexact upper tick for 0.000000000000000003 to inexact lower tick for 0.000000000000000002", | ||
lowerTick: -161001234, | ||
expectedNewLowerTick: -161000000, | ||
upperTick: -160001234, | ||
expectedNewUpperTick: -160000000, | ||
}, | ||
{ | ||
name: "upper tick one tick away from lower tick", | ||
lowerTick: -161001234, | ||
expectedNewLowerTick: -161000000, | ||
upperTick: -160999999, | ||
expectedNewUpperTick: -160000000, | ||
}, | ||
{ | ||
name: "error: new upper tick is lower than new lower tick", | ||
lowerTick: -160001234, | ||
expectedNewLowerTick: -160000000, | ||
upperTick: -161001234, | ||
expectedNewUpperTick: -161000000, | ||
expectedError: types.InvalidLowerUpperTickError{LowerTick: -160000000, UpperTick: -161000000}, | ||
}, | ||
{ | ||
name: "error: new upper tick is the same as new lower tick", | ||
lowerTick: -160001234, | ||
expectedNewLowerTick: -160000000, | ||
upperTick: -160000000, | ||
expectedNewUpperTick: -160000000, | ||
expectedError: types.InvalidLowerUpperTickError{LowerTick: -160000000, UpperTick: -160000000}, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
s.Run(test.name, func() { | ||
s.SetupTest() | ||
|
||
_, sqrtPriceTickLower, err := math.TickToSqrtPrice(test.lowerTick) | ||
s.Require().NoError(err) | ||
_, sqrtPriceTickUpper, err := math.TickToSqrtPrice(test.upperTick) | ||
s.Require().NoError(err) | ||
|
||
// System Under Test | ||
newLowerTick, newUpperTick, err := cl.RoundTickToCanonicalPriceTick(test.lowerTick, test.upperTick, sqrtPriceTickLower, sqrtPriceTickUpper, DefaultTickSpacing) | ||
|
||
if test.expectedError != nil { | ||
s.Require().Error(err) | ||
s.Require().ErrorContains(err, test.expectedError.Error()) | ||
} else { | ||
s.Require().NoError(err) | ||
s.Require().Equal(test.expectedNewLowerTick, newLowerTick) | ||
s.Require().Equal(test.expectedNewUpperTick, newUpperTick) | ||
} | ||
}) | ||
} | ||
} |
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.
Are you explaining being off by one compared to the Wolfram calculation?
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.
Ah yes sorry – the expected output is bankers rounded instead of truncated due to
GetLiquidityFromAmounts
being bankers rounded. This does not pose any security risks as the balance is still deducted from the caller.