TotalStaked and totalVestedStaked are not decreased when unstaking or unstakingVested immediately. TotalStake and totalVestedStaked remain unchanged but it should change.
In unstake()::FjordStaking.sol and unstakeVested()::FjordStaking.sol, there is no decrease of totalStaked (nor totalVestedStaked) which represents the total amount that is staked (and the total amount vested that is staked for totalVestedStaked).
Here is the code for unstake()::FjordStaking.sol:
https://github.com/Cyfrin/2024-08-fjord/blob/main/src/FjordStaking.sol#L473-L476
Here is the code for unstakeVested()::FjordStaking.sol:
https://github.com/Cyfrin/2024-08-fjord/blob/main/src/FjordStaking.sol#L534-L538
Wrong calculation of totalStaked and totalVestedStaked could break the protocol.
Github, VisualCode, Foundry.
Add a decrease of totalStaked and totalVestedStaked by the _amount when unstake() and unstakeVested() to keep a good track of the total amount staked and vested staked.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.