> ## Documentation Index
> Fetch the complete documentation index at: https://pons-labs-llc.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Fees and claims

> Where a v2 launch's fees sit, how they reach the escrow, how creators claim, and how the fee recipient changes.

Fees are never pushed to a wallet. They move in two stages, and an interface
that reads only the last one understates what a creator is owed.

**1. Accrue**

Each trade's fee accrues where the trade happened: on the launch's curve
before graduation, on the hook after it.

**2. Sweep**

A sweep splits the accrued fee into protocol, buyback and creator shares,
credits the escrow, and locks any bought-back tokens in the vault.

**3. Claim**

The recipient withdraws from the escrow whenever they like.

## Sweeps

| Before graduation | After graduation |
| - | - |
| `sweepFees(minBuybackTokensOut)` on the curve | `sweepPoolFees(poolId, minConversionQuoteOut, minBuybackTokensOut)` on the hook |

A sweep that needs an internal swap, to execute a buyback or to convert fees
collected in the launch token, can only be run by the protocol's sweep operator.
A creator calling it then gets `InternalSwapRequiresOperator`. A creator can
sweep alone only when no swap is needed.

The operator is a relay contract,
`0xa1018c1D9655292A2dE0F7dEa9a0F848EaA8cA83`, whose `sweepPool` and `sweepCurve`
anyone can call. It applies a TWAP price guard and a cooldown of one hour per
pool and 30 minutes per curve.

Conversions are capped at a 3% move of the pool's square-root price, about 6% in
price. A conversion or buyback that cannot fill within that is left pending, or
for a buyback, paid to the creator.

To show a creator their full position, add the unswept amounts to the escrow
balance: `quoteFeeBalance()` and `creatorTaxBalance()` on the curve, or
`pendingFees(poolId, currency)` and `pendingCreatorTax(poolId, currency)` on the
hook.

## Claiming

The escrow keeps an ETH ledger and a per-token ledger. An ETH launch credits the
first. An ERC-20 launch credits the second under its quote asset, and a released
vest credits it under the launch token. Each balance is claimed separately.

Balances are also per stack: a token from an [older stack](https://pons-labs-llc.mintlify.site/developers/contracts.md#older-v2-stacks)
pays into that stack's escrow.

```ts theme={null}
const escrowAbi = parseAbi([
  "function balanceOf(address recipient) view returns (uint256)",
  "function balanceOfToken(address recipient, address token) view returns (uint256)",
  "function claim()",
  "function claimToken(address token)",
]);

const ethOwed = await client.readContract({ address: feeEscrow, abi: escrowAbi, functionName: "balanceOf", args: [creator] });
const assetOwed = await client.readContract({ address: feeEscrow, abi: escrowAbi, functionName: "balanceOfToken", args: [creator, quoteAsset] });

if (ethOwed > 0n) await wallet.writeContract({ address: feeEscrow, abi: escrowAbi, functionName: "claim" });
if (assetOwed > 0n) await wallet.writeContract({ address: feeEscrow, abi: escrowAbi, functionName: "claimToken", args: [quoteAsset] });
```

Partial claims exist too: `claim(uint256 amount)` and
`claimToken(address token, uint256 amount)`.

## Changing the fee recipient

`transferCreatorFeeRecipient(token, newRecipient)` on the factory, callable only
by the current recipient (`NotCreatorFeeRecipient` otherwise). It takes effect at
once, before or after graduation, and moves:

* every fee accrued but not yet swept, since a sweep pays whoever is the
  recipient at that moment;
* the whole buyback vest, including tokens vested but not yet released.

Only balances already credited to the escrow stay with the old wallet. Claim
those first.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.