Open code423n4 opened 2 years ago
Use safeTransfer or require()/conditional instead of transfer/transferFrom Agree
Use SafeERC20.safeApprove() disagree as impl is known
Deprecated library used for Solidity 0.8.11: SafeMath Actually safeMath is not deprecated: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol
Missing Address(0) checks Agree
Variables that should be constant Agree (but gas)
Variables that should be bounded Fee unbounded is dup of #242 (med)
Possible division by 0 You don't need it on 0.8.X
Rest is not too noteworthy
2
@CloudEllie please create new issue for the Med finding above.
Created separate issue for "Variables that should be bounded": #277
QA Report
Table of Contents:
Transfers
Prevent accidentally burning tokens
Transferring tokens to the zero address is usually prohibited to accidentally avoid "burning" tokens by sending them to an unrecoverable zero address.
Places where I couldn't find a zero address check (or where the destination isn't a zero-checked address):
I suggest adding a check to prevent accidentally burning tokens.
Use safeTransfer or require()/conditional instead of transfer/transferFrom
Silent failures (lack of failure detection / revert in case of failure) may happen here:
Consider using safeTransfer. That's already the case at other places on the same contract
Use SafeERC20.safeApprove()
approve()
will fail for certain token implementations that do not return a boolean value. It is recommended to use OpenZeppelin's SafeERC20's safeApprove().Instances include:
Libraries
Deprecated library used for Solidity 0.8.11: SafeMath
Use Solidity 0.8.*'s default checks instead:
Variables
Missing Address(0) checks
Variables that should be constant
Variables that are assumed to be initialized before a function call, but might not be
Variables that should be bounded
The variable
MasterChef.sol:43: uint16 depositFeeBP; // Deposit fee in basis points
is never bounded, and UInt16.MaxValue is 65535Variables that should be grouped together in a struct
For maps that use the same key value: having separate fields is error prone (like in case of deletion or future new fields).
File: ConvexStakingWrapper.sol
6 maps can be grouped together, as they use the same
pid
:I'd suggest these 3 related data get grouped in a struct, let's name it
RewardInfo
:And it would be used as a state variable in this manner (where
uint256
ispid
):File: Shelter.sol
3 maps can be grouped together, as they use the same
_token
:I'd suggest these 3 related data get grouped in a struct, let's name it
TokenInfo
:And it would be used as a state variable in this manner (where
IERC20
is_token
):Functions
Functions that should be declared external
Arithmetics
Possible division by 0
There are no checks that the denominator is
!= 0
at thoses lines: