The Bug

A smart contract bug discovered last week in protocol-v1 lead to a ~10M shortfall in the protocol’s collateral vault. This bug had existed undetected in the program since inception, after the protocol getting an audit by Zellic and a $500,000 bug bounty. The bug was amplified and revealed by the recent market volatility, specifically around LUNA-PERP.

The bug was comprised of two issues. The first issue is that the protocol allowed users to withdraw positive realised pnl without an equal amount of negative pnl being realised e.g. one user could close a profitable position and withdraw their profit without needing a second user to have closed their unprofitable position. While the AMM guarantees that every profitable trade is offset by an unprofitable trade (making the system zero-sum), it does not guarantee the order with which they close their positions. As the price of LUNA dropped precipitously, a large number of profitable shorters exited their position and withdraw their positive pnl before additional traders realised negative pnl on their unprofitable positions.

If this were the only issue, the positive pnl would eventually be paid for by unprofitable traders when they closed their positions. Unfortunately there was a second issue that allowed users to withdraw from the collateral collected in market Insurance Fund. The Insurance Fund is budgeted to pay for funding payments as well as market operations. Unfairly depleting the Insurance Fund breaks the incentive for users to continue to arbitrage the AMM. If users were to have realised the fee pool had been depleted, the most likely outcome was that the remaining collateral balance would have gone to zero as the fastest users raced to withdraw the remainder of the collateral vault. The exchange was paused so that the remaining balance in the collateral vault could be distributed across all users.

The protocol’s remaining vault balance is less than both the accounted user collateral and the budgeted Insurance Fund (vault balance is currently at ~5M USDC [1][2] while the accounted user collateral is ~16.5M USDC and the budgeted insurance fund is ~8.3M USDC). As part of the protocol settlement, all user’s impacted by the smart contract bug are set to receive a portion of the remaining balance to cover the shortfall.

The on-chain settlement for the remainder of funds is set as defined below.

Socialized Loss Mechanism

The following socialized loss mechanism is designed to calculate a user’s total collateral claim of the remaining Insurance Fund balance. To begin, each users’ account must be settled. User accounts will be settled by summing their following values:

Once all user’s accounts have been settled, users are given a relative percentage claim on the total remaining value of the Insurance Fund balance. Their percent claim is the value of their settled user account divided by the sum of all settled user accounts.

Before the claim dashboard is live, any addresses can optionally opt out to increase pro-rata share for all remaining addresses. The team and investors will opt of the settlement process.