Skip to main content

Use Case & Applications

Prevents unauthorized fee manipulation in AMMs and DeFi protocols by using a whitelist approach to control fee changes. Critical for AMMs (Velodrome, Aerodrome, Curve), DEX aggregators, lending protocols with origination fees, yield aggregators with performance fees, and cross-chain bridges with transfer fees. Unexpected fee changes can lead to unauthorized manipulation, protocol revenue loss, user losses, or market manipulation through fee bypasses.

Explanation

Uses a whitelist approach to control fee changes:
  • registerStorageChangeTrigger(): Detect changes to fee storage slot
  • ph.load(): Retrieve new fee value after change
  • getStateChangesUint(): Verify all state changes for fee storage slot
  • Maintains hardcoded allowed fee values for stable pools (0.1%, 0.15%) and non-stable pools (0.25%, 0.30%)
When triggered, verifies the new fee matches one of the allowed values, preventing unauthorized modifications while allowing proper protocol updates. For more information about cheatcodes, see the Cheatcodes Documentation.

Code Example

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