QA Report #131
Labels
bug
Something isn't working
QA - High quality report
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
Low Risk Issues
Vaults can be created with non-existent/destructed tokens
At the top of
SafeTransferLib.sol
is the following comment:/// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller.
The functions
safeTransferFrom()
andsafeTransfer()
fromSafeTransferLib.sol
do not check if a token contract actually contains code. Thus, if the provided token address has no code, these functions will not revert as low-level calls to non-contracts always return success.For example, if a user creates a vault and provides
address(0)
as the token address, functions such aswithdraw()
andexercise()
will not revert despite the use of a non-legitimate token address.Below are the instances where
ERC20
token transfers are made without checking for code existence:To prevent users from creating vaults with non-legitimate token addresses, consider verifying the
token
parameter increateVault()
actually contains code. For example:Recommend using
safeTransferFrom()
instead oftransferFrom()
for NFTsThe EIP-721 standard states:
Cally.sol
usestransferFrom()
to facillitate the transfer ofERC721
NFTs from the contract to users, as shown below.In
exercise()
:In
withdraw()
:To prevent a permanent loss of NFTs, there should be checks in place to ensure
msg.sender
is capable of receiving NFTs. Otherwise, consider usingsafeTransferFrom()
instead oftransferFrom()
.Misleading comment on
transferFrom()
inCally.sol
The comment below implies the vault beneficiary is explicitly set to the account receiving the NFT, when it is merely set to
address(0)
:I suggest removing this line to prevent confusion.
Incorrect require string in
createVault()
Should be
"Reserve strike too big"
inCally.sol:169
:Missing parameter validation in functions
getVaultBeneficiary()
,vaults()
,getPremium()
These functions are only meant to be provided with IDs corresponding to vaults. To prevent confusion, they should check if the provided
vaultId
is valid, and revert should users accidentally provide anoptionId
instead.I recommend adding the following check to
getVaultBeneficiary()
,vaults()
,getPremium()
:Non-Critical Issues
Constants should be used rather than magic numbers
Instead of using
1e18
, I suggest using1 ether
to improve code readability.Cally.sol:284
:Cally.sol:418-419
:Typos
it's
should beits
:vaultId's
should bevaultId
string.concat()
can be used insteadstring.concat()
can be used instead ofabi.encodePacked(<str>,<str>)
inCally.sol:473
:Unecessary naming of return variables
Declaring a name for return variables in the following functions serve no purpose. I suggest only declaring the variable type.
Cally.sol:378-383
:Cally.sol:394-397
:The text was updated successfully, but these errors were encountered: