99901
Elysium L2 (Arbitrum Orbit settling to HyperEVM, 100ms block cadence, HYPE gas).
Reference contracts, bitmask flags, and Elysium deployment constants for building or verifying CLOAK privacy pools on top of Uniswap v4.
Elysium L2 (Arbitrum Orbit settling to HyperEVM, 100ms block cadence, HYPE gas).
Shared Uniswap v4 pool engine on Elysium mainnet—zero fragmented pair contracts.
Encodes beforeSwap, afterSwap, and afterSwapReturnDelta.
// 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);
}
}| Callback Flag | Bit | Hex Mask | CLOAK | Purpose |
|---|---|---|---|---|
beforeInitialize | 13 | 0x2000 | — | Gate or configure pool creation params |
afterInitialize | 12 | 0x1000 | — | Emit custom pool registry metadata |
beforeAddLiquidity | 11 | 0x0800 | — | Enforce LP lock or whitelist rules |
afterAddLiquidity | 10 | 0x0400 | — | Track single-sided liquidity deltas |
beforeRemoveLiquidity | 9 | 0x0200 | — | Prevent premature LP rug withdrawals |
afterRemoveLiquidity | 8 | 0x0100 | — | Settle accrued hook fees on exit |
beforeSwap | 7 | 0x0080 | ENABLED | Verify 2-block (200ms) commit hash & block MEV |
afterSwap | 6 | 0x0040 | ENABLED | Dispatch swap output to stealth address |
beforeDonate | 5 | 0x0020 | — | Intercept native LP fee donations |
afterDonate | 4 | 0x0010 | — | Account for post-donation rewards |
beforeSwapReturnDelta | 3 | 0x0008 | — | Take custom input-side swap fee delta |
afterSwapReturnDelta | 2 | 0x0004 | ENABLED | Capture output bps into $CLOAK burn sink |