contract yDAIv2Proxy is ReentrancyGuard, Ownable {
  using SafeERC20 for IERC20;
  using Address for address;
  using SafeMath for uint256;

  address public DAI;
  address public yDAI;

  // 1e18
  uint256 public fee;

  constructor () public {
      DAI = address(0x6B175474E89094C44Da98b954EedeAC495271d0F);
      yDAI = address(0x16de59092dAE5CcF4A1E6439D611fd0653f0Bd01);
      fee = 1000000000000000;

      approveToken();
  }


  function set_new_Fee(uint256 _new_Fee) public onlyOwner {
      fee = _new_Fee;
  }

  function() external payable {

  }

  function approveToken() public {
      IERC20(DAI).safeApprove(yDAI, uint(-1));
  }

  function deposit(uint256 _amount)
      external
      nonReentrant
  {
      require(_amount > 0, "amount must be greater than 0");
      IERC20(DAI).safeTransferFrom(msg.sender, address(this), _amount);
      uint256 _fee = 0;
      if (fee > 0) {
        _fee = _amount.mul(fee).div(1e18);
      }
      uint256 amountSubFee = _amount.sub(_fee);
      yERC20(yDAI).deposit(amountSubFee);
      IERC20(yDAI).safeTransfer(msg.sender, IERC20(yDAI).balanceOf(address(this)));
      require(IERC20(yDAI).balanceOf(address(this)) == 0, "yDAI remainder");
  }

  // incase of half-way error
  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 inCaseTokenGetsStuck(IERC20 _TokenAddress) onlyOwner public {
      uint qty = _TokenAddress.balanceOf(address(this));
      _TokenAddress.safeTransfer(msg.sender, qty);
  }
// incase of half-way error