RainbowHook on MegaETH
Uniswap v4 Hook Contract 0xd57f34d5681230924880fb5f648d7e88f2d120cc on MegaETH · Launchpad · Verified contract
- Volume (24h)
- $0
- Value locked (TVL)
- $0
- All-time volume
- $0
- Pools using this hook
- 2
- Swaps (24h)
- 0 (0 traders)
- Total swaps
- 3
What it does
A fee hook for RainbowFun launch pools that charges a fixed rate, up to 10%, on the pair-asset side of every swap and never on the coin, minting the fee to the vault as ERC-6909 claims.
This read was written for the hook 0x33e7…60cc on Unichain and reused here: the two share a code shape, so constants such as fees, owners and addresses can differ.
How it works step by step
- Charges a fixed fee, capped at 10%, on the quote (pair asset) leg of every swap so the coin is never sold to pay fees.
- Selects beforeSwap or afterSwap depending on whether the quote is the specified or unspecified currency of the swap.
- Mints the fee as ERC-6909 claims on the pool manager directly to the vault, so no token transfer happens inside the swap.
- Tracks per-pool unclaimed and cumulative fee totals and lets the vault release a pool's ledger.
- Restricts pool initialisation to the vault's current launchpad by blocking beforeInitialize and requiring initializePool.
- Swap behaviour
- beforeSwap and afterSwap each charge the quote-leg fee on the side that is the pair asset. Exact-input buys and exact-output sells are charged in beforeSwap; exact-output buys and exact-input sells are charged in afterSwap. The fee is minted to the vault and the hook returns a matching delta so it ends each swap with no balance. Swaps by the vault itself are not charged.
- Liquidity behaviour
- No liquidity callbacks. Liquidity add/remove and donations are not hooked and are handled by the standard pool manager.
- Fee behaviour
- Fixed per-pool rate in hundredths of a bip (cap 10%), charged only on the pair-asset (quote) leg of every swap, never on the coin. On exact-input buys and exact-output sells the fee is taken in beforeSwap on the specified leg; on exact-output buys and exact-input sells it is taken in afterSwap on the unspecified leg. Fees are minted as ERC-6909 claims to the vault. The vault itself is exempt from the fee.
- Owner & admin controls
- No owner or pause. The only privileged parties are the vault (sole caller of release and exempt from fees) and the vault's current launchpad (sole caller of initializePool). Fee rates are fixed at pool creation with a hard cap of 10% (MAX_FEE) and there is no setter; poolManager and vault are immutable.
Enabled Uniswap v4 callbacks
beforeInitialize, beforeSwap, afterSwap, beforeSwapReturnDelta, afterSwapReturnDelta
beforeInitialize reverts for every external caller so pools can only be opened through initializePool. beforeSwap returns a specified-currency delta equal to the quote-leg fee on the appropriate swap direction. afterSwap returns an unspecified-currency delta equal to the quote-leg fee on the other swap direction. beforeSwapReturnDelta and afterSwapReturnDelta permit those deltas to be returned.
Security & trust assessment
Risk level: low (verified source, high confidence).
Who controls it: No owner key. The vault controls release of per-pool ledgers and is the only address exempt from fees. The launchpad controls which pools get opened and at what fee within the 10% cap, but cannot change a pool's fee after creation. Because the vault address is immutable and the launchpad is read from the vault, a compromised or malicious launchpad could open pools with arbitrary rates up to 10%.
Risk to user funds: The hook never holds, transfers or blocks tokens. Fees are minted as ERC-6909 claims to the vault inside the swap and the swap nets to zero for the hook. Users are exposed to a fee of up to 10% on the quote leg of each swap, and to the partial-fill edge case on exact-input buys with price limits.
Security findings
- [info] Immutable fee rate with hard cap: Fee rate is set once in initializePool and cannot be changed. Rate is capped at MAX_FEE of 100000 (10%), enforced in code.
- [low] Fee charged on full specified input when swap is partially filled: The hook takes the quote-leg fee in beforeSwap on exact-input buys before the swap runs, so a caller with a price limit that stops the swap part-way pays the fee on the full specified input. The source documents this trade-off and states routers either set no limit or are exempt.
- [low] Vault exempted from fee: The vault is exempt from fees via sender == vault. Any address able to make the vault swap, or any change to the vault contract, would bypass the charge for that flow.
- [medium] Pool creation gated by external launchpad reference: initializePool trusts IRainbowHookVault(vault).launchpad() as the sole authorised opener. A malicious or compromised launchpad could create pools naming this hook with rates up to 10%.
Contract details
- Verified source
- Yes (RainbowHook)
- Compiler
- solc 0.8.30+commit.73712a01
- Bytecode size
- 5,860 bytes
- Upgradeable proxy
- No
- Detected patterns
- erc6909-claims, launchpad, liquidity-management, return-delta
Pools using RainbowHook
- TEST / FLUFFEY (0.00% fee) — 24h volume $0, TVL $0, 0 swaps today
- TEST / FLUFFEY (0.00% fee) — 24h volume $0, TVL $0, 0 swaps today