Skip to content

Solidity API

HookMiner

This library is intended for forge test environments. There may be gotchas when using salts in forge script or forge create

FLAG_MASK

solidity
uint160 FLAG_MASK

ALL_HOOK_MASK

solidity
uint160 ALL_HOOK_MASK

BEFORE_INITIALIZE_FLAG

solidity
uint160 BEFORE_INITIALIZE_FLAG

AFTER_INITIALIZE_FLAG

solidity
uint160 AFTER_INITIALIZE_FLAG

BEFORE_ADD_LIQUIDITY_FLAG

solidity
uint160 BEFORE_ADD_LIQUIDITY_FLAG

AFTER_ADD_LIQUIDITY_FLAG

solidity
uint160 AFTER_ADD_LIQUIDITY_FLAG

BEFORE_REMOVE_LIQUIDITY_FLAG

solidity
uint160 BEFORE_REMOVE_LIQUIDITY_FLAG

AFTER_REMOVE_LIQUIDITY_FLAG

solidity
uint160 AFTER_REMOVE_LIQUIDITY_FLAG

BEFORE_SWAP_FLAG

solidity
uint160 BEFORE_SWAP_FLAG

AFTER_SWAP_FLAG

solidity
uint160 AFTER_SWAP_FLAG

BEFORE_DONATE_FLAG

solidity
uint160 BEFORE_DONATE_FLAG

AFTER_DONATE_FLAG

solidity
uint160 AFTER_DONATE_FLAG

BEFORE_SWAP_RETURNS_DELTA_FLAG

solidity
uint160 BEFORE_SWAP_RETURNS_DELTA_FLAG

AFTER_SWAP_RETURNS_DELTA_FLAG

solidity
uint160 AFTER_SWAP_RETURNS_DELTA_FLAG

AFTER_ADD_LIQUIDITY_RETURNS_DELTA_FLAG

solidity
uint160 AFTER_ADD_LIQUIDITY_RETURNS_DELTA_FLAG

AFTER_REMOVE_LIQUIDITY_RETURNS_DELTA_FLAG

solidity
uint160 AFTER_REMOVE_LIQUIDITY_RETURNS_DELTA_FLAG

getAllHookFlags

solidity
function getAllHookFlags() internal pure returns (uint160)

MAX_LOOP

solidity
uint256 MAX_LOOP

find

solidity
function find(address deployer, uint160 flags, bytes creationCode, bytes constructorArgs) internal view returns (address, bytes32)

Find a salt that produces a hook address with the desired flags

Parameters

NameTypeDescription
deployeraddressThe address that will deploy the hook. In forge test, this will be the test contract address(this) or the pranking address In forge script, this should be 0x4e59b44847b379578588920cA78FbF26c0B4956C (CREATE2 Deployer Proxy)
flagsuint160The desired flags for the hook address
creationCodebytesThe creation code of a hook contract. Example: type(Counter).creationCode
constructorArgsbytesThe encoded constructor arguments of a hook contract. Example: abi.encode(address(manager))

Return Values

NameTypeDescription
[0]addresshookAddress salt and corresponding address that was found. The salt can be used in new Hook{salt: salt}(<constructor arguments>)
[1]bytes32

computeAddress

solidity
function computeAddress(address deployer, uint256 salt, bytes creationCode) internal pure returns (address hookAddress)

Precompute a contract address deployed via CREATE2

Parameters

NameTypeDescription
deployeraddressThe address that will deploy the hook. In forge test, this will be the test contract address(this) or the pranking address In forge script, this should be 0x4e59b44847b379578588920cA78FbF26c0B4956C (CREATE2 Deployer Proxy)
saltuint256The salt used to deploy the hook
creationCodebytesThe creation code of a hook contract