LaunchpadFactory
Overview
The LaunchpadFactory
contract facilitates the creation and management of launchpad requests. This contract allows users to request a launchpad for their token sale, which can then be approved or canceled by the owner of the contract. The factory also handles the creation of launchpads and manages the vesting contracts for the tokens.
Dependencies
SafeERC20Upgradeable
from OpenZeppelin: Provides safe operations for ERC20 tokens.Initializable
from OpenZeppelin: Allows the contract to be initialized.OwnableUpgradeable
from OpenZeppelin: Provides basic access control mechanism.ILaunchpadFactory
: Interface for the factory contract.ILaunchpadConfiguration
: Interface for launchpad configuration.IAstraDAOWhitelist
: Interface for whitelist checking.Launchpad
: The actual launchpad contract to be created and managed.
Contract Variables
requestCount
: (uint) The total number of launchpad requests made.requests
: (mapping(uint => LaunchpadRequest)) Mapping of request IDs to their corresponding launchpad requests.launchpads
: (address[]) Array of launchpad addresses created.config
: (address) Address of the configuration contract.tokenToLaunchpad
: (mapping(address => address)) Mapping from token addresses to their corresponding launchpad addresses.approvedLaunchpads
: (mapping(address => uint256)) Mapping from launchpad addresses to their corresponding request IDs.
Error Codes
E01
: Blacklisted user.E02
: Launchpad request already approved.E03
: Launchpad request already canceled.E04
: Invalid base token for launchpad sale.
Events
LaunchpadRequestCreated(uint requestId, address admin, address tokenAddress)
: Emitted when a new launchpad request is created.LaunchpadRequestApproved(uint requestId, address launchpadAddress)
: Emitted when a launchpad request is approved.LaunchpadRequestCanceled(uint requestId)
: Emitted when a launchpad request is canceled.
Functions
initialize
function initialize(address _config) public initializer
Initializes the contract with the given configuration address. Sets the owner of the contract to the deployer.
_config
: Address of the configuration contract.
requestLaunchpad
function requestLaunchpad(
address _tokenAddress,
uint256 _saleStartTime,
uint256 _saleEndTime,
uint256 _tokenPrice,
address _baseToken,
uint256 _tokenAmount,
uint256 _baseAmount,
uint256 _minAmount,
bool _isVestingEnabled
) public
Allows users to request the creation of a launchpad for their token sale.
_tokenAddress
: Address of the token to be sold._saleStartTime
: Start time of the token sale._saleEndTime
: End time of the token sale._tokenPrice
: Price of the token._baseToken
: Address of the base token (e.g., stablecoin)._tokenAmount
: Amount of tokens to be sold._baseAmount
: Amount of base tokens to be raised._minAmount
: Minimum amount of tokens to be sold._isVestingEnabled
: Boolean indicating if vesting is enabled.
approveLaunchpadRequest
function approveLaunchpadRequest(uint256 requestId) external onlyOwner
Allows the owner to approve a launchpad request. Creates a new launchpad and transfers the necessary tokens.
requestId
: ID of the request to be approved.
cancelLaunchpadRequest
function cancelLaunchpadRequest(uint256 requestId) external onlyOwner
Allows the owner to cancel a launchpad request.
requestId
: ID of the request to be canceled.
_createLaunchpad
function _createLaunchpad(
address _admin,
address _tokenAddress,
uint256 _saleStartTime,
uint256 _saleEndTime,
uint256 _tokenPrice,
address _baseToken,
uint256 tokenAmount,
uint256 _baseAmount,
uint256 _minAmount,
bool _isVestingEnabled
) private returns (address)
Creates a new launchpad and initializes it with the given parameters. Transfers the necessary tokens to the new launchpad.
_admin
: Address of the launchpad admin._tokenAddress
: Address of the token to be sold._saleStartTime
: Start time of the token sale._saleEndTime
: End time of the token sale._tokenPrice
: Price of the token._baseToken
: Address of the base token (e.g., stablecoin).tokenAmount
: Amount of tokens to be sold._baseAmount
: Amount of base tokens to be raised._minAmount
: Minimum amount of tokens to be sold._isVestingEnabled
: Boolean indicating if vesting is enabled.
isWhitelisted
function isWhitelisted(address user) public view returns (bool)
Checks if a user is whitelisted.
user
: Address of the user to check.
getLaunchpadDetails
function getLaunchpadDetails(address _launchpadAddress) external view returns (LaunchpadRequest memory)
Returns the details of a launchpad given its address.
_launchpadAddress
: Address of the launchpad.
setVestingContract
function setVestingContract(address _launchpadAddress, address _vestingContract) external onlyOwner
Sets the vesting contract for a specific launchpad.
_launchpadAddress
: Address of the launchpad._vestingContract
: Address of the vesting contract.
addLaunchpad
function addLaunchpad(
address _admin,
address _tokenAddress,
uint256 _saleStartTime,
uint256 _saleEndTime,
uint256 _tokenPrice,
address _baseToken,
uint256 _tokenAmount,
uint256 _baseAmount,
uint256 _minAmount,
bool _isVestingEnabled
) public onlyOwner
Allows the owner to directly add a new launchpad without a request.
_admin
: Address of the launchpad admin._tokenAddress
: Address of the token to be sold._saleStartTime
: Start time of the token sale._saleEndTime
: End time of the token sale._tokenPrice
: Price of the token._baseToken
: Address of the base token (e.g., stablecoin)._tokenAmount
: Amount of tokens to be sold._baseAmount
: Amount of base tokens to be raised._minAmount
: Minimum amount of tokens to be sold._isVestingEnabled
: Boolean indicating if vesting is enabled.
Last updated
Was this helpful?