Appearance
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_MASKALL_HOOK_MASK
solidity
uint160 ALL_HOOK_MASKBEFORE_INITIALIZE_FLAG
solidity
uint160 BEFORE_INITIALIZE_FLAGAFTER_INITIALIZE_FLAG
solidity
uint160 AFTER_INITIALIZE_FLAGBEFORE_ADD_LIQUIDITY_FLAG
solidity
uint160 BEFORE_ADD_LIQUIDITY_FLAGAFTER_ADD_LIQUIDITY_FLAG
solidity
uint160 AFTER_ADD_LIQUIDITY_FLAGBEFORE_REMOVE_LIQUIDITY_FLAG
solidity
uint160 BEFORE_REMOVE_LIQUIDITY_FLAGAFTER_REMOVE_LIQUIDITY_FLAG
solidity
uint160 AFTER_REMOVE_LIQUIDITY_FLAGBEFORE_SWAP_FLAG
solidity
uint160 BEFORE_SWAP_FLAGAFTER_SWAP_FLAG
solidity
uint160 AFTER_SWAP_FLAGBEFORE_DONATE_FLAG
solidity
uint160 BEFORE_DONATE_FLAGAFTER_DONATE_FLAG
solidity
uint160 AFTER_DONATE_FLAGBEFORE_SWAP_RETURNS_DELTA_FLAG
solidity
uint160 BEFORE_SWAP_RETURNS_DELTA_FLAGAFTER_SWAP_RETURNS_DELTA_FLAG
solidity
uint160 AFTER_SWAP_RETURNS_DELTA_FLAGAFTER_ADD_LIQUIDITY_RETURNS_DELTA_FLAG
solidity
uint160 AFTER_ADD_LIQUIDITY_RETURNS_DELTA_FLAGAFTER_REMOVE_LIQUIDITY_RETURNS_DELTA_FLAG
solidity
uint160 AFTER_REMOVE_LIQUIDITY_RETURNS_DELTA_FLAGgetAllHookFlags
solidity
function getAllHookFlags() internal pure returns (uint160)MAX_LOOP
solidity
uint256 MAX_LOOPfind
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
| Name | Type | Description |
|---|---|---|
| deployer | address | The 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) |
| flags | uint160 | The desired flags for the hook address |
| creationCode | bytes | The creation code of a hook contract. Example: type(Counter).creationCode |
| constructorArgs | bytes | The encoded constructor arguments of a hook contract. Example: abi.encode(address(manager)) |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | address | hookAddress 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
| Name | Type | Description |
|---|---|---|
| deployer | address | The 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) |
| salt | uint256 | The salt used to deploy the hook |
| creationCode | bytes | The creation code of a hook contract |