Skip to content

Commit

Permalink
chore: Updated Boosted Vault Natspec
Browse files Browse the repository at this point in the history
  • Loading branch information
naddison36 committed Jul 9, 2021
1 parent 771ea5f commit 4609b9b
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 21 deletions.
31 changes: 23 additions & 8 deletions contracts/rewards/boosted-staking/BoostedDualVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol";
import { StableMath } from "../../shared/StableMath.sol";

/**
* @title BoostedVault
* @title BoostedDualVault
* @author mStable
* @notice Accrues rewards second by second, based on a users boosted balance
* @dev Forked from rewards/staking/StakingRewards.sol
Expand All @@ -24,6 +24,7 @@ import { StableMath } from "../../shared/StableMath.sol";
* - `updateBoost` hook called after every external action to reset a users boost
* - Struct packing of common data
* - Searching for and claiming of unlocked rewards
* - Add a second rewards token in the platform rewards
*/
contract BoostedDualVault is
IBoostedDualVaultWithLockup,
Expand Down Expand Up @@ -51,6 +52,7 @@ contract BoostedDualVault is
/// @notice total raw balance
uint256 public totalRaw;

/// @notice length of each staking period in seconds. 7 days = 604,800; 3 months = 7,862,400
uint64 public constant DURATION = 7 days;
/// @notice Length of token lockup, after rewards are earned
uint256 public constant LOCKUP = 26 weeks;
Expand All @@ -59,7 +61,7 @@ contract BoostedDualVault is

/// @notice Timestamp for current period finish
uint256 public periodFinish;
/// @notice RewardRate for the rest of the PERIOD
/// @notice Reward rate for the rest of the period
uint256 public rewardRate;
/// @notice Platform reward rate for the rest of the period
uint256 public platformRewardRate;
Expand Down Expand Up @@ -90,32 +92,45 @@ contract BoostedDualVault is
uint128 rate;
}

/**
* @param _nexus mStable system Nexus address
* @param _stakingToken token that is beinf rewarded for being staked. eg MTA, imUSD or fPmUSD/GUSD
* @param _boostDirector vMTA boost director
* @param _priceCoeff Rough price of a given LP token, to be used in boost calculations, where $1 = 1e18
* @param _boostCoeff Boost coefficent using the the boost formula
* @param _rewardsToken first token that is being distributed as a reward. eg MTA
* @param _platformToken second token that is being distributed as a reward. eg FXS for FRAX
*/
constructor(
address _nexus,
address _stakingToken,
address _boostDirector,
uint256 _priceCoeff,
uint256 _coeff,
uint256 _boostCoeff,
address _rewardsToken,
address _platformToken
)
InitializableRewardsDistributionRecipient(_nexus)
BoostedTokenWrapper(_stakingToken, _boostDirector, _priceCoeff, _coeff)
BoostedTokenWrapper(_stakingToken, _boostDirector, _priceCoeff, _boostCoeff)
{
rewardsToken = IERC20(_rewardsToken);
platformToken = IERC20(_platformToken);
}

