Platform: Code4rena
Start Date: 14/11/2021
Pot Size: $30,000 USDC
Total HM: 7
Participants: 13
Period: 3 days
Judge: leastwood
Total Solo HM: 4
Id: 57
League: ETH
Rank: 11/13
Findings: 2
Award: $95.19
🌟 Selected for report: 1
🚀 Solo Findings: 0
🌟 Selected for report: WatchPug
Also found by: GiveMeTestEther, pmerkleplant, ye0lde
14.6747 USDC - $14.67
ye0lde
Removing unused named return variables and local variables can reduce gas usage and improve code clarity.
calcMint, calcMintWithRen, calcMintWithWbtc Unused named returns https://github.com/Badger-Finance/ibbtc/blob/d8b95e8d145eb196ba20033267a9ba43a17be02c/contracts/Zap.sol#L156
Unused local variables https://github.com/Badger-Finance/ibbtc/blob/d8b95e8d145eb196ba20033267a9ba43a17be02c/contracts/Zap.sol#L178-L179 https://github.com/Badger-Finance/ibbtc/blob/d8b95e8d145eb196ba20033267a9ba43a17be02c/contracts/Zap.sol#L197-L198
calcRedeem, calcRedeemInRen, calcRedeemInWbtc Unused named returns https://github.com/Badger-Finance/ibbtc/blob/d8b95e8d145eb196ba20033267a9ba43a17be02c/contracts/Zap.sol#L251
Unused local variables https://github.com/Badger-Finance/ibbtc/blob/d8b95e8d145eb196ba20033267a9ba43a17be02c/contracts/Zap.sol#L274-L275 https://github.com/Badger-Finance/ibbtc/blob/d8b95e8d145eb196ba20033267a9ba43a17be02c/contracts/Zap.sol#L295-L296
Visual Studio Code, Remix
Remove the unused named returns and local variables
#0 - GalloDaSballo
2021-11-17T16:52:18Z
Agree, we should just removed the named returns
#1 - 0xleastwood
2021-12-09T11:46:39Z
duplicate of #39
🌟 Selected for report: ye0lde
80.5196 USDC - $80.52
ye0lde
Removing unneeded branches and returns can reduce gas usage and improve code clarity.
This code https://github.com/Badger-Finance/ibbtc/blob/d8b95e8d145eb196ba20033267a9ba43a17be02c/contracts/Zap.sol#L309-L317 can be refactored to:
if (bBtc <= max) { // pesimistically charge 0.5% on the withdrawal. // Actual fee might be lesser if the vault keeps keeps a buffer uint strategyFee = sett.mul(controller.strategies(pool.lpToken).withdrawalFee()).div(10000); lp = sett.sub(strategyFee).mul(pool.sett.getPricePerFullShare()).div(1e18); fee = fee.add(strategyFee); }
Visual Studio Code, Remix
See POC