<!-- canonical: https://0xsimao.com/findings/metazero-ii-complete-unstake-following-interactions -->

# completeUnstake() not following checks-effects-interactions pattern

Low/Info · Three Sigma · Omnichain RWA tokenisation · 6th April, 2024

Finding 3S-MZ-N03 of the MetaZero Staking security review.

- Protocol: https://metazero.gg/
- Report: /reports/metazero-ii
- Codebase: https://github.com/0xsimao/stakingContract/tree/dffac73e838a9fbd12bed18e41b9799177bcde7f
- Source: https://cdn.sanity.io/files/qoqld077/production/3e07b0c2806b62578b8031e88c59bc5dbd38de1b.pdf

---

### Description

completeUnstake() transfers tokens before deleting the information of the staker, not
following the checks-effects-interactions pattern.

### Recommendation

Delete the staker mapping before transferring the tokens.

### Status

Addressed in [#67d85d0](https://github.com/metazerogg/stakingContract/tree/67d85d0087e2cbe7547cb8a3eefad37b546366ca).

---

Related findings:

- [Checks effects interactions pattern should always be used](https://0xsimao.com/findings/glacier-checks-effects-interactions-pattern): Glacier
- [Checks effects interactions pattern is now always followed](https://0xsimao.com/findings/orange-effects-interactions-now-followed): Orange Bridge
- [Checks effects interactions pattern is not always followed](https://0xsimao.com/findings/singularity-effects-interactions-pattern-followed): Singularity
- [Checks-effects-interations pattern is not always followed, which can be used to drain all tokens](https://0xsimao.com/findings/singularity-effects-interations-followed-drain): Singularity
