> For the complete documentation index, see [llms.txt](https://docs.peach.ag/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.peach.ag/documentation/arc/launchpad/launchpad-classic/core-features/uniswap-v4-hooks/hook-behavior-and-fees.md).

# 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 + creatorTax
```

Example: 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

```
protocolGross   = floor(hookFee * protocolFeeShareBps / 10000)
creatorGross    = hookFee - protocolGross
partnerFee      = floor(protocolGross * activePartnerShareBps / 10000)
protocolNet     = protocolGross - partnerFee
buybackBudget   = buybackEnabled ? floor(creatorGross * buybackBurnBps / 10000) : 0
creatorImmediate = creatorGross - buybackBudget
creatorPendingIncrease = creatorImmediate + creatorTax
```

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:

| Pending allocation             | Raw amount |
| ------------------------------ | ---------- |
| 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](https://docs.peach.ag/documentation/arc/launchpad/core-features/uniswap-v4-hooks/fee-settlement-and-state).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.peach.ag/documentation/arc/launchpad/launchpad-classic/core-features/uniswap-v4-hooks/hook-behavior-and-fees.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
