Skip to content

Conversation

@jalextowle
Copy link
Contributor

@jalextowle jalextowle commented Feb 17, 2023

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:

$$ z' = (z - \tfrac{o_l}{c}) \cdot \tfrac{l'}{l} $$

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:

$$ \Delta l = \frac{\Delta z \cdot l}{z - \tfrac{o_l}{c} + \tfrac{o_s}{c}} $$

and

$$ \Delta l = \frac{\Delta z \cdot l}{z - \tfrac{v_l}{c} + \tfrac{v_s}{c}} $$

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.

@jalextowle jalextowle force-pushed the jalextowle/hyperdrive/fair-lp-allocation branch 3 times, most recently from 5dde10b to efcbd51 Compare February 17, 2023 19:56
@jalextowle jalextowle force-pushed the jalextowle/hyperdrive/fair-lp-allocation branch 3 times, most recently from dbcd715 to fee1ab9 Compare February 18, 2023 00:05
@coveralls
Copy link
Collaborator

coveralls commented Feb 18, 2023

Pull Request Test Coverage Report for Build 4235537235

  • 10 of 16 (62.5%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+5.0%) to 57.706%

Changes Missing Coverage Covered Lines Changed/Added Lines %
contracts/libraries/HyperdriveMath.sol 0 6 0.0%
Totals Coverage Status
Change from base Build 4235299611: 5.0%
Covered Lines: 322
Relevant Lines: 558

💛 - Coveralls

@jalextowle jalextowle force-pushed the jalextowle/hyperdrive/fair-lp-allocation branch 3 times, most recently from 62beda5 to d41133e Compare February 21, 2023 02:08
@jalextowle jalextowle force-pushed the jalextowle/hyperdrive/fair-lp-allocation branch from cb73208 to 93ce29f Compare February 21, 2023 17:32
@jalextowle jalextowle marked this pull request as ready for review February 21, 2023 17:32
@jrhea
Copy link
Contributor

jrhea commented Feb 21, 2023

image

@jalextowle jalextowle force-pushed the jalextowle/hyperdrive/fair-lp-allocation branch from 754fdc4 to 4922ad6 Compare February 21, 2023 18:02
@jalextowle jalextowle merged commit 4fb2c44 into main Feb 21, 2023
@jalextowle jalextowle deleted the jalextowle/hyperdrive/fair-lp-allocation branch February 21, 2023 18:08
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.

5 participants