DropHook
The Uniswap v4 hook of all launch pools.
DropHook is the hook of every launch pool. The launchpad deploys it in its constructor, so each launchpad has one hook.
Permissions
The hook uses four Uniswap v4 hook functions. Uniswap v4 reads them from the low bits of the hook address.
| Hook function | Behavior |
|---|---|
beforeInitialize | Only the launchpad can initialize a pool. Starts the pool's collection schedule. |
beforeAddLiquidity | Only the launchpad can add liquidity. |
beforeRemoveLiquidity | Allows only changes of zero liquidity, which collect fees. All other removals revert. |
afterSwap | Collects fees on schedule, then emits DropSwap. Does not change the swap amounts. |
The hook does not use beforeSwap, and it does not return deltas.
Fee collection
After each swap, the hook collects the pool's fees if both are true:
- The pool's LP fee is more than zero.
- At least 12 hours have passed since
collectedAt(poolId).
The hook then calls collectSwapFees on the launchpad and sets collectedAt(poolId) to the block timestamp.
Functions
| Function | Returns |
|---|---|
launchpad() | The launchpad that deployed the hook. |
poolManager() | The Uniswap v4 PoolManager. |
collectedAt(poolId) | The time of the pool's last automatic collection, or the time the pool was created. |
Events
event DropSwap(
PoolId indexed poolId,
int128 amount0,
int128 amount1,
uint160 sqrtPriceX96
);Emitted after each swap in a launch pool, including dev buys. The amounts are the swap delta from the swapper's side:
negative is paid into the pool, positive is paid out. sqrtPriceX96 is the price after the swap.
Errors
| Error | Cause |
|---|---|
DropHook__InvalidInitializationSender | A pool with this hook is initialized by another address. |
DropHook__LiquidityLocked | Another address adds liquidity, or anyone removes liquidity. |