Skip to content
Verified contractExactMIT

JobQueue

Address0x4b3b627afeb1a1616bfd11cb85523ca9d2dc71fd
Balance

0 ETH

 

Transactions

3

 

Compiler

solc 0.8.37

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.37+commit.f401782d
Language
solidity
Optimization
Yes, 200 runs
EVM version
osaka
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
25,984,273
Creation transaction
0x6696c416f9…a8656573ae

src/runtime/JobQueue.sol

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

//  ▄▄▄▄▄ ▄   ▄ ▄   ▄
//  █▄▄▄  ▀▄ ▄▀ █▄▄▄█   EVH · Ethereum Virtual Hook
//  █▄▄▄▄   ▀   █   █   plugin hypervisor for Uniswap V4
//
//  ethereumvirtualhook.xyz · x.com/VirtualHookETH

import {ServiceClient} from "../common/ServiceClient.sol";
import {IJobQueue} from "../interfaces/IJobQueue.sol";
import {IPluginRuntime} from "../interfaces/IPluginRuntime.sol";
import {IPluginCatalog} from "../interfaces/IPluginCatalog.sol";
import {IAccessMatrix} from "../interfaces/IAccessMatrix.sol";
import {Invocation} from "../types/Invocation.sol";
import {Phase} from "../types/Phase.sol";
import {Keys} from "../libraries/Keys.sol";
import {Permits} from "../libraries/Permits.sol";

