VTVL contest - JohnnyTime's results

Building no-code token management tools to empower web3 founders and investors, starting with token vesting.

General Information

Platform: Code4rena

Start Date: 20/09/2022

Pot Size: $30,000 USDC

Total HM: 12

Participants: 198

Period: 3 days

Judge: 0xean

Total Solo HM: 2

Id: 164

League: ETH

VTVL

Findings Distribution

Researcher Performance

Rank: 142/198

Findings: 1

Award: $18.87

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

18.8655 USDC - $18.87

Labels

bug
QA (Quality Assurance)
edited-by-warden

External Links

Unused imports of Ownable.sol

Affected Contracts

  • AccessProtected.sol#5
  • VTVLVesting.sol#6

Description

The contracts mentioned above import the Ownable.sol OZ contract without using it.

The AccessProtected.sol implements its own access control functionality and it doesn’t inherit from Ownable.sol neither it used any of its functions.

The VTVLVesting.sol inherits AccessProtected.sol and uses its access control logic. There is no need to import Ownable.sol since it doesn’t use any of its functions or modifiers.

Mitigation

To improve readability and avoid confusion, consider removing unused imports.

Gas Optimization in VTVLVesting.sol (withdraw function)

Affected Functions

Description

The withdraw function reverts in case allowance > usrClaim.amountWithdrawn, in case allowance = usrClaim.amountWithdrawn, it continues its execution calculating the amountRemaining, then transferring the tokens to the recipient.

A user might call this function mistakenly twice in a short period of time which will lead to allowance = usrClaim.amountWithdrawn and amountRemaining = 0.

The require won’t be triggered and the function will continue its execution adding and removing the number 0 from storage variables and calling the safeTransfer function with 0 as a parameter.

These extra opcodes will consume more gas from the user which could be avoided.

Mitigation

Don’t continue the withdraw function execution in case the allowance = usrClaim.amountWithdrawn to save gas for users.

Change the following line of code:

require(allowance > usrClaim.amountWithdrawn, "NOTHING_TO_WITHDRAW");

To:

require(allowance >= usrClaim.amountWithdrawn, "NOTHING_TO_WITHDRAW");
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