Platform: Code4rena
Start Date: 19/04/2022
Pot Size: $30,000 USDC
Total HM: 10
Participants: 43
Period: 3 days
Judges: moose-code, JasoonS
Total Solo HM: 7
Id: 90
League: ETH
Rank: 35/43
Findings: 1
Award: $29.76
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: IllIllI
Also found by: 0v3rf10w, 0xDjango, 0xNazgul, 0xkatana, Dravee, Kenshin, MaratCerby, Tadashi, TerrierLover, Tomio, TrungOre, defsec, ellahi, fatherOfBlocks, fatima_naz, gzeon, joestakey, kenta, minhquanym, oyc_109, rayn, rfa, robee, simon135, slywaters, windhustler, z3s
29.7589 USDC - $29.76
function _chargeAUMFee(address _feePool) internal
Reading factory
from storage two times.
https://github.com/code-423n4/2022-04-phuture/blob/main/contracts/PhutureIndex.sol#L57
https://github.com/code-423n4/2022-04-phuture/blob/main/contracts/PhutureIndex.sol#L65
Initialise temporary variable for factory after if(timePassed > 0)
line:
uint _factory = factory;
function mint(address _recipient) external override
Reading various variables from storage multiple times.
assets
inside for (uint i; i < assets.length(); ++i)
accessed on each loop iteration.
https://github.com/code-423n4/2022-04-phuture/blob/main/contracts/IndexLogic.sol#L39
assets.at(i)
accessed six times on each loop iteration.
https://github.com/code-423n4/2022-04-phuture/blob/main/contracts/IndexLogic.sol#L40
https://github.com/code-423n4/2022-04-phuture/blob/main/contracts/IndexLogic.sol#L41
https://github.com/code-423n4/2022-04-phuture/blob/main/contracts/IndexLogic.sol#L44
https://github.com/code-423n4/2022-04-phuture/blob/main/contracts/IndexLogic.sol#L47
https://github.com/code-423n4/2022-04-phuture/blob/main/contracts/IndexLogic.sol#L48
https://github.com/code-423n4/2022-04-phuture/blob/main/contracts/IndexLogic.sol#L49
weightOf[assets.at(i)]
accessed two times on each loop iteration.
https://github.com/code-423n4/2022-04-phuture/blob/main/contracts/IndexLogic.sol#L41
https://github.com/code-423n4/2022-04-phuture/blob/main/contracts/IndexLogic.sol#L49
inactiveAssets
inside for (uint i; i < inactiveAssets.length(); ++i)
accessed on each loop iteration.
https://github.com/code-423n4/2022-04-phuture/blob/main/contracts/IndexLogic.sol#L60
inactiveAssets.at(i)
accessed three times on each loop iteration.
https://github.com/code-423n4/2022-04-phuture/blob/main/contracts/IndexLogic.sol#L61
https://github.com/code-423n4/2022-04-phuture/blob/main/contracts/IndexLogic.sol#L63
totalSupply()
accessed two times on each loop iteration.
https://github.com/code-423n4/2022-04-phuture/blob/main/contracts/IndexLogic.sol#L63
https://github.com/code-423n4/2022-04-phuture/blob/main/contracts/IndexLogic.sol#L63
Break down the logic inside the mint
function into several smaller functions and for each of the storage variables mentioned above initialize a temporary variable.
function burn(address _recipient) external override
Reading various variables from storage multiple times.
inactiveAssets
inside for (uint i; i < length + inactiveAssets.length(); ++i)
accessed on each loop iteration.
https://github.com/code-423n4/2022-04-phuture/blob/main/contracts/IndexLogic.sol#L125
totalSupply()
accessed three times.
https://github.com/code-423n4/2022-04-phuture/blob/main/contracts/IndexLogic.sol#L125
https://github.com/code-423n4/2022-04-phuture/blob/main/contracts/IndexLogic.sol#L142
Break down the logic inside the burn
function into several smaller functions and for each of the storage variables mentioned above initialize a temporary variable.
function refreshedAssetPerBaseInUQ(address _asset) external override returns (uint)
Potentially unnecessary reading of price0Cumulative
and price1Cumulative
variables from storage in case the time elapsed is less than MIN_UPDATE_INTERVAL
.
https://github.com/code-423n4/2022-04-phuture/blob/main/contracts/UniswapV2PriceOracle.sol#L62
First get the blockTimestamp
to calculate the timeElapsed and move fetching of the price0Cumulative
and price1Cumulative
after the if clause if (timeElapsed >= MIN_UPDATE_INTERVAL)
. This requires a change in UniswapV2OracleLibrary which should accept a blockTimestamp
as an additional parameter.