Submitted by Ruhum, also found by 0xDjango, auditor0517, dipp, GimelSec, GreyArt, p4st13r4, and wagmi
Following scenario:
Alice has staked X token for 6 months that have vested. She stakes Y tokens for another three months. If she now calls unstake(X) to take out the tokens that have vested, the Y tokens she staked for three months will be locked up.
First, heres a test showcasing the issue:
The test implements the scenario Ive described above. In the end, the user got back their amountStaked tokens with the amountStaked2 tokens being locked up in the contract. The user has no tokens staked at the end.
The issue is in the _updateUserStakedAmounts() function:
Dont set userstakedAmounts.amount to 0 if none of its tokens are removed (vestedAmount == 0)
nneverlander (Infinity) confirmed
HardlyDifficult (judge) commented:
