dApp Security Guidelines: Lending
Threat
Impact
Threat 1: Vicious Cycle of Mass Liquidation Leading to Collateral Price Drops and Triggering Further Liquidations
Impact
Guideline
function _requireValidAdjustmentInCurrentMode(...) {... // Collateral repayment is not allowed in recoveryMode if (_isRecoveryMode) { require(_collWithdrawal == 0, "BorrowerOps: Collateral withdrawal not permitted in Recovery Mode"); if (_isDebtIncrease) { _requireICRisAboveCCR(newICR); _requireNewICRisAboveOldICR(newICR, oldICR); } ... } // Closing a loan position is not allowed in recoveryMode function closeDen(...) { ... require(!isRecoveryMode, "BorrowerOps: Operation not permitted during Recovery Mode"); }
function liquidateDens(..) { // In normal mode if (ICR <= _LSP_CR_LIMIT) { singleLiquidation = _liquidateWithoutSP(denManager, account); _applyLiquidationValuesToTotals(totals, singleLiquidation); } else if (ICR < applicableMCR) { singleLiquidation = _liquidateNormalMode( denManager, account, debtInStabPool, denManagerValues.sunsetting ); debtInStabPool -= singleLiquidation.debtToOffset; _applyLiquidationValuesToTotals(totals, singleLiquidation); } else break; // break if the loop reaches a Den with ICR >= MCR // In recoveryMode // Check recoveryMode (CCR > TCR) && check if it's a liquidation target (ICR < TCR) { uint256 TCR = BeraborrowMath._computeCR(entireSystemColl, entireSystemDebt); if (TCR >= borrowerOperations.BERABORROW_CORE().CCR() || ICR >= TCR) break; } // If recoveryMode is on and the Den's ICR is less than TCR, proceed with liquidation singleLiquidation = _tryLiquidateWithCap( denManager, account, debtInStabPool, _getApplicableMCR(account, denManagerValues), denManagerValues.price );
Best practice
Threat 2: ERC-4626 Inflation34 Attack
Impact
Guideline
Best Practice
Threat 3: Incompleteness of Recovery Mode Status Judgment and Transition Mechanism
Impact
Guideline
Best Practice
Threat 4: System Integrity Violation due to Owner Privilege Abuse
Impact
Guideline
Best Practice
Last updated