<!-- canonical: https://0xsimao.com/reports/glacier -->

# Glacier audit

Three Sigma · Liquid staking · 12th July 2023

A private security review of Glacier (liquid staking), conducted with Three Sigma and completed on 12th July 2023 over 8 days. 0xSimao disclosed 32 findings: 6 high severity, 3 medium, 4 low and 19 informational.

## What Glacier is

Glacier is a liquid staking protocol on Avalanche: users deposit any amount of AVAX, the protocol stakes it with network validators, and the position stays liquid, rewards accruing hourly, with reserves split across venues including Aave to keep exits serviceable.

## Scope

The review covered the reserve and rebalance machinery: how per-venue reserves are fetched and summed, share pricing on withdrawal, wAVAX unwrapping in rebalances, and behaviour when a lending reserve freezes.

## High severity findings

- [AaveV3 RewardsController provides rewards in any token, should be handled separately](https://0xsimao.com/findings/glacier-aave-rewards-provides-separately)
- [totalReserves should be fetched from the strategies individually and summed up in the ReservePool](https://0xsimao.com/findings/glacier-reserves-fetched-individually-summed)
- [increaseNetworkTotal() allows big arbitrage opportunities by depositing before an increase transaction](https://0xsimao.com/findings/glacier-network-big-opportunities-transaction)
- [_rebalanceWithdraw() mechanism in glAVAX allows arbitrage opportunities by changing the shares/AVAX ratio](https://0xsimao.com/findings/glacier-withdraw-arbitrage-opportunities-shares)
- [In glAVAX, function _rebalanceWithdraw() withdraws incorrect amount from WAVAX address](https://0xsimao.com/findings/glacier-rebalance-withdraw-withdraws-wavax)
- [In GReservePool, if a strategy is frozen reserve pool stops working](https://0xsimao.com/findings/glacier-reserve-frozen-stops-working)

## Medium severity findings

- [When changing addresses, use 2 step transfer and/or address 0x0 checks](https://0xsimao.com/findings/glacier-changing-addresses-transfer-0x0)
- [Strategy withdraw may fail if weights of strategies differ from the real values and might lead to frozen ReservePool](https://0xsimao.com/findings/glacier-withdraw-weights-differ-real)
- [Withdraw snapshot logic can be tricked allowing users to withdraw right away](https://0xsimao.com/findings/glacier-withdraw-snapshot-tricked-away)

## Low severity findings

- [In glAVAX, should use .call instead of .transfer](https://0xsimao.com/findings/glacier-avax-call-instead-transfer)
- [Strategy percentages will differ over time as yield accrued differs in ReservePool](https://0xsimao.com/findings/glacier-percentages-differ-yield-differs)
- [rebalance() in glAVAX reverts if currentReserves == reserveTarget](https://0xsimao.com/findings/glacier-reverts-current-reserves-target)
- [receive() in glAVAX should only allow wAVAX](https://0xsimao.com/findings/glacier-receive-avax)

## Informational findings

- [Usage of transferFrom() could revert if used from itself](https://0xsimao.com/findings/glacier-usage-transfer-revert-itself)
- [Strategies in the ReservePool could be implemented as an array and Strategy packed](https://0xsimao.com/findings/glacier-strategies-implemented-array-packed)
- [Implement _transferShares() to prevent having to convert shares/wAVAX twice in glAVAX](https://0xsimao.com/findings/glacier-transfer-shares-convert-twice)
- [rebalance(), withdrawAmount needed from the ReservePool can be simplified](https://0xsimao.com/findings/glacier-rebalance-withdraw-needed-simplified)
- [Checks effects interactions pattern should always be used](https://0xsimao.com/findings/glacier-checks-effects-interactions-pattern)
- [If statements can be inverted to increase readability](https://0xsimao.com/findings/glacier-statements-inverted-increase-readability)
- [avaxAmount is never 0 in withdraw() in the first if (avaxAmount > 0 && ...)](https://0xsimao.com/findings/glacier-avax-amount-withdraw-first)
- [Withdraw requests could be stored in a simpler way in glAVAX](https://0xsimao.com/findings/glacier-withdraw-stored-simpler-way)
- [In glAVAX, checking that amount > 0 earlier can save some gas](https://0xsimao.com/findings/glacier-avax-checking-earlier-gas)
- [In glAVAX, naming convention for storage variable should be consistent](https://0xsimao.com/findings/glacier-naming-convention-storage-consistent)
- [Storage variables should be cached whenever possible to save gas](https://0xsimao.com/findings/glacier-storage-cached-whenever-gas)
- [Unnecessary user balance check in _withdrawRequest()](https://0xsimao.com/findings/glacier-unnecessary-balance-withdraw-request)
- [Typo in fufillWithdrawal() in glAVAX, should be fulfillWithdrawal](https://0xsimao.com/findings/glacier-typo-fufill-withdrawal-fulfill)
- [In GReservePool, remove unnecessary logic](https://0xsimao.com/findings/glacier-reserve-remove-unnecessary-logic)
- [In GReservePool, use constants naming conventions](https://0xsimao.com/findings/glacier-reserve-constants-naming-conventions)
- [In GLendingPool, remove incorrect comment](https://0xsimao.com/findings/glacier-lending-remove-incorrect-comment)
- [In GLendingPool, event parameters can be indexed](https://0xsimao.com/findings/glacier-lending-event-parameters-indexed)
- [Remove unused imports](https://0xsimao.com/findings/glacier-remove-unused-imports)
- [NatSpect comments should include explanations of parameters and return variables](https://0xsimao.com/findings/glacier-nat-spect-comments-explanations)

## The report

[Download the report (PDF)](https://0xsimao.com/reports/2023-07-12-glacier.pdf)
