RealmAi
  • Introduction
    • Overview
    • Core Components
  • System Architecture
    • AI Valuation Engine
    • Tokenization Process
    • RealmAi Gov Framework
    • Security & Compliance
    • AI-Powered Asset Analysis for Tokenization
    • Tokenization Viability Scoring (TVS)
    • AIE
    • Tokenization Protocol
    • Solana Integration
  • $RAi Token
    • $RAi Token
    • Roadmap
  • REALM DAPP
    • Asset Portal v1.0
    • Asset Portal v1.2
    • Earn While Hodling
    • API Reference
  • Links & resources
    • RealmAi
Powered by GitBook
On this page
  • RealmAi's 'Earn While Hodling' Staking Program: Technical Documentation
  • 1. Introduction
  • 2. Program Overview
  • 3. Smart Contract Architecture
  • 4. Staking Mechanism
  • 5. Reward Distribution
  • 6. Unstaking Process
  • 7. Security Measures
  • 8. Upgradability
  • 9. Gas Optimization
  • 10. Testing and Auditing
  • 11. Future Enhancements
  • 12. Conclusion
  1. REALM DAPP

Earn While Hodling

RealmAi's 'Earn While Hodling' Staking Program: Technical Documentation

1. Introduction

The 'Earn While Hodling' staking program is a key feature of the RealmAi ecosystem, designed to incentivize long-term holding of $RAi tokens while contributing to the network's security and decentralization. This document outlines the technical specifications and mechanisms of the staking program.

2. Program Overview

The 'Earn While Hodling' program allows $RAi token holders to lock their tokens in a smart contract for a specified period, during which they earn additional $RAi tokens as rewards. This mechanism encourages token retention, reduces circulating supply, and provides a steady income stream for participants.

3. Smart Contract Architecture

3.1 Core Contracts

  • StakingPool.sol: Main contract handling stake deposits, withdrawals, and reward distributions.

  • RewardCalculator.sol: Calculates rewards based on staking duration and amount.

  • TokenVault.sol: Securely stores staked tokens and manages reward token supply.

3.2 Auxiliary Contracts

  • Governance.sol: Handles parameter updates and program governance.

  • EmergencyProtocol.sol: Implements safety measures for unexpected scenarios.

4. Staking Mechanism

4.1 Staking Process

  1. Users approve the StakingPool contract to spend their $RAi tokens.

  2. Users call the stake(uint256 amount, uint256 duration) function.

  3. Tokens are transferred to the TokenVault.

  4. A staking position is created and recorded in the user's account.

4.2 Reward Calculation

Rewards are calculated using the following formula:

reward = (stakedAmount * stakingDuration * rewardRate) / (365 * 100)

Where:

  • stakedAmount is the number of tokens staked

  • stakingDuration is the lock-up period in days

  • rewardRate is the annual percentage yield (APY)

5. Reward Distribution

5.1 Reward Accrual

Rewards accrue in real-time but are not minted until claimed. This approach saves gas and allows for more flexible reward adjustments.

5.2 Claiming Process

  1. Users call the claimRewards() function.

  2. The contract calculates the total rewards accrued.

  3. New $RAi tokens are minted and transferred to the user.

  4. The reward balance is reset to zero.

6. Unstaking Process

6.1 Regular Unstaking

  1. After the lock-up period, users call unstake(uint256 positionId).

  2. The contract verifies the lock-up period has ended.

  3. Staked tokens and any unclaimed rewards are transferred to the user.

6.2 Early Unstaking

Early unstaking is discouraged but allowed with penalties:

  1. Users call earlyUnstake(uint256 positionId).

  2. A penalty is calculated based on the remaining lock-up time.

  3. The penalty is deducted from the staked amount.

  4. Remaining tokens are returned, but all accrued rewards are forfeited.

7. Security Measures

7.1 Reentrancy Protection

All state-changing functions implement the "checks-effects-interactions" pattern and use OpenZeppelin's ReentrancyGuard.

7.2 Access Control

Contract functions use OpenZeppelin's AccessControl to manage permissions.

7.3 Emergency Pause

The EmergencyProtocol contract can pause staking, unstaking, and reward claiming in case of detected vulnerabilities.

8. Upgradability

The staking program uses the OpenZeppelin UUPS (Universal Upgradeable Proxy Standard) pattern, allowing for future improvements while maintaining contract addresses.

9. Gas Optimization

  • Batch processing for rewards calculation and distribution.

  • Use of mappings for efficient data storage and retrieval.

  • Minimize on-chain storage by using events for historical data.

10. Testing and Auditing

  • Comprehensive unit tests covering all functions and edge cases.

  • Integration tests simulating various staking scenarios.

  • External audit to be conducted by a reputable blockchain security firm (details TBA).

11. Future Enhancements

  • Implementation of a tiered staking system with boosted rewards for longer lock-up periods.

  • Integration with RealmAi's governance system, allowing stakers to participate in protocol decisions.

  • Cross-chain staking capabilities to enhance interoperability with other blockchain networks.

12. Conclusion

The 'Earn While Hodling' staking program is designed to provide a secure, efficient, and rewarding experience for $RAi token holders. By incentivizing long-term holding and active participation in the network, this program aims to contribute to the overall stability and growth of the RealmAi ecosystem.

PreviousAsset Portal v1.2NextAPI Reference

Last updated 9 months ago