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
Rank: 181/199
Findings: 1
Award: $21.03
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: c3phas
Also found by: 0xDACA, 0xRB, 0xSmartContract, 0xhacksmithh, 0xnev, Aymen0909, BenRai, Breeje, DishWasher, Erko, EvanW, JCN, MohammedRizwan, NoamYakov, Polaris_tow, Proxy, Rageur, Raihan, RaymondFam, ReyAdmirado, SAAJ, Sathish9098, Satyam_Sharma, Udsen, __141345__, aria, codeslide, decade, fatherOfBlocks, hunter_w3b, karanctf, matrix_0wl, nadin, naman1778, niser93, pavankv, petrichor, pfapostol, sebghatullah, slvDev, trysam2003, xmxanuel
21.0255 USDC - $21.03
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
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++)
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