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

Liquid Insurance Fund #238

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

Liquid Insurance Fund #238

wants to merge 40 commits into from

Conversation

cavemanloverboy
Copy link
Contributor

@cavemanloverboy cavemanloverboy commented Aug 19, 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

  2. User withdraw request

  3. User withdraw claim
    The following instructions are changed:

  4. If there is a LIF present, the group admin can only withdraw the corresponding value of their admin shares.

  5. 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 with several cases (USDC, SOL, PYUSD, some t22 token with fee):

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

Notes:

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.
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 30 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]>
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