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_open_long negative interest check, fix get_spot_price_after_short #919

Merged
merged 8 commits into from
Apr 3, 2024

Conversation

ryangoree
Copy link
Member

@ryangoree ryangoree commented Apr 2, 2024

Description

This PR changes calculate_open_long to use the internal spot_price_after_long for it's negative interest check to ensure the governance fee is accounted for. It also updates the calculate_spot_price_after_short to take an Option<base_amount> similar to calculate_spot_price_after_long with logic to determine the shares delta, accounting for fees, if none is given.

Required for delvtech/hyperdrive-rs#33, delvtech/hyperdrive-rs#21
Related to #833
noticed while reviewing #916

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. If there are
multiple reviewers, copy the checklists into sections titled ## [Reviewer Name].
If the PR doesn't touch Solidity and/or Rust, the corresponding checklist can
be removed.

Sheng

Rust

  • 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?

@ryangoree ryangoree added bug Something isn't working rust-sdk labels Apr 2, 2024
crates/hyperdrive-math/src/short/open.rs Outdated Show resolved Hide resolved
crates/hyperdrive-math/src/short/open.rs Outdated Show resolved Hide resolved
@ryangoree ryangoree force-pushed the ryangoree/patch-negative-interest-checks branch from 382527d to aacdc67 Compare April 2, 2024 22:12
Copy link
Contributor

@slundqui slundqui left a comment

Choose a reason for hiding this comment

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

Existing tests should cover these changes. LGTM

Copy link
Contributor

@mcclurejt mcclurejt left a comment

Choose a reason for hiding this comment

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

LGTM other than the redundant import

crates/hyperdrive-math/src/short/open.rs Outdated Show resolved Hide resolved
@ryangoree ryangoree force-pushed the ryangoree/patch-negative-interest-checks branch from aacdc67 to 83d485d Compare April 3, 2024 15:24
@ryangoree ryangoree merged commit 99e5eeb into main Apr 3, 2024
36 checks passed
@ryangoree ryangoree deleted the ryangoree/patch-negative-interest-checks branch April 3, 2024 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants