Launchpad Initialization

The launchpad initialization process in the ModePad ecosystem involves setting up a new instance of the Launchpad contract.

Let's break down the steps involved in the initializer function of the Launchpad contract:

Launchpad Initialization Process:

1. Function Signature and Modifiers:

function initializer(
    address _owner,
    address _tokenAddress,
    uint256 _price,
    uint256 _minInvestment,
    uint256 _maxInvestment,
    string memory _poolName,
    uint256 _durationInDays
) external {
    require(isInitialized == false, "Contract is Already Initialized!");
    require(msg.sender == owner, "Not Owner!");

    isInitialized = true;

    memeCoinToken = IERC20(_tokenAddress);

    owner = _owner;
    tokenPrice = _price;
    minInvestment = _minInvestment;
    maxInvestment = _maxInvestment;
    saleDurationInSeconds = _durationInDays * 1 days;
    poolName = _poolName;
    saleStartTime = 0;
    isSaleActive = false;
}

2. Initialization Conditions:

  • The function begins with two require statements to ensure that the contract has not been initialized before (isInitialized == false) and that the caller is the owner of the contract (msg.sender == owner).

  • If either condition fails, the function reverts, preventing re-initialization and unauthorized calls.

3. Contract State Initialization:

  • isInitialized is set to true to mark the contract as initialized, preventing future calls to this function.

  • The memeCoinToken variable is initialized with the ERC-20 token contract address (IERC20(_tokenAddress)).

  • The owner is set to the specified address (_owner).

  • The token price (tokenPrice), minimum investment amount (minInvestment), and maximum investment amount (maxInvestment) are set to the provided values.

  • saleDurationInSeconds is calculated based on the provided duration in days.

  • The pool name (poolName) is set to the provided string.

  • saleStartTime is set to 0, indicating that the sale has not started.

  • isSaleActive is set to false initially, signifying that the sale is not active.

4. Overall Flow:

  • This function is intended to be called once during the initialization of the Launchpad contract.

  • It sets up the initial state of the contract, including token-related parameters, investment limits, and sale duration.

  • After successful execution, the contract is marked as initialized, and its state is configured for the upcoming token sale.

Summary:

The launchpad initialization process involves verifying certain conditions, initializing the contract state with parameters provided during deployment, and setting flags to control the subsequent token sale. This meticulous initialization ensures that the launchpad is configured correctly before allowing any token transactions or investment activities.

Last updated