LiquidityGenHook
The all-in-one post-graduation manager. Implements Uniswap V4 hook callbacks for fee collection, and provides permissionless fee distribution, LP reinvestment, buy-and-burn, and CTO voting.
Singleton — one instance per chain. Implements Uniswap V4 beforeSwap and afterSwap hooks. Fully permissionless — no owner, no admin keys.
Fee Distribution Functions
distributeFees(token: address) externalSplit accumulated fees for a token: 30% deployer, 10% platform, 60% reinvested as liquidity. Anyone can call. Not for the platform token.
"Use processPlatformFees"— token is PLATFORM_TOKEN"No position"— token not registered"No fees"— pendingFees is zero
FeesDistributed(token, total) and potentially Reinvested(token, ethAmount, tokensAdded, liquidityAdded)
processPlatformFees() externalProcess accumulated platform fees — 100% goes to platform token liquidity. Anyone can call.
"Below threshold"— platformBalance < PLATFORM_THRESHOLD"Platform token not graduated"— no LP position
withdrawDeployerFees(token: address) externalDeployer withdraws their accumulated fee share. Deployer only.
"Not deployer"— msg.sender ≠ tokenInfo[token].deployer"No fees"— deployerBalance is zero
DeployerWithdrawal(token, deployer, amount)
buyAndBurn(token: address) externalUse ALL pending fees for a buy-and-burn. Takes 10% platform fee first (unless platform token), then swaps the rest into tokens sent to the dead address. Deployer only.
BuyAndBurn(token, ethSpent)
refreshFeeTier(token: address) externalForce-update the cached fee tier for a token. Anyone can call.
CTO Functions
initiate_cto_vote(token: address) → address payableStart a Community Takeover vote. Requires CTO_VOTE_FEE (0.0001 ETH / 0.0002 BNB) and 60M tokens approved to this contract. Returns the newly cloned vote contract address.
"E021"— insufficient fee"E023"— token not registered"E024"— CTO vote already active for this token"E029"— token transfer failed (not approved)
CTOVoteInitiated(token, vote_contract, initiator)
finalize_cto(token: address, new_deployer: address) externalFinalize a successful CTO vote. Called by the vote contract only. Transfers deployer rights, pays out old deployer, transfers socials ownership.
Graduation Function
createPositionAndRegister(token, deployer) → uint256 payableCalled by BondingCurve during graduation. Creates Uniswap V4 pool + mints LP in single atomic multicall. Returns the LP position ID. Excess ETH above GRADUATION_ETH credited to platformBalance.
Hook Callbacks (called by PoolManager)
beforeSwap(sender, key, params, hookData) → bytes externalTaxes buys (ETH → Token). Takes fee from ETH input via PoolManager.take(). Skips fee on internal reinvest swaps.
afterSwap(sender, key, params, swapDelta, hookData) → bytes externalTaxes sells (Token → ETH). Takes fee from ETH output via PoolManager.take(). Skips fee on internal reinvest swaps.
View Functions
| Function | Returns | Description |
|---|---|---|
getTokenInfo(token) | TokenInfo | Returns {deployer, positionId} |
getPendingFees(token) | uint256 | Undistributed fees in wei |
getFeeInfo(token) | (uint256, uint256) | (currentFeeBps, ethInPool) |
isTokenRegistered(token) | bool | Whether token is graduated and registered |
canDistribute(token) | bool | Whether distributeFees() can be called |
canProcessPlatformFees() | bool | Whether processPlatformFees() can be called |
getPoolLiquidity(token) | (uint128, uint160, int24) | (liquidity, sqrtPrice, tick) |
getPoolId(token) | bytes32 | Uniswap V4 pool ID |
canInitiateCTO(token) | bool | Whether a CTO vote can be started |
platformBalance() | uint256 | Accumulated platform fees |
deployerBalance(token) | uint256 | Deployer's claimable balance |
cachedFeeBps(token) | uint256 | Cached fee tier (0 = not cached) |
active_cto_votes(token) | address | Active vote contract (zero if none) |