Documentation · Learn
Fee anatomy
Which fees a GENE swap pays, who receives each one, and how the protocol collects its share into reserves.
Uniswap distinguishes three kinds of swap fee: the LP fee, which pays liquidity providers; the protocol fee, which Uniswap governance can enable; and a hook fee, which a hook contract takes for itself (Uniswap: fees). A GENE swap can pay the first two. It never pays the third.
| Fee | Set by | Received by | In GENE |
|---|---|---|---|
| LP fee | the PoolKey, static | liquidity providers in range | the hook's positions, because the hook is the only provider |
| Uniswap protocol fee | Uniswap governance | the Uniswap protocol | outside GENE's control |
| Hook fee | a hook's own code | the hook | none |
#The LP fee
The pool's LP fee is fixed in the PoolKey (parameters) and is static: GeneHook contains no call that changes it (Genome.sol:16; GeneHook.sol:26-27, :239). Uniswap v4 charges it on the input token of every swap: ETH on buys, GENE on sells.
Liquidity providers in range earn that fee. Because the hook rejects every outside liquidity add, the hook is the pool's only liquidity provider, and the whole LP fee accrues to its positions (GeneHook.sol:337-343).
#The Uniswap protocol fee
Uniswap governance may enable a protocol fee on v4 pools, up to a cap set in v4 core (ProtocolFeeLibrary.sol:8). The PoolManager takes it; GENE receives none of it and cannot switch it on or off.
#No hook fee
GENE takes no hook fee. beforeSwap returns a zero delta and no fee override, and afterSwap returns zero, so the hook never changes what a swap pays or receives (GeneHook.sol:365, :389).
#Revenue is a metric, not the fees collected
Each epoch record has a revenue field. It is the LP-fee share of the ETH buyers paid in, counted on buys only (GeneHook.sol:76, :385-387). It is recorded as evidence for gene conditions and to size the churn tier. It is not the amount of fees collected: sell-side fees are paid in GENE and do not appear in it, and nothing is collected when it is recorded.
Example: a buy that pays 10 ETH into the pool, at a 1% LP fee, adds 0.1 ETH to the epoch's revenue metric. A sell of GENE adds nothing to it, although it also pays the LP fee.
#How fees are collected
Fees accrue inside the protocol's positions until someone calls metabolize(). Nobody else can collect them, because a zero-liquidity call by another address touches only that caller's own empty position.
- Harvest.
metabolize()pokes the genesis position and up to a fixed number of registry positions in rotation (parameters) with zero-liquiditymodifyLiquiditycalls, which return accrued fees only (GeneHook.sol:669-697). - Credit. ETH fees go to
ethReserve. Once REGENERATION is expressed, a fixed share (parameters) goes toregenReserveinstead. GENE fees go togeneReserve(GeneHook.sol:707-718). Fees collected automatically when the hook adds to an existing position are credited the same way (GeneHook.sol:554-559). - Place. Within the same call, reserves become new protocol liquidity under per-epoch budgets and caps (GeneHook.sol:458-476). See net-flow budgets. ETH above the budgets stays in
ethReserve. - Settle. The call nets fees collected against principal added and mints or burns the difference as the hook's own ERC-6909 claims at the PoolManager, so the unlock closes with zero delta (GeneHook.sol:720-725; Uniswap: ERC-6909).
The reserves are public views on GeneHook (GeneHook.sol:181-183). The hook never takes ETH out of the PoolManager, and takes GENE only to itself, to burn it (GeneHook.sol:30-31). See Protocol for the accounting in detail.
Sources (14)
- src/Genome.sol:16
- src/GeneHook.sol:26-31
- src/GeneHook.sol:76
- src/GeneHook.sol:181-183
- src/GeneHook.sol:236-242
- src/GeneHook.sol:337-343
- src/GeneHook.sol:365
- src/GeneHook.sol:385-389
- src/GeneHook.sol:458-476
- src/GeneHook.sol:554-559
- src/GeneHook.sol:669-725
- lib/v4-core/src/libraries/ProtocolFeeLibrary.sol:8
- https://developers.uniswap.org/docs/get-started/concepts/fees
- https://developers.uniswap.org/docs/protocols/v4/concepts/erc-6909
Paths are relative to the GENE repository at tag rc4-audit-candidate (aca5fcd).