Raise Capital From Any Chain, Powered by LayerZero
- Add Your Private Keys to
hardhat.config.jsOR add it your .env file & import it tohardhat.config.js - Add RPC Endpoints for both the chains
- Add All The IDO, LZ & Stargate Details in
scripts/sourceDeploy.js&scripts/destinationDeploy.js - Deploy Destination Contract:
npx hardhat run --network localhost scripts/destinationDeploy.js - Run The
InitializeFunction on Destination contract - Deploy Source Contract:
npx hardhat run --network localhost scripts/sourceDeploy.js
function initialize(
IERC20 _token,
IERC20 _offeringToken,
uint256 _startTime,
uint256 _endTime,
uint256 _offeringAmount,
uint256 _raisingAmount,
uint256 _minAmount
) public onlyOwner
Initializes The IDO Details
| Name | Type | Description |
|---|---|---|
_token |
IERC20 | Investment Token |
_offeringToken |
IERC20 | Token being offered in exchange for _token |
_startTime |
uint256 | The time IDO will start (Unix Timestamp) |
_endTime |
uint256 | The time IDO will end (Unix Timestamp) |
_offeringAmount |
uint256 | The amount of _offeringTokens being offered |
_raisingAmount |
uint256 | The amount of _token being raised |
_minAmount |
uint256 | Minimum amount of _token one user can invest |
function setMinAmount(
uint256 _minAmount
) public onlyOwner
Sets minimum amount of _token one user can invest
| Name | Type | Description |
|---|---|---|
_minAmount |
uint256 | Minimum amount of token one user can invest |
function setOfferingAmount(
uint256 _offerAmount
) public onlyOwner
Sets offering amount. This function will fail in case owner changes amount after startTime
| Name | Type | Description |
|---|---|---|
_offerAmount |
uint256 | The amount of offeringTokens being offered |
function setRaisingAmount(
uint256 _raisingAmount
) public onlyOwner
Sets raising amount. This function will fail in case owner changes amount after startTime
| Name | Type | Description |
|---|---|---|
_raisingAmount |
uint256 | The amount of tokens being raised |
function deposit(uint256 _amount) public
Transfers user's token to the contract and registers user's investment. The function will fail in case user:
- IDO hasn't started
- IDO is already over
_amountis 0_amountis less thanminAmount
| Name | Type | Description |
|---|---|---|
_amount |
uint256 | The amount of tokens user is investing |
function omniDeposit(
uint256 _amount,
address _depositor
) internal
Internal function which registers user's investment - only accepts deposits from stargateRouter. The function will fail in case user:
- IDO hasn't started
- IDO is already over
_amountis 0_amountis less thanminAmount
| Name | Type | Description |
|---|---|---|
_amount |
uint256 | The amount of tokens user is investing |
_depositor |
address | The user who invested token |
function claim(
_user
) public
This functions allows users to claim their offeringTokens. The function will fail in case user:
- IDO hasn't ended
_userhasn't participated_userdoesn't have anything to claim
| Name | Type | Description |
|---|---|---|
_user |
address | The user who's offeringTokens are being claimed |
function hasClaimed(
_user
) external view returns (bool)
This function returns if the user has claimed his/her offeringTokens
| Name | Type | Description |
|---|---|---|
_user |
address | The user who's offeringTokens status you're checking |
function getUserAllocation(
_user
) external view returns (uint256)
This function returns user's allocation
| Name | Type | Description |
|---|---|---|
_user |
address | The user who you're checking |
function getOfferingAmount(
_user
) external view returns (uint256)
This function returns user's offering amount
| Name | Type | Description |
|---|---|---|
_user |
address | The user who you're checking |
function getRefundingAmount(
_user
) external view returns (uint256)
This function returns user's refunding amount
| Name | Type | Description |
|---|---|---|
_user |
address | The user who you're checking |
function getAddressListLength() external view returns (uint256)
This function returns total number of users invested in the IDO
function finalWithdraw(
uint256 _lpAmount,
uint256 _offerAmount
) public onlyOwner
This function helps withdraw token and offeringToken. This function will fail in case:
- It doesn't hold enough
tokens - It doesn't hold enough
offeringTokens - Transaction is not executed by owner
| Name | Type | Description |
|---|---|---|
_lpAmount |
uint256 | The amount of tokens owner wants to withdraw |
_offerAmount |
uint256 | The amount of offeringToken owner wants to withdraw |
function _nonblockingLzReceive(
uint16 _srcChainId,
bytes memory _srcAddress,
uint64 _nonce,
bytes memory _payload
) internal override
Usually meant for the user to remotely claim his assets
function sgReceive(
uint16 _chainId,
bytes memory _srcAddress,
uint _nonce,
address _token,
uint amountLD,
bytes memory _payload
) external
Usually meant for the user to invest remotely
function deposit(uint256 _amount) public
Transfers user's token to the contract and bridge user's investment to destination. The function will fail in case user:
- IDO hasn't started
- IDO is already over
_amountis 0_amountis less thanminAmount
| Name | Type | Description |
|---|---|---|
_amount |
uint256 | The amount of tokens user is investing |
function claim(
_user
) public
This functions allows users to remotely claim their offeringTokens. The function will fail in case user:
- IDO hasn't ended
_userhasn't participated_userdoesn't have anything to claimmsg.valueaka LZ fees aren't provided
| Name | Type | Description |
|---|---|---|
_user |
address | The user who's offeringTokens are being claimed |
function setMinAmount(
uint256 _minAmount
) public onlyOwner
Sets minimum amount of _token one user can invest
| Name | Type | Description |
|---|---|---|
_minAmount |
uint256 | Minimum amount of token one user can invest |
