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

Use external over public

Summary

Using public over external has an impact on execution costs.

Instances:
File: Fees.sol
| sellProfits()

File: Lender.sol
| borrow()
| seizeLoan()
| refinance()

Vulnerability Details

If we run the following methods on Remix, we can see the difference

// execution cost 176 gas
function tt() external returns(uint256) {
return 0;
}
// execution cost 286 gas
function tt_public() public returns(uint256) {
return 0;
}

Impact

Save over 100 gas every time anyone uses each of the functions mentioned above. Considering those are some of the main features of the protocol, the impact can be big if corrected.

Tools Used

Manual

Recommendations

Change function sellProfits(address _profits) public
, function borrow(Borrow[] calldata borrows) public
, function seizeLoan(uint256[] calldata loanIds) public
and function refinance(Refinance[] calldata refinances) public

to
function sellProfits(address _profits) external
, function borrow(Borrow[] calldata borrows) external
, function seizeLoan(uint256[] calldata loanIds) external
and function refinance(Refinance[] calldata refinances) external

Support

FAQs

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