# token

basefun ships two token implementations, picked per launchpad version.

## BasefunToken (V1, FactoryV2)

* Plain OpenZeppelin ERC-20.
* 1B supply minted at deploy, all sent to the bonding curve.
* No transfer hooks. Wallet-to-wallet and pair swaps cost 0% in token (the 1% pre-grad fee is taken in USDC by the curve).
* `imageURI`, `description`, `socials` stored on-chain at deploy.

Post-graduation, V1 tokens trade on Uni V2 with **only** the pair's native 0.3% LP fee. There's no ongoing protocol take.

## BasefunTokenV2 (V2, FactoryV3) — current default

Adds **1% fee-on-transfer** on every transfer that touches a registered Uniswap V2 pair, so the protocol/creator continue to earn fees post-graduation.

### Immutable fields

```solidity
address public immutable feeCollector;       // = keeper EOA
address public immutable treasury;           // protocol cut destination (off-chain split)
address public immutable creatorFeeRecipient; // creator cut destination (off-chain split)
uint256 public constant   FEE_BPS = 100;     // 1.00%
```

`feeCollector`, `treasury`, and `creatorFeeRecipient` are baked into the bytecode at deploy. **They cannot be changed.**

### Registered pairs + exempt addresses

```solidity
mapping(address => bool) public isPair;       // pair contracts that trigger FOT
mapping(address => bool) public isExempt;     // addresses skipped by FOT
```

Both controlled exclusively by the factory:

* `setPair(pair, true)` — called right before the Uni V2 `addLiquidity` in `migrateToUniV2`. Without this, FOT does nothing.
* `setExempt(addr, true)` — set at deploy for: curve, factory, feeCollector, treasury, creator, `0xdead`.

The setExempt list keeps the LP-seed `addLiquidity` from paying fees on the way in (otherwise the pair would receive 99% of the intended tokens and the seed math would be off).

### Transfer hook

In every `_update(from, to, value)`:

```solidity
if (!isExempt[from] && !isExempt[to]
    && (isPair[from] || isPair[to])) {
    uint256 fee = (value * FEE_BPS) / 10_000;     // 1.00%
    super._update(from, feeCollector, fee);       // skim 1%
    value -= fee;
}
super._update(from, to, value);                    // remaining 99%
```

So a Uni V2 buy emits **two** Transfer events:

```
pair → user      = 99% (your tokens out)
pair → keeper    = 1%  (the fee skim)
```

And a sell:

```
user → pair      = 99%
user → keeper    = 1%
```

The keeper then sweeps its accumulated balance — see [Keeper bot](broken://pages/ab2e04f2e1a5e5bc6e904c617917bb21b3319dd9) and [Fees post-bond](broken://pages/4a57e3da8c1f1277bc221ed972c454a8791b7fc5).

### Why FOT instead of taxing the LP

The Uni V2 LP fee (0.3%) is fixed by the protocol and goes entirely to LPs. basefun's LP is **burned at 0xdead**, so that 0.3% effectively vanishes from circulation (it accumulates inside the pair as price impact for everyone). The 1% FOT is the only way for basefun + creator to capture continued post-grad revenue without dumping LP control.

### Verifying constructor args

V2 token bytecode is parameterized by `(name, symbol, imageURI, description, socials, curve, treasury, creatorFeeRecipient)`. The indexer reads the last three from the deployed bytecode's immutable storage and passes them to BaseScan for source verification.


---

# 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/token.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.
