Function: unstake(address _depositToken, uint256 _amount)
Allows unstaking of tokens.
Inputs
_depositTokenControl: The
_depositTokenis controlled by the caller.Constraints: Checked that the token is whitelisted (
isDepositToken).Impact: The token to be unstaked.
_amountControl: The
_amountis controlled by the caller.Constraints: Checked that the amount is greater than zero. Also, in
safeTransfercall, it is checked that the_accounthas enough balance.Impact: The amount of tokens to be unstaked.
Branches and code coverage (including function calls)
Intended branches
Checks that the token is whitelisted (
isDepositToken).Checks that the amount is greater than zero.
Checks that the
_accounthas enough balance (safeTransfer) --- also the check indepositBalances.Decreases the total deposit supply for the
_depositToken.Decreases the
depositBalancesfor the_account.Decreases the
stakedAmountsfor the_account.Decreases the
balancesfor the_account(by burning this contract's tokens).Transfers the
_amountof deposit tokens back to the_account.
Negative behavior
Should not allow withdrawing more than the staked amount.
Should not be callable if
isPrivateStakingModeistrue.Assumes user cannot unstake a token that they have not staked. That is handled by the
depositBalancesdecrease.Should not allow unstaking more tokens than the user has staked.