40,000 USDC
View results
Submission Details
Severity: gas

Overflow-underflow Revert Gas Consumption

Summary

Checking If there's overflow-underflow and revert can help save gas

    uint256 tokenBalance = i_tokenContract.balanceOf(address(this));
    uint256 totalFee = buyerAward + i_arbiterFee; // Reverts on overflow <-- This line in first for check overflow-underflow

POC test case ----

function testPosChangeInResolveDisputeCanSaveGas() public escrowDeployed {
vm.startPrank(BUYER);
escrow.initiateDispute();
vm.stopPrank();
vm.expectRevert();
vm.prank(ARBITER);
escrow.resolveDispute(type(uint256).max);
}

Recommendations

changing the location of overflow-underflow line to first section so can do the revert first hand.

Tools Used

Foundry test suit

Support

FAQs

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