Skip to content
Verified contractExactMIT

HookEthModuleRegistry

Address0x1aa4b539b394f3da2f821f11c296f7311d8d0a8d
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.26

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.26+commit.8a97fa7a
Language
solidity
Optimization
Yes, 50 runs
EVM version
cancun
Via IR
yes
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,469,220
Creation transaction
0x290fbacce8…a070018d2c

src/core/HookEthModuleRegistry.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;

import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {IHookPlugin} from "../interfaces/IHookPlugin.sol";
import {IHookEthModuleRegistry} from "../interfaces/IHookEthVaults.sol";

/// @title HookEthModuleRegistry
/// @notice Curated & halt-safe registry of community-built Workshop hook plugins (API v3).
contract HookEthModuleRegistry is Ownable, IHookEthModuleRegistry {
    uint256 public nextModuleId = 1;
    mapping(uint256 => ModuleEntry) private _modules;
    mapping(address => uint256) public pluginToId;

    event ModuleRegistered(
        uint256 indexed moduleId,
        address indexed plugin,
        address indexed builder,
        bytes32 codehash,
        uint32 capabilities,
        uint32 gasLimit,
        uint16 maxSurchargeBps
    );
    event ModuleHalted(uint256 indexed moduleId, address indexed plugin, string reason);

    error InvalidPlugin();
    error UnsupportedApiVersion();
    error AlreadyRegistered();
    error SurchargeExceedsCap();
    error ModuleNotFound();

    constructor(address initialOwner) Ownable(initialOwner) {}

    /// @notice Registers a reviewed, immutable plugin contract into the Workshop registry.
    function registerModule(address plugin) external onlyOwner returns (uint256 moduleId) {
        if (plugin == address(0) || plugin.code.length == 0) revert InvalidPlugin();
        if (pluginToId[plugin] != 0) revert AlreadyRegistered();

        IHookPlugin p = IHookPlugin(plugin);
        if (p.pluginApiVersion() != 3) revert UnsupportedApiVersion();

        uint16 maxSurcharge = p.maxSurchargeBps();
        if (maxSurcharge > 900) revert SurchargeExceedsCap();

        moduleId = nextModuleId++;
        bytes32 ch = plugin.codehash;
        address builder = p.builderPayout();
        uint32 caps = p.capabilities();
        uint32 gasLimit = p.declaredGasLimit();

        _modules[moduleId] = ModuleEntry({
            plugin: plugin,
            builder: builder,
            codehash: ch,
            capabilities: caps,
            gasLimit: gasLimit,
            maxSurchargeBps: maxSurcharge,
            active: true,
            halted: false
        });
        pluginToId[plugin] = moduleId;

        emit ModuleRegistered(moduleId, plugin, builder, ch, caps, gasLimit, maxSurcharge);
    }

    /// @notice Emergency halt for a faulty plugin. Halted plugins are skipped on swaps; user claims stay open.
    function haltModule(uint256 moduleId, string calldata reason) external onlyOwner {
        ModuleEntry storage entry = _modules[moduleId];
        if (entry.plugin == address(0)) revert ModuleNotFound();
        entry.active = false;
        entry.halted = true;
        emit ModuleHalted(moduleId, entry.plugin, reason);
    }

    function moduleEntry(uint256 moduleId) external view override returns (ModuleEntry memory) {
        return _modules[moduleId];
    }

    function isModuleActive(uint256 moduleId) external view override returns (bool) {
        ModuleEntry storage e = _modules[moduleId];
        return e.active && !e.halted && e.plugin != address(0);
    }
}

@openzeppelin/contracts/access/Ownable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is set to the address provided by the deployer. This can
 * later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

@openzeppelin/contracts/utils/Context.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

src/interfaces/IHookEthTypes.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;

