Platform: Code4rena
Start Date: 05/01/2023
Pot Size: $90,500 USDC
Total HM: 55
Participants: 103
Period: 14 days
Judge: Picodes
Total Solo HM: 18
Id: 202
League: ETH
Rank: 60/103
Findings: 2
Award: $88.11
๐ Selected for report: 0
๐ Solo Findings: 0
๐ Selected for report: ladboy233
Also found by: 0x1f8b, 0xAgro, 0xSmartContract, 0xbepresent, 0xkato, Aymen0909, CodingNameKiki, Cryptor, Deekshith99, Deivitto, HE1M, IllIllI, Kaysoft, Koolex, PaludoX0, Qeew, RaymondFam, Rolezn, Sathish9098, Tointer, a12jmx, arialblack14, ast3ros, ayeslick, bin2chen, btk, caventa, ch0bu, chaduke, chrisdior4, delfin454000, descharre, evan, fatherOfBlocks, georgits, gz627, jasonxiale, joestakey, kaden, lukris02, nicobevi, nogo, oberon, oyc_109, pfapostol, rbserver, sakshamguruji, seeu, shark, simon135, slvDev, synackrst, tnevler, whilom, zaskoh
51.3151 USDC - $51.32
The documentation is stating that a borrower can take up to 5 loans against the same NFT, but the code is not limiting the borrower. Considering adding a check to limit the number of loans or update the documentation.
init
method is callable multiple timesUpgradable contracts should be initialized only once. Consider adding a check to prevent multiple calls to the init method. Even if the method is technically not callable by anyone and it is setting the delegate address and the allow list. It is still a good practice to add a check to prevent multiple calls.
Code architecture, incentives, and error handling/reporting questions/issues should be resolved before deployment.
// check for rounding error since we round down in previewRedeem.
ERC20 tokenContract = ERC20(tokenAddress);
external
over public for function not called internally by the contractAs mentioned in solidity documention, it is recommended to follow the order layout in contract.
NatSpec is missing for some functions.
Considering the number of conditions, it is recommended to use switch statement instead of if-else.
Use pragma abicoder v2 instead
#0 - c4-judge
2023-01-26T14:38:23Z
Picodes marked the issue as grade-b
๐ Selected for report: c3phas
Also found by: 0x1f8b, 0xAgro, 0xSmartContract, 0xackermann, 0xkato, Aymen0909, Bnke0x0, CloudX, IllIllI, PaludoX0, Rageur, Rahoz, RaymondFam, ReyAdmirado, Rolezn, SadBase, SaeedAlipoor01988, caventa, chaduke, chrisdior4, fatherOfBlocks, fs0c, kaden, nogo, pfapostol, shark, synackrst
36.79 USDC - $36.79
No additional checks are required since the function can accept both zero or non-zero values of ether.
_validateCommitment
can be called at the begining of the function to save gas. This will also improve readability.
Custom errors are available from solidity version 0.8.0. Custom errors save ~50 gas each time theyโre hit by avoiding having to allocate and store the revert string. Not defining the strings also save deployment gas.
Booleans are more expensive than uint256 or any type that takes up a full word because each write operation emits an extra SLOAD to first read the slot's contents, replace the bits taken up by the boolean, and then write back. This is the compiler's defense against contract upgrades and pointer aliasing, and it cannot be disabled. Use uint256(1) and uint256(2) for true/false instead
Example
assembly { if iszero(_addr) { mstore(0x00, "zero address") revert(0x00, 0x20) } }
Try to keep the number of internal and private functions to a minimum to balance function complexity and quantity. In turn, this will help you reduce gas fees upon execution by reducing the number of function calls. However, keep in mind that having too large functions makes testing more difficult and even jeopardizes security.
function _settleAuction(CollateralStorage storage s, uint256 collateralId) internal { delete s.collateralIdToAuction[collateralId]; }
#0 - c4-judge
2023-01-25T23:52:16Z
Picodes marked the issue as grade-b