40,000 USDC
View results
Submission Details
Severity: gas
Valid

Gas Optimization / Informational

[G-01] Split && statement in two separate if conditions which is gas efficient

https://github.com/Cyfrin/2023-07-escrow/blob/main/src/Escrow.sol#L67

Recommendation

if (msg.sender != i_buyer) {
if (msg.sender != i_seller) {
revert Escrow__OnlyBuyerOrSeller();
}
}

Gas Savings

Mentioned below is the gas saving report.

Before

src/Escrow.sol:Escrow contract
Function Name min avg median max # calls
initiateDispute 316 16855 23603 23603 10

After

src/Escrow.sol:Escrow contract
Function Name min avg median max # calls
initiateDispute 292 16836 23584 23584 10

[I-01] Global variable i_price is not getting used after setting in the constructor

https://github.com/Cyfrin/2023-07-escrow/blob/main/src/Escrow.sol#L17C1-L17C1

Recommendation

The price amount can be sent to the seller and rest can be sent back to the buyer if anything is left in the contract.

Existing

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

Suggested

i_tokenContract.safeTransfer(i_seller, i_price);
uint currentBal = i_tokenContract.balanceOf(address(this));
if(currentBal > 0) {
i_tokenContract.safeTransfer(i_buyer, currentBal);
}

Support

FAQs

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