/// @title HookEthTypes
/// @notice Shared module bitmasks, fee constants, and launch configuration structs for HookETH (hooketh.fun).
library HookEthTypes {
    // -------------------------------------------------------------------------
    // Protocol Fee & Cap Constants (Basis Points, 10_000 = 100%)
    // -------------------------------------------------------------------------
    uint16 internal constant BPS_DENOMINATOR         = 10_000;
    uint16 internal constant BASE_FEE_BPS            = 100;   // 1.00% base swap fee (quote-only)
    uint16 internal constant MAX_TOTAL_FEE_BPS       = 1_000; // 10.00% hard ceiling (base + hook tax + surcharges)
    uint16 internal constant MAX_HOOK_TAX_BPS        = 900;   // 9.00% max creator-configured hook tax

    // Base 1% fee split: 60% Creator / 30% Protocol Buybacks / 10% Stakers
    uint16 internal constant BASE_CREATOR_SHARE_BPS  = 6_000; // 60%
    uint16 internal constant BASE_PROTOCOL_SHARE_BPS = 3_000; // 30%
    uint16 internal constant BASE_STAKERS_SHARE_BPS  = 1_000; // 10%

    // Max Tx bounds: 0.10% (10 bps) to 2.50% (250 bps) of total supply
    uint16 internal constant MIN_MAX_TX_BPS          = 10;
    uint16 internal constant MAX_MAX_TX_BPS          = 250;

    // Floor Loan duration bounds: 7 to 90 days
    uint32 internal constant MIN_LOAN_DURATION       = 7 days;
    uint32 internal constant MAX_LOAN_DURATION       = 90 days;

    // Evolve / DAO timelock notice for fee/split increases
    uint32 internal constant EVOLVE_NOTICE_DELAY     = 1 hours;
    uint32 internal constant DAO_VOTE_DURATION       = 6 hours;

    // -------------------------------------------------------------------------
    // Direct Uniswap v4 Hook Module Bitmasks (21 Native Modules)
    // -------------------------------------------------------------------------
    // Protection (5)
    uint32 internal constant MOD_ANTI_MEV         = 1 << 0;  // Blocks same-block opposing swaps / cooldown
    uint32 internal constant MOD_ANTI_SNIPE       = 1 << 1;  // Decaying opening buy tax into hook pot
    uint32 internal constant MOD_MAX_TX           = 1 << 2;  // Fixed max swap cap (0.1% - 2.5% supply)
    uint32 internal constant MOD_GATED_BUY        = 1 << 3;  // Launch window allowlist / token / NFT buy gate
    uint32 internal constant MOD_AI_AGENT_ONLY    = 1 << 4;  // Launch window Agent Pass / ERC-8004 buy gate

    // Trading Fees (3)
    uint32 internal constant MOD_FIXED_FEES       = 1 << 5;  // Flat extra quote-only hook tax
    uint32 internal constant MOD_DYNAMIC_FEES     = 1 << 6;  // Depth-relative fee scaling (no oracle)
    uint32 internal constant MOD_VELOCITY_FEE     = 1 << 7;  // Extra fee on dumps < 4h TWAP; cashback on dips

    // Burn & Floor (4)
    uint32 internal constant MOD_BACKED_FLOOR     = 1 << 8;  // Accrues quote backing; zero-slippage redeemFloor
    uint32 internal constant MOD_FLOOR_LOAN       = 1 << 9;  // 7-90d zero-liquidation loans against floor
    uint32 internal constant MOD_AUTO_BURN        = 1 << 10; // Buys & permanently burns tokens from v4 pool
    uint32 internal constant MOD_DEEPEN_LPS       = 1 << 11; // Mints extra locked liquidity into v4 pool

    // Rewards (1)
    uint32 internal constant MOD_HOLDER_AIRDROP   = 1 << 12; // Accrues quote rewards for holder claims

    // Creator (3)
    uint32 internal constant MOD_HOOK_TO_CREATOR  = 1 << 13; // Routes % of hook pot to creator escrow
    uint32 internal constant MOD_CREATOR_TO_HOOK  = 1 << 14; // Routes creator 60% base fee into hook pot
    uint32 internal constant MOD_BUYBACK_VESTING  = 1 << 15; // Vests creator proceeds by timer or FDV target

    // Special (2)
    uint32 internal constant MOD_NFT_STRATEGY     = 1 << 16; // Sweeps NFT floor into vault (raffle or 1.2x resale)
    uint32 internal constant MOD_BOSS_RAID        = 1 << 17; // Qualifying buys deal boss damage; kill splits loot

    // Evolving & AI Hooks (3)
    uint32 internal constant MOD_EVOLVE           = 1 << 18; // Creator can adjust fee/splits (cuts now, raises 1h)
    uint32 internal constant MOD_DAO              = 1 << 19; // Holder-voted Evolve (1 token = 1 vote, 6h window)
    uint32 internal constant MOD_MEMORY           = 1 << 20; // Agent-written on-chain wallet rules & ally rebates

    // -------------------------------------------------------------------------
    // Pot Split Allocation (must sum to 10_000 when hook pot receives funds)
    // -------------------------------------------------------------------------
    struct PotSplit {
        uint16 autoBurnBps;
        uint16 backedFloorBps;
        uint16 deepenLpBps;
        uint16 holderAirdropBps;
        uint16 hookToCreatorBps;
        uint16 nftStrategyBps;
        uint16 bossRaidBps;
        uint16 pluginBps;
    }

    // -------------------------------------------------------------------------
    // Per-Module Parameters
    // -------------------------------------------------------------------------
    struct ProtectionParams {
        uint16 antiSnipeStartBps;     // e.g. 800 (8%) decaying to 0
        uint32 antiSnipeDuration;     // seconds after launch
        uint16 maxTxBps;              // 10..250 bps of totalSupply
        uint32 gateDuration;          // seconds for Gated Buy / AI Agent Only
        address gateToken;            // optional ERC20 or ERC721 required to buy during gate
        uint256 gateMinBalance;       // minimum balance of gateToken (default 1)
        address[] allowlist;          // initial allowlisted buyers for Gated Buy
    }

    struct FeeParams {
        uint16 hookTaxBps;            // 0..900 bps flat extra quote fee
        uint16 dynamicMaxAddBps;      // max extra fee for large depth-consuming swaps
        uint16 velocityDumpMalusBps;  // extra fee on sells below 4h TWAP (max 300 bps)
        uint16 velocityDipRebateBps;  // cashback bps from pot on dip buys
    }

    struct CreatorAndSpecialParams {
        address feeRecipient;         // wallet receiving creator fees (defaults to msg.sender)
        uint32 vestingDuration;       // seconds for Buyback Vesting (0 if FDV-only)
        uint256 vestingFdvTargetWei;  // optional FDV threshold in quote wei
        uint16 loanOriginationFeeBps; // one-off fee sent to floor (e.g. 200 = 2%)
        address nftCollection;        // target Mainnet ERC721 collection for NFT Strategy
        bool nftResaleMode;           // false = raffle to holders, true = 1.2x resale buyback & burn
        uint256 bossHpQuoteWei;       // cumulative buy volume in quote wei to kill Boss
        uint16 bossLastHitBonusBps;   // bonus share of loot for killing blow (e.g. 2000 = 20%)
        uint32 airdropInterval;       // seconds per Holder Airdrop epoch
        address agentOperator;        // AI agent address authorized for Memory / Evolve
    }

    struct PluginAttachment {
        uint256 moduleId;             // Registered plugin ID in HookEthModuleRegistry
        uint16 shareBps;              // Share of pluginBps allocation
        bytes initData;               // Up to 1,024 bytes passed to plugin.onLaunch()
    }

    /// @notice Full input payload for launching a direct Uniswap v4 pool on HookETH.
    struct LaunchParams {
        string name;
        string symbol;
        string metadataURI;           // IPFS / Arweave / on-chain JSON with logo, banner, socials
        uint256 totalSupply;          // e.g. 1_000_000_000e18
        address quoteCurrency;        // address(0) for Native ETH, or WETH/USDC/USDT
        int24 initialTick;            // Starting tick for single-sided concentrated LP
        int24 tickUpper;              // Upper bound tick for single-sided LP
        int24 tickSpacing;            // e.g. 60 or 200
        uint32 moduleMask;            // Bitmask of enabled MOD_* modules
        PotSplit potSplit;            // Must sum to 10_000 if any pot-spending module is active
        ProtectionParams protection;
        FeeParams fees;
        CreatorAndSpecialParams special;
        PluginAttachment[] plugins;   // Optional Workshop community plugins
        uint16 devBuyBps;             // Optional atomic first-block dev buy (0..500 bps)
        bytes32 salt;                 // User salt for deterministic CREATE2 token address
    }

    /// @notice Stored on-chain configuration for every launched Uniswap v4 pool.
    struct PoolConfig {
        address token;
        address quoteCurrency;
        address creator;
        address feeRecipient;
        address agentOperator;
        uint256 totalSupply;
        uint64 launchedAt;
        int24 tickLower;
        int24 tickUpper;
        uint32 moduleMask;
        uint16 hookTaxBps;
        uint16 antiSnipeStartBps;
        uint32 antiSnipeDuration;
        uint16 maxTxBps;
        uint32 gateEndsAt;
        address gateToken;
        uint256 gateMinBalance;
        uint16 dynamicMaxAddBps;
        uint16 velocityDumpMalusBps;
        uint16 velocityDipRebateBps;
        PotSplit potSplit;
        bool initialized;
    }
}