/// @title JobQueue
/// @notice Deferred work without keepers.
///
///         A plugin holding SCHEDULE_JOBS can enqueue a job with a not-before
///         timestamp. The hypervisor drains ready jobs at the end of each swap
///         under a strict fuel budget: the next swapper pays for deferred work in
///         exchange for the fee the pool charges them. No swaps, no drain — the
///         honest behaviour, and the UI says so.
contract JobQueue is ServiceClient, IJobQueue {
    Job[] internal _jobs;
    /// @dev poolId => job ids, append-only
    mapping(bytes32 => uint256[]) internal _byPool;
    /// @notice poolId => index of the first unfinished job in that pool's list
    mapping(bytes32 => uint256) public headOf;

    mapping(bytes32 => uint256) public openJobs;
    uint256 public openJobCap = 8;
    uint64 public horizon = 30 days;

    event JobEnqueued(
        uint256 indexed jobId, bytes32 indexed poolId, bytes32 indexed pluginId, uint64 notBefore, uint32 fuelCap
    );
    event JobVoided(uint256 indexed jobId, bytes32 indexed pluginId);
    event JobDone(uint256 indexed jobId, bytes32 indexed pluginId, bool ok, uint256 fuelUsed);
    event BoundsSet(uint256 openJobCap, uint64 horizon);

    error NotEnrolled();
    error OpenJobCapReached();
    error BeyondHorizon();
    error UnknownJob();
    error CallerNotJobOwner();

    constructor(address steward_, address directory_) ServiceClient(steward_, directory_) {}

    function _serviceKeys() internal pure override returns (bytes32[] memory keys) {
        keys = new bytes32[](4);
        keys[0] = Keys.RUNTIME;
        keys[1] = Keys.CATALOG;
        keys[2] = Keys.ACCESS;
        keys[3] = Keys.HYPERVISOR;
    }

    function setBounds(uint256 openJobCap_, uint64 horizon_) external onlySteward {
        openJobCap = openJobCap_;
        horizon = horizon_;
        emit BoundsSet(openJobCap_, horizon_);
    }

    // ------------------------------------------------------------ scheduling

    /// @notice Called by a plugin (as msg.sender), typically inside its own run.
    function enqueue(bytes32 poolId, uint64 notBefore, uint32 fuelCap, bytes calldata data)
        external
        override
        returns (uint256 jobId)
    {
        bytes32 pluginId = IPluginCatalog(_service(Keys.CATALOG)).pluginIdOf(msg.sender);
        if (pluginId == bytes32(0)) revert NotEnrolled();
        IAccessMatrix(_service(Keys.ACCESS)).requirePermit(pluginId, Permits.SCHEDULE_JOBS);
        if (notBefore > block.timestamp + horizon) revert BeyondHorizon();
        if (openJobs[pluginId] >= openJobCap) revert OpenJobCapReached();

        jobId = _jobs.length;
        _jobs.push(
            Job({
                pluginId: pluginId,
                poolId: poolId,
                notBefore: notBefore,
                fuelCap: fuelCap,
                voided: false,
                done: false,
                data: data
            })
        );
        _byPool[poolId].push(jobId);
        unchecked {
            openJobs[pluginId] += 1;
        }
        emit JobEnqueued(jobId, poolId, pluginId, notBefore, fuelCap);
    }

    function void(uint256 jobId) external override {
        if (jobId >= _jobs.length) revert UnknownJob();
        Job storage j = _jobs[jobId];
        IPluginCatalog.PluginRecord memory r = IPluginCatalog(_service(Keys.CATALOG)).recordOf(j.pluginId);
        if (msg.sender != r.plugin && msg.sender != r.author && msg.sender != steward) revert CallerNotJobOwner();
        if (j.done || j.voided) return;
        j.voided = true;
        _release(j.pluginId);
        emit JobVoided(jobId, j.pluginId);
    }

    // ---------------------------------------------------------------- drain

    /// @notice Run up to `maxJobs` ready jobs for `poolId` within `fuelBudget`.
    /// @dev    A persistent head keeps the scan O(drained), not O(ever queued).
    function drain(bytes32 poolId, uint256 maxJobs, uint256 fuelBudget)
        external
        override
        onlyService(Keys.HYPERVISOR)
        returns (uint256 done)
    {
        IPluginRuntime runtime = IPluginRuntime(_service(Keys.RUNTIME));
        uint256[] storage ids = _byPool[poolId];
        uint256 i = headOf[poolId];
        uint256 n = ids.length;
        uint256 spent;

        while (i < n && done < maxJobs && spent < fuelBudget) {
            uint256 jobId = ids[i];
            Job storage j = _jobs[jobId];
            if (j.done || j.voided) {
                unchecked {
                    ++i;
                }
                continue;
            }
            if (j.notBefore > block.timestamp) break;
            // A job run starved of gas would still be marked done and lost. Leave
            // it for a later swap that brings enough gas instead.
            if (gasleft() < (uint256(j.fuelCap) * 64) / 63 + 150_000) break;

            Invocation memory inv;
            inv.poolId = poolId;
            inv.pluginId = j.pluginId;
            inv.origin = address(this);
            inv.hypervisor = msg.sender;
            inv.phase = uint8(Phase.PostSwap);
            inv.fuelCap = j.fuelCap;
            inv.blockNumber = uint64(block.number);
            inv.timestamp = uint64(block.timestamp);
            inv.data = j.data;

            bool ok;
            uint256 used;
            try runtime.dispatchOne(j.pluginId, inv) returns (bool ran, bytes memory, uint256 fuel) {
                ok = ran;
                used = fuel;
            } catch {}

            j.done = true;
            _release(j.pluginId);
            emit JobDone(jobId, j.pluginId, ok, used);

            unchecked {
                spent += used;
                ++done;
                ++i;
            }
        }
        headOf[poolId] = i;
    }

    function _release(bytes32 pluginId) internal {
        if (openJobs[pluginId] != 0) {
            unchecked {
                openJobs[pluginId] -= 1;
            }
        }
    }

    // ----------------------------------------------------------------- views

    function readyCount(bytes32 poolId) external view override returns (uint256 n) {
        uint256[] storage ids = _byPool[poolId];
        for (uint256 i = headOf[poolId]; i < ids.length; ++i) {
            Job storage j = _jobs[ids[i]];
            if (j.done || j.voided) continue;
            if (j.notBefore > block.timestamp) break;
            unchecked {
                ++n;
            }
        }
    }

    function jobOf(uint256 jobId) external view override returns (Job memory) {
        return _jobs[jobId];
    }

    function jobCount() external view returns (uint256) {
        return _jobs.length;
    }

    function jobPage(bytes32 poolId, uint256 offset, uint256 limit)
        external
        view
        returns (uint256[] memory ids, Job[] memory jobs)
    {
        uint256[] storage all = _byPool[poolId];
        uint256 total = all.length;
        if (offset >= total) return (new uint256[](0), new Job[](0));
        uint256 end = offset + limit > total ? total : offset + limit;
        uint256 n = end - offset;
        ids = new uint256[](n);
        jobs = new Job[](n);
        for (uint256 i; i < n; ++i) {
            ids[i] = all[offset + i];
            jobs[i] = _jobs[ids[i]];
        }
    }
}

src/common/ServiceClient.sol

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

