contract CoinolixPresale is 
    AirdropAndAffiliateCrowdsale,
    //MintedCrowdsale,
    CappedCrowdsale,
    TimedCrowdsale,
    WhitelistedCrowdsale {
    using SafeMath for uint256;

    // Min investment
            uint256 public presaleRate;
    uint256 public minInvestmentInWei;
        event CurrentRateChange(uint256 rate);

    // Investments
    mapping (address => uint256) internal invested;

    /**
     * @dev Contract constructor
     * @param _cap uint256 hard cap of the crowdsale
     * @param _openingTime uint256 crowdsale start date/time
     * @param _closingTime uint256 crowdsale end date/time
     * @param _rate uint256 initial rate CLX for 1 ETH
     * @param _wallet address address where the collected funds will be transferred
     * @param _token CoinolixToken our token
     */
    constructor(
        uint256 _cap, 
        uint256 _openingTime, 
        uint256 _closingTime, 
        uint256 _rate, 
        uint256 _minInvestmentInWei,
        address _wallet, 
        CoinolixToken _token,
        uint256 _valueAirDrop, 
        uint256 _referrerBonus1, 
        uint256 _referrerBonus2) 
        Crowdsale(_rate, _wallet, _token)
        AirdropAndAffiliateCrowdsale(_valueAirDrop, _referrerBonus1, _referrerBonus2)
        CappedCrowdsale(_cap)
        TimedCrowdsale(_openingTime, _closingTime) public {
        minInvestmentInWei = _minInvestmentInWei;
        presaleRate = _rate;

     }
        //update rate function by owner to keep stable rate in USD
      function updatepresaleRate(uint256 _rate) external onlyOwner {
    presaleRate = _rate;
    rate = presaleRate;
      }
  
    /**
    * @dev Validate min investment amount
    * @param _beneficiary address token purchaser
    * @param _weiAmount uint256 amount of wei contributed
    */
    function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
        super._preValidatePurchase(_beneficiary, _weiAmount);
        require(_weiAmount >= minInvestmentInWei);
    }

    /**
    * @dev Transfer the ownership of the token conctract 
    * @param _newOwner address the new owner of the token
    */
    function transferTokenOwnership(address _newOwner) onlyOwner public { 
        Ownable(token).transferOwnership(_newOwner);
    }
}
/**
 * @title Coinolix icoPresale Contract
 * @dev Coinolix icoPresale Contract
 * The contract is for the private sale of the Coinolix icotoken. It is:
 * - With a hard cap in ETH
 * - Limited in time (start/end date)
 * - Only for whitelisted participants to purchase tokens
 * - Tokens are minted on each purchase
 */
function updatepresaleRate(uint256 _rate) external onlyOwner {
    presaleRate = _rate;
    rate = presaleRate;
      }
//update rate function by owner to keep stable rate in USD