Use Case & Applications
Ensures harvest operations in yield farming protocols maintain integrity by preventing balance decreases and price per share manipulation. Critical for yield farming protocols (Beefy, Yearn, Harvest), liquidity mining programs, staking protocols with reward distribution, and auto-compounding vaults. Incorrect harvest implementations could lead to loss of user funds, price per share manipulation enabling flash loan attacks, or protocol insolvency through improper reward distribution.Explanation
Implements multi-layered approach to verify harvest operations:forkPreState()
/forkPostState()
: Capture vault balance and price per share before/after harvestgetStateChangesUint()
: Monitor all balance changes during transaction executionregisterCallTrigger()
: Trigger on harvest function calls- Ensures balance hasn’t decreased (can stay same if harvested recently)
- Confirms price per share hasn’t decreased
- Prevents manipulation through multiple harvest calls
Code Example
Note: Full examples with tests available in the Phylax Assertion Examples Repository.