Use Case & Applications
Ensures protocols maintain proper security controls during emergency pause states, allowing existing users to withdraw funds while preventing new deposits. Critical for yield aggregators and vaults (Yearn, Beefy), lending protocols with pause mechanisms, DEXs with emergency circuit breakers, cross-chain bridges with pause functionality, and any protocol with emergency pause capabilities. Improper handling of pause states can lead to fund lockups, unauthorized access, or users being unable to exit during emergencies.Explanation
Monitors protocol balance and pause state to ensure proper emergency behavior using a multi-layered approach:ph.forkPreState()
/ph.forkPostState()
: Capture protocol state before and after transactiongetStateChangesUint()
: Track all state changes during transactionregisterCallTrigger()
: Monitor all function calls to the contract- Verify protocol balance can only decrease when paused (allowing withdrawals)
- Detect unauthorized modifications during pause periods
Note: In the future, this assertion could be optimized with a new trigger type that only fires when a specific storage slot has a specific value (e.g., when the pause flag is true). This would reduce unnecessary assertion checks and improve efficiency.For more information about cheatcodes, see the Cheatcodes Documentation.
Code Example
Note: Full examples with tests available in the Phylax Assertion Examples Repository.