Closed 0xferit closed 3 years ago
@ferittuncer I think that += should go here https://github.com/ferittuncer/ubi/blob/4697614453a20854d5a851e4cefd4a4b814aa99c/contracts/UBI.sol#L93.
Look what happens when someone calls mintAccrued()
10 times in a row in the same block.
@fnanni-0 i think that makes sense. you can do a PR with the modification as well.. and a test case would be dope.
Yeah, I did not notice it. Let me commit the fix. Thanks @fnanni-0
This is the minimal change and its test to make accruing tokens happen retroactively while preventing negative balance withdrawals.
This ensures users who started accruing at the same time, end up with the same amount of tokens.
Edge case: If accruing rate slows down, some users who withdrawn recently might see a negative balance available to withdraw. This is a temporary situation and the system acts as if the user has withdrawn his/her tokens in advance. After a while balance becomes positive again.
Key change:
And also
accruedSince[human]
now stores the initial accruing timestamp.