Skip to content

msvprotocol/msvptoken

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MSVP Token Airdrop with Tokenomics-Based Vesting

A complete BEP20 token system with automated airdrop and tokenomics-based vesting functionality for the MetaSoilVerseProtocol (MSVP) token. This system implements a sophisticated vesting schedule with 6-month cliff periods and 1.2% unlocks every 4-6 months alternating over 10+ years.

Features

Integrated Token with Tokenomics-Based Vesting (MSVP.sol) - RECOMMENDED

  • BEP20 Standard: Full ERC20 compatibility on Binance Smart Chain
  • Tokenomics-Based Vesting: Sophisticated vesting schedule with 6-month cliff and 1.2% unlocks
  • Transfer Taxes: Configurable 5% transfer tax with distribution to:
    • LP Contribution (2%)
    • Development Fee (1.5%)
    • Marketing (1%)
    • Burn (0.5%)
  • Max Transaction Limits: Prevents large dumps
  • Admin Controls: Pause/unpause, tax rate adjustments, wallet updates
  • Security: Reentrancy protection, ownership controls
  • Automatic Unlocking: Tokens unlock automatically without claiming mechanism
  • 6-Month Cliff Period: No tokens unlocked before 6 months from TGE
  • 1.2% Unlock Pattern: Each unlock releases exactly 1.2% of total allocation
  • Alternating Intervals: 4 months, then 6 months, then 4 months, etc.
  • Long-Term Vesting: Support for 30+ unlock phases over 10+ years
  • Large-Scale Support: Handles 50B token airdrop distribution
  • Additional Purchases: Immediately transferable
  • Early Release: Admin can release specific amounts
  • High Precision: 1e18 precision for accurate calculations
  • Gas Optimization: Individual user updates for efficiency
  • Inconsistency Detection: Audit trail for edge cases

Admin Dashboard

  • Modern UI: Beautiful, responsive interface with Bootstrap 5.3
  • CSV Upload: Drag & drop functionality for bulk operations
  • Real-time Stats: Live vesting statistics with tax breakdown
  • Participant Management: Search and modify individual schedules
  • Wallet Integration: MetaMask and WalletConnect support
  • Enhanced Balance Display: Multiple balance types (base, transferable, locked, vested)
  • Export Functionality: Download participant data as CSV
  • Gas Optimization: Individual user updates with warnings for bulk operations

Token Configuration

Integrated Token (MSVP.sol)

Field Value
Token Name MetaSoilVerse
Token Symbol MSV
Total Supply 100,000,000,000 (100 Billion)
Decimals 18
Mintable No
Burnable Yes
Initial Transfer Tax 5%
Max Transfer Tax 10%
Vesting Type Tokenomics-Based
Cliff Period 6 Months from TGE
Unlock Pattern 1.2% every 4-6 months alternating
Unlock Intervals 4 months, 6 months, 4 months, 6 months, etc.
Total Unlock Phases 30+ phases over 10+ years
Airdrop Supply 50B tokens (50% of total supply)
Locked Tokens Visible in balance, non-transferable
Automatic Unlocking No claiming required - tokens unlock automatically
Additional Purchases Immediately transferable
Precision 1e18 (18 decimal places)

Installation & Setup

Prerequisites

  • Node.js (v16 or higher)
  • npm or yarn
  • MetaMask wallet
  • BSC testnet/mainnet access

1. Clone and Install

git clone <repository-url>
cd TokenAirdrop
npm install

2. Environment Setup

cp env.example .env

Edit .env file:

PRIVATE_KEY=your_private_key_here
BSCSCAN_API_KEY=your_bscscan_api_key_here
LP_WALLET=your_lp_wallet_address
MARKETING_WALLET=your_marketing_wallet_address
DEVELOPMENT_WALLET=your_development_wallet_address
REPORT_GAS=true

3. Compile Contracts

npm run compile

4. Run Tests

npm test