//  ▄▄▄▄▄ ▄   ▄ ▄   ▄
//  █▄▄▄  ▀▄ ▄▀ █▄▄▄█   EVH · Ethereum Virtual Hook
//  █▄▄▄▄   ▀   █   █   plugin hypervisor for Uniswap V4
//
//  ethereumvirtualhook.xyz · x.com/VirtualHookETH

import {Stewarded} from "./Stewarded.sol";
import {ISystemDirectory} from "../interfaces/ISystemDirectory.sol";

/// @title ServiceClient
/// @notice Base for every EVH contract that talks to its peers.
///
///         Each client declares the directory keys it depends on. `syncServices`
///         copies those bindings into local storage, so the hot path reads one
///         warm slot instead of making an external call to the directory on
///         every swap.
abstract contract ServiceClient is Stewarded {
    ISystemDirectory public immutable directory;

    mapping(bytes32 => address) internal _services;

    event ServicesSynced(uint256 count);

    error CallerNotService(bytes32 key);
    error ServiceUnbound(bytes32 key);

    constructor(address steward_, address directory_) Stewarded(steward_) {
        if (directory_ == address(0)) revert NullAddress();
        directory = ISystemDirectory(directory_);
    }

    /// @notice Pull this contract's dependencies from the directory.
    /// @dev    Permissionless: it can only copy what the directory's steward has
    ///         already bound.
    function syncServices() external {
        bytes32[] memory keys = _serviceKeys();
        for (uint256 i; i < keys.length; ++i) {
            _services[keys[i]] = directory.resolve(keys[i]);
        }
        emit ServicesSynced(keys.length);
    }

    function serviceAt(bytes32 key) public view returns (address) {
        return _services[key];
    }

    /// @dev The keys this contract resolves. Implemented by each client.
    function _serviceKeys() internal pure virtual returns (bytes32[] memory);

    function _service(bytes32 key) internal view returns (address addr) {
        addr = _services[key];
        if (addr == address(0)) revert ServiceUnbound(key);
    }

    function _isService(bytes32 key) internal view returns (bool) {
        return msg.sender == _services[key] && msg.sender != address(0);
    }

    modifier onlyService(bytes32 key) {
        if (!_isService(key)) revert CallerNotService(key);
        _;
    }
}

src/common/Stewarded.sol

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

//  ▄▄▄▄▄ ▄   ▄ ▄   ▄
//  █▄▄▄  ▀▄ ▄▀ █▄▄▄█   EVH · Ethereum Virtual Hook
//  █▄▄▄▄   ▀   █   █   plugin hypervisor for Uniswap V4
//
//  ethereumvirtualhook.xyz · x.com/VirtualHookETH

import {Versioned} from "./Versioned.sol";

/// @title Stewarded
/// @notice Two-step stewardship. Every EVH system contract carries one steward,
///         so the whole system can be handed to the Chronolock in a single sweep.
/// @dev    A nomination never moves control on its own; the nominee has to pull
///         it. That makes a typo'd address a no-op instead of a lost protocol.
abstract contract Stewarded is Versioned {
    address public steward;
    address public nominee;

    event StewardNominated(address indexed from, address indexed to);
    event StewardshipTransferred(address indexed from, address indexed to);

    error CallerNotSteward();
    error CallerNotNominee();
    error NullAddress();

    modifier onlySteward() {
        if (msg.sender != steward) revert CallerNotSteward();
        _;
    }

    constructor(address steward_) {
        if (steward_ == address(0)) revert NullAddress();
        steward = steward_;
        emit StewardshipTransferred(address(0), steward_);
    }

    function nominateSteward(address to) external onlySteward {
        if (to == address(0)) revert NullAddress();
        nominee = to;
        emit StewardNominated(steward, to);
    }

    function acceptStewardship() external {
        if (msg.sender != nominee) revert CallerNotNominee();
        address previous = steward;
        steward = msg.sender;
        nominee = address(0);
        emit StewardshipTransferred(previous, msg.sender);
    }
}

src/common/Versioned.sol

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

//  ▄▄▄▄▄ ▄   ▄ ▄   ▄
//  █▄▄▄  ▀▄ ▄▀ █▄▄▄█   EVH · Ethereum Virtual Hook
//  █▄▄▄▄   ▀   █   █   plugin hypervisor for Uniswap V4
//
//  ethereumvirtualhook.xyz · x.com/VirtualHookETH

