Skip to content

Latest commit

 

History

History
390 lines (276 loc) · 11 KB

PrivateSale.md

File metadata and controls

390 lines (276 loc) · 11 KB

Virtual Rehab Private Sale. (PrivateSale.sol)

contract PrivateSale is TokenPrice, EtherPrice, BinanceCoinPrice, CreditsTokenPrice, BonusHolder, FinalizableCrowdsale, CustomWhitelist

PrivateSale

This contract enables contributors to participate in Virtual Rehab Private Sale.

The Virtual Rehab Private Sale provides early investors with an opportunity to take part into the Virtual Rehab token sale ahead of the pre-sale and main sale launch. All early investors are expected to successfully complete KYC and whitelisting to contribute to the Virtual Rehab token sale.

US investors must be accredited investors and must provide all requested documentation to validate their accreditation. We, unfortunately, do not accept contributions from non-accredited investors within the US along with any contribution from China, Republic of Korea, and New Zealand. Any questions or additional information needed can be sought by sending an e-mail to investors@virtualrehab.co.

Accepted Currencies: Ether, Binance Coin, Credits Token.

Constructor

Creates and constructs this private sale contract.

constructor(uint256 _startTime, uint256 _endTime) public

Arguments

Contract Members

Constants & Variables

//public members
contract ERC20 public binanceCoin;
contract ERC20 public creditsToken;
uint256 public totalTokensSold;
uint256 public totalSaleAllocation;
uint256 public minContributionInUSDCents;
mapping(address => uint256) public assignedBonusRates;
uint256[3] public bonusLimits;
uint256[3] public bonusPercentages;
bool public initialized;

//private members
uint256 private amountInUSDCents;

Events

event SaleInitialized();
event MinimumContributionChanged(uint256 _newContribution, uint256 _oldContribution);
event ClosingTimeChanged(uint256 _newClosingTime, uint256 _oldClosingTime);
event FundsWithdrawn(address indexed _wallet, uint256 _amount);
event ERC20Withdrawn(address indexed _contract, uint256 _amount);
event TokensAllocatedForSale(uint256 _newAllowance, uint256 _oldAllowance);
Name Type Description
_startTime uint256 The date and time of the private sale start.
_endTime uint256 The date and time of the private sale end.

Functions

initializePrivateSale

Initializes the private sale.

function initializePrivateSale(uint256 _etherPriceInCents, uint256 _tokenPriceInCents, uint256 _binanceCoinPriceInCents, uint256 _creditsTokenPriceInCents, uint256 _minContributionInUSDCents) external onlyAdmin

Arguments

Name Type Description
_etherPriceInCents uint256 Ether Price in cents
_tokenPriceInCents uint256 VRHToken Price in cents
_binanceCoinPriceInCents uint256 Binance Coin Price in cents
_creditsTokenPriceInCents uint256 Credits Token Price in cents
_minContributionInUSDCents uint256 The minimum contribution in dollar cent value

contributeInBNB

Enables a contributor to contribute using Binance coin.

function contributeInBNB() external ifWhitelisted whenNotPaused onlyWhileOpen

contributeInCreditsToken

function contributeInCreditsToken() external ifWhitelisted whenNotPaused onlyWhileOpen

setMinimumContribution

function setMinimumContribution(uint256 _cents) public whenNotPaused onlyAdmin

Arguments

Name Type Description
_cents uint256

_preValidatePurchase

🔺 overrides TimedCrowdsale._preValidatePurchase

Additional validation rules before token contribution is actually allowed.

function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal whenNotPaused ifWhitelisted

Arguments

Name Type Description
_beneficiary address The contributor who wishes to purchase the VRH tokens.
_weiAmount uint256 The amount of Ethers (in wei) wished to contribute.

_processPurchase

🔺 overrides Crowdsale._processPurchase

This function is automatically called when a contribution request passes all validations.

function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal

Arguments

Name Type Description
_beneficiary address The contributor who wishes to purchase the VRH tokens.
_tokenAmount uint256 The amount of tokens wished to purchase.

calculateBonus

Calculates bonus.

function calculateBonus(uint256 _tokenAmount, uint256 _percentage) public pure
returns(uint256)

Arguments

Name Type Description
_tokenAmount uint256 The total amount in VRH tokens.
_percentage uint256 bonus percentage.

setBonuses

Sets the bonus structure. The bonus limits must be in decreasing order.

function setBonuses(uint256[] _bonusLimits, uint256[] _bonusPercentages) public onlyAdmin

Arguments

Name Type Description
_bonusLimits uint256[]
_bonusPercentages uint256[]

getBonusPercentage

Gets the bonus applicable for the supplied dollar cent value.

function getBonusPercentage(uint256 _cents) public view
returns(uint256)

Arguments

Name Type Description
_cents uint256

convertToCents

Converts the amount of Ether (wei) or amount of any token having 18 decimal place divisible to cent value based on the cent price supplied.

function convertToCents(uint256 _tokenAmount, uint256 _priceInCents, uint256 _decimals) public pure
returns(uint256)

Arguments

Name Type Description
_tokenAmount uint256
_priceInCents uint256
_decimals uint256

_getTokenAmount

🔺 overrides Crowdsale._getTokenAmount

Calculates the number of VRH tokens for the supplied wei value.

function _getTokenAmount(uint256 _weiAmount) internal view
returns(uint256)

Arguments

Name Type Description
_weiAmount uint256 The total amount of Ether in wei value.

getTokenAmountForWei

Used only for test, drop this function before deployment.

function getTokenAmountForWei(uint256 _weiAmount) external view
returns(uint256)

Arguments

Name Type Description
_weiAmount uint256 The total amount of Ether in wei value.

increaseTokenSaleAllocation

Recalculates and/or reassigns the total tokens allocated for the private sale.

function increaseTokenSaleAllocation() public whenNotPaused onlyAdmin

withdrawToken

Enables the admins to withdraw Binance coin or any ERC20 token accidentally sent to this contract.

function withdrawToken(address _token) external onlyAdmin

Arguments

Name Type Description
_token address

finalizeCrowdsale

Must be called after crowdsale ends, to do some extra finalization work.

function finalizeCrowdsale() public onlyAdmin

hasClosed

🔺 overrides TimedCrowdsale.hasClosed

Signifies whether or not the private sale has ended.

function hasClosed() public view
returns(bool)

Returns

Returns true if the private sale has ended.

finalization

🔺 overrides FinalizableCrowdsale.finalization

Reverts the finalization logic. Use finalizeCrowdsale instead.

function finalization() internal

_forwardFunds

🔺 overrides Crowdsale._forwardFunds

Stops the crowdsale contract from sending ethers.

function _forwardFunds() internal

withdrawFunds

Enables the admins to withdraw Ethers present in this contract.

function withdrawFunds(uint256 _amount) external whenNotPaused onlyAdmin

Arguments

Name Type Description
_amount uint256 Amount of Ether in wei value to withdraw.

changeClosingTime

Adjusts the closing time of the crowdsale.

function changeClosingTime(uint256 _closingTime) external whenNotPaused onlyAdmin

Arguments

Name Type Description
_closingTime uint256 The timestamp when the crowdsale is closed.

getRemainingTokensForSale

function getRemainingTokensForSale() public view
returns(uint256)

Contracts