ERC-7641 Token

The ERC-7641 token is an upgradeable revenue-sharing token standard that extends ERC-20. It enables proportional revenue distribution via two mechanisms:

  • Claim-based revenue sharing (Gold tier only).

  • Burn-to-redeem mechanism (all holders).

The contract uses a snapshot mechanism to track token balances and revenue distribution at specific points in time.

Key Features

  • Upgradeable implementation using transparent proxy pattern.

  • Dual revenue pool system (claim pool and burn pool).

  • Tier-based revenue claiming rights.

  • Snapshot-based revenue distribution.

  • Revenue token-agnostic design.

Contract Details

Inheritance Structure

ERC7641Upgradeable
  ├── Initializable
  ├── ERC20SnapshotUpgradeable
  ├── IERC7641Upgradeable
  └── OwnableUpgradeable

State Variables

// Core State
_lastSnapshotBlock: uint256          // Last snapshot block number
percentClaimable: uint256            // % of revenue for claim pool
_currentSnapshotId: uint256          // Current snapshot identifier

// Revenue Pools
_claimPool: uint256                  // Available for Gold tier claims
_burnPool: uint256                   // Available for burning
_burned: uint256                     // Tracked burned amount

// Snapshot Mappings
_claimableAtSnapshot                 // Revenue per snapshot
_claimedAtSnapshot                   // Claim status tracking
_goldTierBalanceAtSnapshot           // Gold tier balances
_goldTierSupplyAtSnapshot            // Total Gold tier supply

Functions

Initialization and Setup

initialize(string name, string symbol, uint256 _percentClaimable, address _stakingContract, address revToken)

  • Purpose: Initializes the upgradeable token contract.

  • Access: Public, can only be called once.

  • Parameters:

    • name: Token name.

    • symbol: Token symbol.

    • _percentClaimable: Percentage for claim pool.

    • _stakingContract: Staking contract address.

    • revToken: Revenue token address.

  • Validations:

    • _percentClaimable ≤ 100

    • _stakingContract and revToken contract addresses must be non-zero addresses


Revenue Distribution

snapshot()

  • Purpose: Creates a new revenue distribution checkpoint.

  • Process Flow:

    1. Creates a new ERC-20 snapshot.

    2. Calculates and records new revenue.

    3. Updates the claim and burn pools.

    4. Records current Gold tier balances.

  • Constraints: Minimum 1000 blocks between snapshots (configurable).

  • Returns: New snapshot ID.

  • Events Triggered: SnapshotTaken.


claim(uint256 snapshotId)

  • Purpose: Claims revenue for Gold tier holders.

  • Access: Gold tier only.

  • Process Flow:

    1. Verifies that the caller has Gold tier status.

    2. Calculates the claimable revenue amount for the caller.

    3. Transfers the calculated amount of revenue tokens to the caller.

    4. Updates the claim status to prevent duplicate claims.

  • Events Triggered: RevenueClaimed.


burn(uint256 amount)

  • Purpose: Burns tokens for revenue redemption.

  • Access: Any token holder.

  • Process Flow:

    1. Calculates the redeemable revenue amount based on the amount of tokens to be burned.

    2. Burns the specified amount of IMO tokens from the caller’s balance.

    3. Transfers the corresponding amount of revenue tokens to the caller.

  • Events Triggered: RevenueBurned.


Calculation Functions

claimableRevenue(address account, uint256 snapshotId)

  • Purpose: Calculates claimable revenue.

  • Formula: (goldBalance * claimable) / goldTotalSupply.

  • Returns: Claimable amount for the snapshot.


redeemableOnBurn(uint256 amount)

  • Purpose: Calculates redeemable amount for burning.

  • Formula: burnableFromNewRevenue + burnableFromPool.

  • Returns: Total redeemable amount.


Administrative Functions

mint(address account, uint256 amount)

  • Purpose:

    • Mints new IMO tokens to the specified address.

    • Tracks Gold tier status for revenue claiming.

    • Primarily used during IMO token distribution.

  • Who can mint?

    • During Initial Distribution:

      • The IMOSale contract via distributeTokens().

    • After Distribution:

      • The IMOSale owner can mint via proxy.

  • Access:

modifier onlyOwner()  // From Ownable contract modifier 
onlyProxy()           // Ensures proxy delegation
  • Additional:

    • Updates the total token supply.

    • Updates the recipient's balance.

    • Tracks the Gold tier status of the recipient for revenue claiming eligibility.

    • Events Triggered Transfer.


View Functions

claimPool()

  • Purpose: Returns the current claim pool balance.


burnPool()

  • Purpose: Returns the current burn pool balance.


revenueToken()

  • Purpose: Returns the revenue token address.


getCurrentSnapshotId()

  • Purpose: Returns the latest snapshot ID.


Events

SnapshotTaken(uint256 id)
RevenueReceived(uint256 amount)
RevenueClaimed(address indexed user, uint256 amount)
RevenueBurned(address indexed user, uint256 amount)

Security Features

Access Control

  • onlyProxy modifier: Restricts certain functions to proxy-only calls.

  • onlyOwner modifier: Limits administrative functions to the contract owner.

  • Tier-based access: Controls access for claims based on investor tier level.

Safety Checks

  • Overflow protection: Prevents numerical overflow and underflow issues.

  • Transfer success verification: Ensures that all token transfers are successfully completed.

  • Revenue pool balance validation: Confirms sufficient balance in revenue pools before distribution.

  • Snapshot spacing requirements: Enforces minimum block spacing between snapshots.

Upgradeability

The contract uses OpenZeppelin's transparent proxy pattern:

  • Logic contract: ERC7641Upgradeable (contains the core functionality).

  • Proxy contract: ERC7641Proxy (handles interactions with the logic contract).

  • Admin contract: ProxyAdmin (manages proxy upgrades).

Last updated