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.

Contract Type

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) external

Split accumulated fees for a token: 30% deployer, 10% platform, 60% reinvested as liquidity. Anyone can call. Not for the platform token.

Reverts
  • "Use processPlatformFees" — token is PLATFORM_TOKEN
  • "No position" — token not registered
  • "No fees" — pendingFees is zero
Emits

FeesDistributed(token, total) and potentially Reinvested(token, ethAmount, tokensAdded, liquidityAdded)

processPlatformFees() external

Process accumulated platform fees — 100% goes to platform token liquidity. Anyone can call.

Reverts
  • "Below threshold" — platformBalance < PLATFORM_THRESHOLD
  • "Platform token not graduated" — no LP position
withdrawDeployerFees(token: address) external

Deployer withdraws their accumulated fee share. Deployer only.

Reverts
  • "Not deployer" — msg.sender ≠ tokenInfo[token].deployer
  • "No fees" — deployerBalance is zero
Emits

DeployerWithdrawal(token, deployer, amount)

buyAndBurn(token: address) external

Use 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.

Emits

BuyAndBurn(token, ethSpent)

refreshFeeTier(token: address) external

Force-update the cached fee tier for a token. Anyone can call.

CTO Functions

initiate_cto_vote(token: address) → address payable

Start 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.

Reverts
  • "E021" — insufficient fee
  • "E023" — token not registered
  • "E024" — CTO vote already active for this token
  • "E029" — token transfer failed (not approved)
Emits

CTOVoteInitiated(token, vote_contract, initiator)

finalize_cto(token: address, new_deployer: address) external

Finalize 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 payable

Called 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 external

Taxes buys (ETH → Token). Takes fee from ETH input via PoolManager.take(). Skips fee on internal reinvest swaps.

afterSwap(sender, key, params, swapDelta, hookData) → bytes external

Taxes sells (Token → ETH). Takes fee from ETH output via PoolManager.take(). Skips fee on internal reinvest swaps.

View Functions

FunctionReturnsDescription
getTokenInfo(token)TokenInfoReturns {deployer, positionId}
getPendingFees(token)uint256Undistributed fees in wei
getFeeInfo(token)(uint256, uint256)(currentFeeBps, ethInPool)
isTokenRegistered(token)boolWhether token is graduated and registered
canDistribute(token)boolWhether distributeFees() can be called
canProcessPlatformFees()boolWhether processPlatformFees() can be called
getPoolLiquidity(token)(uint128, uint160, int24)(liquidity, sqrtPrice, tick)
getPoolId(token)bytes32Uniswap V4 pool ID
canInitiateCTO(token)boolWhether a CTO vote can be started
platformBalance()uint256Accumulated platform fees
deployerBalance(token)uint256Deployer's claimable balance
cachedFeeBps(token)uint256Cached fee tier (0 = not cached)
active_cto_votes(token)addressActive vote contract (zero if none)