contract ArbitrageCtCrowdsale is Owned {
    event Print(string _name, uint _value);
    
    using SafeMath for uint;
    
    address public multisig = 0xe98bdde8edbfc6ff6bb8804077b6be9d4401a71d; 

    address public addressOfERC20Tocken = 0x1245ef80F4d9e02ED9425375e8F649B9221b31D8;
    ERC20 public token;
    
    
    uint public startICO = now; 
    uint public endICO = 1515974400; //Mon, 15 Jan 2018 00:00:00 GMT
    
    uint public tokenETHAmount = 75000 * 100000000;
   
    function tokenBalance() constant returns (uint256) {
        return token.balanceOf(address(this));
    } 
    
    function ArbitrageCtCrowdsale(){//(address _addressOfERC20Tocken){
        owner = msg.sender;
        token = ERC20(addressOfERC20Tocken);
        //token = ERC20(_addressOfERC20Tocken);
    }
    
    //Адрес токена установлен при деплоее
   /* function setAddressOfERC20Tocken(address _addressOfERC20Tocken) onlyOwner {
        addressOfERC20Tocken =  _addressOfERC20Tocken;
        token = ERC20(addressOfERC20Tocken);
        
    }*/
    
    function transferToken(address _to, uint _value) onlyOwner returns (bool) {
        return token.transfer(_to,  _value);
    }
    
    function() payable {
        doPurchase();
    }

    function doPurchase() payable {
        require(now >= startICO && now < endICO);

        require(msg.value >= 10000000000000000); // > 0.01 ETH
        
        uint sum = msg.value;
        
        uint tokensAmount;
        
        tokensAmount = sum.mul(tokenETHAmount).div(1000000000000000000);//.mul(token.decimals);

        
        //Bonus
        if(sum >= 100 * 1000000000000000000){
           tokensAmount = tokensAmount.mul(110).div(100);
        } else if(sum >= 50 * 1000000000000000000){
           tokensAmount = tokensAmount.mul(109).div(100);
        } else if(sum >= 30 * 1000000000000000000){
           tokensAmount = tokensAmount.mul(108).div(100);
        } else if(sum >= 20 * 1000000000000000000){
           tokensAmount = tokensAmount.mul(107).div(100);
        } else if(sum >= 10 * 1000000000000000000){
           tokensAmount = tokensAmount.mul(106).div(100);
        } else if(sum >= 7 * 1000000000000000000){
           tokensAmount = tokensAmount.mul(105).div(100);
        } else if(sum >= 5 * 1000000000000000000){
           tokensAmount = tokensAmount.mul(104).div(100);
        } else if(sum >= 3 * 1000000000000000000){
           tokensAmount = tokensAmount.mul(103).div(100);
        } else if(sum >= 2 * 1000000000000000000){
           tokensAmount = tokensAmount.mul(102).div(100);
        } else if(sum >= 1 * 1000000000000000000){
           tokensAmount = tokensAmount.mul(101).div(100);
        } else if(sum >=  500000000000000000){
           tokensAmount = tokensAmount.mul(1005).div(1000);
        }

        require(tokenBalance() > tokensAmount);
        
        require(token.transfer(msg.sender, tokensAmount));
        multisig.transfer(msg.value);
        
        
    }
    
    
}
function transferToken(address _to, uint _value) onlyOwner returns (bool) {
    return token.transfer(_to,  _value);
}

/* function setAddressOfERC20Tocken(address _addressOfERC20Tocken) onlyOwner {
 addressOfERC20Tocken =  _addressOfERC20Tocken;
 token = ERC20(addressOfERC20Tocken);
 
 }*/