/// @title Versioned
/// @notice One release string for the whole system. Every EVH contract inherits
///         it, so any deployed address answers `VERSION()` with the same value.
abstract contract Versioned {
    string public constant VERSION = "1.0";
}

src/interfaces/IAccessMatrix.sol

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

//  ▄▄▄▄▄ ▄   ▄ ▄   ▄
//  █▄▄▄  ▀▄ ▄▀ █▄▄▄█   EVH · Ethereum Virtual Hook
//  █▄▄▄▄   ▀   █   █   plugin hypervisor for Uniswap V4
//
//  ethereumvirtualhook.xyz · x.com/VirtualHookETH

interface IAccessMatrix {
    error PermitMissing(bytes32 pluginId, uint8 permit);

    function grantedOf(bytes32 pluginId) external view returns (uint8);
    function askedOf(bytes32 pluginId) external view returns (uint8);
    function holds(bytes32 pluginId, uint8 permit) external view returns (bool);
    function requirePermit(bytes32 pluginId, uint8 permit) external view;
    function isCallTarget(address target) external view returns (bool);
    function onEnroll(bytes32 pluginId, uint8 asked) external;
    function onCertify(bytes32 pluginId) external;
    function onStrip(bytes32 pluginId) external;
}

src/interfaces/IJobQueue.sol

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

//  ▄▄▄▄▄ ▄   ▄ ▄   ▄
//  █▄▄▄  ▀▄ ▄▀ █▄▄▄█   EVH · Ethereum Virtual Hook
//  █▄▄▄▄   ▀   █   █   plugin hypervisor for Uniswap V4
//
//  ethereumvirtualhook.xyz · x.com/VirtualHookETH

interface IJobQueue {
    struct Job {
        bytes32 pluginId;
        bytes32 poolId;
        uint64 notBefore;
        uint32 fuelCap;
        bool voided;
        bool done;
        bytes data;
    }

    function enqueue(bytes32 poolId, uint64 notBefore, uint32 fuelCap, bytes calldata data)
        external
        returns (uint256 jobId);
    function void(uint256 jobId) external;
    function drain(bytes32 poolId, uint256 maxJobs, uint256 fuelBudget) external returns (uint256 done);
    function readyCount(bytes32 poolId) external view returns (uint256);
    function jobOf(uint256 jobId) external view returns (Job memory);
}

src/interfaces/IPluginCatalog.sol

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

//  ▄▄▄▄▄ ▄   ▄ ▄   ▄
//  █▄▄▄  ▀▄ ▄▀ █▄▄▄█   EVH · Ethereum Virtual Hook
//  █▄▄▄▄   ▀   █   █   plugin hypervisor for Uniswap V4
//
//  ethereumvirtualhook.xyz · x.com/VirtualHookETH

import {PluginState} from "../types/PluginTypes.sol";

interface IPluginCatalog {
    struct PluginRecord {
        address plugin;
        address author;
        bytes32 codehash;
        uint16 phaseMask;
        uint32 fuelCap;
        uint8 permits;
        PluginState state;
        uint8 strikes;
        uint64 enrolledAt;
        uint256 runs;
        uint256 faults;
        uint256 fuelBurned;
    }

    function pluginIdOf(address plugin) external view returns (bytes32);
    function recordOf(bytes32 pluginId) external view returns (PluginRecord memory);
    function labelsOf(bytes32 pluginId)
        external
        view
        returns (string memory label, string memory semver, string memory sourceURI);
    function isRunnable(bytes32 pluginId) external view returns (bool);
    function runnableMask(bytes32[] calldata pluginIds) external view returns (bool[] memory);
    function logRun(bytes32 pluginId, uint256 fuel, bool ok) external;
    function penalize(bytes32 pluginId, bytes calldata revertData) external;
    function pluginCount() external view returns (uint256);
    function pluginIdAt(uint256 index) external view returns (bytes32);
    function totalFuelBurned() external view returns (uint256);
}

src/interfaces/IPluginRuntime.sol

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

//  ▄▄▄▄▄ ▄   ▄ ▄   ▄
//  █▄▄▄  ▀▄ ▄▀ █▄▄▄█   EVH · Ethereum Virtual Hook
//  █▄▄▄▄   ▀   █   █   plugin hypervisor for Uniswap V4
//
//  ethereumvirtualhook.xyz · x.com/VirtualHookETH

import {Invocation} from "../types/Invocation.sol";

