Assessment reports>Aura Finance>Threat Models>Function: stake(uint256 _amount)

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

  • _amount

    • Control: The caller has full control but cannot use more tokens than owned.

    • Constraints: If msg.sender owns less amount of stakingToken, transaction will be reverted.

    • Impact: The amount of staking tokens.

Branches and code coverage (including function calls)

Intended branches

  • After first stake call, the rewards[msg.sender] is zero.

  • If the caller's balance is nonzero, the rewards[msg.sender] is calculated properly.

Negative behavior

  • Revert if msg.sender's stakingToken balance is less than _amount.

  • _amount is zero.

Function call analysis

  • stakingToken.safeTransferFrom(msg.sender, address(this), _amount)

    • External/internal? External.

    • Argument control? _amount.

    • Impact Transfer stakingToken from msg.sender to current contract.

  • updateReward(msg.sender)

    • External/internal? Internal.

    • Argument control? N/A.

    • Impact Updates global lastUpdateTime and rewardPerTokenStored. Sets rewards and userRewardPerTokenPaid of msg.sender.

Zellic © 2024Back to top ↑