40,000 USDC
View results
Submission Details
Severity: gas

Use one method to generate address

Summary

Choosing one method of create2 instead of two will save gas.

Vulnerability Details

The following methods in EscrowFactory.sol are used.

Escrow escrow = new Escrow{salt: salt}(
price,
tokenContract,
msg.sender,
seller,
arbiter,
arbiterFee
);

And

function computeEscrowAddress(
bytes memory byteCode,
address deployer,
uint256 salt,
uint256 price,
IERC20 tokenContract,
address buyer,
address seller,
address arbiter,
uint256 arbiterFee
) public pure returns (address) {
address predictedAddress = address(
uint160(
uint256(
keccak256(
abi.encodePacked(
bytes1(0xff),
deployer, //@audit address(this)??
salt, //@audit why uint256 and not bytes32?
keccak256(
abi.encodePacked(
byteCode, abi.encode(price, tokenContract, buyer, seller, arbiter, arbiterFee)
)
)
)
)
)
)
);
return predictedAddress;
}

Impact

Higher gas cost is used

Tools Used

Manual review

Recommendations

Since both achieve same result, you can use the newer and less error-prone way.

Escrow escrow = new Escrow{salt: salt}(
price,
tokenContract,
msg.sender,
seller,
arbiter,
arbiterFee
);

Support

FAQs

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