Building Hooks
Hooks add custom logic at protocol events.
Interface
interface IHooks {
// Term events
function beforeTermInitialize(address caller, TermKey memory termKey, bytes calldata hookData) external;
function afterTermInitialize(address caller, TermKey memory termKey, bytes calldata hookData) external;
function beforeTermModifyPosition(address caller, TermKey memory termKey, TermModifyPositionParams memory params, bytes calldata hookData) external;
function afterTermModifyPosition(address caller, TermKey memory termKey, TermModifyPositionParams memory params, bytes calldata hookData) external;
function beforeTermSettle(address caller, TermKey memory termKey, TermSettleParams memory params, bytes calldata hookData) external;
function afterTermSettle(address caller, TermKey memory termKey, TermSettleParams memory params, bytes calldata hookData) external;
// Loan events
function beforeAllocate(address caller, TermKey memory termKey, LoanKey memory loanKey, AllocateParams memory params, bytes calldata hookData) external;
function afterAllocate(address caller, TermKey memory termKey, LoanKey memory loanKey, AllocateParams memory params, bytes calldata hookData) external;
function beforeRepay(address caller, TermKey memory termKey, LoanKey memory loanKey, RepayParams memory params, bytes calldata hookData) external;
function afterRepay(address caller, TermKey memory termKey, LoanKey memory loanKey, RepayParams memory params, bytes calldata hookData) external;
}Use Cases
Access Control - Whitelist addresses, require KYC Protocol Integration - Connect to Aave, Compound, etc. Custom Logic - Rate limiting, timelocks, custom fees
Built-in Hooks
P2P - Manual loan approval AaveV3 - Idle capital optimization Timelock - Delayed execution
Integration Notes
Implement the interface above
All functions are optional
Reverting blocks the operation
Reference deployed contracts for implementation details
Last updated