Platform: Code4rena
Start Date: 23/06/2023
Pot Size: $60,500 USDC
Total HM: 31
Participants: 132
Period: 10 days
Judge: 0xean
Total Solo HM: 10
Id: 254
League: ETH
Rank: 113/132
Findings: 1
Award: $12.47
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: JCN
Also found by: 0xAnah, DavidGiladi, MohammedRizwan, Rageur, Raihan, ReyAdmirado, Rolezn, SAAJ, SAQ, SM3_SS, Sathish9098, ayo_dev, dharma09, fatherOfBlocks, hunter_w3b, mgf15, mrudenko, naman1778, shamsulhaq123, souilos, turvy_fuzz
12.4743 USDC - $12.47
This report focuses on Lybra contest, in context of various improvements that can be made in terms of gas cost.
Some of the opportunities identified for improving gas efficiency throughout the codebase of Lybra protocol are categorised into 06 main areas; with further multiple instances in each of the category.
If not cached, the solidity compiler will always read the length of the array during each iteration. That is, if it is a storage array, this is an extra sload operation (100 additional extra gas for each iteration except for the first) and if it is a memory array, this is an extra mload operation (3 additional gas for each iteration except for the first).
Link to the Code:
Declaring a variable inside a loop result in variable being redeclared during each loop iteration which consume higher gas. The variable gets reallocated when declared outside loop making it more gas efficient.
Link to the Code: https://github.com/code-423n4/2023-06-lybra/blob/main/contracts/lybra/miner/EUSDMiningIncentives.sol#L140
Wastage of gas during deployment; when return is absent for named variable when function returns.
Link to the Code:
Instead of using address(this), it is more gas-efficient to pre-calculate and use the hardcoded address.
Link to the code:
Link to the Code:
Using calldata in external function does not require data to be stored, which reduced the process time as compared to memory. This in return saves gas during calling the data.
Link to the Code:
#0 - c4-pre-sort
2023-07-27T22:47:10Z
JeffCX marked the issue as low quality report
#1 - JeffCX
2023-07-27T22:48:03Z
G-03 and G-04 maybe valuable
#2 - c4-pre-sort
2023-07-27T22:48:07Z
JeffCX marked the issue as high quality report
#3 - c4-judge
2023-07-27T23:42:19Z
0xean marked the issue as grade-a
#4 - c4-judge
2023-07-27T23:44:55Z
0xean marked the issue as grade-b
#5 - c4-sponsor
2023-07-29T10:36:18Z
LybraFinance marked the issue as sponsor acknowledged