Platform: Code4rena
Start Date: 26/09/2022
Pot Size: $50,000 USDC
Total HM: 13
Participants: 113
Period: 5 days
Judge: 0xean
Total Solo HM: 6
Id: 166
League: ETH
Rank: 113/113
Findings: 1
Award: $24.02
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: IllIllI
Also found by: 0x1f8b, 0x5rings, 0xNazgul, 0xRoxas, 0xSmartContract, 0xbepresent, 0xmatt, Aeros, Amithuddar, Awesome, Aymen0909, B2, Bnke0x0, ChristianKuri, CodingNameKiki, Deivitto, Diraco, Fitraldys, HardlyCodeMan, JC, Mukund, Noah3o6, Olivierdem, RaymondFam, ReyAdmirado, RockingMiles, Rolezn, Ruhum, Saintcode_, Shinchan, SnowMan, TomJ, Tomio, Tomo, V_B, Waze, __141345__, ajtra, asutorufos, aysha, beardofginger, bobirichman, brgltd, bulej93, c3phas, ch0bu, cryptonue, defsec, delfin454000, dharma09, durianSausage, emrekocak, erictee, fatherOfBlocks, francoHacker, gianganhnguyen, gogo, imare, kaden, karanctf, ladboy233, lukris02, m_Rassska, martin, medikko, mics, natzuu, oyc_109, peiw, rbserver, ret2basic, rotcivegaf, saian, shark, slowmoses, tnevler, trustindistrust, zeesaw, zishansami
24.0179 USDC - $24.02
1.1. File DataStorage.sol, line 119:
index -= 1;
Becomes:
--index;
1.2. File DataStorage.sol, line 307:
for (uint256 i = 0; i < secondsAgos.length; i++) {
Becomes:
for (uint256 i = 0; i < secondsAgos.length; ++i) {
1.3. File TickTable.sol, line 100:
tick += 1;
Becomes:
++tick;
File DataStorage.sol, line 307:
for (uint256 i = 0; i < secondsAgos.length; i++) {
Becomes:
for (uint256 i; i < secondsAgos.length; ++i) {
File DataStorage.sol, line 307:
for (uint256 i = 0; i < secondsAgos.length; i++) {
Becomes:
uint256 length = secondsAgos.length; for (uint256 i; i < length; ++i) {
4.1. File AlgebraPool.sol, line 722 - 728:
currentPrice = globalState.price; currentTick = globalState.tick; cache.fee = globalState.fee; cache.timepointIndex = globalState.timepointIndex; uint256 _communityFeeToken0 = globalState.communityFeeToken0; uint256 _communityFeeToken1 = globalState.communityFeeToken1; bool unlocked = globalState.unlocked;
Becomes:
GlobalState memory globalStateCache = globalState; currentPrice = globalStateCache.price; currentTick = globalStateCache.tick; cache.fee = globalStateCache.fee; cache.timepointIndex = globalStateCache.timepointIndex; uint256 _communityFeeToken0 = globalStateCache.communityFeeToken0; uint256 _communityFeeToken1 = globalStateCache.communityFeeToken1; bool unlocked = globalStateCache.unlocked;
4.2. File AlgebraPool.sol, line 116:
TickManager.Tick storage _lower = ticks[bottomTick];
Becomes:
TickManager.Tick memory _lower = ticks[bottomTick];
File AlgebraPool.sol, line 127. File DataStorage.sol line 120, 228, 392, 411. File TickManager.sol, line 47, 48.
#0 - vladyan18
2022-10-04T17:17:48Z
4.1 Please note that writing to memory also costs gas. Moreover, the memory is not cleared inside the call. So reading directly onto the stack/destination will be cheaper if the optimizer can do it in one SLOAD (it can).