-
Notifications
You must be signed in to change notification settings - Fork 6
Fair LP Allocation #82
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
Merged
Merged
Conversation
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
5dde10b to
efcbd51
Compare
jrhea
reviewed
Feb 17, 2023
dbcd715 to
fee1ab9
Compare
Collaborator
Pull Request Test Coverage Report for Build 4235537235
💛 - Coveralls |
62beda5 to
d41133e
Compare
cb73208 to
93ce29f
Compare
Contributor
aleph-v
reviewed
Feb 21, 2023
754fdc4 to
4922ad6
Compare
aleph-v
approved these changes
Feb 21, 2023
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.

Overview
The current LP scheme is safe but isn't fair. In the case where an LP joins immediately after a long is opened, the LP will receive more LP shares than an LP that joined prior to the long. When the long is closed, the new LP will benefit more from the closure than an LP that joined before the long. The exact opposite occurs with shorts. These games can lead to new LPs getting significant rewards without taking on risk and vice-versa.
This PR implements a scheme that interpolates between two schemes that are fair in special cases. Since the flat+curve model linearly matures a long or short position, a linear interpolation seems like a good initial approximation; however, more testing should be done to ensure that the scheme works in general.
Methodology
Let$c$ be the share price, $z$ be the share reserves, $l$ be the total supply of LP shares, $\Delta z$ be the amount of shares the new LP supplied to the pool, and $\Delta l$ be the amount of LP shares awarded to the LP. The amount of shares $z'$ that can be immediately withdrawn by an LP with $l'$ shares:
Furthermore, let$o_l$ denote the outstanding longs, $o_s$ denote the outstanding shorts, $v_l$ denote the base volume for longs, and $v_s$ denote the base volume for shorts. The two LP schemes that we interpolate between are:
and
Both of these schemes are unfair for LPs in different situations (they are flipped for longs and shorts). Having said this, there are examples of when each is fair for LPs. In particular, the first scheme is fair for LPs when a short is opened. The second scheme is fair for LPs when a long is opened. To get the best of both worlds, we linearly interpolate between the two versions.