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

Add calculate_shares_delta_given_bonds_delta_derivative #7

Merged

Conversation

sentilesdal
Copy link
Contributor

@sentilesdal sentilesdal commented Apr 29, 2024

Resolved Issues

This is a part of adding functions needed to test remove_liquidity

Description

  • Adds the lower level function calculate_shares_delta_given_bonds_delta_derivative to lp.rs
  • Adds a new version of calculate_present_value_safe that doesn't panic. Future work will remove the previous version.
  • Adds a helper function to calculate idle reserves
  • Tests calculate_shares_delta_given_bonds_delta_derivative.

I ran diagnostics to make sure that we were actually testing the function, the test errors on the present value calculation about half the time, errors on the actual function 1/4 time and succeeds about a 1/4 of the time.

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?

Copy link
Contributor

@jalextowle jalextowle left a comment

Choose a reason for hiding this comment

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

The impl looks right to me. A few style nits that should be addressed before merging, but otherwise LGTM

@sentilesdal sentilesdal force-pushed the matt/calculate-shares-delta-given-bonds-delta-derivative branch from f655ccb to 06b6646 Compare April 30, 2024 14:41
@sentilesdal sentilesdal force-pushed the matt/calculate-shares-delta-given-bonds-delta-derivative branch from 06b6646 to 72a9062 Compare April 30, 2024 15:54
Copy link
Member

@dpaiton dpaiton left a comment

Choose a reason for hiding this comment

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

approved pending replies to our comments

@sentilesdal sentilesdal force-pushed the matt/calculate-shares-delta-given-bonds-delta-derivative branch from 72a9062 to 3f4c4b3 Compare April 30, 2024 18:35
@sentilesdal sentilesdal force-pushed the matt/calculate-shares-delta-given-bonds-delta-derivative branch 2 times, most recently from c46cc22 to 6693f32 Compare April 30, 2024 18:38
@sentilesdal sentilesdal force-pushed the matt/calculate-shares-delta-given-bonds-delta-derivative branch from 6693f32 to 1c0052b Compare April 30, 2024 18:39
@sentilesdal sentilesdal merged commit 7908c27 into main Apr 30, 2024
4 checks passed
@sentilesdal sentilesdal deleted the matt/calculate-shares-delta-given-bonds-delta-derivative branch April 30, 2024 19:12
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.

3 participants