Platform: Code4rena
Start Date: 21/06/2022
Pot Size: $50,000 USDC
Total HM: 31
Participants: 99
Period: 5 days
Judges: moose-code, JasoonS, denhampreen
Total Solo HM: 17
Id: 139
League: ETH
Rank: 99/99
Findings: 1
Award: $26.57
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: BowTiedWardens
Also found by: 0v3rf10w, 0x1f8b, 0x29A, 0xKitsune, 0xNazgul, 0xf15ers, 0xkatana, 0xmint, 8olidity, ACai, Bnke0x0, Chom, ElKu, Fabble, Fitraldys, FudgyDRS, Funen, GalloDaSballo, GimelSec, IllIllI, JC, Kaiziron, Lambda, Limbooo, MiloTruck, Noah3o6, Nyamcil, Picodes, PwnedNoMore, Randyyy, RedOneN, Sm4rty, StErMi, TomJ, Tomio, TrungOre, UnusualTurtle, Waze, _Adam, aga7hokakological, ajtra, antonttc, asutorufos, bardamu, c3phas, defsec, delfin454000, exd0tpy, fatherOfBlocks, hansfriese, ignacio, joestakey, kenta, ladboy233, m_Rassska, mics, minhquanym, oyc_109, pashov, reassor, robee, s3cunda, sach1r0, saian, sashik_eth, scaraven, sikorico, simon135, slywaters
26.5706 USDC - $26.57
in these two functions below, since creditAmout&allowance was already checked in previous require statement, so the next-line algo can use unchecked modifier to reduce gas consumption.
function transfer(address _to, uint256 _value) public override returns (bool) { require(_to != address(0), "Invalid address"); uint256 creditAmount = _value * rebasingCreditsPerToken; require(creditAmount <= creditBalances[msg.sender], "Not enough funds");//@s3cunda: gas //use unchecked creditBalances[msg.sender] = creditBalances[msg.sender] - creditAmount; creditBalances[_to] = creditBalances[_to] + creditAmount; emit Transfer(msg.sender, _to, _value); return true; } /** @notice transfer from address to address with amount @param _from address @param _to address @param _value uint @return bool */ function transferFrom( address _from, address _to, uint256 _value ) public override returns (bool) { require(_allowances[_from][msg.sender] >= _value, "Allowance too low");//@s3cunda: gas //use unchecked uint256 newValue = _allowances[_from][msg.sender] - _value; _allowances[_from][msg.sender] = newValue; emit Approval(_from, msg.sender, newValue); uint256 creditAmount = creditsForTokenBalance(_value); creditBalances[_from] = creditBalances[_from] - creditAmount; creditBalances[_to] = creditBalances[_to] + creditAmount; emit Transfer(_from, _to, _value); return true; }