-
Notifications
You must be signed in to change notification settings - Fork 5
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
Adds mint
and burn
functions
#1220
Merged
Merged
Conversation
This file contains 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
jalextowle
requested review from
jrhea,
mcclurejt,
cashd,
sentilesdal,
dpaiton and
slundqui
as code owners
November 20, 2024 07:42
jrhea
reviewed
Dec 2, 2024
jrhea
reviewed
Dec 2, 2024
Sean329
reviewed
Dec 8, 2024
Sean329
reviewed
Dec 8, 2024
jrhea
reviewed
Jan 16, 2025
jrhea
reviewed
Jan 16, 2025
jrhea
reviewed
Jan 16, 2025
jrhea
reviewed
Jan 16, 2025
jrhea
reviewed
Jan 16, 2025
Sean329
reviewed
Jan 17, 2025
jrhea
approved these changes
Jan 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥
github-merge-queue
bot
removed this pull request from the merge queue due to no response for status checks
Jan 22, 2025
github-merge-queue
bot
removed this pull request from the merge queue due to no response for status checks
Jan 23, 2025
github-merge-queue
bot
removed this pull request from the merge queue due to no response for status checks
Jan 23, 2025
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.
Description
This PRs adds two functions that together allow traders to completely bypass Hyperdrive's AMM system while still allowing them to open long and short positions. In order to bypass the AMM and avoid the use of LP funds,
mint
andburn
provide the low-level plumbing required for traders to be matched directly against each other. These functions provide a way to directly mint longs and shorts equal in value to a given amount of base and directly burn longs and shorts for the amount of value underlying the bonds.Mint
The operation of minting takes in a share deposit$\Delta z$ and outputs an amount of bonds $\Delta y$ that were minted. The bonds are split between long and short tokens that are both minted with amounts equal to $\Delta y$ .
One of the goals for the
mint
function is to interoperate with the existing accounting mechanisms. Long and short tokens that are created through calling themint
function must be able to be closed by callingcloseLong
orcloseShort
without negatively impacting the system invariants like solvency. Since offsetting positions are created, the price shouldn't change when positions are minted.To mint matched long and short positions, a few things must be paid for:
Given all of this information, we can set up the equality relating the shares deposited to the bond amount:
Since the trade isn't happening on the curve and conceptually the long and short trades are perfectly matched, the only accounting updates the need to be made is to update the average maturity times, the longs outstanding, the shorts outstanding, and the amount of governance fees that have accrued.
Burn
burn
does the opposite ofmint
. It takes inmint
function,burn
should be able to interoperate seamlessly with positions opened byopenLong
andopenShort
.When positions are burned, several things must be accounted for:
The proceeds in shares is given by:
The share and bond reserves aren't updated since the long and short trades perfectly cancel out. The only state changes that must be made are updating the average maturity times, the longs outstanding, the shorts outstanding, and the amount of governance fees accrued.
Todos
mint
andburn
mint
function.mint
.mint
.burn
function.burn
.burn
.mint
.test_lp_withdrawal_pair_redemption
.mint
andburn
to the instance test framework.