Function: _stakeFor(address _account, uint256 _amount)
This function will be called by the stake
function, used for users to stake stakeToken
and record the relevant information of this transaction.
Inputs
_account
Control: Arbitrary.
Constraints: None.
Impact: The address of the user performing the staking.
_amount
Control: Arbitrary.
Constraints: Greater than zero.
Impact: The amount of
stakeToken
the user wants to stake.
Branches and code coverage
Intended branches
Transfer
stakeToken
to the current contract.Get the
UserInfo
structure of_account
to update the user's staking information.Calculate, by iterating over
rewardPoolInfo
, therewardDebt
for each reward pool and update the user'srewardDebt
with the new amount.Update
user.lastStakeTime
to the currentblock.timestamp
to record the time when the staking occurs.
Negative behavior
Revert if
_amount
is zero.