> For the complete documentation index, see [llms.txt](https://docs.fira.money/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fira.money/developers/token-contracts/fw-tokens.md).

# FW Tokens

FW token base contracts and the USDCFW implementation that wraps USDC through an ERC-4626 vault for yield generation.

{% hint style="info" %}
**Source:** `src/fira_bonding/StandardizedYield/FWBase.sol`, `src/fira_bonding/StandardizedYield/implementations/USDCFW.sol`
{% endhint %}

## FWBase

Abstract base that all FW tokens inherit. Extends `FiraERC20Permit`, `TokenHelper`, `BoringOwnableUpgradeable`, and `Pausable`.

### Deposit flow

1. Validate input token via `isValidTokenIn`
2. Transfer tokens in via `_transferIn`
3. Call `_deposit(tokenIn, amount)` — abstract, implemented by derived contracts
4. Mint FW shares to receiver
5. Check `minSharesOut` slippage guard

### Redeem flow

1. Validate output token via `isValidTokenOut`
2. Burn FW shares (or from `address(this)` if `burnFromInternalBalance`)
3. Call `_redeem(receiver, tokenOut, shares)` — abstract
4. Check `minTokenOut` slippage guard

### Pause controls

Three independent mechanisms: `depositsPaused`, `redemptionsPaused`, and global `pause()` (blocks all transfers).

## USDCFW

The production FW implementation. Wraps USDC and earns yield by deploying a portion into an ERC-4626 vault.

### State

* `yieldToken` — USDC address (immutable)
* `vault` — ERC-4626 vault (immutable)
* `idleAssets` / `vaultShares` — Tracked explicitly to prevent donation-based manipulation

### Exchange rate

```
exchangeRate = totalUnderlying / totalSupply
```

Where `totalUnderlying = idleAssets + vault.convertToAssets(vaultShares)`.

### Deposit

USDC deposits are added to `idleAssets`. Vault share deposits are converted to equivalent USDC. First deposit mints 1:1. The market is seeded on deployment to prevent ERC-4626 inflation attacks.

### Redeem

Draws from idle USDC first, then from the vault if needed, minimizing gas costs.

### Rehypothecation

`triggerRehypothecation()` (permissionless) and `forceRehypothecation()` (owner-only) rebalance between idle and vault based on the RehypothecationModule parameters.


---

# 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.fira.money/developers/token-contracts/fw-tokens.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.
