Platform: Code4rena
Start Date: 25/01/2022
Pot Size: $50,000 USDT
Total HM: 17
Participants: 39
Period: 3 days
Judge: LSDan
Total Solo HM: 9
Id: 79
League: ETH
Rank: 36/39
Findings: 1
Award: $9.63
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: WatchPug
Also found by: Dravee, Jujic, Rhynorater, TomFrenchBlockchain, defsec, hyh, ye0lde
Rhynorater
It is possible to optimize the gas efficiency of this code by modifying the following line:
https://github.com/code-423n4/2022-01-trader-joe/blob/a1579f6453bc4bf9fb0db9c627beaa41135438ed/contracts/LaunchEvent.sol#L361
require( user.balance >= _amount, "LaunchEvent: withdrawn amount exceeds balance" ); user.balance -= _amount;
to
require( user.balance >= _amount, "LaunchEvent: withdrawn amount exceeds balance" ); unchecked{ user.balance -= _amount; }
This is due to the fact Solidity 0.8.0+ has built-in overflow/underflow math check and since user.balance
will never underflow per the above statement checking that user.balance
is greater than _amount
, this check is unnecessary. Adding the unchecked
directive will save on gas.
#0 - cryptofish7
2022-01-31T14:08:41Z
Duplicate of #233
🌟 Selected for report: sirhashalot
Also found by: Dravee, Rhynorater, robee
Rhynorater
The withdrawAVAX
function defined on line #349 of LaunchEvent.sol
is defined as a public
function. However, since the contract in question does not call the withdrawAVAX
, it should be defined as external
to save on gas.
#0 - cryptofish7
2022-01-31T12:03:11Z
Duplicate of #262