When updating the strategy rewards on the StakingPool, there is a scenario when the totalFeeAmounts >= totalStaked
which causes the rewards to be lost because no shares will minted.
There is a safety check that when totalFeeAmounts >= totalStaked
is true, it sets totalFeeAmounts to 0
, which ends up causing the minting of shares for those fees to be skipped.
There is a scenario when updating strategy rewards on the StakingPool that causes the rewards to be lost because no shares will be minted to the feeReceivers.
When totalFeeAmounts >= totalStaked
, the totalFeeAmounts
is set to 0, which causes the minting of shares to be skipped, therefore, causing the feeReceivers to not receive the corresponding shares for their earned fees, this means that those fees are donated to the pool for all the shares holders.
StakingPool._updateStrategyRewards()
An example when totalFeeAmounts >= totalStaked
would be true is when there are no tokens staked because all the deposits were withdrawn, but, there are still pending rewards to be distributed, in this case, totalFeeAmount will be the same as totalStaked
, which would cause the rewards being distributed to be lost, the feeReceivers won't receive any shares to claim those rewards.
Strategy rewards are lost because shares are not minted when totalFeeAmounts >= totalStaked
.
Manual Audit
Refactor the logic to mint the corresponding shares for rewards.
There is no need to update the totalStaked
before minting the shares, use the same approach as when minting shares for deposits, first mint shares and then update totalStaked
.
Remove the safety check, when totalFeeAmounts >= totalStaked
it means that the shares for the fees should be minted at a 1:1 ratio because there are no tokens staked on the pool, a.k.a, totalStaked == 0
Update the current approach for minting the shares for the fees. Instead, call the _mint()
and pass the totalFeeAmounts
as a parameter, let the _mint()
to compute the amount of shares that should be minted for the totalFees, the same approach as for deposits.
The changes on the code would look like these:
StakingPool._updateStrategyRewards()
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.