When a user invokes decreasePosition, the function checks the current holder's position. If the position is empty, the current holder will be popped from the holders array. However, if there is a pending stake by the current holder, this pending staker will be added to the position with a 1-day duration. The next time the manager invokes distributeAssets and loops through the current holders array, it may not find this holder even if they have an active position.
Position holder invoke decreasePosition to derease his positon:
and function check if current holder's position is empty
Note that it's a storage variable of position only check the amount of position without check the pending staker.
Assuming Alice invokes increasePosition to add a position twice, and after one day, Alice invokes decreasePosition. Since Alice's position is now ZERO, her address could be popped from the holders array, even if Alice has a pending stake. The positions() function will return the current position along with the pending position. Alice's pending position will be added to the position after some time; however, we won't find Alice's address in the holders array if she doesn't increase her position again.
Here is my test written using foundry:
output:
As we can see the length of holders is ZERO even if alice has position. Lead to next distributeFees or distributeAssets can't find alice's position address.
Let's take distributeFees as example :
When distributing fees, if a user is not present in the holders array, and they increase their position within one day, their stake tokens are added to the position. As a result, their stake tokens are not included in the pending stake. Consequently, when fees are distributed, the user receives no reward.
staker lost distribute fees and assets.
Foundry
recommend to check pending stake along with position stake before delete holder.
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.