/**
* @dev StakingRewards is a TokenWrapper and RewardRecipient
* Constants added to bytecode at deployTime to reduce SLOAD cost
* @dev Initialization function for upgradable proxy contract.
* This function should be called via Proxy just after contract deployment.
* To avoid variable shadowing appended `Arg` after arguments name.
* @param _rewardsDistributorArg mStable Reward Distributor contract address
* @param _nameArg token name. eg imUSD Vault or GUSD Feeder Pool Vault
* @param _symbolArg token symbol. eg v-imUSD or v-fPmUSD/GUSD
*/
function initialize(
address _rewardsDistributor,
address _rewardsDistributorArg,
string calldata _nameArg,
string calldata _symbolArg
) external initializer {
InitializableRewardsDistributionRecipient._initialize(_rewardsDistributor);
InitializableRewardsDistributionRecipient._initialize(_rewardsDistributorArg);
BoostedTokenWrapper._initialize(_nameArg, _symbolArg);
platformTokenVendor = new PlatformTokenVendor(platformToken);
}
Expand Down
5 changes: 5 additions & 0 deletions contracts/rewards/boosted-staking/BoostedTokenWrapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ contract BoostedTokenWrapper is InitializableReentrancyGuard {
* @param _stakingToken Wrapped token to be staked
* @param _boostDirector vMTA boost director
* @param _priceCoeff Rough price of a given LP token, to be used in boost calculations, where $1 = 1e18
* @param _boostCoeff Boost coefficent using the the boost formula
*/
constructor(
address _stakingToken,
Expand All @@ -62,6 +63,10 @@ contract BoostedTokenWrapper is InitializableReentrancyGuard {
boostCoeff = _boostCoeff;
}

/**
* @param _nameArg token name. eg imUSD Vault or GUSD Feeder Pool Vault
* @param _symbolArg token symbol. eg v-imUSD or v-fPmUSD/GUSD
*/
function _initialize(string memory _nameArg, string memory _symbolArg) internal {
_initializeReentrancyGuard();
_name = _nameArg;
Expand Down
41 changes: 28 additions & 13 deletions contracts/rewards/boosted-staking/BoostedVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,27 @@ contract BoostedVault is
event Poked(address indexed user);
event RewardPaid(address indexed user, uint256 reward);

/// @notice token the rewards are distributed in. eg MTA
IERC20 public immutable rewardsToken;

/// @notice length of each staking period in seconds. 7 days = 604,800; 3 months = 7,862,400
uint64 public constant DURATION = 7 days;
// Length of token lockup, after rewards are earned
/// @notice Length of token lockup, after rewards are earned
uint256 public constant LOCKUP = 26 weeks;
// Percentage of earned tokens unlocked immediately
/// @notice Percentage of earned tokens unlocked immediately
uint64 public constant UNLOCK = 33e16;

// Timestamp for current period finish
/// @notice Timestamp for current period finish
uint256 public periodFinish;
// RewardRate for the rest of the PERIOD
/// @notice RewardRate for the rest of the period
uint256 public rewardRate;
// Last time any user took action
/// @notice Last time any user took action
uint256 public lastUpdateTime;
// Ever increasing rewardPerToken rate, based on % of total supply
/// @notice Ever increasing rewardPerToken rate, based on % of total supply
uint256 public rewardPerTokenStored;

mapping(address => UserData) public userData;
// Locked reward tracking
/// @notice Locked reward tracking
mapping(address => Reward[]) public userRewards;
mapping(address => uint64) public userClaim;

Expand All @@ -73,30 +76,42 @@ contract BoostedVault is
uint128 rate;
}

/**
* @param _nexus mStable system Nexus address
* @param _stakingToken token that is beinf rewarded for being staked. eg MTA, imUSD or fPmUSD/GUSD
* @param _boostDirector vMTA boost director
* @param _priceCoeff Rough price of a given LP token, to be used in boost calculations, where $1 = 1e18
* @param _boostCoeff Boost coefficent using the the boost formula
* @param _rewardsToken first token that is being distributed as a reward. eg MTA
*/
constructor(
address _nexus,
address _stakingToken,
address _boostDirector,
uint256 _priceCoeff,
uint256 _coeff,
uint256 _boostCoeff,
address _rewardsToken
)
InitializableRewardsDistributionRecipient(_nexus)
BoostedTokenWrapper(_stakingToken, _boostDirector, _priceCoeff, _coeff)
BoostedTokenWrapper(_stakingToken, _boostDirector, _priceCoeff, _boostCoeff)
{
rewardsToken = IERC20(_rewardsToken);
}

/**
* @dev StakingRewards is a TokenWrapper and RewardRecipient
* Constants added to bytecode at deployTime to reduce SLOAD cost
* @dev Initialization function for upgradable proxy contract.
* This function should be called via Proxy just after contract deployment.
* To avoid variable shadowing appended `Arg` after arguments name.
* @param _rewardsDistributorArg mStable Reward Distributor contract address
* @param _nameArg token name. eg imUSD Vault or GUSD Feeder Pool Vault
* @param _symbolArg token symbol. eg v-imUSD or v-fPmUSD/GUSD
*/
function initialize(
address _rewardsDistributor,
address _rewardsDistributorArg,
string calldata _nameArg,
string calldata _symbolArg
) external initializer {
InitializableRewardsDistributionRecipient._initialize(_rewardsDistributor);
InitializableRewardsDistributionRecipient._initialize(_rewardsDistributorArg);
BoostedTokenWrapper._initialize(_nameArg, _symbolArg);
}

Expand Down

0 comments on commit 4609b9b

Please sign in to comment.