Skip to content

Building Hooks

Hooks add custom logic at protocol events.

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;
}

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)


  • Implement the interface above
  • All functions are optional
  • Reverting blocks the operation
  • Reference deployed contracts for implementation details