40,000 USDC
View results
Submission Details
Severity: gas

Unnecessary call to .balanceOf

Summary

i_tokenContract.balanceOf(address(this)) called twice in the scope of resolveDispute`. This can be avoided by calculating the remainder of the token balance in-function.

Vulnerability Details

Before the update:

Deployment Cost | Deployment Size
Function Name | min | avg | median | max | # calls |
resolveDispute | 383 | 27017 | 22342 | 62460 | 8

After the update:

Deployment Cost | Deployment Size
Function Name | min | avg | median | max | # calls |
resolveDispute | 377 | 26622 | 21946 | 61683 | 8 |

Impact

Tools Used

forge t --gas-report

Recommendations

Change L125 from

tokenBalance = i_tokenContract.balanceOf(address(this));

to

tokenBalance -= totalFee;

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.