EscrowVesting

The EscrowVesting contract manages the gradual release of funds raised from IMO sales to project teams. It implements a phase-based vesting schedule with milestone-dependent releases to ensure project accountability and protect investor interests.

Key Features

  • Phase-based vesting schedule (configurable, default 3 phases).

  • Milestone-gated fund releases.

  • Emergency withdrawal mechanism.

  • Time-locked release schedule.

  • Milestone checker integration.

Contract Details

Constants

TOTAL_PHASES = 3 TOTAL_PERCENTAGE = 100

Vesting Schedule

Default phases after IMO completion:

Phase 0: 30% after 90 days
Phase 1: 30% after 180 days
Phase 2: 40% after 365 days

State Variables

// Core Addresses
imoToken: IERC20              // ERC-7641 token address
usdtToken: IERC20             // USDT token address
projectWallet: address        // Beneficiary wallet
milestoneChecker: address     // Release authorization
imoSaleContract: address      // IMO sale contract

// Vesting State
totalEscrowedAmount: uint256  // Total USDT in escrow
releasedAmount: uint256       // Total USDT released
imoEndTime: uint256           // Vesting start timestamp
isPhasesInitialized: bool     // Phase initialization flag

Functions

Core Functions

release(uint256 _phaseIndex)

  • Purpose: Releases funds for a specific vesting phase.

  • Access: MilestoneChecker only.

  • Requirements:

    • Valid phase index (0-2).

    • Phase has not yet been released.

    • Release time has been reached.

    • Milestone conditions have been met.

    • Funds are available.

  • Process Flow:

    1. Validates all release conditions to be met.

    2. Calculates the amount to be released.

    3. Marks the phase as released.

    4. Transfers the calculated USDT amount to the project wallet.

  • Events Triggered: FundsReleased.


Setup Functions

constructor(address _projectWallet, address _imoSaleContract, address _usdtToken)

  • Purpose: Initializes the vesting contract with necessary addresses.

  • Parameters:

    • _projectWallet: The address of the project wallet.

    • _imoSaleContract: The address of the IMO sale contract.

    • _usdtToken: The address of the USDT token.

  • Validation: Ensures all addresses are non-zero.


setIMOEndTime(uint256 _endTime)

  • Purpose: Sets the vesting start time and initializes the vesting phases.

  • Access: Owner or IMOSale.

  • Phase Setup:

Phase 0: {30%, 90 days, false}
Phase 1: {30%, 180 days, false}
Phase 2: {40%, 365 days, false}
  • Events Triggered:

    • IMOEndTimeSet.

    • PhasesInitialized.


setMilestoneChecker(address _milestoneChecker)

  • Purpose: Sets the address of the milestone checker contract.

  • Access: Owner only.

  • Validation: Non-zero address.


setIMOToken(address _imoToken)

  • Purpose: Sets the address of the IMO token contract.

  • Access: Owner or IMOSale.

  • Validation:

    • Non-zero address.

    • Must be contract.

    • One-time setting.

  • Events Triggered: IMOTokenSet.


Fund Management

receiveUSDT(uint256 _amount)

  • Purpose: Receives and manages USDT funds sent to the contract by IMOSale.sol.

  • Access: IMOSale only.

  • Process Flow:

    1. Transfers the specified amount of USDT from the sender.

    2. Updates the total escrowed amount in the contract.

  • Events Triggered: FundsReceived.


emergencyWithdraw(address _recipient)

  • Purpose: Emergency withdrawal of funds to a specified recipient.

  • Access: Owner or IMOSale.

  • Requirements: The contract must have positive balance.

  • Security: Critical function for emergency use only.


View Functions

getReleaseableAmount(uint256 _phaseIndex)

  • Purpose: Calculates the amount of USDT that can be released for a specified phase.

  • Formula: (totalEscrowedAmount * releasePercentage) / 100.

  • Returns: The amount of USDT available for release.


getPhaseInfo(uint256 _phaseIndex)

  • Purpose: Retrieves details of the specified phase.

  • Returns: Phase information (release percentage, scheduled release time, and release status).


getTotalReleasedAmount()

  • Purpose: Retrieves the total amount of USDT that has been released.

  • Returns: Total USDT amount released to date.


getRemainingEscrowBalance()

  • Purpose: Retrieves the remaining balance of escrowed USDT.

  • Returns: The amount of USDT still held in escrow.

Last updated