src/interfaces/IHookEthVaults.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;

import {HookEthTypes} from "./IHookEthTypes.sol";

interface IHookEthFloorVault {
    function registerPool(
        bytes32 poolId,
        address token,
        address quoteCurrency,
        bool loansEnabled,
        uint16 originationFeeBps
    ) external;

    function fundFloor(bytes32 poolId, uint256 amount) external payable;
    function floorPricePerToken(bytes32 poolId) external view returns (uint256);
    function floorReserve(bytes32 poolId) external view returns (uint256);
    function redeemFloor(bytes32 poolId, uint256 tokenAmount, uint256 minQuoteOut) external returns (uint256 quoteOut);
    function borrowAgainstFloor(bytes32 poolId, uint256 tokenAmount, uint32 duration) external returns (uint256 loanId, uint256 principal);
    function repayLoan(uint256 loanId) external payable;
}

interface IHookEthFeeEscrow {
    function registerPool(
        bytes32 poolId,
        address token,
        address quoteCurrency,
        address creator,
        address feeRecipient,
        uint32 moduleMask,
        HookEthTypes.CreatorAndSpecialParams calldata special
    ) external;

    function creditBaseFees(
        bytes32 poolId,
        address quoteCurrency,
        uint256 creatorAmount,
        uint256 protocolAmount,
        uint256 stakerAmount
    ) external payable;

