-
Notifications
You must be signed in to change notification settings - Fork 3
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
Fixed get_max_short
#559
Merged
Merged
Fixed get_max_short
#559
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
… certain tests fail
jalextowle
force-pushed
the
jalextowle/rust/max-trades-with-netting
branch
from
August 18, 2023 20:31
8aff8b4
to
2a9a5c2
Compare
jalextowle
commented
Aug 18, 2023
jalextowle
commented
Aug 18, 2023
jalextowle
commented
Aug 18, 2023
jalextowle
commented
Aug 18, 2023
jalextowle
force-pushed
the
jalextowle/rust/max-trades-with-netting
branch
from
August 19, 2023 16:52
05285a2
to
29e7f0b
Compare
jalextowle
force-pushed
the
jalextowle/rust/max-trades-with-netting
branch
from
August 19, 2023 16:56
29e7f0b
to
1008653
Compare
jalextowle
force-pushed
the
jalextowle/rust/max-trades-with-netting
branch
from
August 19, 2023 17:35
7a9e912
to
160b4a5
Compare
…rades-with-netting
…rades-with-netting
jrhea
approved these changes
Aug 23, 2023
Co-authored-by: Jonny Rhea <[email protected]>
…netting' into jalextowle/rust/max-trades-with-netting
jalextowle
added a commit
that referenced
this pull request
Aug 25, 2023
* implement and test netting * fixed issues found running tests and fuzzing * prettier * remove old code * exposure should be updated by the delta in openLong. also, changed mulDiv to mul * more compact/efficient solvency check * improve fuzz testing * changed the closeShort method to mirror closeLong * add cross checkpoint fuzzing tests * add more comprehensive fuzzing, fix some minor issues and explain why certain tests fail * derp * finish merge * Tweaked the fuzz tests * move close position exposure logic to calculateClosePositionExposure helper * remove shareReservesExceedsBondReserves revert * move exposure to marketState and fix test_LongAvoidsDrainingBufferReserves() test * test__calculateClosePositionExposure() tests * remove print imports * reduce num trades in netting fuzz to speed up test * update foundry action * add exposure to rust hyperdrive math * update hyperdrive-math-py with exposure * fml * simplify calculateClosePositionExposure and update tests * fix stack issue with via-ir prod build * make calculateClosePositionExposure even simpler * changing back to nightly for coverage bc it is 404ing * added idleShareReserves calculation * fixes to removeLiquidity idle calc. update tests * remove printout * Use ChaCha8Rng instead of ThreadRng so that fuzz runs are reproducible * working on fixing tests * Reverted to the old idle calculation and fixed some tests * Update contracts/src/Hyperdrive.sol Co-authored-by: Alex Towle <[email protected]> * Fixed the remaining LP fairness tests * Fixed the remaining `removeLiquidity` unit tests * implementing review comments * prettier * more review fixes * fix lint issues * Update contracts/src/HyperdriveLong.sol Co-authored-by: Alex Towle <[email protected]> * Update contracts/src/Hyperdrive.sol Co-authored-by: Alex Towle <[email protected]> * Update contracts/src/HyperdriveLong.sol Co-authored-by: Alex Towle <[email protected]> * Update contracts/src/HyperdriveShort.sol Co-authored-by: Alex Towle <[email protected]> * prettier * spelling * put solvency check in method * Update contracts/src/HyperdriveShort.sol Co-authored-by: Alex Towle <[email protected]> * Uncommented test * Made several fixes to `get_max_short` and started to test it more rigorously * Worked on improving the `get_max_short` calculation * Significantly improved the accuracy of the agent's `get_max_short` calculation * Added a `get_max_short` function * Cleanups * Removed some where clauses * Tweaks * Adds a unit test to test the fix * Fixed the python tests * Debugging * Fixed a bug in `calculateShortProceeds` * Fixed the `calculateShortProceeds` test * Fuzzing parameter tweaks * Last few fixes * Appeased the linter * Update test/units/hyperdrive/OpenShortTest.t.sol Co-authored-by: Jonny Rhea <[email protected]> * Addressed review feedback from @jrhea --------- Co-authored-by: jonny rhea <[email protected]> Co-authored-by: Jonny Rhea <[email protected]>
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.
This PR fixes the
get_max_short
function and adds fuzz tests that verify that it is within a specified tolerance. This function will need to be improved as we start writing fuzz tests; however, this is a good cutoff point for now.During the process of fixing
get_max_short
, I stumbled across two bugs in the logic for computing a short's deposit. The first is that we were removing the governance fee from the trader's short deposit and the second is that we weren't converting the flat fee to share fees when we added the flat fee to the short deposit. Both of these issues have been fixed and tested.