-
Notifications
You must be signed in to change notification settings - Fork 0
calc abs max short guess #202
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
Merged
Merged
Conversation
This file contains hidden or 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
0cbfffe to
4cc1f81
Compare
57159bb to
12f2a29
Compare
9fbc55d to
89d3725
Compare
6d6e635 to
ee792ad
Compare
jrhea
approved these changes
Dec 17, 2024
Contributor
jrhea
left a comment
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.
great work!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
improves the function for calculating the absolute max short.
We use a linear approximation that passes the test 99.67% of the time (7441/7465 passed). There is an additional loop to ensure the remaining tests pass. Future work should be to fix the linear estimate to remove this loop -- it should not be required if the theory & code are correct.
Additional changes:
calculate_absolute_max_short. This was failing in cases when solidity was successful and erroneous. The new (rust) starting point obtained by the approximate estimate can succeed when the old (solidity) function fails, and it can also result in a lower final value than the solidity version. Follow-up PRs will add more tests that concretely demonstrate tolerances for final solvency after opening the max short. Once we are happy with the Rust version, we can port the code back over to Solidity & add back the parity tests.calculate_spot_pricetocalculate_spot_price_downand added a*_upversion -- this is helpful for over/under estimating the price in the approximation code.solvency_after_shortDerivation of approximate function