Frankencoin - ReyAdmirado's results

A decentralized and fully collateralized stablecoin.

General Information

Platform: Code4rena

Start Date: 12/04/2023

Pot Size: $60,500 USDC

Total HM: 21

Participants: 199

Period: 7 days

Judge: hansfriese

Total Solo HM: 5

Id: 231

League: ETH

Frankencoin

Findings Distribution

Researcher Performance

Rank: 171/199

Findings: 1

Award: $21.03

Gas:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

1. state variables should be cached in stack variables rather than re-reading them from storage

Caching of a state variable replace each Gwarmaccess (100 gas) with a much cheaper stack read. Other less obvious fixes/optimizations include having local memory caches of state variable structs, or having local caches of state variable contracts/addresses.

minters[_minter] should be cached before #L294 because the is a high possibilty of it being read twice from storage

possible 97 gas save with risking loss of only 3 gas. if the check passes we save 97 for the second minted read and if it fails we just lose 3 gas. cache it before this line

minted should be cached before #L141 because its being read at least twice. first read is in the condition in #L141 in case the condition succeeds its gonna be read in the #L142 which could be prevented by using the cached version. in case the condition in #L141 fails its gonna be read in #L149.

2. can make the variable outside the loop to save gas

make the variable outside the loop and only give the value to variable inside

current

j

3. Ternary over if ... else

Using ternary operator instead of the if else statement saves gas. the placed that it make sense are listed here

4. Use assembly to check for address(0)

saves 6 gas per instance

5. before some functions we should check some variables for possible gas save

before transfer we should check for amount being 0 so the function doesnt run when its not gonna do anything

check amount

freedAmount - _amountExcludingReserve

reserveLeft

6. Non-strict inequalities are cheaper than strict ones

In the EVM, there is no opcode for non-strict inequalities (>=, <=) and two operations are performed (> + = or < + =). consider replacing >= with the strict counterpart > and add - 1 to the second side

#0 - c4-judge

2023-05-16T14:21:36Z

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