The Staking contract does not account for any WETH deposited until the first time deposit() is called. This leads to that WETH being permanently stuck and unclaimable
The accounting of the Staking.sol contract only updates when there is a difference in ETH from the previous balance to new ETH balance.
However, when WETH is transferred to this contract before there are any stakers, it does not get updated/accounted for. This is because the update() function is first called in the contract after the first deposit() of TKN, but not after WETH is received. This is likely to happen when a fee contract is attached to the staking contract, as the first fee deposit can reasonably come before the first person stakes.
This can be verified by checking that when a deposit is sent to the staking contract after ETH, that the claimable mapping remains zero (you could also check via vm.warp that this is a time-based issue, but its not). We can see in this Proof of Concept that when bob stakes and withdraws, they don't get any of the WETH. In fact, any subsequent stakers seem to be unable to claim that ETH, meaning that the ETH is permanently stuck in the contract. This exact fact is hard to conclusively prove with POC:
Here are the console logs of this POC (forge tets -vvv):
[PASS] test_POC_WETH_Stuck() (gas: 321710)
Logs:
1000 initial weth balance
400 claimed
469 claimed
We see from the console logs Bob got to claim 50% of the 800 WETH that was deposited after he had deposited, because he owns 200/400 or 50% of the total staked TKN. But he gets 0% of the 1000WETH
Then when the other staker withdraws, and there is another WETH deposit. He owns the entire staking pool and there is 1469 WETH. He gets the 100% of the 469 WETH when he calls staking.claim but 0% of the 1000WETH because that is WETH is stuck, due to the bug that WETH deposited before staking is stuck in the contract.
WETH deposited before staking is permanently stuck.
Foundry testing
Call update() or a variant of that function when WETH is received before the first stake.
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.