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 open_short_curve_fee #97

Merged
merged 4 commits into from
May 14, 2024
Merged

Fix open_short_curve_fee #97

merged 4 commits into from
May 14, 2024

Conversation

ryangoree
Copy link
Member

Resolved Issues

Related to #88

Description

We were using mul_up where the contracts use mulDown: https://github.com/delvtech/hyperdrive/blob/33982bba72d861b3b90cb0b4083fec30accb649f/test/utils/HyperdriveUtils.sol#L1362

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?

@ryangoree ryangoree enabled auto-merge (squash) May 14, 2024 05:32
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.

As mentioned offline, we may want to wait on the Solidity fixes. I’ll approve in case this makes the fixes tonight/tomorrow easier, but we’ll want to revert this after v1.0.7 lands.

@ryangoree ryangoree merged commit 05cec36 into main May 14, 2024
8 checks passed
@ryangoree ryangoree deleted the ryangoree/short-fees branch May 14, 2024 05:37
dpaiton added a commit that referenced this pull request May 14, 2024
@dpaiton dpaiton mentioned this pull request May 14, 2024
6 tasks
dpaiton added a commit that referenced this pull request May 14, 2024
dpaiton added a commit that referenced this pull request May 14, 2024
dpaiton added a commit that referenced this pull request May 14, 2024
# Description
This PR is the result of an audit of the fee functions. The following
changes were made (one commit per bullet):

1. revert the rounding adjustment from #97. We realized that the bug
actually lies in the solidity _test utils_. This has been fixed so I
reverted the rounding behavior to match.
2. update docstrings to use a more consistent format. I introduce a
convention of my own to use upper-case $\Phi_{c,ol}(...)$ for the fee
function and lower-case $\phi_{c}$ for the fee multiplier constant. The
subscript on the fee function is the fee type $\in c, g, f$ for curve,
gov, and flat; as well as the trade type $\in ol, cl, os, cs$ for
opening or closing a long or short. This replaces the inconsistent
method of using e.g. `c(x)` at some times and `curve_fee` at other
times, or using repeat symbols for different equations.
3. add `maybe_curve_fee` arg to gov fee calculations to fix #43 and
reduce computation.
4. change the rounding behavior to match solidity (note it's matching
the eqs in `internal/HyperdriveBase.sol`
5. the above changes revealed a unit issue in `calculate_targeted_long`
where the gov fee (and derivative) was not converted to shares. I
updated my [overleaf
doc](https://www.overleaf.com/read/jkngspgyqzkf#1de6ce), the docstrings,
and the code itself.
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.

2 participants