code-423n4 / 2022-04-phuture-findings

0 stars 0 forks source link

Gas Optimizations #98

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Gas1: prefer fixing pragma instead of floating pragma

Gas2: break && into seperate statements for require() save gas

chainlinkpriceoracle.md - l#86 ManagedIndexReweightingLogic.sol - l#29-32

Gas3: prefer uint256 instead of other uint types

BaseIndex.sol - l#77 IndexLibrary.sol - l#14,17,26 TopNMarketCapIndex.sol - l#8

Gas4: For unsigned integer, no need to check >, instead check for !=, which save gas

IndexLibrary.sol l#29 (_assetPerBaseInUQ) IndexLogic.sol - l#98 (value)

Gas5: use prefix {++i}

UniswapV2PricePathOracle.sol - It don't follow prefix optimisations for loops, It should also use prefix ++i instead of i++ to save gas as other