code-423n4 / 2022-05-bunker-findings

1 stars 0 forks source link

Gas Optimizations #98

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago
  1. Title : Saving gas by removing = 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

1. CNft.sol#L49 2. CNft.sol#L97 3. CNft.sol#L119 4. CNft.sol#L175 5. UniswapV2PriceOracle.sol#L41 6. CEther.sol#L178

  1. Title : Using short reason string can be used for saving more gas

Every reason string takes at least 32 bytes. Use short reason strings that fits in 32 bytes or it will become more expensive.

Tool Used

Manual Review

Occurances

1. CNft.sol#L24 2. CNft.sol#L25 3. CNft.sol#L52 4. CNft.sol#L100 5. CNft.sol#L124 6. CNft.sol#L148 7. CNft.sol#L208 8. CNft.sol#L209 9. /CNft.sol#L279

  1. Title : change uint256 i = 0 into uint256 ifor saving more gas

https://github.com/bunkerfinance/bunker-protocol/blob/752126094691e7457d08fc62a6a5006df59bd2fe/contracts/Oracles/UniswapV2PriceOracle.sol#L42

using this implementation can saving more gas for each loops.

Tool Used

Manual Review & Remix

Recommended Mitigation

Change it

  1. Title : Unused SafeTransferFrom() can be removed for saving more gas

since this SafeTransferFrom() function was unused it can be deleted instead for saving more gas cause of recommendation of used safeBatchTransferFrom instead

Tool Used

Manual Review, Remix