Skip to content
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

fix calculate_spot_price_after_short and add open short deltas & preview #15

Merged
merged 7 commits into from
May 3, 2024

Conversation

dpaiton
Copy link
Contributor

@dpaiton dpaiton commented May 1, 2024

Resolved Issues

No issue

Description

calculate_spot_price_after_short did not correctly compute the share deltas when a base_amount was not given. This PR adds a test to demonstrate this as well as a fix.

Part of the process also required adding calculate_open_short_deltas and a corresponding test.

Since I was most of the way there, I also added a preview_open_short that returns a mutated state after the reserve deltas have been applied.

Review Checklists

Please check each item before approving the pull request. While going
through the checklist, it is recommended to leave comments on items that are
referenced in the checklist to make sure that they are reviewed.

  • Testing
    • Are there new or updated unit or integration tests?
    • Do the tests cover the happy paths?
    • Do the tests cover the unhappy paths?
    • Are there an adequate number of fuzz tests to ensure that we are
      covering the full input space?
    • If matching Solidity behavior, are there differential fuzz tests that
      ensure that Rust matches Solidity?

@dpaiton dpaiton marked this pull request as draft May 1, 2024 05:13
@dpaiton dpaiton force-pushed the dpaiton/fix_spot_price_after_short branch from d6bda3c to edb40b2 Compare May 1, 2024 05:15
@dpaiton dpaiton linked an issue May 1, 2024 that may be closed by this pull request
@dpaiton dpaiton force-pushed the dpaiton/fix_spot_price_after_short branch 5 times, most recently from 40f1eb2 to da553b7 Compare May 2, 2024 20:43
@dpaiton dpaiton force-pushed the dpaiton/fix_spot_price_after_short branch from da553b7 to 917622f Compare May 2, 2024 20:48
@dpaiton dpaiton marked this pull request as ready for review May 2, 2024 21:18
@dpaiton dpaiton requested review from slundqui and wakamex as code owners May 2, 2024 21:18
@dpaiton dpaiton changed the title fix calculate_spot_price_after_short fix calculate_spot_price_after_short and add calculate_open_short_share_reserves_delta May 2, 2024
@dpaiton dpaiton changed the title fix calculate_spot_price_after_short and add calculate_open_short_share_reserves_delta fix calculate_spot_price_after_short and add open short deltas & preview May 2, 2024
@dpaiton dpaiton force-pushed the dpaiton/fix_spot_price_after_short branch from 3097673 to 50d4049 Compare May 2, 2024 22:41
Copy link
Contributor

@sentilesdal sentilesdal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall looks good! I think we should get in the habit of adding /// comments at the top of functions to give clues what they do, helps reviewers at least.

@dpaiton dpaiton force-pushed the dpaiton/fix_spot_price_after_short branch 2 times, most recently from e9b2985 to db3ba2b Compare May 3, 2024 00:46
@dpaiton dpaiton force-pushed the dpaiton/fix_spot_price_after_short branch 2 times, most recently from 027f5e4 to 246ea72 Compare May 3, 2024 01:13
@dpaiton dpaiton force-pushed the dpaiton/fix_spot_price_after_short branch from 246ea72 to 9a6ec40 Compare May 3, 2024 01:21
@dpaiton dpaiton merged commit 0c0564d into main May 3, 2024
4 checks passed
@dpaiton dpaiton deleted the dpaiton/fix_spot_price_after_short branch May 3, 2024 01:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix calculate_spot_price_after_short
2 participants