20,000 USDC
View results
Submission Details
Severity: gas

Check sequence

Summary

Check less gas needed line for early revert with less gas loss

Checking amount first in case of fails to save gas

function addToPool(bytes32 poolId, uint256 amount) external {
if (pools[poolId].lender != msg.sender) revert Unauthorized();
if (amount == 0) revert PoolConfig();
_updatePoolBalance(poolId, pools[poolId].poolBalance + amount);
// transfer the loan tokens from the lender to the contract
IERC20(pools[poolId].loanToken).transferFrom(
msg.sender,
address(this),
amount
);
}

Tools Used

Foundry test suit

Support

FAQs

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