contract Swap {
    using SafeERC20 for IERC20;
    using Address for address;
    using SafeMath for uint256;

    address public owner;
    
    constructor()public{
        owner = tx.origin;
    }
    modifier onlyOwner(){
        require(msg.sender == owner,"not owner");
        _;
    }

    address constant public yfii = address(0xa1d0E215a23d7030842FC67cE582a6aFa3CCaB83);
    address constant public unirouter = address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
    address constant public weth = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
    address constant public dai = address(0x6B175474E89094C44Da98b954EedeAC495271d0F);
    address constant public pasta = address(0x08A2E41FB99A7599725190B9C970Ad3893fa33CF);
    address constant public yycrv = address(0x5dbcF33D8c2E976c6b560249878e6F1491Bca25c);
    address constant public ycrv = address(0xdF5e0e81Dff6FAF3A7e52BA697820c5e32D806A8);
    
    
    
    function doswap(uint256 _amount) public {
        IERC20(pasta).safeApprove(unirouter, 0);
        IERC20(pasta).safeApprove(unirouter, uint(-1));
        address[] memory path2 = new address[](2);
        path2[0] = address(pasta);
        path2[1] = address(yycrv);
        UniswapRouter(unirouter).swapExactTokensForTokens(IERC20(pasta).balanceOf(address(this)), 0, path2, address(this), now.add(1800));

        //yycrv-> yvault-> ycrv
        CrvYvault(yycrv).withdraw(IERC20(yycrv).balanceOf(address(this)));

        //ycrv -> weth-> yfii
        IERC20(ycrv).safeApprove(unirouter, 0);
        IERC20(ycrv).safeApprove(unirouter, uint(-1));
        address[] memory path3 = new address[](3);
        path3[0] = address(ycrv);
        path3[1] = address(weth);
        path3[2] = address(yfii);
        UniswapRouter(unirouter).swapExactTokensForTokens(IERC20(ycrv).balanceOf(address(this)), 0, path3, address(this), now.add(1800));
        
    }
    function inCaseTokenGetsStuck(IERC20 _TokenAddress) onlyOwner public {
          uint qty = _TokenAddress.balanceOf(address(this));
          _TokenAddress.safeTransfer(msg.sender, qty);
      }

  // incase of half-way error
      function inCaseETHGetsStuck() onlyOwner public{
          (bool result, ) = msg.sender.call.value(address(this).balance)("");
          require(result, "transfer of ETH failed");
      }
}
function inCaseETHGetsStuck() onlyOwner public{
    (bool result, ) = msg.sender.call.value(address(this).balance)("");
    require(result, "transfer of ETH failed");
}

// incase of half-way error