$CLOAKBUY ON MONTRA ↗✓ V4 HOOK VERIFIED ↗SYNCING · MAINNET
Protocol specification · Uniswap v4 on Elysium

CLOAK Architecture

Reference contracts, bitmask flags, and Elysium deployment constants for building or verifying CLOAK privacy pools on top of Uniswap v4.

CHAIN ID

99901

Elysium L2 (Arbitrum Orbit settling to HyperEVM, 100ms block cadence, HYPE gas).

SINGLETON POOLMANAGER

0xE2e105d3F7209A9DA11f83cCf3E7398a753823F1

Shared Uniswap v4 pool engine on Elysium mainnet—zero fragmented pair contracts.

HOOK BITMASK

0x00C4

Encodes beforeSwap, afterSwap, and afterSwapReturnDelta.

Reference contract

CloakHook.sol (Core)

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

import {BaseHook} from "v4-periphery/src/utils/BaseHook.sol";
import {Hooks} from "v4-core/src/libraries/Hooks.sol";
import {IPoolManager} from "v4-core/src/interfaces/IPoolManager.sol";
import {PoolKey} from "v4-core/src/types/PoolKey.sol";
import {BalanceDelta} from "v4-core/src/types/BalanceDelta.sol";
import {BeforeSwapDelta, BeforeSwapDeltaLibrary} from "v4-core/src/types/BeforeSwapDelta.sol";

/// @title CloakHook — 200ms commit-reveal + stealth afterSwap on Elysium
contract CloakHook is BaseHook {
    uint256 public constant MIN_COMMIT_BLOCKS = 2; // 200ms on Elysium
    mapping(bytes32 => uint256) public commits;

    constructor(IPoolManager _poolManager) BaseHook(_poolManager) {}

    function getHookPermissions() public pure override returns (Hooks.Permissions memory) {
        return Hooks.Permissions({
            beforeInitialize: false,
            afterInitialize: false,
            beforeAddLiquidity: false,
            afterAddLiquidity: false,
            beforeRemoveLiquidity: false,
            afterRemoveLiquidity: false,
            beforeSwap: true,              // bit 7 (0x0080)
            afterSwap: true,               // bit 6 (0x0040)
            beforeDonate: false,
            afterDonate: false,
            beforeSwapReturnDelta: false,
            afterSwapReturnDelta: true,    // bit 2 (0x0004)
            afterAddLiquidityReturnDelta: false,
            afterRemoveLiquidityReturnDelta: false
        });
    }

    function commitIntent(bytes32 intentHash) external {
        commits[intentHash] = block.number;
    }

    function _beforeSwap(
        address sender,
        PoolKey calldata key,
        IPoolManager.SwapParams calldata params,
        bytes calldata hookData
    ) internal override returns (bytes4, BeforeSwapDelta, uint24) {
        (bytes32 salt, address stealthRecipient) = abi.decode(hookData, (bytes32, address));
        bytes32 h = keccak256(abi.encode(sender, key.toId(), params.zeroForOne, params.amountSpecified, salt, stealthRecipient));
        uint256 cBlock = commits[h];
        require(cBlock != 0 && block.number >= cBlock + MIN_COMMIT_BLOCKS, "CLOAK: COMMIT_TOO_FRESH");
        delete commits[h];
        return (BaseHook.beforeSwap.selector, BeforeSwapDeltaLibrary.ZERO_DELTA, 0);
    }
}
Uniswap v4 permission bits

14-bit address encoding

Callback FlagBitHex MaskCLOAKPurpose
beforeInitialize130x2000—Gate or configure pool creation params
afterInitialize120x1000—Emit custom pool registry metadata
beforeAddLiquidity110x0800—Enforce LP lock or whitelist rules
afterAddLiquidity100x0400—Track single-sided liquidity deltas
beforeRemoveLiquidity90x0200—Prevent premature LP rug withdrawals
afterRemoveLiquidity80x0100—Settle accrued hook fees on exit
beforeSwap70x0080ENABLEDVerify 2-block (200ms) commit hash & block MEV
afterSwap60x0040ENABLEDDispatch swap output to stealth address
beforeDonate50x0020—Intercept native LP fee donations
afterDonate40x0010—Account for post-donation rewards
beforeSwapReturnDelta30x0008—Take custom input-side swap fee delta
afterSwapReturnDelta20x0004ENABLEDCapture output bps into $CLOAK burn sink
Open Cipher Terminal →Back to overview