Platform: Code4rena
Start Date: 21/04/2022
Pot Size: $100,000 USDC
Total HM: 18
Participants: 60
Period: 7 days
Judge: gzeon
Total Solo HM: 10
Id: 112
League: ETH
Rank: 36/60
Findings: 2
Award: $248.66
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: IllIllI
Also found by: 0v3rf10w, 0x52, 0xDjango, 0xkatana, Dravee, Funen, Kenshin, Ruhum, StyxRave, Tadashi, TerrierLover, TrungOre, antonttc, berndartmueller, catchup, csanuragjain, defsec, dipp, fatherOfBlocks, hake, horsefacts, hubble, jayjonah8, joestakey, kebabsec, kenta, m4rio_eth, oyc_109, pauliax, peritoflores, rayn, remora, robee, securerodd, simon135, sorrynotsorry, sseefried, z3s
159.3125 USDC - $159.31
the current implementation was set return true, so it has not the same as comment do. cause it was return true if address of the new staker vault for the pool was correct.
##Tool Used Manual Review
##Recommended Mitigation Change it or remove it
##Another Occurances
1.StakerVault 2.TopUpKeeperHelper
Since isShutdown was return value false, it would be missbehavior executed after. cause return was false. This implementation usually or common use using logical operator !
for isShutdown below can be set for good or you can set it into modifier for is it done or not.
##Tool Used Manual Review
##POC Using this logic https://www.tabnine.com/code/java/methods/io.netty.util.concurrent.EventExecutor/isShutdown
##Recommended Mitigation function shutdown() external override onlyVault returns (bool) { if (!isShutdown) return false; isShutdown = true; emit Shutdown(); return true; }
or you can using this logic :
contract Shutdownable is Ownable { bool public isShutdown;
event Shutdown(); modifier notShutdown { require(!isShutdown, "Smart contract is shut down."); _; } function shutdown() public onlyOwner { isShutdown = true; emit Shutdown(); }
}
🌟 Selected for report: joestakey
Also found by: 0v3rf10w, 0x1f8b, 0x4non, 0xDjango, 0xNazgul, 0xkatana, 0xmint, Dravee, Funen, IllIllI, MaratCerby, NoamYakov, Tadashi, TerrierLover, Tomio, WatchPug, catchup, defsec, fatherOfBlocks, hake, horsefacts, kenta, oyc_109, pauliax, rayn, rfa, robee, saian, securerodd, simon135, slywaters, sorrynotsorry, tin537, z3s
89.3504 USDC - $89.35
Using i++ instead ++i for all the loops, the variable i is incremented using i++. It is known that implementation by using ++i costs less gas per iteration than i++.
Manual Review
contracts/actions/topup/TopUpAction.sol#L188 contracts/actions/topup/TopUpAction.sol#L456 contracts/actions/topup/TopUpAction.sol#L479 contracts/actions/topup/TopUpAction.sol#L506 contracts/actions/topup/TopUpAction.sol#L891 contracts/StakerVault.sol#L260 contracts/strategies/ConvexStrategyBase.sol#L313 contracts/strategies/ConvexStrategyBase.sol#L380 contracts/actions/topup/handlers/CTokenRegistry.sol#L61 contracts/actions/topup/TopUpKeeperHelper.sol#L43 contracts/actions/topup/TopUpKeeperHelper.sol#L72 contracts/actions/topup/TopUpKeeperHelper.sol#L93 contracts/actions/topup/TopUpKeeperHelper.sol#L165
uint256 i = 0
into uint i
for saving more gasusing this implementation can saving more gas for each loops.
##Tool Used Manual Review & Remix
##Recommended Mitigation Change it
##Occurances
contracts/actions/topup/TopUpAction.sol#L188 contracts/actions/topup/TopUpAction.sol#L456 contracts/actions/topup/TopUpAction.sol#L479 contracts/actions/topup/TopUpAction.sol#L506 contracts/actions/topup/TopUpAction.sol#L891 contracts/StakerVault.sol#L260 contracts/strategies/ConvexStrategyBase.sol#L313 contracts/strategies/ConvexStrategyBase.sol#L380 contracts/actions/topup/handlers/CTokenRegistry.sol#L61 contracts/actions/topup/TopUpKeeperHelper.sol#L43 contracts/actions/topup/TopUpKeeperHelper.sol#L72 contracts/actions/topup/TopUpKeeperHelper.sol#L93 contracts/actions/topup/TopUpKeeperHelper.sol#L165
immutable
for saving more gasthis can be set as immutable for saving more gas
##Tool Used Remix
##Recommended Mitigation
add immutable
##Occurances
ConvexStrategyBase.sol
main/backd/contracts/strategies/ConvexStrategyBase.sol#L47 main/backd/contracts/strategies/ConvexStrategyBase.sol#L56 main/backd/contracts/strategies/ConvexStrategyBase.sol#L58 main/backd/contracts/strategies/ConvexStrategyBase.sol#L59
= 0
If a variable was not set/initialized, it is assumed to have default value to 0
this implementation was used for saving more gas by removing = 0
##TOOLS USED Remix, Manual Review
##Mitigation Step
Remove = 0
##Occurances
contracts/actions/topup/TopUpAction.sol#L63 contracts/pool/LiquidityPool.sol#L389 contracts/StakerVault.sol#L144 contracts/Controller.sol#L114
safeERC20
for saving more gasThis implementation can be used to saving more gas instead.
##Recommended Mitigation
by not declaring :
using SafeERC20 for IERC20;
and changed to :
SafeERC20.safeTransferFrom(IERC20(token), payer, address(this), depositAmount); SafeERC20.safeApprove(IERC20(token),stakerVaultAddress, depositAmount);
##Another Occurances
The same method can be used for this contract
StrategySwapper.sol ConvexStrategyBase.sol Erc20Pool.sol Erc20Vault.sol VaultReserve.sol CvxCrvRewardsLocker.sol
in this line since was used for read only, it can be saving by caching in memory instead of using storage
##Tool Used Manual Review, Remix
>
instead of >=
for saving more gasThis current implementation indeed can saving more gas
##Tool Used Remix
##Occurances
contracts/StakerVault.sol#L107 contracts/StakerVault.sol#L148 contracts/StakerVault.sol#L153 contracts/GasBank.sol#L68
This implementation using ++topupsAdded can be saving more gas instead.
##Tool Used Remix