Platform: Code4rena
Start Date: 12/07/2022
Pot Size: $35,000 USDC
Total HM: 13
Participants: 78
Period: 3 days
Judge: 0xean
Total Solo HM: 6
Id: 135
League: ETH
Rank: 37/78
Findings: 2
Award: $77.05
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: joestakey
Also found by: 0x1f8b, 0x52, 0xDjango, 0xNazgul, 0xNineDec, 8olidity, Avci, Bahurum, Bnke0x0, Chom, ElKu, Funen, GimelSec, JC, Junnon, Kaiziron, Meera, PaludoX0, Picodes, ReyAdmirado, Sm4rty, Soosh, Waze, _Adam, __141345__, ak1, aysha, benbaessler, bin2chen, c3phas, cccz, cryptphi, csanuragjain, defsec, exd0tpy, fatherOfBlocks, gogo, hake, hansfriese, itsmeSTYJ, jonatascm, kyteg, mektigboy, oyc_109, pashov, rbserver, rishabh, robee, rokinot, sach1r0, sashik_eth, scaraven, simon135, slywaters
48.3438 USDC - $48.34
Severity: Low
Context: Swivel.sol#L544-L569
Description: Giving max/infinite approvals to contracts are dangerous because if those contracts are exploited then they can remove all the funds from the approving addresses.
Recommendation: Check allowance and approve as much as required.
Severity: Informational
Context: LibFuse.sol (All 3 contracts)
Description: These contracts are missing the SPDX license Identifier before the pragma version.
Recommendation:
Consider adding the SPDX license, more specifically, // SPDX-License-Identifier: AGPL-3.0-only
from transmissions11's original contract.
Severity: Informational
Context: ZcToken.sol#L152-L155 (onlyAdmin => onlyAuthorised)
,
Description: The modifier name is either not as it describes or can be more descriptive.
Recommendation: Change all occurrences of this modifier to be more intuitive.
Severity: Informational
Context: Swivel.sol#L33
, Swivel.sol#L120
, Swivel.sol#L157
, Swivel.sol#L192
, Swivel.sol#L221
, Swivel.sol#L286
, Swivel.sol#L317
, Swivel.sol#L347
, Swivel.sol#L382
, Swivel.sol#L707
, Swivel.sol#L708
, Swivel.sol#L716
, Swivel.sol#L721
, Swivel.sol#L740
, Swivel.sol#L741
, Swivel.sol#L748
, Swivel.sol#L752
Description: There should never be any TODOs in the code when deploying.
Recommendation: Finish the TODOs before deploying.
Severity: Informational
Context: Swivel.sol#L677 (reddem => redeem)
, Swivel.sol#L682 (Varifies => Verifies)
, Swivel.sol#L747 (withraw => withdraw)
, ZcToken.sol#L9 (compatability => compatibility)
, ZcToken.sol#L22 (compatability => compatibility)
, ZcToken.sol#L127 (delete it 2nd can)
, ZcToken.sol#L145 (recieving => receiving)
Description: Spelling errors in comments can cause confusion to both users and developers.
Recommendation: Check all misspellings to ensure they are corrected.
Severity: Informational
Context: All Contracts
Description: Some functions are missing @notice/@dev NatSpec comments for the function, @param for all/some of their parameters and @return for return values. Given that NatSpec is an important part of code documentation, this affects code comprehension, auditability and usability.
Recommendation: Add in full NatSpec comments for all functions to have complete code documentation for future use.
Severity: Informational
Context: ZcToken.sol
Description: Contracts should be deployed with the same compiler version and flags that they have been tested with thoroughly. Locking the pragma helps to ensure that contracts do not accidentally get deployed using, for example, an outdated compiler version that might introduce bugs that affect the contract system negatively.
Recommendation: Lock the pragma version.
Severity: Informational
Context: All Contracts
Description: It is better to use one Solidity compiler version across all contracts instead of different versions with different bugs and security checks.
Recommendation: Ensure all pragma versions are the same one.
Severity: Informational
Context: ZcToken.sol
Description: Using very old versions of Solidity prevents benefits of bug fixes and newer security checks. Using the latest versions might make contracts susceptible to undiscovered compiler bugs.
Recommendation: Consider using the most recent version.
🌟 Selected for report: joestakey
Also found by: 0x040, 0x1f8b, 0xDjango, 0xNazgul, 0xsam, Avci, Aymen0909, Bnke0x0, CRYP70, ElKu, Fitraldys, Funen, JC, Kaiziron, MadWookie, Meera, ReyAdmirado, Sm4rty, Soosh, TomJ, Waze, _Adam, __141345__, ajtra, benbaessler, c3phas, csanuragjain, durianSausage, exd0tpy, fatherOfBlocks, hake, ignacio, karanctf, kyteg, m_Rassska, oyc_109, rbserver, robee, rokinot, samruna, sashik_eth, simon135, slywaters
28.7085 USDC - $28.71
2**256 - 1
When 2**255
Should Be UsedContext: Swivel.sol#L549
Description:
Infinity can also be represented via ``2255, it's hex representation is
0x8000000000000000000000000000000000000000000000000000000000000000while
2256 - 1is
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff`. Then main difference is and where the gas savings come from is, zeros are cheaper than non-zero values in hex representation.
Recommendation:
Use 2**255
instead of 2**256 - 1
to save gas on deployment.
memory
Keyword When storage
Should Be UsedContext: MarketPlace.sol#L91
, MarketPlace.sol#L132
, MarketPlace.sol#L216
, MarketPlace.sol#L228
, MarketPlace.sol#L248
, MarketPlace.sol#L266
, MarketPlace.sol#L284
Description: When copying a state struct in memory, there are as many SLOADs and MSTOREs as there are fields. When reading the whole struct multiple times is not needed, it's better to actually only read the relevant field(s). When only some of the fields are read several times, these particular values should be cached instead of the whole state struct.
Recommendation:
Use the storage
keyword instead of the memory
keyword in these situations.
Context: VaultTracker.sol#L49-L77 (maturityRate)
, VaultTracker.sol#L82-L109 (maturityRate)
, VaultTracker.sol#L113-L139 (maturityRate)
, VaultTracker.sol#L152-L203 (maturityRate)
, VaultTracker.sol#L208-L239 (maturityRate)
, ZcToken.sol#L43-L48 (maturity, redeemer, protocol)
, ZcToken.sol#L52-L57 (maturity, redeemer, protocol)
, ZcToken.sol#L70-L75 (maturity, redeemer, protocol)
, ZcToken.sol#L79-L84 (maturity, redeemer, protocol)
, ZcToken.sol#L88-L93 (maturity, redeemer, protocol)
, ZcToken.sol#L98-L119 (maturity, redeemer, protocol)
, ZcToken.sol#L124-L137 (maturity, redeemer, protocol)
Description:
Functions that read state variables more than once can cache it into a local variable for repeated reads saving gas by converting expensive SLOAD
s into much cheaper MLOAD
s.
Recommendation: It's best to cach the state variables into memory when read more than once.
Immutable
Context: Swivel.sol#L33
Description:
Solidity 0.6.5
introduced immutable
as a major feature. It allows setting contract-level variables at construction time which gets stored in code rather than storage. Each call to it reads from storage, using a sload
costing 2100 gas cold or 100 gas warm. Setting it to immutable
will have each storage read of the state variable to be replaced by the instruction push32 value
, where value
is set during contract construction time and this costs only 3 gas.
Recommendation:
Set the state variable to immutable
Context: All Contracts
Description:
You can cut out 10 opcodes in the creation-time EVM bytecode if you declare a constructor payable. Making the constructor payable eliminates the need for an initial check of msg.value == 0
and saves 21 gas on deployment with no security risks.
Recommendation: Set the constructor to payable.
Context: All Contracts
Description:
Contracts most called functions could simply save gas by function ordering via Method ID. Calling a function at runtime will be cheaper if the function is positioned earlier in the order (has a relatively lower Method ID) because 22 gas are added to the cost of a function for every position that came before it. The caller can save on gas if you prioritize most called functions. One could use This tool
to help find alternative function names with lower Method IDs while keeping the original name intact.
Recommendation:
Find a lower method ID name for the most called functions for example mostCalled()
vs. mostCalled_41q()
is cheaper by 44 gas.
#0 - robrobbins
2022-08-31T19:27:54Z
some dupas or wontfixes