XL Token#

Overview#

XL Token is a token contract based on an upgraded ERC20 standard that implements the following core functionalities:

  1. Token Distribution: Manages tokens for different purposes through linear vesting and pre-allocation mechanisms

  2. Access Control: Role-based access control (inherited from Auth contract)

  3. Claim Mechanism: Supports users claiming tokens through whitelist and receiving ERB rewards

  4. Time Release: Sets linear vesting schedules for ecosystem fund, strategic financing, and team tokens

Core Constants Definition#

Token Parameters#

uint256 public constant MAX_SUPPLY = 10_000_000_000 * 10 ** 18; // 10 billion tokens (18 decimals)

Time Parameters#

uint256 public constant THREE_YEARS = 3 * 365 days;
uint256 public constant FIVE_YEARS = 5 * 365 days;
uint256 public constant MONTH = 30 days;
uint256 public constant QUARTER = 90 days;

Token Distribution Structure#

Pre-allocation Addresses#

address public taskIncentiveAddress; // Task incentive address
address public ecosystemFundAddress; // Ecosystem fund address
address public strategicFinanceAddress; // Strategic finance address
address public teamAddress; // Team address
address public marketingAddress; // Marketing address

Supply Distribution#

// 62% Bonding curve release
uint256 public constant BONDING_SUPPLY = 6_200_000_000e18;

// 8% Pre-allocation (instant unlock)
uint256 public constant TASK_INCENTIVE_SUPPLY = 800_000_000e18;

// 12% Linear vesting (5 years, monthly release)
uint256 public constant ECOSYSTEM_FUND_SUPPLY = 1_200_000_000e18;

// 10% Linear vesting (3 years, monthly release)
uint256 public constant STRATEGIC_FINANCE_SUPPLY = 1_000_000_000e18;

// 6% Linear vesting (5 years, quarterly release)
uint256 public constant TEAM_SUPPLY = 600_000_000e18;

// 2% Pre-allocation (instant unlock)
uint256 public constant MARKETING_SUPPLY = 200_000_000e18;

Core Variables#

Timestamp Records#

uint256 public ecosystemStartTime; // Ecosystem release start time
uint256 public strategicFinanceStartTime; // Strategic finance start time
uint256 public teamStartTime; // Team token start time

Released Amount Records#

uint256 public ecosystemReleased; // Released ecosystem tokens
uint256 public strategicFinanceReleased; // Released strategic finance tokens
uint256 public teamReleased; // Released team tokens

Total Claim Records#

uint256 public totalClaimed; // Total claimed bonding tokens

Error Definitions#

error InvalidZeroAddress(); // Invalid zero address
error CallerIsZeroAddress(); // Caller is zero address
error ExceedsClaimSupply(uint256 claimed, uint256 lAmt); // Exceeds claim supply
error InsufficientERBBalance(address from, uint256 balance); // Insufficient ERB balance

Core Events#

event Claim(
    address indexed recipient, // Recipient address
    uint256 indexed xlAmt,    // Claimed XL amount
    uint256 indexed erbAmt    // Transferred ERB amount
);

Core Functions Explained#

1. Initialize Function#

function initialize(...) public initializer {
    // Initialize access control
    super.initializeAuth(_superOwner);

    // Initialize ERC20 token parameters
    __ERC20_init("XL", "XL");

    // Set pre-allocation addresses
    taskIncentiveAddress = _taskIncentiveAddress;
    ecosystemFundAddress = _ecosystemFundAddress;
    strategicFinanceAddress = _strategicFinanceAddress;
    teamAddress = _teamAddress;
    marketingAddress = _marketingAddress;

    // Pre-allocate tokens
    _mint(taskIncentiveAddress, TASK_INCENTIVE_SUPPLY);
    _mint(marketingAddress, MARKETING_SUPPLY);

    // Set initial timestamps
    ecosystemStartTime = block.timestamp;
    strategicFinanceStartTime = block.timestamp;
    teamStartTime = block.timestamp;
}
  • Requires super admin and other address parameters

  • Pre-allocates 8% and 2% of tokens

  • Initializes release timestamps to contract deployment time

2. Claim Function#

function claim(address payable recipient, uint256 _xlAmt)
    external payable onlyWhitelisted {
    // Safety checks
    if (address(this).balance < msg.value) revert InsufficientERBBalance(...);
    if (recipient == address(0)) revert InvalidZeroAddress();
    if (msg.sender == address(0)) revert CallerIsZeroAddress();
    if (totalClaimed + _xlAmt > BONDING_SUPPLY) revert ExceedsClaimSupply(...);

    // Claim logic
    totalClaimed += _xlAmt;
    _mint(recipient, _xlAmt);

    // Transfer ERB
    recipient.transfer(msg.value);

    // Emit event
    emit Claim(recipient, _xlAmt, msg.value);
}
  • Must be called through whitelist

  • Checks address validity and total claim limit

  • Transfers user-paid ERB (via msg.value)

  • Emits Claim event to record claim details

3. Linear Release Function#

function releaseLinear() external onlySuperOwner {
    // Calculate tokens to release for each part
    uint256 ecosystemToRelease = calculateLinearRelease(
        ECOSYSTEM_FUND_SUPPLY, FIVE_YEARS, ecosystemStartTime,
        ecosystemReleased, MONTH
    );

    // Same calculation for strategic finance and team tokens
    // ...

    // Mint and update records
    if (ecosystemToRelease > 0) {
        ecosystemReleased += ecosystemToRelease;
        _mint(ecosystemFundAddress, ecosystemToRelease);
    }
    // Same for other parts
}
  • Only callable by super admin

  • Uses calculateLinearRelease to calculate release amount

  • Releases tokens monthly/quarterly

4. Linear Release Calculation Function#

function calculateLinearRelease(
    uint256 total,
    uint256 duration,
    uint256 startTime,
    uint256 alreadyReleased,
    uint256 releaseInterval
) internal view returns (uint256) {
    // Calculate elapsed time
    uint256 elapsedTime = block.timestamp - startTime;

    // Calculate total and elapsed periods
    uint256 totalPeriods = duration / releaseInterval;
    uint256 elapsedPeriods = elapsedTime / releaseInterval;

    // Calculate total amount to release
    uint256 totalToRelease = (total * elapsedPeriods) / totalPeriods;

    // Ensure not exceeding total supply
    if (totalToRelease > total) totalToRelease = total;

    // Calculate amount for this release
    return totalToRelease - alreadyReleased;
}
  • Calculates released periods based on time

  • Calculates tokens to be released proportionally

  • Returns remaining amount for this release

Access Control#

Role Management#

  • MINTER_ROLE: Allows calling mint function

  • BURNER_ROLE: Allows calling burn function

  • WHITELISTED_ROLE: Allows calling claim function

  • SUPER_OWNER: Allows calling releaseLinear and setAddresses

Modifiers#

modifier onlyWhitelisted() {
    require(hasRole(WHITELISTED_ROLE, msg.sender), "Not whitelisted");
    _;
}

Security Measures#

  1. Address Validation:
    • Check zero address (InvalidZeroAddress)

    • Verify caller validity (CallerIsZeroAddress)

  2. Supply Limits:
    • Total claims not exceeding BONDING_SUPPLY

    • Linear release not exceeding total allocation

  3. Fund Security:
    • Check contract balance sufficient for ERB transfer

    • Use payable function for Ethereum transfers

Version Information#

function getVersion() public pure returns (string memory) {
    return "1.0.0";
}