Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CodeArena] - Med/High Risk fixes #100

Merged
merged 8 commits into from
Feb 18, 2022
5 changes: 4 additions & 1 deletion contracts/NestedFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ contract NestedFactory is INestedFactory, ReentrancyGuard, OwnableProxyDelegatio
}

/// @dev Receive function
receive() external payable {}
receive() external payable {
require(msg.sender == address(weth), "NF: ETH_SENDER_NOT_WETH");
}

/* ------------------------------ MODIFIERS ---------------------------- */

Expand Down Expand Up @@ -486,6 +488,7 @@ contract NestedFactory is INestedFactory, ReentrancyGuard, OwnableProxyDelegatio
bool _fromReserve
) private returns (IERC20, uint256) {
if (address(_inputToken) == ETH) {
require(!_fromReserve, "NF: NO_ETH_FROM_RESERVE");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❔ I'm not sure I understand why is this one necessary.

Copy link
Contributor Author

@maximebrugel maximebrugel Feb 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

safe guard to not use ETH when it's from the reserve (this is possible) and the user can take the ETH from the contract

require(address(this).balance >= _inputTokenAmount, "NF: INVALID_AMOUNT_IN");
weth.deposit{ value: _inputTokenAmount }();
return (IERC20(address(weth)), _inputTokenAmount);
Expand Down