-
Notifications
You must be signed in to change notification settings - Fork 609
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
feat: mitigate inverse relationship problems in swaps; more tests; clean up spot price #5002
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
czarcas7ic
approved these changes
Apr 25, 2023
Co-authored-by: Adam Tucker <adam@osmosis.team>
Co-authored-by: Adam Tucker <adam@osmosis.team>
Co-authored-by: Adam Tucker <adam@osmosis.team>
Co-authored-by: Adam Tucker <adam@osmosis.team>
Co-authored-by: Adam Tucker <adam@osmosis.team>
AlpinYukseloglu
approved these changes
Apr 25, 2023
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.
Nice work, I really like the abstractions you set up here
p0mvn
added
no-changelog
V:state/compatible/no_backport
State machine compatible PR, depends on prior breaks
labels
Apr 25, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
C:x/concentrated-liquidity
V:state/compatible/no_backport
State machine compatible PR, depends on prior breaks
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes: #XXX
What is the purpose of the change
This PR is focused on truncations in the right direction as we square "square root price" in swaps.
While working on inverse relationship tests, I realized that some of the fractional residues due to intermediary math calculations are inevitable. Ref: #4998 (comment)
In swaps, what we want to guarantee is that we always round in the direction of the pool. As a result, here we introduce a method defined on the swap strategy that rounds in the desired direction based on swap strategy.
There are 2 drive-by changes here:
CalculateSpotPrice
keeper method to use pool's spot price implementation instead of re-implementing on its ownBrief Changelog
math.SquareRoundUp
andmath.SquareRoundDown
SquareSqrtPrice
defined on each of the swap strategies and utilizing the methods aboveCalculateSpotPrice
Testing and Verifying
This change is already covered by existing tests
Documentation and Release Note
Unreleased
section inCHANGELOG.md
? no