The Staking
contract incorrectly updates the WETH token balance when claiming staking rewards, preventing newly topped-up WETH rewards from being reflected in the index
storage variable.
Claiming staking rewards with the claim
function in the Staking
contract updates the contract's storage variable balance
to the current WETH balance in line 47. This update intends to reflect the WETH transfer out of the contract to the staker, i.e., the sent rewards.
However, if the total supply (totalSupply
, i.e., staked TKN
tokens) is zero, the reward index
is not updated due to the if
in line 63, while the WETH balance
is updated in line 57. Please note that totalSupply
can be zero right after the staking contract is deployed and before stakers deposit tokens. It can also be zero at a later time in case all stakers unstaked their deposits. Moreover, the claim
function can be called by anyone, even if the caller is not a staker and has no claimable rewards.
Storing the current WETH token balance in balance
while there have been new WETH tokens sent to the contract as rewards (by the Fees
contract), those rewards are not reflected in the index
as the balance check in line 65 would not detect the WETH balance change.
As the Lending
contract continuously accrues fees and sends fees via the Fees
contract to the Staking
contract, WETH rewards can potentially accumulate in the Staking
contract before stakers deposit tokens (i.e., totalSupply == 0
). Thus the chosen High severity as the likelihood of stuck WETH rewards is high.
Topped-up WETH rewards can not be claimed as rewards and remain unutilized and stuck in the Staking
contract.
Manual Review
Consider subtracting the claimed rewards amount from balance
in line 57 instead of storing the current WETH balance.
Additionally, consider reverting if no rewards are claimable, i.e., claimable[msg.sender] == 0
by the caller (msg.sender
) in the claim
function.
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.