40,000 USDC
View results
Submission Details
Severity: gas

Unnecessary global state read in ```Escrow.confirmReciept()```

Summary

Escrow.confirmReciept() reads token balance of a contract which can just be accessed by reading the immutable variable i_price to save gas.

Vulnerability Details

It is assumed that the escrow contract will have a fixed balance of i_price, so instead of reading the global variable to get the contract balance we can just use i_price and save the extra gas cost.

Impact

This reads can cost around 800 gas so it is recommended to use i_price.

Tools Used

manual review

Recommendations

change this line

i_tokenContract.safeTransfer(i_seller, i_tokenContract.balanceOf(address(this)));

with this line

i_tokenContract.safeTransfer(i_seller, i_price);

Support

FAQs

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