Function: stake(uint256 _amount)
The msg.sender provides stakingToken to the current contract. The _totalSupply and _balances of msg.sender is increased by _amount-provided tokens. Also, the updateReward modifier is triggered.
Inputs
_amountControl: The caller has full control but cannot use more tokens than owned.
Constraints: If
msg.senderowns less amount ofstakingToken, transaction will be reverted.Impact: The amount of staking tokens.
Branches and code coverage (including function calls)
Intended branches
After first
stakecall, therewards[msg.sender]is zero.If the caller's balance is nonzero, the
rewards[msg.sender]is calculated properly.
Negative behavior
Revert if
msg.sender'sstakingTokenbalance is less than_amount._amountis zero.
Function call analysis
stakingToken.safeTransferFrom(msg.sender, address(this), _amount)External/internal? External.
Argument control?
_amount.Impact Transfer
stakingTokenfrommsg.senderto current contract.
updateReward(msg.sender)External/internal? Internal.
Argument control? N/A.
Impact Updates global
lastUpdateTimeandrewardPerTokenStored. SetsrewardsanduserRewardPerTokenPaidofmsg.sender.