Hooks
Hooks are arbitrary third-party functions that get automatically executed by the Sablier Protocol in response to
cancel and withdraw events. They are similar to callback functions in web2.
Hooks have to be allowlisted before they can be run. Currently, only the Protocol Admin has permission to do this. In the future, we may decentralize this process through governance.
Hooks are a powerful feature that enable Sablier streams to interact with other DeFi protocols. Let's consider an example:
You own a Sablier stream that expires in two years. You are interested into taking a loan against it with the intention to pay it all back after it expires. Hooks are what enable you to do that. With the help of Hooks, we can create an ecosystem of varied use cases for Sablier streams. This can range from lending, staking, credit, and more.
It is worth noting that once a hook has been allowlisted, it can never be removed. This is to ensure stronger immutability and decentralization guarantees. Once a recipient contract is allowlisted, integrators do NOT have to trust us to keep their contract on the allowlist.
Checklist
The requirements a hook contract must meet:
- The contract is not upgradeable.
- The contract was audited by a third-party security researcher.
- The contract implements
supportsInterfaceand returnstruefor0xf8ee98d3, i.e.,type(ISablierLockupRecipient).interfaceId. - If it implements
onSablierLockupCancel:- It returns
ISablierLockupRecipient.onSablierLockupCancel.selector. - It reverts if
msg.senderis not the Lockup contract. - It uses input parameters correctly:
streamId,sender,senderAmount,recipientAmount. - Be aware that if the call reverts, the entire
cancelexecution would revert too.
- It returns
- If it implements
onSablierLockupWithdraw:- It returns
ISablierLockupRecipient.onSablierLockupWithdraw.selector. - It reverts if
msg.senderis not Lockup contract. - It uses input parameters correctly:
streamId,caller,to,amount. - Be aware that if the call reverts, the entire
withdrawexecution would revert too.
- It returns
Visual representation
If the recipient contract is not on the Sablier allowlist, the hooks will not be executed.
Cancel hook
Withdraw hook
Next steps
If you are interested into using Sablier hooks into your protocol, please check the Hook guide. If you are looking to get on the allowlist, reach out to us on Discord.