Index / Liquidity lock
pattern · MIT · last updated 2026-08-27
Liquidity lock
afterAddLiquidity sets unlock time; beforeRemoveLiquidity reverts until lock expires.
First-party rewrite inspired by Hookathon C1 LiquidityLock / timelock LP. lockDuration is added to block.timestamp on each net add keyed by the liquidity sender (router in tests). Removes revert with StillLocked until unlock. Launchpad LP commitment pattern. Listing is not an audit.
Permission bits
These bits must match the deployed address. Confirm on-chain before you route.
afterAddLiquiditybeforeRemoveLiquidity
Solidity
Excerpt from contracts/LiquidityLock.sol. Copy the full file to implement this. Not an audit.
function getHookPermissions() public pure override returns (Hooks.Permissions memory) {
return Hooks.Permissions({
beforeInitialize: false,
afterInitialize: false,
beforeAddLiquidity: false,
afterAddLiquidity: true,
beforeRemoveLiquidity: true,
afterRemoveLiquidity: false,
beforeSwap: false,
afterSwap: false,
beforeDonate: false,
afterDonate: false,
beforeSwapReturnDelta: false,
afterSwapReturnDelta: false,
afterAddLiquidityReturnDelta: false,
afterRemoveLiquidityReturnDelta: false
});
}Spec
| Kind | pattern |
|---|---|
| Status | experimental |
| License | MIT |
| Source | https://github.com/CryptoGnome/v4hooks |
| Categories | LaunchpadsLP management |
| Properties | Vanilla swap |
| Chains | Ethereum |
FAQ
Can I paste this into production? The snippet is an excerpt. Use the full file at the source URL, match flags to the address, and treat this page as a map, not a guarantee.
How do I build this safely? Start with secure v4 hooks and the OpenZeppelin hooks guide.