// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {IJBProjects} from "@bananapus/core-v6/src/interfaces/IJBProjects.sol"; import {IJBRulesetDataHook} from "@bananapus/core-v6/src/interfaces/IJBRulesetDataHook.sol"; import {DefaultHookSegment} from "../structs/DefaultHookSegment.sol"; /// @notice Stores the buyback hook each project should use and resolves the default hook for newly created projects. interface IJBBuybackHookRegistry is IJBRulesetDataHook { /// @notice Emitted when a hook is allowed for use by projects. /// @param hook The hook that was allowed. /// @param caller The address that allowed the hook. event JBBuybackHookRegistry_AllowHook(IJBRulesetDataHook hook, address caller); /// @notice Emitted when a hook is disallowed from use by projects. /// @param hook The hook that was disallowed. /// @param caller The address that disallowed the hook. event JBBuybackHookRegistry_DisallowHook(IJBRulesetDataHook hook, address caller); /// @notice Emitted when a project's hook is locked, preventing future changes. /// @param projectId The ID of the project whose hook was locked. /// @param caller The address that locked the hook. event JBBuybackHookRegistry_LockHook(uint256 projectId, address caller); /// @notice Emitted when the default hook is set. /// @param hook The hook that was set as the default. /// @param caller The address that set the default hook. event JBBuybackHookRegistry_SetDefaultHook(IJBRulesetDataHook hook, address caller); /// @notice Emitted when a hook is set for a specific project. /// @param projectId The ID of the project the hook was set for. /// @param hook The hook that was set. /// @param caller The address that set the hook. event JBBuybackHookRegistry_SetHook(uint256 indexed projectId, IJBRulesetDataHook hook, address caller); /// @notice The JBProjects ERC-721 contract used to verify project ownership. /// @return The projects contract. function PROJECTS() external view returns (IJBProjects); /// @notice The default buyback hook used when a project hasn't registered a specific one. /// @return The default data hook. function defaultHook() external view returns (IJBRulesetDataHook); /// @notice The segment of the default-hook history at the given index, in insertion (chronological) order. /// @dev Each segment records a previous default hook and the project-ID range that was created while it was active. /// @param index The history index, in insertion order. Reverts on out-of-bounds. /// @return segment The segment at that index. function defaultHookHistoryAt(uint256 index) external view returns (DefaultHookSegment memory segment); /// @notice The number of segments in the default-hook history. /// @return length The number of historical default-hook segments. function defaultHookHistoryLength() external view returns (uint256 length); /// @notice The project ID threshold below which the default hook does not apply. /// @dev Set to `PROJECTS.count()` each time the default hook changes. Only projects with IDs above this threshold /// get the default hook, preventing the registry owner from unilaterally granting mint permission to existing /// projects via a new default. /// @return The project ID threshold. function defaultHookProjectIdThreshold() external view returns (uint256); /// @notice Whether the hook for the given project is locked and cannot be changed. /// @param projectId The ID of the project. /// @return Whether the hook is locked. function hasLockedHook(uint256 projectId) external view returns (bool); /// @notice The hook for the given project, or the default hook if none is set. /// @param projectId The ID of the project. /// @return The data hook for the project. function hookOf(uint256 projectId) external view returns (IJBRulesetDataHook); /// @notice Whether the given hook is allowed to be set for projects. /// @param hook The hook to check. /// @return Whether the hook is allowed. function isHookAllowed(IJBRulesetDataHook hook) external view returns (bool); /// @notice Allow a buyback hook implementation to be used by projects. /// @param hook The hook to allow. function allowHook(IJBRulesetDataHook hook) external; /// @notice Disallow a buyback hook implementation from use by projects. /// @param hook The hook to disallow. function disallowHook(IJBRulesetDataHook hook) external; /// @notice Initialize a Uniswap V4 pool and configure it as the buyback pool for a project, forwarding to the /// resolved buyback hook implementation. /// @dev Resolves the hook for the project (or the default), then calls initializePoolFor on it. /// @param projectId The ID of the project to set the pool for. /// @param fee The Uniswap V4 pool fee tier. /// @param tickSpacing The Uniswap V4 pool tick spacing. /// @param twapWindow The period of time over which the TWAP is computed. /// @param terminalToken The address of the terminal token that payments to the project are made in. function initializePoolFor( uint256 projectId, uint24 fee, int24 tickSpacing, uint256 twapWindow, address terminalToken, uint160 sqrtPriceX96 ) external; /// @notice Permanently lock the buyback hook for a project, preventing future changes. /// @param projectId The ID of the project to lock the hook for. /// @param expectedHook The hook the caller expects to lock. Prevents race conditions where the hook changes /// between transaction submission and execution. function lockHookFor(uint256 projectId, IJBRulesetDataHook expectedHook) external; /// @notice Set the default buyback hook used for projects that haven't configured a project-specific one. /// @param hook The hook to set as the default. function setDefaultHook(IJBRulesetDataHook hook) external; /// @notice Set the hook for a specific project. /// @param projectId The ID of the project to set the hook for. /// @param hook The hook to set. function setHookFor(uint256 projectId, IJBRulesetDataHook hook) external; /// @notice Set the Uniswap V4 pool for a project, forwarding to the resolved buyback hook implementation. /// @dev Resolves the hook for the project (or the default), then calls setPoolFor on it. /// @param projectId The ID of the project to set the pool for. /// @param fee The Uniswap V4 pool fee tier. /// @param tickSpacing The Uniswap V4 pool tick spacing. /// @param twapWindow The period of time over which the TWAP is computed. /// @param terminalToken The address of the terminal token that payments to the project are made in. function setPoolFor( uint256 projectId, uint24 fee, int24 tickSpacing, uint256 twapWindow, address terminalToken ) external; }