contract Crowdsale {
    address payable owner;
    address me = address(this);
    uint sat = 1e18;
    
    // *** Config ***
    uint startFst = 1599753600;
    uint periodFst = 1 days;
    uint periodScd = 1 days;
    uint percentSell = 35;
    uint256 priceFst = 4; // 0.4 ETH
    uint256 priceScd = 5; // 0.5 ETH
    // --- Config ---

    uint startScd =  startFst + periodFst;
    uint stopSell = startScd + periodScd;
    ERC20 token = new ERC20();
    
    constructor() public {
        owner = msg.sender;
        token.transfer(owner, token.totalSupply() / 100 * (100 - percentSell));
    }

    function() external payable {
        require(startFst < now && now < stopSell, "Period error");
        uint amount = msg.value / getPrice() * 10;
        require(amount <= token.balanceOf(address(this)), "Infucient token balance in ICO");
        token.transfer(msg.sender, amount);
    }
    
    function manualGetETH() public payable {
        require(msg.sender == owner, "You is not owner");
        owner.transfer(address(this).balance);
    }
    
    function getLeftTokens() public {
        require(msg.sender == owner, "You is not owner");
        require(now > stopSell, "ICO is not closed");
        token.transfer(owner, token.balanceOf(address(this)));
    }
    
    function getPrice() public view returns (uint) {
        return now < startScd ? priceFst : priceScd;
    }
    
    // Utils
    function getStartICO() public view returns (uint) {
        return startFst - now;
    }
    function getStartScd() public view returns (uint) {
        return startScd - now;
    }
    function getStopSell() public view returns(uint){
        return stopSell - now;
    }
    function tokenAddress() public view returns (address){
        return address(token);
    }
    function ICO_deposit() public view returns(uint){
        return token.balanceOf(address(this));
    }
    function myBalance() public view returns(uint){
        return token.balanceOf(msg.sender);
    }
}
function getStartICO() public view returns (uint) {
        return startFst - now;
    }
// Utils