Neo Tokyo contest - 0x6980's results

A staking contract for the crypto gaming illuminati.

General Information

Platform: Code4rena

Start Date: 08/03/2023

Pot Size: $60,500 USDC

Total HM: 2

Participants: 123

Period: 7 days

Judge: hansfriese

Id: 220

League: ETH

Neo Tokyo

Findings Distribution

Researcher Performance

Rank: 94/123

Findings: 1

Award: $29.67

QA:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

1. for modern and more readable code; update import usages

Context: All Contracts.

//File:contracts/staking/BYTES2.sol
4:  import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
5:  import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

7:  import "../access/PermitControl.sol";
8:  import "../interfaces/IByteContract.sol";
9:  import "../interfaces/IStaker.sol";
//File:contracts/staking/NeoTokyoStaker.sol
4:  import "@openzeppelin/contracts/security/ReentrancyGuard.sol";

6:  import "../access/PermitControl.sol";
7:  import "../interfaces/IByteContract.sol";
8:  import "../interfaces/IGenericGetter.sol";

Recommendation: import {contract1 , contract2} from "filename.sol";

2. Function writing that does not comply with the Solidity Style Guide

Order of Functions; ordering helps readers identify which functions they can call and to find the constructor and fallback definitions easier. But there are contracts in the project that do not comply with this. soliditylang-style-guide Functions should be grouped according to their visibility and ordered:

constructor

receive function (if exists)

fallback function (if exists)

external

public

internal

private

within a grouping, place the view and pure functions last

3. Empty blocks should be removed or Emit something

Code contains empty block

193:	) external {
194:	}

207:	) external {
208:	}

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.

4. Showing the actual values of numbers in natspec comments makes checking and reading code easier.

197:	uint256 constant private _PRECISION = 1e12; // 1_000_000_000_000

203:	uint256 constant private _BYTES_PER_POINT = 200 * 1e18; 200_000_000_000_000_000_000

5. Use delete to clear variables instead of zero assignment.

You can use the delete keyword instead of setting the variable as zero.

1517:		stakedCitizen.stakedBytes = 0;
1518:		stakedCitizen.timelockEndTime = 0;
1519:		stakedCitizen.points = 0;
1520:		stakedCitizen.hasVault = false;
1521:		stakedCitizen.stakedVaultId = 0;

6. Generate perfect code headers every time.

Description: I recommend using header for Solidity code layout and readability

Headers

/*//////////////////////////////////////////////////////////////
                           TESTING 123
//////////////////////////////////////////////////////////////*/

7. Missing ReEntrancy Guard to upgradeBytes function.

93: 	function upgradeBytes (

8. Missing ReEntrancy Guard to getReward function

114:	function getReward (

#0 - c4-judge

2023-03-17T02:50:41Z

hansfriese marked the issue as grade-b

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter