The Insurance Fund

Summary

While every Custody account carries with it a token account that holds funds representing the collected fees, current Position collateral, and LP funds given for loans to traders, they also have a separate account called the insurance fund. This fund is used in certain circumstances to pay out excess profits beyond pre-determined thresholds to traders in both liquidation and closure events and is funded during profitable liquidations (for the protocol, not the trader) and when the traders pay borrowing fees.

Notably, a key difference between the two token accounts is that while most tokens in the primary account are accessible for swapping by LP holders, the insurance fund is untouchable and exists only to provide a backbone of liquidity support.

Funding Conditions

Borrowing fees are applied any time a Position is updated, which includes increases, decreases, partial or full closures, or liquidations. During the increases, decreases, partial and full closures exclusively (not liquidations), a portion of the borrowing fee, given by borrow_fee_liquidation_fund_contribution_dps (a constant on Pool Fees), is granted to the insurance fund.

When liquidation occurs, if the effective_collateral is greater than 0, then the insurance fund earns a fee on the liquidation equivalent to insurance_fund_liquidation_fee_bps (a separate constant from borrow_fee_liquidation_fund_contribution_dps) on the effective_collateral of the Position.

Payout Conditions

Insurance pays out during some Liquidation events and some Position closure events.

There are a few Liquidation cases that should each be considered separately, and you can read more about them in the Liquidator Engine Concept section.

In the (very rare) scenario where losses cause collateral to fall below 0, the insurance fund pays the liquidator fee. This only could really happen in a black swan spike where the volatility swings fast enough that the crank cannot run before the Position is beyond 0, or the crank has infrastructure issues.

When a Position is closed or even partially closed (including in a max_size violating liquidation event), and it is profitable for the trader, in all cases the Position pays up it's most recent borrowing fees, some portion of which fuel the insurance fund.

Then, if the amount of tokens being removed from the Position (in total, collateral + loan + profit) is less than locked_amount, the insurance fund isn't touched further here.

Position will decrease locked_amount by the amount being removed and make requisite changes to owned, locked, and base on Custody, accordingly, to assure that the set-aside tokens aren't "reused."

At start, loan + collateral for a Position is always at least locked_amount.

However, in the event that the profits cause the locked_amount to be breached, the insurance fund will be used until it is entirely empty. Once it's empty, then tokens will be taken out of the base pool of tokens for the Custody, leading to a loss for the LP holders in terms of their LP token value.

If you want to read more about this waterfall of losses, from locked tokens, to insurance, to base tokens, you can do so here.

Last updated