# Staking & Unstaking Process

<figure><img src="https://3157490457-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhRRAl1ruYT1ocCVUHNcn%2Fuploads%2FsTGATByUfGjXKXSu9KPX%2FChatGPT%20Image%20Apr%201%2C%202025%2C%2012_43_33%20PM.png?alt=media&#x26;token=d2cd88df-09d7-4c13-9885-8209c1b1ad62" alt=""><figcaption></figcaption></figure>

The above diagram illustrates the journey of EAI tokens through the staking lifecycle in the contract:<br>

1. **Staking During Epoch N**
   * A user stakes EAI tokens.
   * If staking occurs **mid-epoch**, tokens are placed in the **Pending Stake** pool.
2. **Pending Stake**
   * These tokens are **not eligible for rewards** during the current epoch.
   * They remain here until the epoch rolls over.
3. **Epoch Transition**
   * At the start of a new epoch (Epoch N+1), the epoch number and end time are updated. The tokens are migrated from `pendingStake → lockedStake`.
4. **Locked Stake**
   * Tokens moved here become **eligible for rewards** in EAI and/or USDC.
   * Rewards are calculated proportionally based on each user's `lockedStake`.
5. **Claim Rewards**
   * Users can claim their rewards via `Rewards`  section of TradeDividends
6. **Unstaking**
   * When users unstake:
     * It removes from **pending stake first** (no impact on rewards).
     * Then from **locked stake** if necessary \
       (reduces eligible reward amount if done before claiming).
