Closed code423n4 closed 2 years ago
- _safeMint() should be used rather than _mint() wherever possible
Duplicate: Contracts that can’t handle ERC721 tokens will lose their Putty ERC721 position tokens: https://github.com/code-423n4/2022-06-putty-findings/issues/327
Disagree with (1), checking return value for WETH is unneeded. Since (2) is upgraded, I'm invalidating this report.
1. Use safeTransfer/safeTransferFrom consistently instead of transfer/transferFrom
It is good to add a require() statement that checks the return value of token transfers or to use something like OpenZeppelin’s safeTransfer/safeTransferFrom unless one is sure the given token reverts in case of a failure. Failure to do so will cause silent failures of transfers and affect token accounting in contract.
Instances:
PuttyV2.sol #L336
Reference:
This similar medium-severity finding from Consensys Diligence Audit of Fei Protocol.
Recommended Mitigation Steps:
Consider using safeTransfer/safeTransferFrom or require() consistently.
2. _safeMint() should be used rather than _mint() wherever possible
_mint()
is discouraged in favor of_safeMint()
which ensures that the recipient is either an EOA or implementsIERC721Receiver
. Both open OpenZeppelin and solmate have versions of this function so that NFTs aren’t lost if they’re minted to contracts that cannot transfer them back out.Instances
PuttyV2.sol #L303 PuttyV2.sol #L303
Recommendations:
Use _safeMint() instead of _mint().