    function creditPotAllocations(
        bytes32 poolId,
        address quoteCurrency,
        address trader,
        bool isBuy,
        uint256 buyQuoteNotional,
        uint256 airdropAmount,
        uint256 creatorAmount,
        uint256 nftStrategyAmount,
        uint256 bossRaidAmount,
        uint256 velocityCashbackReserve
    ) external payable;

    function creditVelocityCashback(bytes32 poolId, address trader, uint256 amount) external payable;
    function creditBuilderCut(address builder, address quoteCurrency, uint256 amount) external payable;
}

interface IHookEthModuleRegistry {
    struct ModuleEntry {
        address plugin;
        address builder;
        bytes32 codehash;
        uint32 capabilities;
        uint32 gasLimit;
        uint16 maxSurchargeBps;
        bool active;
        bool halted;
    }

    function moduleEntry(uint256 moduleId) external view returns (ModuleEntry memory);
    function isModuleActive(uint256 moduleId) external view returns (bool);
}

src/interfaces/IHookPlugin.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;

library HookPluginCaps {
    uint32 internal constant CAP_ON_LAUNCH          = 1 << 0;
    uint32 internal constant CAP_BEFORE_SWAP        = 1 << 15;
    uint32 internal constant CAP_AFTER_SWAP         = 1 << 16;
    uint32 internal constant CAP_GUARD              = 1 << 17;
    uint32 internal constant CAP_SELL_GUARD_ANTIMEV = 1 << 18;
    uint32 internal constant CAP_FEE_SURCHARGE      = 1 << 19;
    uint32 internal constant CAP_POT_SPEND          = 1 << 20;
    uint32 internal constant CAP_BEFORE_SWAP_DELTA  = 1 << 28;
}

/// @title IHookPlugin (Plugin API v3)
/// @notice Interface for community-built immutable Workshop plugins attached to HookEthMasterHook pools.
interface IHookPlugin {

    struct SwapCtx {
        bytes32 poolId;
        bool isBuy;
        bool exactInput;
        uint256 quoteNotional;
        uint160 sqrtPriceX96;
        int24 tick;
        uint16 hookTaxBps;
        uint16 feeHeadroomBps;
        uint256 availablePot;
        uint256 rebateHeadroom;
        address sender;
        address origin;
        address hint;
    }

    struct BeforeSwapResult {
        uint8 guard;            // 0 = allow, 1 = block
        uint16 reason;          // plugin-defined block code
        uint16 surchargeBps;    // extra fee into hook pot (<= maxSurchargeBps & feeHeadroomBps)
        uint256 maxQuoteNotional; // 0 = no cap
        uint256 rebate;         // quote handed back to swapper (<= rebateHeadroom & availablePot)
    }

    struct AfterSwapSpend {
        uint256 burnAmount;
        uint256 floorAmount;
        uint256 deepenLpAmount;
        uint256 airdropAmount;
        uint256 creatorAmount;
        uint256 builderCutAmount; // up to 20% of plugin spend paid to plugin builder
    }

    function pluginApiVersion() external pure returns (uint16);
    function capabilities() external pure returns (uint32);
    function declaredGasLimit() external pure returns (uint32);
    function maxSurchargeBps() external pure returns (uint16);
    function builderPayout() external view returns (address);

    function onLaunch(bytes32 poolId, bytes calldata initData) external;
    function beforeSwapPlugin(SwapCtx calldata ctx) external returns (BeforeSwapResult memory);
    function afterSwapPlugin(SwapCtx calldata ctx, uint256 potBudget) external returns (AfterSwapSpend memory);
}
Compiler settingsShow
{
  "viaIR": true,
  "optimizer": {
    "runs": 50,
    "enabled": true
  },
  "evmVersion": "cancun"
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.