# BoostedSavingsVault V2

{% tabs %}
{% tab title="Ethereum Mainnet" %}

| Contract                                                                                                                   | Address                                                                                                               |
| -------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| [imUSD Vault](https://github.com/mstable/mStable-contracts/blob/master/contracts/rewards/boosted-staking/BoostedVault.sol) | [0x78befca7de27d07dc6e71da295cc2946681a6c7b](https://etherscan.io/address/0x78befca7de27d07dc6e71da295cc2946681a6c7b) |
| [imBTC Vault](https://github.com/mstable/mStable-contracts/blob/master/contracts/rewards/boosted-staking/BoostedVault.sol) | [0xf38522f63f40f9dd81abafd2b8efc2ec958a3016](https://etherscan.io/address/0xf38522f63f40f9dd81abafd2b8efc2ec958a3016) |
| {% endtab %}                                                                                                               |                                                                                                                       |
| {% endtabs %}                                                                                                              |                                                                                                                       |

## Functions

### stake()

`function stake (uint256 _amount) external`

Stakes a given amount of the StakingToken for the sender

| Parameter | Type    | Description           |
| --------- | ------- | --------------------- |
| `_amount` | uint256 | Units of StakingToken |

### stake()

`function stake (address _beneficiary, uint256 _amount) external`

Stakes a given amount of the StakingToken for a given beneficiary

| Parameter      | Type    | Description                                |
| -------------- | ------- | ------------------------------------------ |
| `_beneficiary` | address | Staked tokens are credited to this address |
| `_amount`      | uint256 | Units of StakingToken                      |

### exit()

`function exit () external`

Withdraws stake from pool and claims any unlocked rewards.Note, this function is costly - the args for \_claimRewardsshould be determined off chain and then passed to other fn

### exit()

`function exit (uint256 _first, uint256 _last) external`

Withdraws stake from pool and claims any unlocked rewards.

| Parameter | Type    | Description                               |
| --------- | ------- | ----------------------------------------- |
| `_first`  | uint256 | Index of the first array element to claim |
| `_last`   | uint256 | Index of the last array element to claim  |

### withdraw()

`function withdraw (uint256 _amount) external`

Withdraws given stake amount from the pool

| Parameter | Type    | Description                           |
| --------- | ------- | ------------------------------------- |
| `_amount` | uint256 | Units of the staked token to withdraw |

### withdrawAndUnwrap()

1. Redeems the underlying mAsset tokens for bAsset tokens.
2. Swaps the underlying mAsset tokens for fAsset tokens in a Feeder Pool.

Redeems staked interest-bearing asset tokens for either bAsset or fAsset tokens. Withdraws a given staked amount of interest-bearing assets from the vault, redeems the interest-bearing asset for the underlying mAsset and either

`function withdrawAndUnwrap (uint256 _amount, uint256 _minAmountOut, address _output, address _beneficiary, address _router, bool _isBassetOut) external returns (uint256 outputQuantity)`

| Parameter       | Type    | Description                                                                                                                                                                                                                                                                                                                                                                                           |            |
| --------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- |
| `_amount`       | uint256 | Units of the staked interest-bearing asset tokens to withdraw. eg imUSD or imBTC.                                                                                                                                                                                                                                                                                                                     |            |
| `_minAmountOut` | uint256 | Minimum units of `output` tokens to be received by the beneficiary. This is to the same decimal places as the `output` token.                                                                                                                                                                                                                                                                         |            |
| `_output`       | address | <p>Asset to receive in exchange for the redeemed mAssets. This can be a bAsset or a fAsset. For example:    </p><ul><li>bAssets (USDC, DAI, sUSD or USDT) or fAssets (GUSD, BUSD, alUSD, FEI or RAI) for mainnet imUSD Vault.</li><li>bAssets (USDC, DAI or USDT) or fAsset FRAX for Polygon imUSD Vault.</li><li>bAssets (WBTC, sBTC or renBTC) or fAssets (HBTC or TBTCV2) for mainnet imBTC Vault. | </li></ul> |
| `_beneficiary`  | address | Address to send `output` tokens to.                                                                                                                                                                                                                                                                                                                                                                   |            |
| `_router`       | address | mAsset address if the `output` is a bAsset. Feeder Pool address if the `output` is a fAsset.                                                                                                                                                                                                                                                                                                          |            |
| `_isBassetOut`  | bool    | `true` if `output` is a bAsset. `false` if `output` is a fAsset                                                                                                                                                                                                                                                                                                                                       |            |

### claimReward()

`function claimReward () external`

Claims only the tokens that have been immediately unlocked, not includingthose that are in the lockers.

### claimRewards()

`function claimRewards () external`

Claims all unlocked rewards for sender.Note, this function is costly - the args for \_claimRewardsshould be determined off chain and then passed to other fn

### claimRewards()

`function claimRewards (uint256 _first, uint256 _last) external`

Claims all unlocked rewards for sender. Both immediately unlockedrewards and also locked rewards past their time lock.

| Parameter | Type    | Description                               |
| --------- | ------- | ----------------------------------------- |
| `_first`  | uint256 | Index of the first array element to claim |
| `_last`   | uint256 | Index of the last array element to claim  |

### pokeBoost()

`function pokeBoost () external`

Pokes a given account to reset the boost

### getRewardToken()

`function getRewardToken () external returns (contract IERC20)`

Gets the RewardsToken

### lastTimeRewardApplicable()

`function lastTimeRewardApplicable () public returns (uint256)`

Gets the last applicable timestamp for this reward period

### rewardPerToken()

`function rewardPerToken () public returns (uint256)`

Calculates the amount of unclaimed rewards per token since last update,and sums with stored to give the new cumulative reward per token

### earned()

`function earned (address _account) public returns (uint256)`

Returned the units of IMMEDIATELY claimable rewards a user has to receive. Note - thisdoes NOT include the majority of rewards which will be locked up.

| Parameter  | Type    | Description  |
| ---------- | ------- | ------------ |
| `_account` | address | User address |

### unclaimedRewards()

`function unclaimedRewards (address _account) external returns (uint256 amount, uint256 first, uint256 last)`

Calculates all unclaimed reward data, finding both immediately unlocked rewardsand those that have passed their time lock.

| Parameter  | Type    | Description  |
| ---------- | ------- | ------------ |
| `_account` | address | User address |

### notifyRewardAmount()

`function notifyRewardAmount (uint256 _reward) external`

Notifies the contract that new rewards have been added.Calculates an updated rewardRate based on the rewards in period.

| Parameter | Type    | Description                                           |
| --------- | ------- | ----------------------------------------------------- |
| `_reward` | uint256 | Units of RewardToken that have been added to the pool |
