Overview
Auto-deleveraging is a risk management mechanism that allows Kamino Lending market owners to mark risky obligations for automatic position reduction. This protects the protocol during periods of high volatility by giving users a grace period to reduce their leverage before facing liquidation.How Auto-Deleveraging Works
Mark Obligation for Deleveraging
Handler:handler_mark_obligation_for_deleveraging.rs:8
lending_operations.rs:1892):
lending_market_owner can mark obligations for deleveraging (handler_mark_obligation_for_deleveraging.rs:26).
When Auto-Deleveraging Triggers
Auto-deleveraging is typically used during:- High Volatility: Sudden market movements increase liquidation risk
- Price Oracle Issues: Unreliable price feeds create uncertainty
- Large Position Risk: Oversized positions that threaten protocol solvency
- Pre-Liquidation Warning: Give users time to act before forced liquidation
Target LTV Configuration
Setting Target LTV
Validation (lending_operations.rs:1915):
70: User must reduce LTV to 70% or below50: User must reduce LTV to 50% or below (more aggressive)0: User must completely close the position (full deleverage)
Unmarking for Deleveraging
Special Value (lending_operations.rs:1900):
NO_DELEVERAGING_MARKER (typically 255) is used to unmark an obligation.
Deleveraging Margin Call Period
Configuration
Lending Market Field (state/lending_market.rs:127):
lending_operations.rs:1930):
3600: 1 hour grace period14400: 4 hour grace period86400: 24 hour grace period
Grace Period Mechanism
When marked for deleveraging:- Timestamp Recorded (
state/obligation.rs:495):
-
User Has Grace Period:
individual_autodeleverage_margin_call_period_secsto reduce position - After Grace Period: Liquidators can liquidate with special autodeleverage rules
Checking Deleveraging Status
Is Marked Check (state/obligation.rs:491):
lending_operations.rs:211):
state/obligation.rs:508):
Obligation State Changes
Obligation Fields
Tracking Fields (state/obligation.rs:75):
Unmarking Process
Unmark Implementation (state/obligation.rs:503):
- User successfully deleverages to target LTV
- Market conditions improve
- Risk assessment changes
Threshold Decrease During Deleveraging
During the grace period, liquidation thresholds may be progressively decreased to incentivize deleveraging: Liquidation Check (state/liquidation_operations.rs:476):
- Time elapsed since marking
- Target LTV vs current LTV
- Market configuration
Monitoring and Prevention
User-Side Monitoring
Prevention Strategies
1. Maintain Healthy LTV:Market Owner Workflow
Best Practices
For Users
- Monitor positions: Regularly check LTV and deleveraging status
- Maintain buffer: Keep LTV well below liquidation threshold
- Set alerts: Get notified immediately when marked for deleveraging
- Act quickly: Use the grace period to reduce risk
- Understand target: Know what LTV you need to achieve
For Market Owners
- Configure grace period: Set reasonable
individual_autodeleverage_margin_call_period_secs - Conservative targets: Set target LTVs that leave safety margin
- Clear communication: Notify users when marking positions
- Monitor compliance: Track if users are deleveraging
- Unmark when safe: Remove marking once risk is mitigated
Errors
ObligationCurrentlyMarkedForDeleveraging:autodeleverage_target_ltv_pct> 100individual_autodeleverage_margin_call_period_secsnot set
Summary
Auto-deleveraging provides a controlled mechanism for risk management:- Proactive: Prevents liquidations during volatile periods
- User-friendly: Gives grace period to adjust positions
- Flexible: Configurable target LTV and grace periods
- Transparent: Clear on-chain state tracking