interface IPluginRuntime {
    /// @notice The caller did not supply enough gas to run the phase's lineup at
    ///         full caps. Bubbled out of the hypervisor on purpose: see dispatch.
    error FuelShortfall(uint256 need, uint256 have);

    struct Outcome {
        uint256 ran;
        uint256 faulted;
        uint256 fuelUsed;
        uint24 feeBid;
        bool hasFeeBid;
    }

    function dispatch(Invocation memory inv, uint256 fuelBudget) external returns (Outcome memory);
    function dispatchOne(bytes32 pluginId, Invocation memory inv)
        external
        returns (bool ok, bytes memory out, uint256 used);
}

src/interfaces/ISystemDirectory.sol

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

//  ▄▄▄▄▄ ▄   ▄ ▄   ▄
//  █▄▄▄  ▀▄ ▄▀ █▄▄▄█   EVH · Ethereum Virtual Hook
//  █▄▄▄▄   ▀   █   █   plugin hypervisor for Uniswap V4
//
//  ethereumvirtualhook.xyz · x.com/VirtualHookETH

interface ISystemDirectory {
    function resolve(bytes32 key) external view returns (address);
    function entries() external view returns (bytes32[] memory keys, address[] memory addrs);
}

src/libraries/Keys.sol

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

//  ▄▄▄▄▄ ▄   ▄ ▄   ▄
//  █▄▄▄  ▀▄ ▄▀ █▄▄▄█   EVH · Ethereum Virtual Hook
//  █▄▄▄▄   ▀   █   █   plugin hypervisor for Uniswap V4
//
//  ethereumvirtualhook.xyz · x.com/VirtualHookETH

/// @title Keys
/// @notice SystemDirectory binding keys. The deploy script and the frontend
///         derive the same values as `keccak256("evh.service.<NAME>")`.
library Keys {
    bytes32 internal constant TOKEN = keccak256("evh.service.TOKEN");
    bytes32 internal constant SCANNER = keccak256("evh.service.SCANNER");
    bytes32 internal constant ACCESS = keccak256("evh.service.ACCESS");
    bytes32 internal constant STAKE_VAULT = keccak256("evh.service.STAKE_VAULT");
    bytes32 internal constant BONDS = keccak256("evh.service.BONDS");
    bytes32 internal constant FUEL = keccak256("evh.service.FUEL");
    bytes32 internal constant MEMORY = keccak256("evh.service.MEMORY");
    bytes32 internal constant CATALOG = keccak256("evh.service.CATALOG");
    bytes32 internal constant BOARD = keccak256("evh.service.BOARD");
    bytes32 internal constant RUNTIME = keccak256("evh.service.RUNTIME");
    bytes32 internal constant JOBS = keccak256("evh.service.JOBS");
    bytes32 internal constant SPLITTER = keccak256("evh.service.SPLITTER");
    bytes32 internal constant BUYBACK = keccak256("evh.service.BUYBACK");
    bytes32 internal constant ROYALTIES = keccak256("evh.service.ROYALTIES");
    bytes32 internal constant FORGE = keccak256("evh.service.FORGE");
    bytes32 internal constant HYPERVISOR = keccak256("evh.service.HYPERVISOR");
    bytes32 internal constant CHRONOLOCK = keccak256("evh.service.CHRONOLOCK");
    bytes32 internal constant COUNCIL = keccak256("evh.service.COUNCIL");
    bytes32 internal constant LENS = keccak256("evh.service.LENS");
}

src/libraries/Permits.sol

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

//  ▄▄▄▄▄ ▄   ▄ ▄   ▄
//  █▄▄▄  ▀▄ ▄▀ █▄▄▄█   EVH · Ethereum Virtual Hook
//  █▄▄▄▄   ▀   █   █   plugin hypervisor for Uniswap V4
//
//  ethereumvirtualhook.xyz · x.com/VirtualHookETH

/// @title Permits
/// @notice The 8-bit permit mask. Bit positions are part of the public ABI.
library Permits {
    uint8 internal constant READ_STATE = 1 << 0;
    uint8 internal constant WRITE_MEMORY = 1 << 1;
    uint8 internal constant EXTERNAL_CALL = 1 << 2;
    uint8 internal constant MOVE_TOKENS = 1 << 3;
    uint8 internal constant SET_FEE = 1 << 4;
    uint8 internal constant EMIT_LOGS = 1 << 5;
    uint8 internal constant SCHEDULE_JOBS = 1 << 6;
    uint8 internal constant REENTER_POOL = 1 << 7;

    /// @dev Granted at enrollment without a vote.
    uint8 internal constant OPEN = READ_STATE | WRITE_MEMORY | SET_FEE | EMIT_LOGS | SCHEDULE_JOBS;

    /// @dev Granted only by Council certification.
    uint8 internal constant GATED = EXTERNAL_CALL | MOVE_TOKENS | REENTER_POOL;

    function includes(uint8 mask, uint8 permit) internal pure returns (bool) {
        return mask & permit != 0;
    }
}

