Skip to content
Verified contractExactMIT

HookEthGovernance

Address0xab61bba859bee047116f5f990daba03eba2e6086
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,221
Creation transaction
0xb6ce9820c8…aac14fcc52

src/core/HookEthGovernance.sol

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

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {HookEthTypes} from "../interfaces/IHookEthTypes.sol";

interface IMasterHookGovTarget {
    function getPoolConfig(bytes32 poolId) external view returns (HookEthTypes.PoolConfig memory);
    function applyGovernanceUpdate(bytes32 poolId, uint16 newHookTaxBps, HookEthTypes.PotSplit calldata newSplit) external;
}

/// @title HookEthGovernance
/// @notice Implements Evolve, DAO (1 token = 1 vote, 6h window), and AI Memory wallet rules for HookETH pools.
contract HookEthGovernance {
    struct EvolvePending {
        uint16 newHookTaxBps;
        HookEthTypes.PotSplit newSplit;
        uint64 executableAt;
        bool active;
    }

    struct DaoProposal {
        uint16 proposedHookTaxBps;
        HookEthTypes.PotSplit proposedSplit;
        uint64 endsAt;
        uint256 votesFor;
        uint256 votesAgainst;
        bool executed;
    }

    struct MemoryWalletRule {
        bool isAlly;
        uint16 extraFeeBps;
        uint16 rebateBps;
    }

    IMasterHookGovTarget public immutable masterHook;

    mapping(bytes32 => EvolvePending) public pendingEvolves;
    mapping(bytes32 => uint256) public nextDaoProposalId;
    mapping(bytes32 => mapping(uint256 => DaoProposal)) public daoProposals;
    mapping(bytes32 => mapping(uint256 => mapping(address => bool))) public daoVoted;
    mapping(bytes32 => mapping(address => MemoryWalletRule)) public memoryRules;

    event EvolveAnnounced(bytes32 indexed poolId, uint16 newHookTaxBps, uint64 executableAt);
    event EvolveApplied(bytes32 indexed poolId, uint16 newHookTaxBps);
    event DaoProposalCreated(bytes32 indexed poolId, uint256 indexed proposalId, uint16 hookTaxBps, uint64 endsAt);
    event DaoVoted(bytes32 indexed poolId, uint256 indexed proposalId, address indexed voter, bool support, uint256 weight);
    event MemoryRuleSet(bytes32 indexed poolId, address indexed wallet, bool isAlly, uint16 extraFeeBps, uint16 rebateBps);

    error Unauthorized();
    error InvalidFeeCap();
    error InvalidPotSplit();
    error EvolveNotReady();
    error DaoVoteClosed();
    error DaoAlreadyVoted();
    error DaoNotPassed();

    constructor(address masterHook_) {
        masterHook = IMasterHookGovTarget(masterHook_);
    }

    /// @notice Evolve module: cuts apply at once; raises or split changes wait 1h notice.
    function evolvePool(bytes32 poolId, uint16 newHookTaxBps, HookEthTypes.PotSplit calldata newSplit) external {
        HookEthTypes.PoolConfig memory cfg = masterHook.getPoolConfig(poolId);
        if ((cfg.moduleMask & HookEthTypes.MOD_EVOLVE) == 0) revert Unauthorized();
        if (msg.sender != cfg.creator && msg.sender != cfg.agentOperator) revert Unauthorized();
        if (newHookTaxBps > HookEthTypes.MAX_HOOK_TAX_BPS) revert InvalidFeeCap();
        _validateSplit(newSplit);

        if (newHookTaxBps <= cfg.hookTaxBps && _sameSplit(cfg.potSplit, newSplit)) {
            masterHook.applyGovernanceUpdate(poolId, newHookTaxBps, newSplit);
            emit EvolveApplied(poolId, newHookTaxBps);
        } else {
            uint64 execAt = uint64(block.timestamp + HookEthTypes.EVOLVE_NOTICE_DELAY);
            pendingEvolves[poolId] = EvolvePending({
                newHookTaxBps: newHookTaxBps,
                newSplit: newSplit,
                executableAt: execAt,
                active: true
            });
            emit EvolveAnnounced(poolId, newHookTaxBps, execAt);
        }
    }

    function executeEvolve(bytes32 poolId) external {
        EvolvePending storage p = pendingEvolves[poolId];
        if (!p.active || block.timestamp < p.executableAt) revert EvolveNotReady();
        p.active = false;
        masterHook.applyGovernanceUpdate(poolId, p.newHookTaxBps, p.newSplit);
        emit EvolveApplied(poolId, p.newHookTaxBps);
    }

    /// @notice DAO module: holders propose fee/split changes and vote 1 token = 1 vote (no staking) for 6 hours.
    function proposeDaoChange(bytes32 poolId, uint16 proposedHookTaxBps, HookEthTypes.PotSplit calldata proposedSplit)
        external
        returns (uint256 proposalId)
    {
        HookEthTypes.PoolConfig memory cfg = masterHook.getPoolConfig(poolId);
        if ((cfg.moduleMask & HookEthTypes.MOD_DAO) == 0) revert Unauthorized();
        if (IERC20(cfg.token).balanceOf(msg.sender) == 0) revert Unauthorized();
        if (proposedHookTaxBps > HookEthTypes.MAX_HOOK_TAX_BPS) revert InvalidFeeCap();
        _validateSplit(proposedSplit);

        proposalId = ++nextDaoProposalId[poolId];
        uint64 endsAt = uint64(block.timestamp + HookEthTypes.DAO_VOTE_DURATION);
        daoProposals[poolId][proposalId] = DaoProposal({
            proposedHookTaxBps: proposedHookTaxBps,
            proposedSplit: proposedSplit,
            endsAt: endsAt,
            votesFor: 0,
            votesAgainst: 0,
            executed: false
        });
        emit DaoProposalCreated(poolId, proposalId, proposedHookTaxBps, endsAt);
    }

    function voteDao(bytes32 poolId, uint256 proposalId, bool support) external {
        DaoProposal storage prop = daoProposals[poolId][proposalId];
        if (prop.endsAt == 0 || block.timestamp > prop.endsAt) revert DaoVoteClosed();
        if (daoVoted[poolId][proposalId][msg.sender]) revert DaoAlreadyVoted();

        HookEthTypes.PoolConfig memory cfg = masterHook.getPoolConfig(poolId);
        uint256 weight = IERC20(cfg.token).balanceOf(msg.sender);
        if (weight == 0) revert Unauthorized();

        daoVoted[poolId][proposalId][msg.sender] = true;
        if (support) prop.votesFor += weight;
        else prop.votesAgainst += weight;

        emit DaoVoted(poolId, proposalId, msg.sender, support, weight);
    }

    function executeDaoProposal(bytes32 poolId, uint256 proposalId) external {
        DaoProposal storage prop = daoProposals[poolId][proposalId];
        if (prop.executed || block.timestamp <= prop.endsAt) revert DaoVoteClosed();
        if (prop.votesFor <= prop.votesAgainst || prop.votesFor == 0) revert DaoNotPassed();

        prop.executed = true;
        masterHook.applyGovernanceUpdate(poolId, prop.proposedHookTaxBps, prop.proposedSplit);
        emit EvolveApplied(poolId, prop.proposedHookTaxBps);
    }

    /// @notice AI Memory module: agent writes per-wallet ally rebates or extra fees within hard caps.
    function setMemoryRule(
        bytes32 poolId,
        address wallet,
        bool isAlly,
        uint16 extraFeeBps,
        uint16 rebateBps
    ) external {
        HookEthTypes.PoolConfig memory cfg = masterHook.getPoolConfig(poolId);
        if ((cfg.moduleMask & HookEthTypes.MOD_MEMORY) == 0) revert Unauthorized();
        if (msg.sender != cfg.agentOperator && msg.sender != cfg.creator) revert Unauthorized();
        if (extraFeeBps > 500 || rebateBps > 500) revert InvalidFeeCap();

        memoryRules[poolId][wallet] = MemoryWalletRule({
            isAlly: isAlly,
            extraFeeBps: extraFeeBps,
            rebateBps: rebateBps
        });
        emit MemoryRuleSet(poolId, wallet, isAlly, extraFeeBps, rebateBps);
    }

    function getMemoryRule(bytes32 poolId, address wallet)
        external
        view
        returns (bool isAlly, uint16 extraFeeBps, uint16 rebateBps)
    {
        MemoryWalletRule storage r = memoryRules[poolId][wallet];
        return (r.isAlly, r.extraFeeBps, r.rebateBps);
    }

    function _validateSplit(HookEthTypes.PotSplit memory s) internal pure {
        uint256 sum = uint256(s.autoBurnBps) + s.backedFloorBps + s.deepenLpBps + s.holderAirdropBps +
            s.hookToCreatorBps + s.nftStrategyBps + s.bossRaidBps + s.pluginBps;
        if (sum != 0 && sum != HookEthTypes.BPS_DENOMINATOR) revert InvalidPotSplit();
    }

    function _sameSplit(HookEthTypes.PotSplit memory a, HookEthTypes.PotSplit memory b) internal pure returns (bool) {
        return a.autoBurnBps == b.autoBurnBps &&
            a.backedFloorBps == b.backedFloorBps &&
            a.deepenLpBps == b.deepenLpBps &&
            a.holderAirdropBps == b.holderAirdropBps &&
            a.hookToCreatorBps == b.hookToCreatorBps &&
            a.nftStrategyBps == b.nftStrategyBps &&
            a.bossRaidBps == b.bossRaidBps &&
            a.pluginBps == b.pluginBps;
    }
}

@openzeppelin/contracts/token/ERC20/IERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)

pragma solidity >=0.4.16;

/**
 * @dev Interface of the ERC-20 standard as defined in the ERC.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the value of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 value) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 value) external returns (bool);
}

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