<!-- canonical: https://0xsimao.com/findings/glacier-strategies-implemented-array-packed -->

# Strategies in the ReservePool could be implemented as an array and Strategy packed

Low/Info · Three Sigma · Liquid staking · 12th July, 2023

Finding 3S-GLACIER-N02 of the Glacier security review.

- Protocol: https://www.glacier.io/
- Report: /reports/glacier
- Source: https://cdn.sanity.io/files/qoqld077/production/21bd3b6fa78c55968a6c9c7ea4fd49f34a8bd3d8.pdf

---

### Description

The strategies are stored in the ReservePool as a mapping _strategies and length
_strategyCount. This could be reduced to an array of [Strategy](https://github.com/JackFrostDev/glacier-contracts/blob/main/contracts/protocol/ReservePool/GReservePool.sol#L36-L44), Strategy[] public
_strategies;, increasing readability and gas savings.
Additionally, the struct Strategy can be reduced to 2 variables and occupy only 1 storage
slot by packing the logic and the weight together (deposited is not needed).

### Recommendation

Refactor the code to:

```solidity
contract GReservePool is Initializable, IGReservePool, AccessControlManager
{
    ... struct Strategy {
```

IGReserveStrategy logic; // 20 bytes
uint96 weight; // so weight can have at most 12 bytes or uint96 to
fill the 32 bytes storage slot

```solidity
}
Strategy[] public _strategies;
... }
```

### Status

This issue has been addressed in commit: [#4bb9844](https://github.com/threesigmaxyz/glacier-contracts-foundry/commit/4bb98443a617fcb95418986c6bc7cb54e06f29ea).

---

Related findings:

- [DoSed StrategyRouter:withdrawFromStrategies() if strategyTokenBalancesUsd[i] is too small in the swapping phase](https://0xsimao.com/findings/clip-finance-i-withdraw-balances-usd-phase): Clip Finance Strategies
- [Batch:withdraw() can be DoSed by frontrunning it with strategyRouter:allocateToStrategies()](https://0xsimao.com/findings/clip-finance-i-withdraw-frontrunning-allocate-strategies): Clip Finance Strategies
- [Yield loss due to StrategyRouterLib:rebalanceStrategies() not allocating saturated strategy deposits](https://0xsimao.com/findings/clip-finance-i-yield-allocating-saturated-deposits): Clip Finance Strategies
- [`VaultPoolLib::reserve()` will store the `Pa` not attributed to user withdrawals incorrectly and leave in untracked once it expires again](https://0xsimao.com/findings/cork-protocol-attributed-withdrawals-untracked-expires): Cork Protocol
