Open codehawks-bot opened 1 year ago
Gas Optimization / Informational
The contract reads the balance multiple times:
https://github.com/Cyfrin/2023-07-escrow/blob/main/src/Escrow.sol#L44
https://github.com/Cyfrin/2023-07-escrow/blob/main/src/Escrow.sol#L125
https://github.com/Cyfrin/2023-07-escrow/blob/main/src/Escrow.sol#L98
We can set a constant in the ctor to reduce storage reads.
And this storage access
can be replaced by tokenBalance - buyerAward - i_arbiterFee
balanceOf(address(this)) can be replaced with a constant
Severity
Gas Optimization / Informational
The contract reads the balance multiple times:
https://github.com/Cyfrin/2023-07-escrow/blob/main/src/Escrow.sol#L44
https://github.com/Cyfrin/2023-07-escrow/blob/main/src/Escrow.sol#L125
https://github.com/Cyfrin/2023-07-escrow/blob/main/src/Escrow.sol#L98
We can set a constant in the ctor to reduce storage reads.
And this storage access
https://github.com/Cyfrin/2023-07-escrow/blob/main/src/Escrow.sol#L125
can be replaced by tokenBalance - buyerAward - i_arbiterFee