Closed pldespaigne closed 3 years ago
Please add a require for amount to be less or equal to tokens length also
If amount
is greater than tokens.length
, then the first line (stakingContractEth.unstakeFrom(msg.sender, amount);
) will already revert with "Distribute: Dont have enough staked"
.
Do you still want me to add a require()
?
No you're right. Maybe just add a comment then, saying that at this point amount cant be greater than length (for auditors)
The Bug
When unstaking user is asked to fill an
amount
parameter, but the code does not take it into account:Proposed Fix
We want to remove
amount
number of elements from the array. Because we use .pop(), we remove elements starting from the end of the array.