-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve audit feedback and convert SavingsVault to initializable
- Loading branch information
Showing
7 changed files
with
256 additions
and
46 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
contracts/rewards/InitializableRewardsDistributionRecipient.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
pragma solidity 0.5.16; | ||
|
||
import { InitializableModule2 } from "../shared/InitializableModule2.sol"; | ||
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
import { IRewardsDistributionRecipient } from "../interfaces/IRewardsDistributionRecipient.sol"; | ||
|
||
/** | ||
* @title RewardsDistributionRecipient | ||
* @author Originally: Synthetix (forked from /Synthetixio/synthetix/contracts/RewardsDistributionRecipient.sol) | ||
* Changes by: Stability Labs Pty. Ltd. | ||
* @notice RewardsDistributionRecipient gets notified of additional rewards by the rewardsDistributor | ||
* @dev Changes: Addition of Module and abstract `getRewardToken` func + cosmetic | ||
*/ | ||
contract InitializableRewardsDistributionRecipient is IRewardsDistributionRecipient, InitializableModule2 { | ||
|
||
// @abstract | ||
function notifyRewardAmount(uint256 reward) external; | ||
function getRewardToken() external view returns (IERC20); | ||
|
||
// This address has the ability to distribute the rewards | ||
address public rewardsDistributor; | ||
|
||
/** @dev Recipient is a module, governed by mStable governance */ | ||
function _initialize(address _nexus, address _rewardsDistributor) internal { | ||
rewardsDistributor = _rewardsDistributor; | ||
InitializableModule2._initialize(_nexus); | ||
} | ||
|
||
/** | ||
* @dev Only the rewards distributor can notify about rewards | ||
*/ | ||
modifier onlyRewardsDistributor() { | ||
require(msg.sender == rewardsDistributor, "Caller is not reward distributor"); | ||
_; | ||
} | ||
|
||
/** | ||
* @dev Change the rewardsDistributor - only called by mStable governor | ||
* @param _rewardsDistributor Address of the new distributor | ||
*/ | ||
function setRewardsDistribution(address _rewardsDistributor) | ||
external | ||
onlyGovernor | ||
{ | ||
rewardsDistributor = _rewardsDistributor; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.