-
Notifications
You must be signed in to change notification settings - Fork 5
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] : Gas optimizations fixes #101
Conversation
@@ -138,7 +137,7 @@ contract NestedFactory is INestedFactory, ReentrancyGuard, OwnableProxyDelegatio | |||
/// @inheritdoc INestedFactory | |||
function unlockTokens(IERC20 _token) external override onlyOwner { | |||
uint256 amount = _token.balanceOf(address(this)); | |||
_token.safeTransfer(owner(), amount); | |||
SafeERC20.safeTransfer(_token, msg.sender, amount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previous logic was sending tokens to the owner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function is onlyOwner
, so msg.sender = owner()
. It was better to user msg.sender
instead of calling the function.
_transferFeeWithRoyalty(amountFees, _buyToken, _nftId); | ||
_safeTransferAndUnwrap(_buyToken, amountBought, _msgSender()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the gas opt worth doing something like this?
From what I read in the documentation, it should be safe to englobe the rest of the function in the unchecked scope but it still makes me a bit uncomfortable while reading the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the function calls inside the unchecked
block because they need to reach the two variables (amountBought
and amountFees
), everything declared inside a block is not reachable (unchecked {...}
or simply {...}
).
However, It will not effect the _transferFeeWithRoyalty
and _transferFeeWithRoyalty
that will stay checked, it only affect arithmetic operations :
Contains all gas optimizations issues