Platform: Code4rena
Start Date: 14/06/2022
Pot Size: $50,000 USDC
Total HM: 19
Participants: 99
Period: 5 days
Judge: HardlyDifficult
Total Solo HM: 4
Id: 136
League: ETH
Rank: 29/99
Findings: 1
Award: $276.92
🌟 Selected for report: 0
🚀 Solo Findings: 0
276.9248 USDC - $276.92
https://github.com/code-423n4/2022-06-infinity/blob/main/contracts/staking/InfinityStaker.sol#L116-L131 https://github.com/code-423n4/2022-06-infinity/blob/main/contracts/staking/InfinityStaker.sol#L290-L325
Users could lose an unvested amount permanently after InfinityStaker.unstake().
It's because the timestamp of lower duration would be larger than the one of higher duration. So vested amount of higher duration would be positive when vested amount of lower duration is 0.
Manual Review
The vested amount is 0 or staked amount whether it meets timestamp requirement or not. So you can check if the vested amount is greater than 0 before clear staked amount.
if (amount > noVesting) { userstakedAmounts[user][Duration.NONE].amount = 0; userstakedAmounts[user][Duration.NONE].timestamp = 0; amount = amount - noVesting; if (amount > vestedThreeMonths) { if(vestedThreeMonths != 0) { //new condition userstakedAmounts[user][Duration.THREE_MONTHS].amount = 0; userstakedAmounts[user][Duration.THREE_MONTHS].timestamp = 0; amount = amount - vestedThreeMonths; } if (amount > vestedSixMonths) { if(vestedSixMonths != 0) { //new condition userstakedAmounts[user][Duration.SIX_MONTHS].amount = 0; userstakedAmounts[user][Duration.SIX_MONTHS].timestamp = 0; amount = amount - vestedSixMonths; } if (amount > vestedTwelveMonths) { if(vestedTwelveMonths != 0) //new condition { userstakedAmounts[user][Duration.TWELVE_MONTHS].amount = 0; userstakedAmounts[user][Duration.TWELVE_MONTHS].timestamp = 0; } } else { userstakedAmounts[user][Duration.TWELVE_MONTHS].amount -= amount; } } else { userstakedAmounts[user][Duration.SIX_MONTHS].amount -= amount; } } else { userstakedAmounts[user][Duration.THREE_MONTHS].amount -= amount; } } else { userstakedAmounts[user][Duration.NONE].amount -= amount; }
#0 - nneverlander
2022-06-22T12:40:46Z
#1 - nneverlander
2022-07-05T11:21:23Z
#2 - nneverlander
2022-07-05T11:21:38Z
#3 - nneverlander
2022-07-05T11:21:49Z
#4 - nneverlander
2022-07-05T11:22:08Z
#5 - nneverlander
2022-07-05T11:22:17Z
#6 - nneverlander
2022-07-05T11:22:29Z
#7 - HardlyDifficult
2022-07-10T14:57:10Z