Hook behavior and fees
MemeHook enables beforeInitialize, afterSwap, and afterSwapReturnDelta. The last flag allows the swap callback to return a fee delta to PoolManager; it is not a separate lifecycle stage.
Initialization
The configured GraduationExecutor first registers the expected key and initialization price. beforeInitialize accepts calls only from PoolManager and verifies the prepared state, executor sender, expected initial price and zero core fee. An unrelated pool cannot simply attach itself to the shared Hook.
Other callbacks are disabled in the Hook permission bits. Their Solidity stubs revert if called directly, but PoolManager does not dispatch those callbacks for this Hook. The disabled callbacks do not independently restrict normal swaps, liquidity changes or donations.
Swap charging
The current base protocol fee is 1% (100 bps). It is collected by BondingCurve during the bonding curve phase and by MemeHook after graduation. Creator Tax is configured separately.
afterSwap requires an active official pool. It selects the swap's unspecified currency, calculates Hook Fee and Creator Tax separately with floor rounding, takes their sum into the Hook and returns that positive fee delta. PoolManager incorporates it into the caller's settlement.
The unspecified currency is the output for exact-input swaps and the input for exact-output swaps. “Buy” below means quote token in and launch token out.
Trade
amountSpecified
Fee currency
User effect
Buy, exact input
Negative quote amount
Launch token output
Receive output minus Hook Fee and Creator Tax
Sell, exact input
Negative launch-token amount
Quote output
Receive output minus Hook Fee and Creator Tax
Buy, exact output
Positive launch-token amount
Quote input
Pay required quote input plus Hook Fee and Creator Tax
Sell, exact output
Positive quote amount
Launch token input
Pay required token input plus Hook Fee and Creator Tax
For either token ordering, zeroForOne selects currency0 input versus currency1 input. Do not assume currency0 is always the quote asset. The table describes V4 Hook semantics; the current Aggregator V4 adapter executes exact-input swaps even when the API was asked for an output-targeted quote.
Fee calculation
basis = absolute value of the unspecified-currency pre-Hook delta
hookFee = floor(basis * hookFeeBps / 10000)
creatorTax = floor(basis * creatorTaxBps / 10000)
totalFee = hookFee + creatorTaxExample: basis 1,000,000, Hook Fee 100 bps (1%), Creator Tax 200 bps (2%). Hook Fee is 10,000, Creator Tax is 20,000, total is 30,000 raw units of the fee currency. An exact-input swap with that pre-Hook output delivers 970,000. An exact-output swap with that pre-Hook input requires 1,030,000 input units. These are fee arithmetic examples, not exchange-rate quotes.
The two fees are floored separately. For small amounts, floor(basis * (hookFeeBps + creatorTaxBps) / 10000) can differ from the actual sum. Do not use floating-point token amounts or subtract fees twice from a quote already produced with Hook accounting.
Allocation of the Hook Fee
Using the example above, a 30% protocol share, a 20% Partner share of the protocol bucket, and a 50% buyback share of the creator bucket produce:
Protocol net
2400
Partner
600
Buyback budget
3500
Creator, including Creator Tax
23500
Total
30000
Creator Tax goes entirely to the creator; it is not split again into protocol, Partner or buyback. Pool configuration snapshots determine rates. Read poolConfig(poolId) for the actual launch; current factory defaults do not rewrite an existing pool's fee snapshot. Creator recipient and buyback-enabled state can change through their authorized controls.
Internal swaps and accounting
When the Hook itself initiates conversion or buyback, its afterSwap branch returns zero additional Hook fee, avoiding recursive self-charging. This exemption is tied to the Hook sender and is not something a third-party Router can request using hookData.
Fees can accumulate in both currencies. Collection does not immediately make them withdrawable: the Hook records pending allocations, then settlement converts launch-token fees and credits recipients. Continue with Fee settlement and state.
Last updated
Was this helpful?