Submitted by pkqs90
Liquidation cannot be executed if there is bad debt (vault position is negative) after liquidation.
See the liquidation flowchart here.
The liquidator would call a Market contract, which triggers the liquidation logic in PredyPool. The tokens would then be swapped accordingly using the SettlementCallbackLib.
The issue is during the end of liquidation, if the position is entirely wiped out (e.g. hasPosition == false in the following code), the code checks whether there is still margin left in the vault.
For case 2, the code tries to transfer token from msg.sender to PredyPool. However, the msg.sender is the Market protocol, and not the liquidator. This means liquidating a vault with negative margin is impossible, and this bad debt will never be cleared. Whats worse, the lending fees would still accumulate for this vault, and the bad debt keeps getting larger.
Transfer quoteTokens from the liquidator instead of the Market protocol.
Token-Transfer
0xsomeone (judge) commented:
pkqs90 (warden) commented:
syuhei176 (Predy) confirmed and commented:
0xsomeone (judge) commented:
Eeyore (warden) commented:
0xsomeone (judge) commented:
Note: For full discussion, see here.
