Liquidation Protection System
Loopify Finance implements health factor monitoring and emergency deleveraging to protect leveraged positions from liquidation.
Health Factor Calculation
The health factor determines position safety:
// Health Factor = (Collateral Value × Liquidation Threshold) / Debt Value
function getHealthFactor(address user) public view returns (uint256) {
if (pos.debtValue == 0) return type(uint256).max;
return (pos.collateralValue * LIQUIDATION_THRESHOLD * 1e18) / (pos.debtValue * 10000);
}
Health Factor Zones:
- Safe: > 2.0 (Healthy position)
- Caution: 1.8 - 2.0 (Monitor closely)
- Warning: 1.3 - 1.8 (Consider adding collateral)
- Critical: 1.01 - 1.3 (High liquidation risk)
- Emergency: < 1.01 (Automatic deleveraging triggered)
Portfolio Monitoring System
The portfolio manager continuously monitors all user positions using real-time data feeds:
Monitoring Infrastructure:
- 24/7 Health Factor Tracking: Continuous calculation across all positions
- Price Feed Integration: Multiple oracle sources for accurate valuations
- Gas-Optimized Checks: Efficient monitoring without excessive network costs
- Multi-Position Management: Simultaneous tracking of leveraged strategies
- Live Notifications: Real-time alerts via Notifi Network integration for position changes
Competitive Advantage: Unlike competitors who charge 0.25%+ fees for safety measures and collateral adjustments, Loopify provides zero-cost protection mechanisms. Users benefit from automated position management without additional fees beyond standard transaction costs.
Emergency Protection
When health factor drops below 1.01, the system automatically:
- Triggers Flash Loan: Borrows assets to repay part of user's debt
- Deleverages Position: Reduces debt by 30% to improve health factor
- Withdraws Collateral: Uses collateral to repay flash loan
- Updates Position: Records new collateral/debt values
User Controls
Manual Protection:
function protectPosition() external {
// Users can manually trigger protection when health factor < 1.1
}
function emergencyExit() external {
// Close entire position and withdraw all funds
}
System Limitations
- Response Time: 1-2 block confirmation (12-15 seconds)
- Success Rate: Target 85-90% (realistic protection rates)
- Gas Costs: 150k-300k gas per protection action
- No Predictions: System reacts to current conditions only
- Development Phase: Currently in testnet
The system provides essential liquidation protection without AI/ML predictions or guaranteed outcomes.