Skip to main content

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:
  • forkPreTx() / forkPostTx(): Capture oracle price before and after transaction, compare for deviations
  • getCallInputs(): Monitor all price update function calls within transaction
  • registerCallTrigger(): 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
The assertion ensures oracle prices remain within acceptable deviation range throughout transaction, detecting and preventing flash loan attacks that attempt to manipulate prices. For more information about cheatcodes, see the Cheatcodes Documentation.

Code Example

Full examples with tests available in the Phylax Assertion Examples Repository.