5. Deploy Contracts

# Deploy Integrated Token (Recommended)
npm run deploy:integrated

# Deploy to BSC testnet
npm run deploy:testnet:integrated

# Deploy to BSC mainnet
npm run deploy:mainnet:integrated

Current Deployment Status

BSC Testnet Deployment

Test Results

  • Total Tests: 63/63 passing (100% success rate)
  • Coverage: All edge cases, tokenomics, and functionality tested
  • Tokenomics Tests: 11/11 passing (100% coverage)
  • Gas Optimization: Individual user updates ~46,792 gas, bulk updates ~165,154 gas
  • Security: All access controls and validations verified
  • Vesting Precision: High precision calculations with 1e18 accuracy

Admin Dashboard Usage

Quick Start

  1. Start the server:

    cd admin-dashboard
    python3 -m http.server 8081
  2. Access dashboard: Open http://localhost:8081 in your browser

  3. Connect wallet: Use MetaMask or WalletConnect (ensure you're on BSC Testnet)

  4. Start managing: All functions are available once connected

Key Features

  • Real-time Statistics: Live updates every 30 seconds
  • Tax Management: Configure all tax components (0-10% max)
  • Vesting Management: Create, modify, and monitor vesting schedules
  • Participant Lookup: Detailed balance information for each user
  • Emergency Controls: Pause/unpause, emergency unlock all, and burn admin rights
  • Export Data: Download participant information as CSV

Balance Types Displayed

  • Base Balance: Actual tokens held by user
  • Transferable Balance: Tokens that can be transferred
  • Locked Amount: Tokens still in vesting
  • Vested Amount: Calculated vested amount
  • Total Balance: Display balance including locked tokens

Key Features:

  • 6-Month Cliff: No tokens unlocked before 6 months
  • 1.2% Unlocks: Each phase releases exactly 1.2% of total allocation
  • Alternating Intervals: 4 months, then 6 months, then 4 months, etc.
  • Long-Term: Designed for 30+ unlock phases over 10+ years
  • Large-Scale: Supports 50B token airdrop distribution

Usage Guide

Admin Functions Explained

Early Release Function

  • Purpose: Allows admin to unlock a portion of locked tokens early
  • Example: User has 1000 tokens locked -> Admin can unlock 500 tokens early -> Only 500 tokens remain for vesting period
  • Function: earlyRelease(address user, uint256 amount)
  • Restrictions: Cannot release more than remaining locked tokens

Emergency Unlock ALL Function

  • Purpose: CRITICAL - Instantly unlocks ALL remaining tokens for a user
  • Example: User has 1000 tokens locked -> Admin emergency unlocks ALL -> All 1000 tokens become immediately transferable
  • Function: emergencyUnlockAll(address user)
  • Restrictions: Only admin can call, requires active vesting schedule, cannot be undone
  • Use Cases: Medical emergencies, legal requirements, contract bugs, or other critical situations

Modify Vesting Schedule Function

  • Purpose: Allows admin to increase or decrease total allocation for a user
  • Example: User has 1000 tokens locked -> Admin adds 1000 more tokens -> User now has 2000 tokens total for vesting
  • Function: modifyVestingSchedule(address user, uint256 newAmount)
  • Restrictions: New amount cannot be less than already unlocked tokens

Vesting Schedule Management Functions

Deactivate Vesting Schedule

  • Purpose: Temporarily pause a vesting schedule without removing it
  • Example: User has ongoing vesting -> Admin deactivates -> Vesting stops, but can be reactivated later
  • Function: deactivateVestingSchedule(address user)
  • Use Cases: Temporary suspension, investigations, or contract maintenance

Reactivate Vesting Schedule

  • Purpose: Resume a previously deactivated vesting schedule
  • Example: Previously paused vesting -> Admin reactivates -> Vesting continues from where it left off
  • Function: reactivateVestingSchedule(address user)
  • Restrictions: Can only reactivate deactivated schedules

Cancel Vesting Schedule (Emergency)

  • Purpose: Completely remove a vesting schedule and reclaim locked tokens
  • Example: User has 1000 tokens locked -> Admin cancels -> 1000 tokens returned to contract allocation
  • Function: cancelVestingSchedule(address user)
  • Effects: Reduces total allocated tokens, permanently stops vesting
  • Use Cases: Fraud detection, contract violations, emergency situations

Toggle Airdrop Status

  • Purpose: Change the classification of a vesting schedule between airdrop and non-airdrop
  • Function: toggleAirdropStatus(address user)
  • Use Cases: Correcting misclassified vesting schedules, reporting purposes

Check Vesting Completion

  • Purpose: Programmatically check if a vesting schedule is complete
  • Function: isVestingComplete(address user) -> bool
  • Returns: true if all tokens have been unlocked, false otherwise

🔄 Automatic Vesting Management

Auto-Deactivation on Completion

  • Purpose: Automatically deactivate vesting schedules when 100% complete
  • Trigger: Called when updateUnlockedAmountsForUser() detects completion
  • Event: Emits VestingScheduleCompleted(user, totalAmount, timestamp)
  • Benefits: Gas optimization, clean state management, clear completion tracking

1. Deploy Contracts

Integrated Token (Recommended)

// Deploy Integrated MSVP Token with Vesting
const MSVP = await ethers.getContractFactory("MSVP");
const msvpToken = await MSVP.deploy(lpWallet, marketingWallet, developmentWallet);

2. Prepare CSV File

Create a CSV file with the following format:

address,amount
0x1234567890123456789012345678901234567890,10000
0x2345678901234567890123456789012345678901,15000

3. Use Admin Dashboard

  1. Open admin-dashboard/index.html in a web browser
  2. Connect MetaMask wallet
  3. Upload CSV file
  4. Create vesting schedules (automatic start)
  5. Monitor and manage participants

4. Participant Management

Integrated Token

// Check unlocked amount
const unlocked = await msvpToken.getUnlockedAmount(userAddress);

// Check locked amount
const locked = await msvpToken.getLockedAmount(userAddress);

// Check transferable balance (includes unlocked tokens)
const transferable = await msvpToken.transferableBalance(userAddress);

// Manual update of unlocked amounts (optional)
await msvpToken.updateUnlockedAmountsForUser(userAddress); // Gas efficient
await msvpToken.updateUnlockedAmounts(); // All participants (high gas)

Admin Functions

Token Management

// Update transfer tax rate (0-100, max 10%)
await msvpToken.updateTransferTaxRate(50); // 5%

// Update individual tax components
await msvpToken.updateLPContributionRate(20);
await msvpToken.updateDevelopmentRate(15);
await msvpToken.updateMarketingRate(10);
await msvpToken.updateBurnRate(5);

// Exclude address from tax
await msvpToken.setTaxExclusion(address, true);

Vesting Management

Integrated Token

// Create individual vesting schedule (automatic start)
// ✔ FIXED: Now transfers tokens to user + creates vesting schedule
await msvpToken.createVestingSchedule(userAddress, amount);

// Create batch vesting schedules from CSV
// ✔ FIXED: Now transfers tokens to all users + creates vesting schedules
await msvpToken.createVestingSchedules(addresses, amounts);

// Check vesting requirements before bulk operations (view function)
const requirements = await msvpToken.checkVestingRequirements(addresses, amounts);
console.log(`Total tokens needed: ${requirements.totalTokensNeeded}`);
console.log(`Admin balance: ${requirements.adminBalance}`);
console.log(`Can proceed: ${requirements.canProceed}`);
console.log(`Valid entries: ${requirements.validEntries}`);

// Early release for specific user
await msvpToken.earlyRelease(userAddress, amount);

// Emergency unlock ALL remaining tokens for a user
await msvpToken.emergencyUnlockAll(userAddress);

// Modify vesting schedule (can increase or decrease total allocation)
await msvpToken.modifyVestingSchedule(userAddress, newAmount);

//  Vesting Schedule Management
await msvpToken.deactivateVestingSchedule(userAddress); // Pause vesting
await msvpToken.reactivateVestingSchedule(userAddress); // Resume vesting
await msvpToken.cancelVestingSchedule(userAddress); // Cancel completely (emergency)
await msvpToken.toggleAirdropStatus(userAddress); // Toggle airdrop classification

// Check vesting status
const isComplete = await msvpToken.isVestingComplete(userAddress);

// Update unlocked amounts (auto-deactivates when complete)
await msvpToken.updateUnlockedAmountsForUser(userAddress); // Single user
await msvpToken.updateUnlockedAmounts(); // All participants

// Check balances
const baseBalance = await msvpToken.balanceOf(userAddress);
const transferableBalance = await msvpToken.transferableBalance(userAddress);
const lockedAmount = await msvpToken.getLockedAmount(userAddress);

Critical Fix Implemented

Vesting Token Transfer Issue - RESOLVED

Problem: The original createVestingSchedules function only created vesting schedule records without actually transferring tokens to users. This caused:

  • Users to have 0 actual token balance
  • Vesting logic to fail completely
  • balanceOf() to show locked amounts but no real tokens

Solution: Updated both createVestingSchedule and createVestingSchedules functions to:

  1. Transfer tokens first from admin to users
  2. Create vesting schedules with the transferred tokens
  3. Ensure users have actual token balance to start vesting
  4. Add balance validation before operations
  5. Emit events for token transfers

New Features Added:

  • checkVestingRequirements() - View function to check bulk operation feasibility
  • TokensTransferredForVesting event - Track token transfers during vesting creation
  • Balance validation - Prevents operations when admin has insufficient tokens

Result: Users now receive actual tokens and can participate in vesting immediately!


Testing

Run All Tests

npm test

Run Specific Test Files

# Integrated Token Tests
npx hardhat test test/MSVP.test.js

Test Coverage

npm run coverage

Tokenomics-Specific Tests

# Run only tokenomics tests
npm test -- --grep "Tokenomics-Specific Vesting Tests"

# Test coverage includes:
# - 6-Month Cliff Period (2 tests)
# - 1.2% Unlock Pattern (2 tests)  
# - Large-Scale Airdrop Testing (2 tests)
# - Cumulative Unlock Tracking (2 tests)
# - Transfer Restrictions (1 test)
# - Early Release with Constraints (1 test)
# - Gas Optimization (1 test)

Gas Report

REPORT_GAS=true npm test

Project Structure

TokenAirdrop/
├── contracts/
│   └── MSVP.sol   # MetaSoilVerseProtocol token with vesting (RECOMMENDED)
├── scripts/
│   ├── deploy-integrated.js  # Integrated token deployment
│   ├── deploy-bsc-testnet.js # BSC testnet deployment
│   └── check-balance.js      # Balance checking utility
├── test/
│   └── MSVP.test.js # Integrated token tests
├── admin-dashboard/
│   ├── index.html            # Dashboard UI
│   ├── dashboard.js          # Dashboard logic
│   ├── deployment-info.json  # Deployment details
│   └── README.md             # Dashboard documentation
├── sample-airdrop.csv        # Sample CSV file
├── hardhat.config.js         # Hardhat configuration
├── package.json              # Dependencies
├── env.example               # Environment variables template
├── DEPLOYMENT_GUIDE.md       # Deployment instructions
├── BSCSCAN_INSTRUCTIONS.md   # BSCScan interaction guide
└── README.md                 # This file

Security Features

Token Security

  • Reentrancy Protection: Prevents reentrancy attacks
  • Ownership Controls: Admin-only functions
  • Pausable: Emergency pause functionality
  • Max Transaction Limits: Prevents large dumps
  • Tax Exclusions: Configurable tax exemptions
  • High Precision: 1e18 precision to prevent rounding errors
  • Overflow Protection: Comprehensive validation

Vesting Security

  • Non-reentrant Updates: Safe update functions
  • Admin Controls: Restricted admin functions
  • Emergency Controls: Pause/unpause and admin rights burning
  • Immutable Parameters: Core vesting parameters cannot be changed
  • Transparency: All schedules publicly viewable
  • Inconsistency Detection: Audit trail for edge cases

Network Configuration

BSC Testnet

  • Network ID: 97
  • RPC URL: https://data-seed-prebsc-1-s1.binance.org:8545/
  • Explorer: https://testnet.bscscan.com/

BSC Mainnet

  • Network ID: 56
  • RPC URL: https://bsc-dataseed.binance.org/
  • Explorer: https://bscscan.com/

How The Smart Contract Works

Smart Contract Architecture

The MSVP contract implements a sophisticated balance management system with three different balance types to handle vested tokens:

1. Display Balance (balanceOf)

function balanceOf(address account) public view override returns (uint256) {
    uint256 baseBalance = super.balanceOf(account);
    uint256 lockedAmount = getLockedAmount(account);
    return baseBalance + lockedAmount;
}

What users see:

  • Total tokens = Regular tokens + Locked (vested) tokens
  • Purpose: Shows complete token ownership for display in wallets
  • Example: If user has 1,000 regular tokens + 10,000 locked tokens = 11,000 tokens displayed

What this represents:

  • Actual ERC20 tokens held in the wallet
  • Freely transferable without restrictions
  • Not subject to vesting rules

3. Transferable Balance (transferableBalance)

function transferableBalance(address account) public view returns (uint256) {
    uint256 baseBalance = super.balanceOf(account);
    uint256 unlockedAmount = getUnlockedAmount(account);
    return baseBalance + unlockedAmount;
}

What users can actually use:

  • Base tokens + Unlocked vested tokens
  • Maximum amount available for transfers
  • Real spendable balance

Vesting System Structure

Each user has a VestingSchedule that tracks:

  • totalAmount: Total tokens allocated (e.g., 1M tokens)
  • unlockedAmount: Tokens unlocked so far (updated over time)
  • startTime: When vesting began (TGE - Token Generation Event)
  • isActive: Whether vesting is currently active

Vesting Timeline & Unlocking Process

The contract implements the exact vesting schedule:

Phase Month Unlock % Notes Tokens Released Cumulative % Cumulative Tokens
Cliff M0 0 0 Cliff period 0 0 0
Cliff M6 6 0 Cliff period 0 0 0
Q1 7 1.2 First year release 600,000,000 1.2 600,000,000
Q2 10 1.2 First year release 600,000,000 2.4 1,200,000,000
Q3 13 1.2 First year release 600,000,000 3.6 1,800,000,000
Q4 16 1.2 First year release 600,000,000 4.8 2,400,000,000
Q5 19 1.2 Extended release 600,000,000 6 3,000,000,000
Q6 22 7 Post-Q5 unlock 3,500,000,000 13 6,500,000,000
Q7 25 7 Post-Q5 unlock 3,500,000,000 20 10,000,000,000
Q8 28 7 Post-Q5 unlock 3,500,000,000 27 13,500,000,000
Q9 31 7 Post-Q5 unlock 3,500,000,000 34 17,000,000,000
Q10 34 7 Post-Q5 unlock 3,500,000,000 41 20,500,000,000
Q11 37 7 Post-Q5 unlock 3,500,000,000 48 24,000,000,000
Q12 40 7 Post-Q5 unlock 3,500,000,000 55 27,500,000,000
Q13 43 7 Post-Q5 unlock 3,500,000,000 62 31,000,000,000
Q14 46 7 Post-Q5 unlock 3,500,000,000 69 34,500,000,000
Q15 49 7 Post-Q5 unlock 3,500,000,000 76 38,000,000,000
Q16 52 6 Final period 3,000,000,000 82 41,000,000,000
Q17 55 6 Final period 3,000,000,000 88 44,000,000,000
Q18 58 6 Final period 3,000,000,000 94 47,000,000,000
Q19 61 6 Final unlock 3,000,000,000 100 50,000,000,000

Balance Update Mechanism

The contract automatically updates unlocked amounts during:

  1. Token Transfers:

    // In _transfer function
    if (isParticipant[from]) {
        updateUnlockedAmountsForUser(from);
    }
  2. Manual Updates: Admin or users can call updateUnlockedAmountsForUser()

  3. Bulk Updates: Admin can update all participants with updateUnlockedAmounts()

Transfer Restrictions & Limitations

Key Limitations

  1. Transferable Balance Check:

    uint256 transferable = transferableBalance(from);
    require(transferable >= amount, "Insufficient transferable balance");
    • Users cannot transfer locked tokens
    • Only base balance + unlocked vested tokens are transferable
  2. 💸 Transaction Limits:

    require(amount <= maxTxAmount, "Transfer amount exceeds max transaction limit");
    • Default: 1% of total supply per transaction
    • Can be modified by admin
    • Certain addresses can be excluded
  3. Transfer Tax (5% default):

    • 2% to LP wallet
    • 1.5% to development
    • 1% to marketing
    • 0.5% burned

Practical Example

Let's say Alice has an airdrop allocation:

Initial State (Month 0)

Alice's Address: 0x123...
├── Display Balance (balanceOf): 10,000,000 tokens
├── Transferable Balance: 0 tokens
├── Locked Amount: 10,000,000 tokens
└── Unlocked Amount: 0 tokens (cliff period)

Month 7 (First Unlock - 1.2%)

Alice's Address: 0x123...
├── Display Balance: 10,000,000 tokens (unchanged)
├── Base Balance: 0 tokens
├── Transferable Balance: 120,000 tokens ✔
├── Locked Amount: 9,880,000 tokens
└── Unlocked Amount: 120,000 tokens (1.2% unlocked)

After Alice Receives 1,000 Regular Tokens

Alice's Address: 0x123...
├── Display Balance: 10,001,000 tokens
├── Base Balance: 1,000 tokens
├── Transferable Balance: 121,000 tokens ✔
├── Locked Amount: 9,880,000 tokens  
└── Unlocked Amount: 120,000 tokens

How Users Interact

For Regular Users:

  1. Check Display Balance: balanceOf(address) - Shows total ownership
  2. Check Transferable: transferableBalance(address) - Shows spendable amount
  3. Transfer Tokens: Regular transfer() with automatic vesting updates
  4. Update Vesting: Call updateUnlockedAmountsForUser() to refresh unlocked amounts

For DApp Developers:

// Get complete user balance information
const displayBalance = await contract.balanceOf(userAddress);
const transferableBalance = await contract.transferableBalance(userAddress);
const lockedAmount = await contract.getLockedAmount(userAddress);
const unlockedAmount = await contract.getUnlockedAmount(userAddress);

// Display to user
console.log({
    total: displayBalance,           // What user "owns"
    available: transferableBalance,  // What user can "spend"
    locked: lockedAmount,           // What's still vesting
    unlocked: unlockedAmount        // What's been unlocked from vesting
});

⚡ Gas Optimization Features

  1. Individual Updates: updateUnlockedAmountsForUser() - Gas efficient
  2. Automatic Updates: During transfers - No extra gas needed
  3. Bulk Updates: updateUnlockedAmounts() - Admin only, gas expensive
  4. View Functions: All balance queries are gas-free

Security Features

  1. Immutable Vesting Logic: Once schedule is set, unlock timing cannot be changed
  2. Admin Controls: Early release and schedule modifications (with restrictions)
  3. Pause Functionality: Emergency stop for all transfers
  4. Overflow Protection: SafeMath and modern Solidity version
  5. Reentrancy Protection: ReentrancyGuard implementation

This design ensures that users can see their complete token ownership while only being able to spend what's actually available, providing transparency and security in the vesting process.

Vesting Schedule Lifecycle Management

Automatic Lifecycle Stages:

  1. Creation (isActive = true)

    • Schedule created with createVestingSchedule()
    • Tokens allocated but locked during cliff period
    • User appears in participant list
  2. Active Vesting (isActive = true)

    • Tokens unlock according to tokenomics schedule
    • updateUnlockedAmountsForUser() updates available amounts
    • Transfers automatically update vesting progress
  3. Completion & Auto-Deactivation (isActive = false)

    • Automatic: When 100% of tokens are unlocked
    • Event: VestingScheduleCompleted emitted
    • Benefits: Gas optimization, clean state management

Manual Management Functions:

// Pause vesting temporarily
await msvpToken.deactivateVestingSchedule(userAddress);

// Resume paused vesting
await msvpToken.reactivateVestingSchedule(userAddress);

// Emergency cancellation (permanent)
await msvpToken.cancelVestingSchedule(userAddress);

// Check completion status
const isComplete = await msvpToken.isVestingComplete(userAddress);

State Transitions:

Created → Active Vesting → Auto-Deactivated (Complete)
    ↓           ↓              ↑
    ↓       Manual Pause → Manual Resume
    ↓           
    → Emergency Cancel (Permanent)

Tokenomics Implementation Details

Vesting Algorithm

The contract implements a sophisticated tokenomics-based vesting system:

  1. 6-Month Cliff Period: No tokens are unlocked before 6 months from TGE
  2. 1.2% Unlock Pattern: Each unlock phase releases exactly 1.2% of the total allocation
  3. Alternating Intervals:
    • Phase 1: 6 months (first unlock)
    • Phase 2: 4 months later (10 months total)
    • Phase 3: 6 months later (16 months total)
    • Phase 4: 4 months later (20 months total)
    • And so on...
  4. Long-Term Support: Designed for 30+ unlock phases over 10+ years
  5. Large-Scale: Handles 50B token airdrop distribution efficiently

Mathematical Precision

  • Unlock Amount: (totalAllocation * 12) / 1000 (1.2% = 12/1000)
  • Time Calculation: Precise timestamp-based calculations
  • Cumulative Tracking: Accurate progression through unlock phases
  • High Precision: 1e18 precision to prevent rounding errors

Test Coverage

The system includes comprehensive tests covering:

  • ✔ 6-Month cliff period enforcement
  • ✔ 1.2% unlock pattern accuracy
  • ✔ Alternating 4-6 month intervals
  • ✔ Large-scale 50B token distribution
  • ✔ 30+ unlock phases over 10 years
  • ✔ Cumulative unlock tracking
  • ✔ Transfer restrictions during vesting
  • ✔ Early release with tokenomics constraints
  • ✔ Gas optimization for large operations

Important Notes

Gas Optimization

  • Use updateUnlockedAmountsForUser() for individual participants (low gas)
  • Use updateUnlockedAmounts() sparingly for all participants (high gas)
  • Automatic updates occur during transfers
  • Monitor gas usage for large operations

Tax Rate Limits

  • Maximum tax rate: 10% (100/1000)
  • Individual components cannot exceed total tax rate
  • Zero tax rate is supported
  • All tax components are configurable

Vesting Features

  • Tokenomics-Based: 6-month cliff with 1.2% unlocks every 4-6 months alternating
  • Automatic unlocking: No manual claiming required
  • High precision calculations: 1e18 precision for accurate calculations
  • Inconsistency detection: Audit trail for edge cases
  • Long-term support: 30+ unlock phases over 10+ years
  • Large-scale: Handles 50B token airdrop distribution
  • Early release: Admin can release specific amounts within constraints
  • Transfer restrictions: Locked tokens visible but non-transferable

Testing Requirements

  • Always test on testnet before mainnet deployment
  • Verify all functions work as expected
  • Check gas usage for large operations
  • Test edge cases and error conditions

Troubleshooting

Connection Issues

  • Ensure you're on BSC Testnet (chainId: 97)
  • Check if MetaMask is installed and unlocked
  • Verify you're the contract owner
  • Clear browser cache and localStorage if needed

Transaction Failures

  • Check gas limits and fees
  • Ensure sufficient BNB for gas
  • Verify input parameters are valid
  • Check if contract is paused

Display Issues

  • Refresh the page if statistics don't update
  • Check browser console for errors
  • Ensure JavaScript is enabled
  • Clear browser cache

Support

For support and questions:

  • Create an issue in the repository
  • Check the test files for usage examples
  • Review the contract comments for detailed explanations
  • Check the browser console for error messages
  • Verify contract address and network settings

Version History

  • v3.0.0: Tokenomics-Based Vesting - Implemented sophisticated vesting schedule with 6-month cliff, 1.2% unlocks every 4-6 months alternating, 30+ unlock phases over 10+ years, 50B airdrop support, comprehensive test coverage (63/63 tests passing)
  • v2.0.0: Enhanced balance management, gas optimization, automatic vesting, high precision calculations, inconsistency detection
  • v1.0.0: Initial release with basic token and vesting system

Changelog

Version 2.1.0 - Vesting Management & Auto-Deactivation

New Features Added:

  1. Emergency Unlock ALL Function

    • emergencyUnlockAll(address user) - Instantly unlock all remaining tokens
    • Complete emergency override for critical situations
    • Comprehensive test coverage and admin dashboard integration
  2. Complete Vesting Schedule Management

    • deactivateVestingSchedule(address user) - Pause vesting temporarily
    • reactivateVestingSchedule(address user) - Resume paused vesting
    • cancelVestingSchedule(address user) - Permanently cancel vesting (emergency)
    • toggleAirdropStatus(address user) - Toggle airdrop classification
    • isVestingComplete(address user) - Check completion status
  3. 🔄 Automatic Lifecycle Management

    • Auto-deactivation when vesting reaches 100% completion
    • Gas optimization by deactivating completed schedules
    • VestingScheduleCompleted event emission for tracking
    • Clean state management with clear active/inactive distinction

Breaking Changes:

  1. Removed releaseInterval Parameter (Breaking Change)

    • Before: createVestingSchedule(user, amount, releaseInterval)
    • After: createVestingSchedule(user, amount)
    • Reason: Parameter was unused due to hardcoded tokenomics schedule
    • Migration: Remove the third parameter from all function calls
  2. Updated Event Signatures

    • Before: VestingScheduleCreated(user, amount, startTime, endTime, releaseInterval)
    • After: VestingScheduleCreated(user, amount, startTime, endTime)

Updated Features:

  1. Enhanced isVestingComplete() Function

    • Now works correctly for both active and deactivated schedules
    • Returns true for completed schedules even after auto-deactivation
  2. Improved Admin Dashboard

    • Added emergency unlock ALL button with confirmation dialogs
    • Removed unused interval selection inputs
    • Updated CSV format documentation (now: address,amount)

Test Coverage:

  • 32 comprehensive tests including new management functions
  • 6 new tests specifically for vesting schedule management
  • 100% test coverage for all new functionality
  • Backward compatibility verified for existing features

Version 2.0.0 - Initial Implementation

  • Tokenomics-based vesting with precise 61-month schedule
  • Early release and schedule modification functions
  • Comprehensive admin dashboard
  • Transfer tax system with multiple recipient wallets

License

This project is licensed under the MIT License.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure all tests pass
  6. Submit a pull request

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages