<!-- canonical: https://0xsimao.com/findings/fuji-finance-saving-memory-spends-gas -->

# Saving parameters in memory without using them spends gas

Low/Info · Three Sigma · Lending aggregator · 6th May, 2023

Finding 3S-FUJI-N18 of the Fuji Finance security review.

- Report: /reports/fuji-finance
- Source: https://cdn.sanity.io/files/qoqld077/staging/32181a28eac3175d15fb8924d249bb0d91ca350c.pdf

---

### Description

In BaseVault.sol several functions receive a variable as a parameter then save it in memory
and immediately use it to make a call without making any changes. This is most likely done
to increase readability however since there is no reason to save it in memory, this is
spending unnecessary gas.

```solidity
function increaseAllowance(address receiver, uint256 shares) public
override returns (bool) {
    address operator = receiver;
    increaseWithdrawAllowance(operator, receiver, convertToAssets(shares));
    return true;
}
```

### Recommendation

In the mentioned functions in the links, remove the variable in memory being created and
pass the variable directly to the call. In the example above, address operator.

### Status

Addressed here: [Fujicracy/fuji-v2#625](https://github.com/Fujicracy/fuji-v2/pull/625)

---

Related findings:

- [Signatures missing some parameters being vulnerable to attackers using them coupled with malicious parameters](https://0xsimao.com/findings/crestal-network-signatures-parameters-them-coupled): Crestal Network
- [pool-v2-private: cache list length in memory and uncheck i_ to save gas.](https://0xsimao.com/findings/maple-finance-iii-private-cache-uncheck-gas): Maple Finance
- [Variables should be cached to memory to save gas](https://0xsimao.com/findings/metazero-ii-variables-cached-memory-gas): MetaZero Staking
- [BRC20 parameters should be passed as arguments to the constructor of BRC20 to save gas](https://0xsimao.com/findings/orange-parameters-passed-arguments-gas): Orange Bridge
