Negative Interest: Round Trip#600
Merged
jalextowle merged 3 commits intojalextowle/bug/negative-interest-mature-positionsfrom Sep 29, 2023
Merged
Conversation
45ca838 to
fe7796e
Compare
9ca3b3e to
a1032de
Compare
jrhea
approved these changes
Sep 28, 2023
Contributor
jrhea
left a comment
There was a problem hiding this comment.
lgtm - just a couple of nits.
fe7796e to
af25c00
Compare
f1ce4fa to
6525ba4
Compare
Contributor
Author
|
I need to fix the rust implementation in this PR. |
ef62e6c to
6730117
Compare
0950f34
into
jalextowle/bug/negative-interest-mature-positions
jalextowle
added a commit
that referenced
this pull request
Oct 9, 2023
* Made some progress on the negative interest issues * Simplified the mature negative interest flow and fixed the flow for shorts * Fixed a discrepancy in the negative interest logic in `closeLong` * Cleanup * Fixed issue after merge * Refactored out `sharePaymentWithoutFees` * Refactored out `shareProceedsWithFees` * Addressed review feedback from @jrhea * "Fixed" an intermittent failure in `test_lp_withdrawal_long_and_short_maturity * Commit intermmediate progress * Made the share adjustment fixes * Added a `minSharePrice` * Fixed some tests * Fixed the Rust codebase * Name changes in `HyperdriveLong` 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`. * Removed the long share price and did some renaming in `HyperdriveShort` * De-duplicated the negative interest logic between `closeLong` and `closeShort` * Renamed `shareCurvePayment` and `shareCurveProceeds` to `shareCurveDelta` * Negative Interest: Round Trip (#600) * Added a `minSharePrice` * Fixed some tests * Fixed the Rust codebase * Renamed `bondCurvePayment` and `bondCurveProceeds` to `bondCurveDelta` * Fixed issues after merge * Addressed review feedback
jalextowle
added a commit
that referenced
this pull request
Oct 11, 2023
* Made some progress on the negative interest issues * Simplified the mature negative interest flow and fixed the flow for shorts * Fixed a discrepancy in the negative interest logic in `closeLong` * Cleanup * Fixed issue after merge * Refactored out `sharePaymentWithoutFees` * Refactored out `shareProceedsWithFees` * Addressed review feedback from @jrhea * "Fixed" an intermittent failure in `test_lp_withdrawal_long_and_short_maturity * Commit intermmediate progress * Made the share adjustment fixes * Added a `minSharePrice` * Fixed some tests * Fixed the Rust codebase * Name changes in `HyperdriveLong` 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`. * Removed the long share price and did some renaming in `HyperdriveShort` * De-duplicated the negative interest logic between `closeLong` and `closeShort` * Renamed `shareCurvePayment` and `shareCurveProceeds` to `shareCurveDelta` * Negative Interest: Round Trip (#600) * Added a `minSharePrice` * Fixed some tests * Fixed the Rust codebase * Renamed `bondCurvePayment` and `bondCurveProceeds` to `bondCurveDelta` * Fixed issues after merge * Fixed the path independence test and added a test for k invariance * Addressed review feedback * Cleaned up the comments * Fixed a bug in `openShort` caused by negative interest * Added negative interest to `test_path_independence`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The current accounting system uses the share price at the beginning of the checkpoint to assess whether or not negative interest accrued in the checkpoint. With this in mind, the system doesn't distinguish between traders that opened their positions before or after the negative interest accrued. This has the consequence that opening a long after negative interest accrues in a checkpoint locks in an immediate loss (aside from slippage and fees) since the trader's proceeds will be discounted by the negative interest if they immediately close their long. There is a separate issue with shorts that needs to be addressed in a follow-up.
A solution to this problem is to add a parameter to
openLongandopenShortthat allows trader's to specify a minimum share price at which to open their position. If the share price is lower than this threshold, the transaction will revert. This prevents traders from getting into a bad situation in the event that negative interest accrues atomically. It's good to allow the trader to pick their own tolerance because there may be yield sources in the future that accrue dust negative interest occasionally.