# FireLabs USD - FUSD

## Summary

FireLabs USD (FUSD) is a yield-bearing stablecoin fully backed by USDT0 and integrated with Compound v3 (Comet).\
\
When users mint FUSD, their USDT0 is supplied to Compound, where it earns yield.\
The generated yield is automatically converted into DCI, the Firebot ecosystem’s growth and reward token.\
\
FUSD holders continuously earn DCI proportional to their FUSD balance and holding time — no staking, locking, or claiming is required.\
At any time, FUSD can be redeemed 1:1 for USDT0 (minus rounding effects).

## 1. Backing and Peg

* Each FUSD is fully backed by **1 USDT0** supplied to Compound v3 (Polygon USDT0 market).
* The contract ensures the system’s solvency by keeping total FUSD supply ≤ Compound base balance.
* USDT0 can be withdrawn at any time to fulfill redemptions.

FUSD therefore maintains a **1:1 peg with USDT0**, itself pegged to USD.

## 2. Yield Generation and Conversion

1. **Supply:**\
   All deposited USDT0 is supplied to **Compound v3 (Comet)**, which accrues interest automatically.
2. **Yield:**\
   Over time, the Compound balance grows slightly faster than the total FUSD supply due to accrued interest.
3. **Conversion to DCI:**
   * The difference between the Compound balance and the total FUSD supply (“**excess**”) represents accumulated yield.
   * When the excess exceeds **$1**, it is automatically withdrawn and sent to a **trusted oracle-based Issuer**.
   * The Issuer converts USDT0 → DCI using an on-chain oracle price feed.
   * The resulting DCI stays in the FUSD contract and becomes claimable by FUSD holders.
4. **Reward Distribution:**
   * Rewards are distributed over time according to **balance × time** (“points”).
   * The more FUSD you hold, and the longer you hold it, the more DCI you earn.

## 3. Reward Mechanics

#### **Checkpoint System**

* Every mint, redeem, or transfer updates checkpoints for the affected addresses.
* For each user:

  ```
  points[account] += balance * (time since last checkpoint)
  ```
* Globally:

  ```
  totalPoints += totalSupply * (time since last global checkpoint)
  ```

#### **Claiming**

* Anyone can call `claim(address account)` to distribute DCI to a holder.
* The reward for an account is proportional to:

  ```
  rewards = DCI_balance * points[account] / totalPoints
  ```
* Rewards are paid in **DCI** to the account, or to a redirected address if the owner set one.

#### **Buffer Mechanism**

* The contract initializes with a small `totalPoints` buffer (`100,000 * 365 days`) to prevent the total denominator from ever reaching zero.
* This ensures the contract always holds a small DCI reserve and remains claim-safe.

## 4. Contract Flow

#### **Mint**

1. User transfers USDT0 to the FUSD contract.
2. Contract mints equivalent FUSD to the user.
3. Idle USDT0 is supplied to Compound.
4. Contract optionally converts any accumulated yield into DCI.

#### **Redeem**

1. User burns FUSD.
2. Contract withdraws corresponding USDT0 from Compound.
3. USDT0 is transferred back to the user.
4. Yield (if any) is converted into DCI.

#### **Claim**

* Users (or anyone) can call `claim(address)` to receive accumulated DCI rewards.
* Rewards are non-custodial — they accumulate automatically in the contract and can be claimed anytime.

## 5. Safety and Efficiency Features

* ✅ **Fully backed:** Every FUSD corresponds to at least 1 USDT0 in Compound.
* ✅ **Audited dependencies:** Built on OpenZeppelin libraries and Compound v3 (Comet).
* ✅ **Reentrancy protection:** All external functions are guarded by `nonReentrant`.
* ✅ **Automatic gas efficiency:** Converts only when the yield exceeds $1 to avoid rounding losses.
* ✅ **No admin minting:** Owner privileges are limited to reward redirection control and Compound reward collection.
* ✅ **Transparent yield logic:** All balances and checkpoints are on-chain and publicly readable.

## 6. Integration Notes

#### **Key Contract Addresses**

<table><thead><tr><th width="240">Component</th><th>Address</th></tr></thead><tbody><tr><td>FUSD Token</td><td><code>0xf642bB1cf2A474d3976c6D07307D4772B13Ff07E</code></td></tr><tr><td>USDT0 (Polygon)</td><td><code>0xc2132D05D31c914a87C6611C10748AEb04B58e8F</code></td></tr><tr><td>Compound Comet (USDT0)</td><td><code>0xaeB318360f27748Acb200CE616E389A6C9409a07</code></td></tr><tr><td>DCI Token</td><td><code>0xc91953E110EbB0039859304A0d1b64f8450763fC</code></td></tr><tr><td>DCI Issuer</td><td><code>0xf03D690099dbCa0E8787a3223918634696E9Ae50</code></td></tr></tbody></table>

#### **Interfaces**

* FUSD implements `ERC20`, compatible with all standard DeFi integrations.
* Supports standard functions:
  * `mint(uint256)`
  * `redeem(uint256,uint256)`
  * `claim(address)`
  * `convert()`
* Also exposes view-like helper:
  * `previewCompoundRewards()` → shows pending Compound rewards.

## 7. Governance & Ownership

* The owner can:
  * Collect Compound (COMP) rewards via `claimCompoundRewards()`.
  * Redirect DCI rewards for specific addresses (for LPs or partnerships).
* The owner **cannot** mint, seize, or alter user funds or rewards.

Ownership may be transferred to a DAO or multisig for decentralization.

## 8. Summary

| Property           | Description                           |
| ------------------ | ------------------------------------- |
| Token Symbol       | FUSD                                  |
| Backing            | 100% USDT0 supplied to Compound       |
| Yield Conversion   | USDT0 → DCI via Oracle Issuer         |
| Reward Mechanism   | Time-weighted balance (points)        |
| Reward Token       | DCI                                   |
| Minimum Conversion | 1 USDT0                               |
| Audited Base       | OpenZeppelin + Compound v3            |
| Security           | ReentrancyGuard, no arbitrary minting |
