Using calldata instead of memory for read-only arguments in external functions saves gas
By declaring loan as calldata, the Solidity compiler will optimize the function to directly read the Loan data from the calldata, avoiding unnecessary data copying. This can lead to gas savings, especially when the Loan struct is large, as it reduces the cost of reading data from storage.
The only time it makes sense to read the whole struct/array into a memory variable, is if the full struct/array is being returned by the function, is being passed to a function that requires memory, or if the array/struct is being read from another memory array/struct.
Instances:
Lender.sol: Line 117
Huge savings in gas.
Manual audit
Declare the variable as calldata.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.