When to Use This Pattern
Ensures the health factor of updated positions in lending protocols remains above a threshold, preventing unauthorized liquidations and protocol insolvency. Critical for lending protocols (Aave, Compound, Morpho), margin trading platforms, and any DeFi protocol using health factors for position management. Focuses on core lending operations (supply, borrow, withdraw, repay) while allowing other functions like liquidations to operate as designed.What This Pattern Checks
Monitors health factors of positions during specific lending operations using:getCallInputs(): Track all function calls to specified protocol functionsregisterFnCallTrigger(): Trigger on lending operations (supply, borrow, withdraw, repay)_postTx(): Verify health factor after each operation (used by default if no pre-state specified)
Assertion Pattern
Full examples and mock protocol code are available in credible-std.
Extending Assertions: When new functions are added to the protocol that should maintain healthy positions, you can create a new assertion file (e.g.,
LendingHealthFactorExtendedAssertion.sol) that follows the same pattern. This allows you to:- Keep the original assertions active for existing functions
- Add new assertions for new functions without modifying existing code
- Maintain clear separation of concerns between different protocol features

