Skip to content

Negative Interest: Refactor#601

Merged
jalextowle merged 26 commits intomainfrom
jalextowle/negative-interest/refactor
Oct 9, 2023
Merged

Negative Interest: Refactor#601
jalextowle merged 26 commits intomainfrom
jalextowle/negative-interest/refactor

Conversation

@jalextowle
Copy link
Copy Markdown
Contributor

This PR contains several refactoring changes that fit into the overall negative interest effort. The driving principles were:

  • We shouldn't use the same names in different contexts in the main flows (shareReservesDelta was a negative example before this PR)
  • We should only use the names shareReservesDelta and bondReservesDelta to refer to quantities that will be added or subtracted directly to the reserves. Any other use is inherently confusing.

Beyond this, this PR also removes the longOpenSharePrice and longSharePrice. #600 adds the _minSharePrice field, which provides assurance that traders won't accidentally get into round trip situations. The recent round of idle changes in #581 was the last piece in the puzzle of calculating the proceeds of LPs "declaratively" by trusting the output of the present function. The present value incorporates information about the variable interest collected by LPs from the open long positions. With this in mind, there is no need to store longSharePrice or longOpenSharePrice.

@jalextowle jalextowle changed the base branch from main to jalextowle/negative-interest/round-trip September 29, 2023 04:59
@jalextowle
Copy link
Copy Markdown
Contributor Author

I should de-duplicate the negative interest logic from calculateCloseLong and calculateCloseShort and test it in isolation.

1. `shareReservesDelta` and `bondReservesDelta` always refer to the
   amount of shares or bonds that are being added or subtracted from the
   share reserves.
2. `shareCurvePayment` refers to the amount of shares priced by the
   curve. We think of this as a payment because the LPs are paying
   shares in return for a proceed in bonds, `bondCurveProceeds`.
@jalextowle jalextowle force-pushed the jalextowle/negative-interest/refactor branch from 1d96ac7 to 91d7b79 Compare September 29, 2023 16:38
Comment thread contracts/src/token/ERC20Forwarder.sol
@jalextowle jalextowle force-pushed the jalextowle/negative-interest/round-trip branch from ef62e6c to 6730117 Compare September 29, 2023 22:04
* Added a `minSharePrice`

* Fixed some tests

* Fixed the Rust codebase
Base automatically changed from jalextowle/negative-interest/round-trip to jalextowle/bug/negative-interest-mature-positions September 29, 2023 22:04
@jalextowle jalextowle requested a review from jrhea September 29, 2023 22:05
…-mature-positions' into jalextowle/negative-interest/refactor
@jalextowle jalextowle force-pushed the jalextowle/negative-interest/refactor branch from 91f7839 to 3de3601 Compare September 29, 2023 22:12
Base automatically changed from jalextowle/bug/negative-interest-mature-positions to main September 30, 2023 00:26
@jalextowle jalextowle force-pushed the jalextowle/negative-interest/refactor branch from 3de3601 to f06bd6b Compare September 30, 2023 02:16
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Sep 30, 2023

Hyperdrive Gas Benchmark

Benchmark suite Current: 657f370 Previous: 314cd40 Deviation Status
addLiquidity: min 807 gas 807 gas 0% 🟰
addLiquidity: avg 56922 gas 57120 gas -0.3466%
addLiquidity: max 98918 gas 98964 gas -0.0465%
checkpoint: min 514 gas 514 gas 0% 🟰
checkpoint: avg 30335 gas 30256 gas 0.2611% 🚨
checkpoint: max 79955 gas 69464 gas 15.1028% 🚨
closeLong: min 852 gas 852 gas 0% 🟰
closeLong: avg 23000 gas 23124 gas -0.5362%
closeLong: max 105073 gas 126328 gas -16.8252%
closeShort: min 854 gas 765 gas 11.6340% 🚨
closeShort: avg 24513 gas 24183 gas 1.3646% 🚨
closeShort: max 105436 gas 105208 gas 0.2167% 🚨
initialize: min 803 gas 803 gas 0% 🟰
initialize: avg 161914 gas 161947 gas -0.0204%
initialize: max 235547 gas 235574 gas -0.0115%
openLong: min 768 gas 768 gas 0% 🟰
openLong: avg 57128 gas 59491 gas -3.9720%
openLong: max 224842 gas 229350 gas -1.9656%
openShort: min 744 gas 744 gas 0% 🟰
openShort: avg 57965 gas 61213 gas -5.3061%
openShort: max 222544 gas 244292 gas -8.9025%
removeLiquidity: min 784 gas 784 gas 0% 🟰
removeLiquidity: avg 78871 gas 78569 gas 0.3844% 🚨
removeLiquidity: max 184133 gas 171450 gas 7.3975% 🚨

This comment was automatically generated by workflow using github-action-benchmark.

@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Sep 30, 2023

Coverage Status

coverage: 97.206% (+4.7%) from 92.507% when pulling 657f370 on jalextowle/negative-interest/refactor into cdb87e1 on main.

Copy link
Copy Markdown
Contributor

@jrhea jrhea left a comment

Choose a reason for hiding this comment

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

looks good. just a couple of nits

Comment thread contracts/src/HyperdriveShort.sol Outdated
Comment thread contracts/src/token/ERC20Forwarder.sol
Comment thread test/integrations/hyperdrive/PresentValueTest.t.sol Outdated
@jalextowle jalextowle enabled auto-merge (squash) October 6, 2023 14:16
@jalextowle jalextowle disabled auto-merge October 6, 2023 14:17
@jalextowle jalextowle enabled auto-merge (squash) October 6, 2023 14:17
@jalextowle jalextowle merged commit b7bffe4 into main Oct 9, 2023
@jalextowle jalextowle deleted the jalextowle/negative-interest/refactor branch October 9, 2023 16:07
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