40,000 USDC
View results
Submission Details
Severity: gas

resolveDispute calls i_tokenContract.balanceOf twice

Summary

In Escrow.sol line 125 the amount sent to the seller is determined by calling i_tokenContract.balanceOf(address(this)) again. The data is already locally available in the function though and can be determined with tokenBalance - totalFee;

Recommendations

Just perform the subtraction rather than calling balanceOf a second time.

uint256 sellerAward = tokenBalance - totalFee;
if (sellerAward > 0) {
i_tokenContract.safeTransfer(i_seller, sellerAward);
}

Saves ~10000 gas on each of the resolve dispute tests.

Support

FAQs

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