You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the addRewards function, you should store IRewardStaking(convexBooster).poolInfo(_pid) into a locally scoped variable so it is cheaper to retrieve mainPool (line 94) and lptoken (line 98).
In the addRewards function, you should use extraToken on line 131 instead of calling IRewardStaking(extraPool).rewardToken() to retrieve it again.
MasterChef
This require statement require(_token != address(0), "zero address"); in the add() function is IMO not required because only the owner can call this function.
This require statement require(user.amount > 0, "MasterChef: nothing to withdraw"); in the withdraw() function is not needed because if user.amount is actually 0, the function will still work correctly as intended since the next require statement will ensure that the user cannot withdraw more than his balance.
This if branch if (_amount > 0) in the withdraw() function is also not needed because user.amount is not modified when _amount is 0.
The text was updated successfully, but these errors were encountered:
In the addRewards function, you should store IRewardStaking(convexBooster).poolInfo(_pid) into a locally scoped variable so it is cheaper to retrieve mainPool (line 94) and lptoken (line 98).
Wouldn't actually save gas as both slots are read separately
In the addRewards function, you should use extraToken on line 131 instead of calling IRewardStaking(extraPool).rewardToken() to retrieve it again.
Would save 97 gas
This require statement require(_token != address(0), "zero address"); in the add() function is IMO not required because only the owner can call this function.
Refreshing take but ultimately will give 0 as someone else would argue the opposite and have a point
This require statement require(user.amount > 0, "MasterChef: nothing to withdraw"); in the withdraw() function is not needed because if user.amount is actually 0, the function will still work correctly as intended since the next require statement will ensure that the user cannot withdraw more than his balance.
Same as above, valid argument, no points
This if branch if (_amount > 0) in the withdraw() function is also not needed because user.amount is not modified when _amount is 0.
Gas optimisation
addRewards
function, you should storeIRewardStaking(convexBooster).poolInfo(_pid)
into a locally scoped variable so it is cheaper to retrieve mainPool (line 94) and lptoken (line 98).addRewards
function, you should useextraToken
on line 131 instead of callingIRewardStaking(extraPool).rewardToken()
to retrieve it again.require(_token != address(0), "zero address");
in theadd()
function is IMO not required because only the owner can call this function.require(user.amount > 0, "MasterChef: nothing to withdraw");
in thewithdraw()
function is not needed because ifuser.amount
is actually 0, the function will still work correctly as intended since the next require statement will ensure that the user cannot withdraw more than his balance.if (_amount > 0)
in thewithdraw()
function is also not needed becauseuser.amount
is not modified when_amount
is 0.The text was updated successfully, but these errors were encountered: