<!-- canonical: https://0xsimao.com/findings/mitosis-storage-variables-cached-gas -->

# Storage variables can be cached to save gas

Low/Info · Three Sigma · Cross-chain liquidity layer 1 · 25th June, 2024

Finding 3S-Mitosis-N13 of the Mitosis security review.

- Protocol: https://mitosis.org/
- Report: /reports/mitosis
- Source: https://cdn.sanity.io/files/qoqld077/production/b6b3bd7bb47407d99e76abb7c6dc615c1db5018e.pdf

---

### Description

Storage variables should be cached to avoid reading from storage more than once and
incurring extra gas costs.

### Recommendation

In BasicVault::enableEOL(), $.asset.forceApprove(address($v2.eol),
type(uint256).max); should use eol instead.
In RedeemQueue::push(), queue._count++; could be queue._count = requestId + 1.
In RedeemQueue::resolve(), update() writes the whole request to storage, when only the
resolved at field is modified.
In StrategyExecutor::disableStrategy, enabled.length should be cached.

### Status

Addressed in [#43e8fea](https://github.com/mitosis-org/evm/pull/211/commits/43e8fea2e12fd5d0596cbfd44ef498de6d70376c).

---

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/orange-storage-variables-cached-gas): Orange Bridge
- [Variables should be cached to memory to save gas](https://0xsimao.com/findings/metazero-ii-variables-cached-memory-gas): MetaZero Staking
- [genesisLimit can be placed as constant variables to save gas.](https://0xsimao.com/findings/metazero-i-genesis-placed-constant-gas): MetaZero Omnichain NFTs
