Use Case & Applications
Prevents TWAP (Time-Weighted Average Price) price manipulation by ensuring oracle prices don’t deviate more than X% from pre-state TWAP prices. Critical for AMMs and DEXs (price discovery), lending protocols (collateral valuation), yield aggregators (rebalancing), options protocols (settlement), and cross-chain bridges (asset pricing). Sudden price deviations could indicate manipulation through flash loan attacks or oracle failures, potentially leading to protocol insolvency or fund extraction.Explanation
Monitors TWAP price changes using a two-stage approach to ensure price stability:ph.forkPreTx()/ph.forkPostTx(): Compare post-transaction price against pre-transaction TWAPgetStateChangesUint(): Track all price changes during transaction executionregisterStorageChangeTrigger(): Trigger when price storage slot changes
Code Example
Full examples with tests available in the Phylax Assertion Examples Repository.

