contract VestingFactory is Ownable {
    
    event VestingCreated(address vestingContractAddress, address beneficiary);
    
    uint256 public constant START  = 1618707600; // start time 1618707600
    
    uint256 public constant CLIFF  = 86400 * 30; //30 days
    
    uint256 public constant DURATION  = 86400 * 180; //180 days
    
    uint256 public _usdcPrice = 150 * 1e4; // 1.5 USD 
    
    address public constant LIX = address(0xd0345D30FD918D7682398ACbCdf139C808998709); // LIX TOKEN 0xd0345D30FD918D7682398ACbCdf139C808998709
    
    address private constant USDC = address(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48); //USDC 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
    
    
    function purchaseWithUSDC(uint256 amount) public {
        uint256 cost = SafeMath.mul(amount, _usdcPrice);
        
        IERC20(USDC).transferFrom(msg.sender, address(this), cost);
        TokenVesting newVestingContract = new TokenVesting(msg.sender, START, CLIFF, DURATION, false); // IRREVOCCABLE. Meaning, once vested, the tokens stay vested. There's no admin function to cancel it midway.
        IERC20(LIX).transfer(address(newVestingContract), SafeMath.mul(amount, 1e18));
        VestingCreated(address(newVestingContract), msg.sender);
    }
    
    function changePrice(uint256 price) onlyOwner public {
        _usdcPrice = price;
    }
    
    function withdraw() onlyOwner public {
        uint balance = address(this).balance;
        msg.sender.transfer(balance);
    }
    
    function withdrawUSDC() onlyOwner public {
        uint balance = IERC20(USDC).balanceOf(address(this));
        IERC20(USDC).transfer(msg.sender, balance);
    }
    
    function withdrawLIX() onlyOwner public {
        uint balance = IERC20(LIX).balanceOf(address(this));
        IERC20(LIX).transfer(msg.sender, balance);
    }
    
}
function purchaseWithUSDC(uint256 amount) public {
    uint256 cost = SafeMath.mul(amount, _usdcPrice);
        
    IERC20(USDC).transferFrom(msg.sender, address(this), cost);
    TokenVesting newVestingContract = new TokenVesting(msg.sender, START, CLIFF, DURATION, false); // IRREVOCCABLE. Meaning, once vested, the tokens stay vested. There's no admin function to cancel it midway.
    IERC20(LIX).transfer(address(newVestingContract), SafeMath.mul(amount, 1e18));
    VestingCreated(address(newVestingContract), msg.sender);
}

//USDC 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48