Users will experience delayed liquidations because the maintenance margin uses the wrong price when determining liquidation status, leading to the maintenance margin decreasing as the user's collateral value decreases.
The minimum margin value that users need to stay above in order to avoid liquidation is calculated by first taking the size of the user's position(s) and multiplying it by the price of the index. Then, the minimum margin is derived from this value by taking a percentage of it, as seen in getMarginRequirement.
All of this is used to determine a user's liquidatable status. If the user's collateral value is less than the maintenance margin, they are eligible to be liquidated, as seen here:
The issue with this maintenance margin is that it always bases its value off the current price, not the price of the index at which the position was made. Because of this, as the price of the index goes down, so will the user's maintenance margin. Therefore, as the user approaches liquidation, the liquidation threshold will move as well, leading to a delayed liquidation and worsening the health of the protocol.
Example:
Alice provides 200 stables as collateral.
Alice opens a long position with a size of 1000.
The price of the index is $1.00.
ALICE
Collateral: 200e18
PnL: 0
Position: 1000e18
Index: 1e8
MMR: 1e17
MM: ((1000e18 * 1e8 / 1e8) * 1e17 / 1e18) = 100e18
Collateral value: 200e18 + 0 = 200e18
200e18 > 100e18 means no liquidation.
At this point, if Alice's collateral combined with losses brings her below 100e18 in collateral value, she should be liquidated. However, this will not be the case.
Price of the index drops by 0.10
ALICE
Collateral: 200e18
PnL: (1000e18 * 0.89e8 / 1e8) - (1000e18 * 1e8 / 1e8) = -110e18
Position: 1000e18
Index: 0.9e8
MMR: 1e17
MM: ((1000e18 * 0.89e8 / 1e8) * 1e17 / 1e18) = 89e18
Collateral value: 200e18 + (-110e18) = 90e18
90e18 > 89e18 means no liquidation.
As you can see, the user's collateral value went well below what the original maintenance margin was. But because the maintenance margin is based on the current price, it also decreased as the collateral value did, allowing the user to hold a position well beyond what the maintenance margin was supposed to be.
Liquidations will be delayed, worsening the health of the protocol and allowing users to take unintended losses without consequence.
Manual analysis.
Use the lastInteractionPrice when calculating the maintenance margin and initial margin. This will ensure that the thresholds are accurate regardless of price changes and help ensure liquidations happen at the right time.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.