code-423n4 / 2024-02-wise-lending-findings

11 stars 8 forks source link

Gas Optimizations #254

Open c4-bot-6 opened 5 months ago

c4-bot-6 commented 5 months ago

See the markdown file with the details of this report here.

c4-pre-sort commented 5 months ago

GalloDaSballo marked the issue as insufficient quality report

c4-pre-sort commented 5 months ago

GalloDaSballo marked the issue as grade-c

albahaca0000 commented 4 months ago

Hi judge

I dont' know why my report has grade c , I suggest alot of gas techniques that are similar to the grade a reports like additionnal with more unique ones

summary of my report

issue instance
[G‑01] Functions guaranteed to revert when called by normal users can be marked payable 58
[G‑02] Use Modifiers Instead of Functions To Save Gas 2
[G‑03] State variables only set in the constructor should be declared immutable 7
[G‑04] Use calldata instead of memory for function arguments that do not get mutated 5
[G‑05] Avoid contract existence checks by using low level calls 8
[G‑06] Replace state variable reads and writes within loops with local variable reads and writes 3
[G‑07] Optimizing Gas Consumption by Rearranging Operations in the PtOracleDerivative::latestAnswer Function 2
[G‑08] Optimizing Gas Consumption in the PtOraclePure::latestAnswer Function 1
[G‑09] Optimizing Gas Consumption in the FeeManager::removePoolTokenManual Function ~
[G‑10] Optimizing Gas Consumption in FeeManager::paybackBadDebtForToken Function 2
[G‑11] Gas Efficiency Optimization for FeeManager::paybackBadDebtNoReward Function 1
[G‑12] Gas Optimization in PendlePowerFarmDeclarations Constructor ~
[G‑13] Gas Optimization Report for PendlePowerManager::manuallyWithdrawShares Function 1
[G‑14] Do not calculate constants 15
[G‑15] With assembly, .call (bool success) transfer can be done gas-optimized 5
[G‑16] Refactor external/internal function to avoid unnecessary External Calls 2
[G‑17] Optimizing Gas Usage: Rearranging Operations in the PendleLpOracle::latestAnswer Function 1
[G‑18] Use assembly to perform efficient back-to-back calls 7
[G‑19] Use of emit inside a loop 1
[G‑20] Use assembly to emit an event ~
[G‑21] multiplications of powers of 2 can be replaced by a left shift operation to save gas 3
[G‑22] Gas Optimization Issue - Gas-Efficient Alternatives for Common Math Operations 9
[G‑23] Use selfbalance() instead of address(this).balance 2
[G‑24] Optimize External Calls with Assembly for Memory Efficiency 16
[G‑25] Pre-increment and pre-decrement are cheaper thanĀ +1 ,-1 6
[G‑26] Consider merging sequential loops 1
[G‑27] Move storage pointer to top of function to avoid offset calculation 1
[G‑28] Consider using OZ EnumerateSet in place of nested mappings 2
[G‑29] Shorten the array rather than copying to a new one 4
[G‑30] Use ERC721A instead ERC721 1
[G‑31] Gas Optimization: Declare Variables Outside the Loop 2
[G‑32] Amounts should be checked for 0 before calling a transfer 1
[G‑33] Change public state variable visibility to private ~

This encompasses my gas optimization technique suggestions, akin to those found in grade-A reports.

1. [G-01] Functions guaranteed to revert when called by normal users can be marked payable this issue is similer to #248 G-14

2. [G-04] Use calldata instead of memory for function arguments that do not get mutated this issue is similer to #248 G-10

3. [G-06] Replace state variable reads and writes within loops with local variable reads and writes

this issue is similer to #248 G-08

4. [G-19] Use of emit inside a loop this issue is similer to #248 G-12

5. [G-25] Pre-increment and pre-decrement are cheaper thanĀ +1 ,-1 this issue is similer to #152 G-07

6. [G‑03] State variables only set in the constructor should be declared immutable this issue is similer to #305 G-06

7. [G-07] Optimizing Gas Consumption by Rearranging Operations in the PtOracleDerivative::latestAnswer Function this issue is similer to #305 G-08

8. [G-08] Optimizing Gas Consumption in the PtOraclePure::latestAnswer Function this issue is similer to #305 G-09

these issue similer to 7,8 [G-09] Optimizing Gas Consumption in the FeeManager::removePoolTokenManual Function [G-10] Optimizing Gas Consumption in FeeManager::paybackBadDebtForToken Function [G-11] Gas Efficiency Optimization for FeeManager::paybackBadDebtNoReward Function [G-12] Gas Optimization in PendlePowerFarmDeclarations Constructor [G-13] Gas Optimization Report for PendlePowerManager::manuallyWithdrawShares Function [G-17] Optimizing Gas Usage: Rearranging Operations in the PendleLpOracle::latestAnswer Function

this issue's instence are not find by other check this also [G-16] Refactor external/internal function to avoid unnecessary External Calls

etc..

c4-judge commented 4 months ago

trust1995 marked the issue as grade-b