# 8. Earn System

### 8.1 Overview

The **Earn System** enables users to generate yield through two core mechanisms:

* **Farms (MOORCraftsmanV2)** – Stake LP or single-asset tokens to earn **MOOR** rewards from pre-funded pools (no token minting).
* **Auto-Vault (MOORVaultV2)** – Stake **MOOR** to earn automatically compounded rewards with public harvest bounties.

Both contracts are designed for **fixed-supply tokenomics**, transparent fee structures, and robust anti-abuse protection.

***

### 8.2 Contracts (Cronos Mainnet)

All Earn System contracts are deployed and verified on Cronos Mainnet.

| Contract            | Role                                                             | Address                                      | Explorer                                                                                                  |
| ------------------- | ---------------------------------------------------------------- | -------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| **MOORCraftsmanV2** | Budget-based farming contract managing multiple pools and epochs | `0x8eB6B2F5fda6ec6b459d6C92Ecb0F0ebef246Fa0` | [View on Cronos Explorer](https://explorer.cronos.org/address/0x8eB6B2F5fda6ec6b459d6C92Ecb0F0ebef246Fa0) |
| **MOORVaultV2**     | Auto-compounding vault for MOOR staking (Pool #0)                | `0x548620cE72691b490fD219679829068aa290bB2e` | [View on Cronos Explorer](https://explorer.cronos.org/address/0x548620cE72691b490fD219679829068aa290bB2e) |
| **MOOR Token**      | Native governance and reward token                               | `0xFAB5129E3A137032c0dDB55F07a980C963e387e5` | [View on Cronos Explorer](https://explorer.cronos.org/address/0xFAB5129E3A137032c0dDB55F07a980C963e387e5) |

***

### 8.3 MOORCraftsmanV2 (Farms)

#### Design Goals

* **Budget-based emissions**: Rewards distributed per block from pre-funded MOOR budgets (no minting).
* **Dynamic pools**: Any ERC-20 (LP or single asset) can be whitelisted.
* **Epoch system**: Each pool runs for a fixed block range, with configurable budgets and durations.

#### Core Data Structures

```solidity
struct PoolInfo {
  IERC20 stakeToken;
  uint256 totalBudget;
  uint256 rewardPerBlock;
  uint256 startBlock;
  uint256 endBlock;
  uint256 lastRewardBlock;
  uint256 accMoorPerShare;
  uint256 totalDistributed;
  uint256 currentEpoch;
  uint256 lifetimeDistributed;
  bool active;
}
```

```solidity
struct UserInfo {
  uint256 amount;
  uint256 rewardDebt;
  uint64  lastDepositAt;
}
```

**Pending reward:**\
`pending = (user.amount * accMoorPerShare / 1e12) - user.rewardDebt`

#### User Flow

1. **Deposit:** Approve and stake tokens; auto-harvests pending MOOR.
2. **Harvest:** Claim MOOR without withdrawing.
3. **Withdraw:** Unstake and harvest rewards, or use emergency mode for instant exit.

#### Protections

* **Anti-flash-loan:** 10-minute minimum stake time (except whitelisted contracts).
* **Budget safety:** Pools require the budgeted MOOR to be pre-deposited.
* **Reentrancy guards** and **SafeERC20** enforced on all transfers.
* **Whitelist system** for vault/strategy contracts.

#### Fees (Farms)

* **Dev/Treasury Fee:** 10% of the total pool budget (capped at 20%).
  * Deducted from the **budget**, not user funds.
  * Displayed transparently in APR metrics.

**Example:**\
If a pool has 100,000 MOOR budget → 90,000 MOOR for farmers + 10,000 MOOR for treasury.

***

### 8.4 MOORVaultV2 (Auto-Compounding Vault)

#### Design Goals

* Auto-compound rewards from **Craftsman Pool #0** for higher APY.
* Permissionless **harvest()** with a bounty incentive.
* Gas-efficient, share-based accounting for fair reward distribution.

#### Core Structures

```solidity
struct UserInfo {
  uint256 shares;
  uint64  lastDepositedAt;
  uint256 moorAtLastUserAction;
  uint64  lastUserActionAt;
}
```

**Share price:** `pricePerShare = vaultBalance / totalShares`

The first deposit burns a **MINIMUM\_LIQUIDITY** (1000 wei MOOR) to prevent share inflation exploits.

#### Harvest Flow

1. Harvest MOOR from **Craftsman Pool #0**.
2. Deduct **performance fee (2%)** → Treasury.
3. Pay **call fee (0.25%)** → Harvest caller.
4. Compound remaining rewards back into the vault.

#### Fees (Vault)

| Type              | Default | Cap | Applies On                | Recipient |
| ----------------- | ------- | --- | ------------------------- | --------- |
| Performance Fee   | 2%      | 5%  | Harvested rewards         | Treasury  |
| Call Fee (Bounty) | 0.25%   | 1%  | Harvested rewards         | Caller    |
| Withdrawal Fee    | 2%      | 2%  | Within 72 h after deposit | Treasury  |

After 72 h, withdrawals are **fee-free**.

#### Compounding Model

Approximate APY:

```
aprAfterFees = baseAPR × (1 - performanceFee)
apy ≈ (1 + aprAfterFees/365)^365 - 1
```

Example: 100% base APR → \~166% APY with daily compounding.

#### Protections

* Reentrancy guards and SafeERC20 throughout.
* Inflation protection via burned minimum liquidity.
* Withdrawal-fee window discourages short-term churn.
* Emergency functions allow safe unwinding and recovery.

***

### 8.5 Parameters & Caps (Launch Configuration)

| Parameter          | Contract  | Default       | Max Cap    |
| ------------------ | --------- | ------------- | ---------- |
| Dev Fee            | Craftsman | 10%           | 20%        |
| Minimum Stake Time | Craftsman | 10 minutes    | 10 minutes |
| Performance Fee    | Vault     | 2%            | 5%         |
| Call Fee (Bounty)  | Vault     | 0.25%         | 1%         |
| Withdrawal Fee     | Vault     | 2% (≤ 72 h)   | 2%         |
| Burned Liquidity   | Vault     | 1000 wei MOOR | Fixed      |

> All fee parameters are **on-chain enforced** and visible through the front-end.

***

### 8.6 User Interface

The Earn page includes:

* Tabs for **Auto-Vault**, **Farms**, **Finished**, and **Positions**.
* One-click **MAX**, approval, and harvest buttons.
* Real-time updates for pending rewards, APR/APY, and epoch progress.
* Visible bounty buttons for public compound calls.
* Toast and modal feedback for all transactions.

***

### 8.7 Developer Notes

* All events (`Deposit`, `Withdraw`, `Harvest`, `StartEpoch`, `EndEpoch`) are indexed for analytics and APIs.
* Helpers exposed for querying pool data, share prices, and pending rewards.
* Admin actions limited to **pause**, **emergencyWithdraw**, and **parameter management**.
* Recommended post-TGE: migrate control to a **multi-sig** for treasury and contract governance.

***

**The MOOR Earn System** provides a sustainable, secure, and transparent way for users to generate yield within the MOOR • FINANCE ecosystem — fully on-chain, non-custodial, and optimized for Cronos performance.


---

# 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://moor-finance.gitbook.io/moor-finance-docs/8.-earn-system.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.
