This check in the Escrow constructor is redundant:
if (tokenContract.balanceOf(address(this)) < price) revert Escrow__MustDeployWithTokenBalance();
The check if (tokenContract.balanceOf(address(this)) < price) revert Escrow__MustDeployWithTokenBalance();
, along with associated tests, can be removed. Reason being, it checks if the token balance of the Escrow
is less than the price
. However, the check if (arbiterFee >= price)
already ensures that price
can never be 0.
price
is the amount of tokens that get transferred to the Escrow contract. If arbiter fee is 0 and price is also 0, the check if (arbiterFee >= price)
fails. If arbiter fee is more than 0 but price is still 0, the check fails again. Only if the price, i.e., the tokens in Escrow, is greater than the arb fee (which can be 0), will the check pass. Hence, the check Escrow__MustDeployWithTokenBalance()
is redundant.
Gas
Forge, Foundry Toolkit
Remove the check if (tokenContract.balanceOf(address(this)) < price) revert Escrow__MustDeployWithTokenBalance();
. With this change, an overall reduction of 38201
gas was seen across tests, whereas a saving of 1043
gas was seen on Escrow deployment.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.