<!-- canonical: https://0xsimao.com/findings/maple-finance-iii-maple-variables-read-storage -->

# MapleLoan variables read from storage more than once.

Low/Info · Three Sigma · Institutional lending · 10th April, 2024

Finding 3S-MAPLE-N01 of the Maple Finance security review.

- Protocol: https://maple.finance/
- Report: /reports/maple-finance-iii-2024
- Source: https://cdn.sanity.io/files/qoqld077/production/36dbe5ca76da3d2392bcee581548067705b8bd36.pdf

---

### Description

In the MapleLoan contract, the following variables are loaded from storage multiple times:
● acceptNewTerms(): lender is loaded twice from storage.
● acceptNewTerms(): borrower is loaded from storage three times.
● makePayment(): lender is loaded from storage three times.

### Recommendation

These variables should be loaded from storage just once and placed in temporary memory
for later use (within the same function).

### Status

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

---

Related findings:

- [Storage variables should be cached whenever possible to save gas](https://0xsimao.com/findings/glacier-storage-cached-whenever-gas): Glacier
- [Storage variables can be cached to save gas](https://0xsimao.com/findings/mitosis-storage-variables-cached-gas): Mitosis
- [Storage variables can be cached to save gas](https://0xsimao.com/findings/orange-storage-variables-cached-gas): Orange Bridge
