Hooks
Understand validation and execution hooks in Uniswap smart wallet, including call sites and integration cautions.
Hooks are powerful add-ons to keys which can perform arbitrary validation on signatures, and/or actions during execution time.
Hook Types
There are two subtypes of hooks: ValidationHook and ExecutionHook. A hook can implement either, or both interfaces.
Validation Hook Call Sites
Validation hooks have three call sites:
afterVerifySignatureafterIsValidSignatureafterValidateUserOp
Execution Hook Call Sites
Execution hooks have two call sites:
beforeExecuteafterExecute
Hooks must revert to indicate that the given action should revert.
Example Use Cases
Example functionality which can be implemented in hooks includes:
- Spending limits
- Restricting keys from calling certain contracts and methods
- Turning a key into a multisig, effectively requiring additional signatures for verification
- Automated actions before or after swaps
Security Notes
There are a few example hooks referenced in the repo. Be aware that these example hooks are not production code and may contain bugs. We do not recommend you to deploy these hooks or use them as reference implementations for productionized code. They are proof of concepts.