code-423n4 / 2021-11-badgerzaps-findings

0 stars 0 forks source link

Issues with unused named return variables and local variables (calcMint..., calcRedeem...) #20

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

ye0lde

Vulnerability details

Impact

Removing unused named return variables and local variables can reduce gas usage and improve code clarity.

Proof of Concept

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

Tools Used

Visual Studio Code, Remix

Recommended Mitigation Steps

Remove the unused named returns and local variables

GalloDaSballo commented 2 years ago

Agree, we should just removed the named returns

0xleastwood commented 2 years ago

duplicate of #39