Skip to content
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

Cavey/lif #215

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open

Cavey/lif #215

wants to merge 26 commits into from

Conversation

cavemanloverboy
Copy link
Contributor

@cavemanloverboy cavemanloverboy commented Jun 12, 2024

This PR introduces Liquid Insurance Funds to marginfi, allowing users to generate yield from liquidations and improving system robustness.

The following instructions are introduced:

  1. Create a LIF for an existing bank. If there are any existing deposits, new shares are created for the admin.
  2. Create user LIF account
  3. User deposit into LIF
  4. User withdraw request
  5. User withdraw claim

The following instructions are changed:

  1. If there is a LIF present, the group admin can only withdraw the corresponding value of their admin shares.
  2. An admin deposit instruction is introduced to increment admin shares (a direct transfer in would be distributed to all shareholders as if it were liquidation yield)

The following tests are written:
0) Create LIF

  1. User deposit/withdraw
  2. admin deposit/withdraw
  3. admin deposit/withdraw with a liquidation in between (increase share value)
  4. admin deposit/withdraw with a bad debt handled in between (decrease share value)

Notes:

  1. a LIF account has a maximum number of deposits/withdraws. Group admins may want to deposit into all banks. To handle this, admin shares are stored directly in the LIF, and are managed through separate instructions.
  2. The admin withdraw function assumes the input value is token amount if no LIF is present, and is share amount if a LIF is present. This could perhaps be done a little more neatly via an enum that panics when in the wrong variant.

exdx and others added 24 commits May 22, 2024 15:41
This commit introduces a new feature to marginfi, an ability to create
and interact with a liquid insurance pool that is integrated with a
bank's insurance vault. Each liquid insurance pool offers a mint token
which represents shares in the pool. Users can deposit and withdraw from
the pool.

Signed-off-by: Denton X <[email protected]>
@cavemanloverboy cavemanloverboy marked this pull request as ready for review June 12, 2024 10:34
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