contract CroYearnVaultsContract {
    using SafeERC20 for IERC20;
    event TransferVault(address indexed from, address indexed to, uint256 amount);

    function depositEth(
        address payable _wethContract,
        address _yErc20Contract
    ) public payable returns (bool) {
        require((msg.value > 0), "eth amount should be greater than 0");
        //convert ETH to WETH
        IWETH weth = IWETH(_wethContract);
        weth.deposit{value: msg.value, gas: 250000}();
        uint256 wethAmt = weth.balanceOf(address(this));

        //deposit weth to yToken
        weth.approve(_yErc20Contract, wethAmt);
        IYERC20 yToken = IYERC20(_yErc20Contract);
        yToken.deposit(wethAmt);
        uint256 yTokenAmt = yToken.balanceOf(address(this));
        // transfer yToken back to sender
        // yToken.transfer(msg.sender, yTokenAmt);
		IERC20(_yErc20Contract).safeTransfer(msg.sender, yTokenAmt);
        emit TransferVault(address(this), msg.sender, yTokenAmt);
        return true;
    }

    //requires approval from erc20 token to this contract
    function depositErc20(
        address _erc20Contract,
        address _yErc20Contract,
        uint256 _amount
    ) public returns (bool) {
        require((_amount > 0), "amount should be greater than 0");
        // transfer erc20 token to this contract
		IERC20(_erc20Contract).safeTransferFrom(msg.sender, address(this), _amount);
		IERC20(_erc20Contract).safeIncreaseAllowance(_yErc20Contract, _amount);

        // deposit erc20 token to vault
        IYERC20 yToken = IYERC20(_yErc20Contract);
        yToken.deposit(_amount);
        // send yTokens back to sender
        uint256 yTokenAmt = yToken.balanceOf(address(this));
        // yToken.transfer(msg.sender, yTokenAmt);
		IERC20(_yErc20Contract).safeTransfer(msg.sender, yTokenAmt);
        emit TransferVault(address(this), msg.sender, yTokenAmt);
		return true;
    }

	receive() external payable {}
}
function depositErc20(
    address _erc20Contract,
    address _yErc20Contract,
    uint256 _amount
) public returns (bool) {
    require((_amount > 0), "amount should be greater than 0");
    // transfer erc20 token to this contract
RC20(_erc20Contract).safeTransferFrom(msg.sender, address(this), _amount);
RC20(_erc20Contract).safeIncreaseAllowance(_yErc20Contract, _amount);

    // deposit erc20 token to vault
    IYERC20 yToken = IYERC20(_yErc20Contract);
    yToken.deposit(_amount);
    // send yTokens back to sender
    uint256 yTokenAmt = yToken.balanceOf(address(this));
    // yToken.transfer(msg.sender, yTokenAmt);
RC20(_yErc20Contract).safeTransfer(msg.sender, yTokenAmt);
    emit TransferVault(address(this), msg.sender, yTokenAmt);
turn true;
}

//requires approval from erc20 token to this contract