Platform: Code4rena
Start Date: 12/12/2022
Pot Size: $36,500 USDC
Total HM: 8
Participants: 103
Period: 7 days
Judge: berndartmueller
Id: 193
League: ETH
Rank: 45/103
Findings: 2
Award: $64.99
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: 0xSmartContract
Also found by: 0xGusMcCrae, 8olidity, Bnke0x0, IllIllI, JC, RaymondFam, Rolezn, SleepingBugs, UNCHAIN, ahayashi, aviggiano, caventa, cozzetti, h0wl, helios, immeas, ladboy233, minhquanym, obront, rjs, rvierdiiev, shung, unforgiven, yixxas
50.16 USDC - $50.16
N-01 Typos | 1 instance
N-02 Large multiples of ten should use scientific notation | 2 instance
N-03 Consider supporting CryptoPunks and EtherRocks | 1 instances
N-04 The visibility for constructor is ignored | 3 instances
L-01 Unspecific Compiler Version Pragma | 3 instances
L-02 Check that Contract Exists before using solmate's SafeTransferLib | 7 instances
L-03 Pairs do not implement ERC721TokenReceiver | 1 instance
Total: 18 instances in 7 issues.
Instance (1):
Pair.sol https://github.com/code-423n4/2022-12-caviar/blob/main/src/Pair.sol#L465 bytes32 instead of bytes23
Large multiples of ten should use scientific notation (e.g. 1e6) rather than decimal literals (e.g. 1000000), for readability
Instances (2):
Pair.sol https://github.com/code-423n4/2022-12-caviar/blob/main/src/Pair.sol#L399 https://github.com/code-423n4/2022-12-caviar/blob/main/src/Pair.sol#L408
The project SPECIFICATION.md says that Pairs are specifically ERC721 tokens (see import ERC721 lib from solmate), but not all NFTs are ERC721s. CryptoPunks and EtherRocks came before the standard and do not conform to it.
Instance (1):
Pair.sol https://github.com/code-423n4/2022-12-caviar/blob/main/src/Pair.sol#L5
Instances (3):
Pair.sol https://github.com/code-423n4/2022-12-caviar/blob/main/src/Pair.sol#L39
Caviar.sol https://github.com/code-423n4/2022-12-caviar/blob/main/src/Caviar.sol#L21
LpToken.sol https://github.com/code-423n4/2022-12-caviar/blob/main/src/LpToken.sol#L11
Avoid floating pragmas for non-library contracts. While floating pragmas make sense for libraries to allow them to be included with multiple different versions of applications, it may be a security risk for application implementations. A known vulnerable compiler version may accidentally be selected or security tools might fall-back to an older compiler version ending up checking a different EVM compilation that is ultimately deployed on the blockchain. It is recommended to pin to a concrete compiler version, e.g. 'pragma solidity ^0.8.0;' -> 'pragma solidity 0.8.4;"
Instances (3):
https://github.com/code-423n4/2022-12-caviar/blob/main/src/Pair.sol#L2 https://github.com/code-423n4/2022-12-caviar/blob/main/src/Caviar.sol#L2 https://github.com/code-423n4/2022-12-caviar/blob/main/src/LpToken.sol#L2
Functions in solmate's SafeTransferLib library do not check whether a token has code at all. This responsibility is delegated to the caller. As a call to an address with no code will be a no-op, since low-level calls to non-contracts always return true, a transfer of tokens using solmate's SafeTransferLib will succeed if the token does not have any code. Therefore, it is recommended to verify that a contract exists before using any SafeTransferLib functions.
Instances (7):
Pair.sol https://github.com/code-423n4/2022-12-caviar/blob/main/src/Pair.sol#L95 https://github.com/code-423n4/2022-12-caviar/blob/main/src/Pair.sol#L137 https://github.com/code-423n4/2022-12-caviar/blob/main/src/Pair.sol#L172 https://github.com/code-423n4/2022-12-caviar/blob/main/src/Pair.sol#L203 https://github.com/code-423n4/2022-12-caviar/blob/main/src/Pair.sol#L239 https://github.com/code-423n4/2022-12-caviar/blob/main/src/Pair.sol#L259 https://github.com/code-423n4/2022-12-caviar/blob/main/src/Pair.sol#L370
According to the SPECIFICATION.md, Pairs specifically involve ERC721 tokens. Therefore the contract should implement ERC721TokenReceiver, or customer transfers involving safeTransferFrom() calls will revert.
Instance (1):
Pair.sol https://github.com/code-423n4/2022-12-caviar/blob/main/src/Pair.sol#L5
#0 - c4-judge
2023-01-16T11:28:06Z
berndartmueller marked the issue as grade-b
🌟 Selected for report: Rolezn
Also found by: 0x1f8b, 0xAgro, 0xSmartContract, 0xab00, 0xhacksmithh, Aymen0909, Bnke0x0, Breeje, Diana, HardlyCodeMan, IllIllI, JC, JrNet, Madalad, NoamYakov, RaymondFam, ReyAdmirado, SleepingBugs, UdarTeam, c3phas, carlitox477, cryptonue, gz627, lukris02, millersplanet, oyc_109, pavankv, ret2basic, saneryee, tnevler
14.833 USDC - $14.83
Total: 13 instances in 5 issues.
Instances (2):
Pair.sol https://github.com/code-423n4/2022-12-caviar/blob/main/src/Pair.sol#L453
lib/SafeERC20Namer.sol https://github.com/code-423n4/2022-12-caviar/blob/main/src/lib/SafeERC20Namer.sol#L35
++i/i++ should be unchecked{++i}/unchecked{i++} when it is not possible for them to overflow, as is the case when used in for- and while-loops. The unchecked keyword is new in solidity version 0.8.0, so this only applies to that version or higher, which these instances are. This saves 30-40 gas PER LOOP
Instances (7):
Pair.sol https://github.com/code-423n4/2022-12-caviar/blob/main/src/Pair.sol#L238 https://github.com/code-423n4/2022-12-caviar/blob/main/src/Pair.sol#L258 https://github.com/code-423n4/2022-12-caviar/blob/main/src/Pair.sol#L468
lib/SafeERC20Namer.sol https://github.com/code-423n4/2022-12-caviar/blob/main/src/lib/SafeERC20Namer.sol#L13 https://github.com/code-423n4/2022-12-caviar/blob/main/src/lib/SafeERC20Namer.sol#L22 https://github.com/code-423n4/2022-12-caviar/blob/main/src/lib/SafeERC20Namer.sol#L33 https://github.com/code-423n4/2022-12-caviar/blob/main/src/lib/SafeERC20Namer.sol#L39
Instead of using the && operator in a single require statement to check multiple conditions, I suggest using multiple require statements with 1 condition per require statement (saving 3 gas per &).
Instance (1):
Pair.sol https://github.com/code-423n4/2022-12-caviar/blob/main/src/Pair.sol#L71
The code should be refactored such that they no longer exist, or the block should do something useful, such as emitting an event or reverting. If the contract is meant to be extended, the contract should be abstract and the function signatures be added without any default implementation.
Instance (1):
Caviar.sol https://github.com/code-423n4/2022-12-caviar/blob/main/src/Caviar.sol#L21
If a function modifier such as onlyOwner is used, the function will revert if a normal user tries to pay the function. Marking the function as payable will lower the gas cost for legitimate callers because the compiler will not include checks for whether a payment was provided. The extra opcodes avoided are CALLVALUE(2),DUP1(3),ISZERO(3),PUSH2(3),JUMPI(10),PUSH1(3),DUP1(3),REVERT(0),JUMPDEST(1),POP(2), which costs an average of about 21 gas per call to the function, in addition to the extra deployment cost.
Instances (2):
LpToken.sol https://github.com/code-423n4/2022-12-caviar/blob/main/src/LpToken.sol#L19 https://github.com/code-423n4/2022-12-caviar/blob/main/src/LpToken.sol#L26
#0 - c4-judge
2023-01-14T17:12:43Z
berndartmueller marked the issue as grade-b