Typically, a vesting period ensures that users cannot withdraw their staked tokens before a certain time has passed.
This is usually enforced by a check within the withdraw function.
TempleGoldStaking
is missing such checks when an user attempts to withdraw before the end of vesting period.
TempleGoldStaking
contract implements a minimum vesting period of 1 Week.
This vestingPeriod deadline is set in StakeInfo.fullyVestedAt
,
every time an user calls the stake
or stakeFor
function.
https://github.com/TempleDAO/temple/blob/templegold/protocol/contracts/templegold/TempleGoldStaking.sol#L498
However the withdrawFor
function currently has no conditions in place
to check if the user's StakeInfo.fullyVestedAt
deadline has passed.
This allows an user to withdraw anytime.
Premature Withdrawals:
Users can withdraw their staked tokens before the vesting period is over.
This undermines the purpose of the vesting period.
If the vesting period is an essential part of the staking contract's design,
allowing premature withdrawals can impact the contract's intended economic incentives and security model.
Foundry, Manual Review
One solution is to add the following check in the withdrawFor
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.