src/types/Invocation.sol

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

//  ▄▄▄▄▄ ▄   ▄ ▄   ▄
//  █▄▄▄  ▀▄ ▄▀ █▄▄▄█   EVH · Ethereum Virtual Hook
//  █▄▄▄▄   ▀   █   █   plugin hypervisor for Uniswap V4
//
//  ethereumvirtualhook.xyz · x.com/VirtualHookETH

/// @notice The read-only snapshot a plugin receives on every run.
/// @dev    `data` is the phase-specific envelope, abi-encoded. Decode it with the
///         matching struct from `Envelopes`.
struct Invocation {
    bytes32 poolId;
    bytes32 pluginId;
    address origin; //       the address that called into the PoolManager
    address hypervisor;
    uint8 phase; //          Phase
    uint16 rank; //          position in this phase's lineup
    uint32 fuelCap; //       the cap this run executes under
    uint64 blockNumber;
    uint64 timestamp;
    int24 tick;
    uint160 sqrtPriceX96;
    uint128 liquidity;
    uint24 lpFee; //         effective LP fee in pips
    bytes data;
}

src/types/Phase.sol

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

//  ▄▄▄▄▄ ▄   ▄ ▄   ▄
//  █▄▄▄  ▀▄ ▄▀ █▄▄▄█   EVH · Ethereum Virtual Hook
//  █▄▄▄▄   ▀   █   █   plugin hypervisor for Uniswap V4
//
//  ethereumvirtualhook.xyz · x.com/VirtualHookETH

/// @notice The eight V4 lifecycle callbacks, as dispatch phases. Bit `i` of a
///         plugin's `phaseMask` is `Phase(i)`. The ordering is ABI: contracts,
///         scripts and the frontend all index by it. Never reorder.
enum Phase {
    PreInitialize, //        0
    PostInitialize, //       1
    PreAddLiquidity, //      2
    PostAddLiquidity, //     3
    PreRemoveLiquidity, //   4
    PostRemoveLiquidity, //  5
    PreSwap, //              6
    PostSwap //              7
}

uint8 constant PHASE_COUNT = 8;

src/types/PluginTypes.sol

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

//  ▄▄▄▄▄ ▄   ▄ ▄   ▄
//  █▄▄▄  ▀▄ ▄▀ █▄▄▄█   EVH · Ethereum Virtual Hook
//  █▄▄▄▄   ▀   █   █   plugin hypervisor for Uniswap V4
//
//  ethereumvirtualhook.xyz · x.com/VirtualHookETH

/// @notice Lifecycle of an enrolled plugin.
enum PluginState {
    None, //        0 never enrolled
    Probation, //   1 runs; open permits only
    Certified, //   2 Council-approved; every asked permit granted
    Suspended, //   3 skipped at dispatch, recoverable
    Slashed, //     4 struck out; bond seized; unseated everywhere
    Exiled //       5 terminal, Council-imposed
}

/// @notice What a plugin says about itself. `PluginCatalog.enroll` requires the
///         caller's declaration to match this byte for byte.
struct PluginSpec {
    string label;
    string semver;
    uint16 phaseMask; // bit i => Phase(i)
    uint32 fuelCap; //   per-run gas ceiling the plugin asks for
    uint8 permits; //    asked permit mask, see Permits
}
Compiler settingsShow
{
  "viaIR": false,
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "osaka",
  "remappings": [
    "v4-core/=lib/v4-core/",
    "v4-periphery/=lib/v4-periphery/",
    "@uniswap/v4-core/=lib/v4-core/",
    "forge-std/=lib/forge-std/src/",
    "solmate/=lib/v4-core/lib/solmate/",
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "@ensdomains/=lib/v4-core/node_modules/@ensdomains/",
    "ds-test/=lib/v4-core/lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "forge-gas-snapshot/=lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/src/",
    "halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "hardhat/=lib/v4-core/node_modules/hardhat/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "permit2/=lib/v4-periphery/lib/permit2/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.