VaultRouterBranch.unstake reverts if the claimable amount of msg.sender, i.e. amountToClaimX18 is not 0.
https://github.com/Cyfrin/2025-01-zaros-part-2/blob/main/src/market-making/branches/VaultRouterBranch.sol#L599-L602
Market.receiveWethReward updates Market.Data.wethRewardPerVaultShare which changes amountToClaimX18.
https://github.com/Cyfrin/2025-01-zaros-part-2/blob/main/src/market-making/leaves/Market.sol#L524-L525
Market.receiveWethReward is called only in FeeDistributionBranch._handleWethRewardDistribution.
https://github.com/Cyfrin/2025-01-zaros-part-2/blob/main/src/market-making/branches/FeeDistributionBranch.sol#L392
FeeDistributionBranch._handleWethRewardDistribution is called in FeeDistributionBranch.receiveMarketFee.
https://github.com/Cyfrin/2025-01-zaros-part-2/blob/main/src/market-making/branches/FeeDistributionBranch.sol#L112
It is only callable by allowed engines, but not currently used. We can guess WETH fee will be incremented by other
traders' opening or closing positions.
Add this test at the end of Unstake_Integration_Test.
It shows that VaultRouterBranch.unstake reverts if unclaimed fee exists.
FeeDistributionBranch.receiveMarketFee
will be called by other engines. An attacker can prevent stakers from unstaking by calling the functions updating
lastValuePerShare continuously.
Foundry.
Add a new field to store the unclaimed rewards and update rewards in Distribution._updateLastValuePerShare.
https://github.com/Cyfrin/2025-01-zaros-part-2/blob/main/src/market-making/leaves/Distribution.sol#L17-L20
Reference
https://github.com/Synthetixio/synthetix/blob/d7b5c386ffbd0a53a129cfbd8a683a6a3f62cc36/contracts/StakingRewards.sol#L29
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.