# fees pre bond

While a token is still trading on the bonding curve (i.e. `graduated == false`), the fee model is **simple, inline, and always in USDC**.

## Rate

| Component    | Rate      | Destination                                         |
| ------------ | --------- | --------------------------------------------------- |
| Protocol fee | **0.50%** | `protocolFeeRecipient` (treasury EOA)               |
| Creator fee  | **0.50%** | `creatorFeeRecipient` (chosen at deploy, immutable) |
| **Total**    | **1.00%** | —                                                   |

Set in `BondingCurveV2.sol`:

```solidity
uint256 public constant SWAP_FEE_BPS    = 100;  // 1.00%
uint256 public constant PROTOCOL_FEE_BPS = 50;  // 0.50% to treasury
// creator fee = SWAP_FEE_BPS - PROTOCOL_FEE_BPS = 50 = 0.50%
```

## How the fee is taken

In `_buyFor` (called by `buy` and `initialBuy`):

```solidity
usdc.safeTransferFrom(payer, address(this), usdcAmount);   // gross in

(uint256 netUSDC, uint256 protoFee, uint256 creatorFee) = _splitFees(usdcAmount);
if (protoFee   > 0) usdc.safeTransfer(protocolFeeRecipient, protoFee);
if (creatorFee > 0) usdc.safeTransfer(creatorFeeRecipient,  creatorFee);

// rest of the curve math uses netUSDC
```

In `sell`:

```solidity
// curve already has the USDC from LT.redeem
(uint256 netUSDC, uint256 protoFee, uint256 creatorFee) = _splitFees(usdcGross);
require(netUSDC >= minUSDCOut, "slippage");
if (protoFee   > 0) usdc.safeTransfer(protocolFeeRecipient, protoFee);
if (creatorFee > 0) usdc.safeTransfer(creatorFeeRecipient,  creatorFee);
usdc.safeTransfer(msg.sender, netUSDC);
```

## Properties

* **Same transaction.** Both fee recipients are paid before the trade completes. No off-chain process, no claim step, no delayed batch.
* **In USDC.** Not in token. The fee asset doesn't depend on the token's price.
* **No accumulation, no "pending fees" surface.** Earnings are spendable the instant a trade lands.
* **Treasury can be rotated.** Factory owner can call `setProtocolFeeRecipient(newAddr)`, but this **only affects tokens created after the change**. Curves already deployed have a snapshot of `protocolFeeRecipient` from their constructor.
* **Creator recipient cannot be rotated.** The address baked into the curve at deploy is `immutable`.

## Worked example — $100 USDC buy

```
usdcAmount  = $100.00
protoFee    = $100 × 50  / 10_000 = $0.50  →  treasury
creatorFee  = $100 × 100 / 10_000 - $0.50 = $0.50  →  creator
netUSDC     = $100 - $1 = $99.00
```

After fee split:

* Treasury earns **$0.50**.
* Creator earns **$0.50**.
* Curve mints LT against the remaining **$99** and gives the buyer the appropriate tokens.

## Worked example — sell 5,000,000 tokens

Assume the curve quotes `usdcGross = $20.00` for that token amount.

```
protoFee   = $20 × 50  / 10_000 = $0.10  →  treasury
creatorFee = $20 × 100 / 10_000 - $0.10 = $0.10  →  creator
netUSDC    = $20 - $0.20 = $19.80
```

After fee split:

* Treasury earns **$0.10**.
* Creator earns **$0.10**.
* Seller receives **$19.80**, after the LT.redeem brought $20 back from the keeper.

## Where to inspect on-chain

Each `Bought` and `Sold` event emits `usdcIn`/`usdcOut`, but the actual fee transfers are visible as two `Transfer` events on the USDC contract per trade:

```
Transfer(curve, protocolFeeRecipient, protoFee)
Transfer(curve, creatorFeeRecipient,   creatorFee)
```

Searching USDC Transfers `from = curve` filtered by trade tx hash is the cleanest audit path.


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://basefun.gitbook.io/basefun-docs/fees-pre-bond.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
