Frankencoin - 0xRB'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: 181/199

Findings: 1

Award: $21.03

Gas:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

1) Missing checks for address(0x0) when assigning values to address state variables

The contract Equity.sol should have a base case to the canVoteFor function to return false if delegate is the null address (address(0x0)), since in that case there is no delegate to vote for and the function can immediately return false without further recursion. This can save gas in cases where the delegate address is not set.

https://github.com/code-423n4/2023-04-frankencoin/blob/main/contracts/Equity.sol#L225

2) It costs more gas to initialize variables with their default value than letting the default value be applied.

Explicitly initializing variables with its default values wastes around 3 gas per instance.

File: contracts/Equity.sol 192: for (uint i=0; i<helpers.length; i++) 312: for (uint256 i = 0; i<addressesToWipe.length; i++)

3) Eliminate unnecessary operations in calculateProceeds function

In the Equity contract, An optimization can be made to this function by directly using the value of totalSupply(), instead of computing totalShares and newTotalShares separately. This can save gas by avoiding an extra computation step.

The change would be:

function calculateProceeds(uint256 shares) public view returns (uint256) { uint256 capital = zchf.equity(); require(shares + ONE_DEC18 < totalSupply(), "too many shares"); // make sure there is always at least one share uint256 newCapital = _mulD18(capital, _power3(_divD18(totalSupply() - shares, totalSupply()))); return capital - newCapital; }

#0 - 0xA5DF

2023-04-26T16:07:45Z

2 is in automated findings

#1 - c4-judge

2023-05-16T13:26: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