Skip to content
Request an audit

‹ All findings

LoanManager code optimizations: no need to load payment struct from storage if loan is unimpaired.

Low/InfoMaple Finance·Three Sigma · Institutional lending · 10th April, 20243S-MAPLE-N06

Description

In the LoanManager contract, two changes can be made to reduce gas usage and improve readability: In function _accountForLoanImpairmentRemoval(): loading the payment struct from storage should only be performed after the check to see if the loan is impaired, since the vast majority of the time, a payment will be made to an unimpaired loan, so there is no need to load this struct from storage as it will not be used.

This change would result in a makePayment() call cheaper by around 3000 gas. An identical issue can be found in function _accountForLoanImpairment().

Recommendation

Only load the payment struct from storage after the line which returns if the loan is impaired.

Status

Addressed in the following PR: https://github.com/maple-labs/open-term-loan-manager-private/pull/52