Closed code423n4 closed 2 years ago
sponsor disputed: this is by design. currently we have the cooldown set to two epochs to prevent users from claiming right after the epoch rolls over. We want users to gain rewards in the warmup contract as well as not gaining rewards from the cooldown contract.
Lines of code
https://github.com/code-423n4/2022-06-yieldy/blob/524f3b83522125fb7d4677fa7a7e5ba5a2c0fe67/src/contracts/Staking.sol#L688-L693
Vulnerability details
Impact
The warmup and cooldown periods implemented in the
Staking
contract do not enforce a full epoch of staking.Shortly before an epoch ends, one can stake
USDC
(staking token), haveUSDCy
(reward tokens) locked up in the warmup period and immediately callunstake
.Immediately after the next epoch begins, the staking tokens (
USDC
) can be withdrawn. The user did not have to wait for a full warm-up and cooldown period.No additional rewards are received as rewards are issued in a 1 period lagging fashion, however, the user who staked his funds and unstaked immediately after, will lose out on those rewards (the staked capital was working to accrue rewards on Tokemak).
Proof of Concept
https://github.com/code-423n4/2022-06-yieldy/blob/524f3b83522125fb7d4677fa7a7e5ba5a2c0fe67/src/contracts/Staking.sol#L688-L693
The following test case demonstrates how one can stake and unstake regardless of the warmup and cooldown period:
Tools Used
Manual review
Recommended mitigation steps
Consider implementing the warmup period in a way that the warmup period is bound to the amount that was staked at that time by the account.