Neo Tokyo contest - 0xSolus'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: 59/123

Findings: 2

Award: $48.97

QA:
grade-b
Gas:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

---- Bytes.sol ----

Constructor not checking for 0 addresses when deployed in Bytes.sol L80. A mistake on the address is going to affect the whole implementation of the contract and can affect the tokens being minted and burned to 0 address.

UpgradeBytes(_amounts) avoids 0 amount check in Bytes.sol L95, if a user by accident calls the function with 0 as _amount it will actually execute costing gas to the user. The recommendation is to make sure that require(_amount != 0). The following assertion in the tests doesn't revert:

it("should revert on amount 0", async function () { await expect(NTBytes2_0.connect(alice.signer).upgradeBytes(0)).to.be.reverted })

---- NeoTokyoStaker.sol ----

In L1205 consider omitting the check of the range of enum _assetType as solidity already checks for it and emits a Panic error check. In this case the revert InvalidAssetType(uint256(_assetType)) is never hit.
In any case, the range of enum AssetType is 0..3, so the proper range check will be:

if (uint8(_assetType) > 3) { revert InvalidAssetType(uint256(_assetType)); }

There's a similar occurrence in L1688

#0 - c4-judge

2023-03-17T02:59:54Z

hansfriese marked the issue as grade-c

#1 - c4-judge

2023-04-04T09:25:55Z

hansfriese marked the issue as grade-b

#2 - hansfriese

2023-04-04T09:26:25Z

2L

---- NeoTokyoStaker.sol ----

Redundant Code because of repetition in the following lines:
L638-L641 L663-L667 Consider moving that logic into a seperate function to save gas.

function getVaultMultiplier(uint256 _vaultId) internal returns(string memory){ // Retrieve the credit rate multiplier of the Vault. IGenericGetter vault = IGenericGetter(VAULT); return (_vaultId != 0) ? vault.getCreditMultiplier(_vaultId) : ""; }

Replace L644 return identityCreditYield[rewardRate][getVaultMultiplier(_vaultId)];
Replace L670
return vaultCreditMultiplier[getVaultMultiplier(_vaultId)];

---- NeoTokyoStaker.sol ---- Consider changing _stringEquals(_a, _b) in L824 with 2107 gas cost for:

/** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return keccak256(bytes(a)) == keccak256(bytes(b)); }

This is implemented by openzeppelin, it's less code, easier to read and more gas efficient with 1931 gas of execution cost vs 2107.

#0 - c4-judge

2023-03-17T03:58:29Z

hansfriese marked the issue as grade-c

#1 - c4-judge

2023-03-24T14:11:10Z

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