Use Case & Applications
Monitors oracle price updates to detect and prevent price manipulation within a single transaction, protecting against flash loan attacks and malicious arbitrage. Critical for AMM-based DEXs using oracle prices, lending protocols relying on oracles for collateral valuation, synthetic asset platforms, derivatives protocols using oracles for settlement, and yield farming platforms calculating rewards based on asset prices. Intra-transaction price manipulations can lead to flash loan attacks, theft of funds through manipulated liquidations, or protocol insolvency due to incorrect asset valuations.Explanation
Implements approach to verify oracle price updates using both pre/post state comparison and intra-transaction inspection:forkPreState()
/forkPostState()
: Capture oracle price before and after transaction, compare for deviationsgetCallInputs()
: Monitor all price update function calls within transactionregisterCallTrigger()
: Trigger when oracle price update is detected- Verify each update’s price parameter against initial price
- Enforce no price update can deviate more than maximum allowed percentage
Code Example
Note: Full examples with tests available in the Phylax Assertion Examples Repository.