40,000 USDC
View results
Submission Details
Severity: gas

Use named function calls where possible

Description

Codebase can use named function calls, for better visibility and to reduce the chances of any programmatic error.

Recommend Mitigation

Add named function call where possible.

Example how EscrowFactory::newEscrow would look:

function newEscrow(
uint256 price,
IERC20 tokenContract,
address seller,
address arbiter,
uint256 arbiterFee,
bytes32 salt
) external returns (IEscrow) {
address computedAddress = computeEscrowAddress(
{
byteCode: type(Escrow).creationCode,
deployer: address(this),
salt: uint256(salt),
price: price,
tokenContract: tokenContract,
buyer: msg.sender,
seller: seller,
arbiter: arbiter,
arbiterFee: arbiterFee
}
);
tokenContract.safeTransferFrom(msg.sender, computedAddress, price);
Escrow escrow = new Escrow{salt: salt}(
{
price: price,
tokenContract: tokenContract,
buyer: msg.sender,
seller: seller,
arbiter: arbiter,
arbiterFee: arbiterFee
}
);
if (address(escrow) != computedAddress) {
revert EscrowFactory__AddressesDiffer();
}
emit EscrowCreated(
{
escrowAddress: address(escrow),
buyer: msg.sender,
seller: seller,
arbiter: arbiter
}
);
return escrow;
}

Support

FAQs

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