-
Notifications
You must be signed in to change notification settings - Fork 101
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
Chore: Flip Dex Price Logic #NTRN-355 #624
Conversation
x/dex/migrations/v4/store.go
Outdated
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.
Hm, could you clarify why do you change a code for the previous migration?
I don't think we are supposed to change old migrations
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.
MustCalcPrice
fn has been inverted so to achieve the same migration we must flip the sign. The output of the migration should be the same
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.
I think the question was - do we get the same migration output in 2 cases
- Our case. User migrates 3 -> 4 (old one) (neutron v4.2.1) and then 4 -> 5. 3 -> old 4 -> 5
- Imported dex module to third parthy project. User migrates 3 vesrion -> 5 version (current one). 3 -> new 4 -> 5
I dont think it's safe in terms compatibility to modify already released migrations
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.
Yes, that's exactly what i meant
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.
I don't think it's an issue. You can see that the tests are unchanged. So the migrations still produce the same output. @swelf19 @pr0n00gler
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.
Yes, seems you are right. No changes in output. Dont see any problems with a migration now.
Unit tests don't work, please fix it |
x/dex/migrations/v4/store.go
Outdated
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.
I think the question was - do we get the same migration output in 2 cases
- Our case. User migrates 3 -> 4 (old one) (neutron v4.2.1) and then 4 -> 5. 3 -> old 4 -> 5
- Imported dex module to third parthy project. User migrates 3 vesrion -> 5 version (current one). 3 -> new 4 -> 5
I dont think it's safe in terms compatibility to modify already released migrations
I'm assuming this:
Was resolved by the comment above @swelf19, please correct me if not |
@@ -56,7 +56,7 @@ func (k Keeper) Swap( | |||
// but due to rounding and inaccuracy of fixed decimal math, it is possible |
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.
Should update the comment on ln55
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.
Pls resolve conflicts
@@ -96,7 +96,7 @@ func CalcTickIndexFromPrice(price math_utils.PrecDec) (int64, error) { | |||
return 0, ErrPriceOutsideRange | |||
} | |||
|
|||
if price.GT(math_utils.OnePrecDec()) { | |||
if price.LT(math_utils.OnePrecDec()) { |
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.
As far as i understand you need to update comment at line 100 -> >=1
x/dex/migrations/v4/store.go
Outdated
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.
Yes, seems you are right. No changes in output. Dont see any problems with a migration now.
Issue
https://hadronlabs.atlassian.net/browse/NTRN-355?atlOrigin=eyJpIjoiYTI0ODY0YTRhNzdhNDQ1NWFlODZhNzE0N2E0ZDk2MmYiLCJwIjoiaiJ9
Currently the dex stores prices as 1.0001^-TickIndex
This has been a persistent confusion for builders and integrators and also introduces unnecessary loss of precision. We can safely flip prices the other way without changing functionality