FIAT DAO veFDT contest - chrisdior4's results

Unlock liquidity for your DeFi fixed income assets.

General Information

Platform: Code4rena

Start Date: 12/08/2022

Pot Size: $35,000 USDC

Total HM: 10

Participants: 126

Period: 3 days

Judge: Justin Goro

Total Solo HM: 3

Id: 154

League: ETH

FIAT DAO

Findings Distribution

Researcher Performance

Rank: 125/126

Findings: 1

Award: $14.95

🌟 Selected for report: 0

🚀 Solo Findings: 0

++i COSTS LESS GAS THAN i++, ESPECIALLY WHEN IT’S USED IN FOR-LOOPS



There are 4 instances of this issue: 

======================


file: VotingEscrow.sol



for (uint256 i = 0; i < 255; i++) 
for (uint256 i = 0; i < 128; i++) for (uint256 i = 0; i < 128; i++) for (uint256 i = 0; i < 255; i++)

https://github.com/code-423n4/2022-08-fiatdao/blob/fece3bdb79ccacb501099c24b60312cd0b2e4bb2/contracts/VotingEscrow.sol#L309 https://github.com/code-423n4/2022-08-fiatdao/blob/fece3bdb79ccacb501099c24b60312cd0b2e4bb2/contracts/VotingEscrow.sol#L717 https://github.com/code-423n4/2022-08-fiatdao/blob/fece3bdb79ccacb501099c24b60312cd0b2e4bb2/contracts/VotingEscrow.sol#L739 https://github.com/code-423n4/2022-08-fiatdao/blob/fece3bdb79ccacb501099c24b60312cd0b2e4bb2/contracts/VotingEscrow.sol#L834 
 Should be: 


for (uint256 i = 0; i < 255; ++i) 
for (uint256 i = 0; i < 128; ++i) for (uint256 i = 0; i < 128; ++i) 
for (uint256 i = 0; i < 255; ++i) 
 ===================





<X> += <Y> COSTS MORE GAS THAN <X> = <X> + <Y> FOR STATE VARIABLES



There are 8 instances of this issue: 
=================


file: VotingEscrow.sol




locked_.amount += int128(int256(value));
 locked.delegated += int128(int256(_value));



newLocked.amount += int128(int256(_value)); 
newLocked.delegated += int128(int256(_value));



locked_.amount += int128(int256(_value));
 newLocked.delegated += int128(int256(_value));


newLocked.delegated += value;
 penaltyAccumulated += penaltyAmount;




https://github.com/code-423n4/2022-08-fiatdao/blob/fece3bdb79ccacb501099c24b60312cd0b2e4bb2/contracts/VotingEscrow.sol#L418
https://github.com/code-423n4/2022-08-fiatdao/blob/fece3bdb79ccacb501099c24b60312cd0b2e4bb2/contracts/VotingEscrow.sol#L420 https://github.com/code-423n4/2022-08-fiatdao/blob/fece3bdb79ccacb501099c24b60312cd0b2e4bb2/contracts/VotingEscrow.sol#L460 https://github.com/code-423n4/2022-08-fiatdao/blob/fece3bdb79ccacb501099c24b60312cd0b2e4bb2/contracts/VotingEscrow.sol#L461
https://github.com/code-423n4/2022-08-fiatdao/blob/fece3bdb79ccacb501099c24b60312cd0b2e4bb2/contracts/VotingEscrow.sol#L465
https://github.com/code-423n4/2022-08-fiatdao/blob/fece3bdb79ccacb501099c24b60312cd0b2e4bb2/contracts/VotingEscrow.sol#L472
https://github.com/code-423n4/2022-08-fiatdao/blob/fece3bdb79ccacb501099c24b60312cd0b2e4bb2/contracts/VotingEscrow.sol#L603
https://github.com/code-423n4/2022-08-fiatdao/blob/fece3bdb79ccacb501099c24b60312cd0b2e4bb2/contracts/VotingEscrow.sol#L654


Should be:


locked_.amount = locked_.amount + int128(int256(value)); locked.delegated = locked_.delegated + int128(int256(_value));



newLocked.amount = newLocked.amount + int128(int256(_value));
 newLocked.delegated = newLocked.delegated + int128(int256(_value));



locked_.amount = locked_.amount + int128(int256(_value));
 newLocked.delegated = newLocked.delegated + int128(int256(_value));



newLocked.delegated = newLocked.delegated + value;
 penaltyAccumulated = penaltyAccumulated + penaltyAmount;


=================

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