40,000 USDC
View results
Submission Details
Severity: gas

Price does not have to be stored

Summary

The Escrow contract does not need to store the price.

Vulnerability Details

The Escrow contract constructor gets the agreed price as a parameter. It uses it to check if the contract is sufficiently funded. Also it is stored in an immutable variable and acessible via a view function. However gas can be saved by not storing the price, as it is never used in the contract again (besides view function).
Moreover the actual price is the tokenBalance of the contract, therefore the immutable price variable can be ommited to save gas.

Impact

unneccessary immutable variable.

Tools Used

Manual Review

Recommendations

Do not store price in contract.
In getPrice function the tokenBalance can be returned.

Support

FAQs

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