-
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.
- Loading branch information
Showing
43 changed files
with
6,983 additions
and
513 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
pragma solidity 0.5.16; | ||
|
||
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
|
||
interface IBoostedVaultWithLockup { | ||
|
||
/** | ||
* @dev Stakes a given amount of the StakingToken for the sender | ||
* @param _amount Units of StakingToken | ||
*/ | ||
function stake(uint256 _amount) external; | ||
|
||
/** | ||
* @dev Stakes a given amount of the StakingToken for a given beneficiary | ||
* @param _beneficiary Staked tokens are credited to this address | ||
* @param _amount Units of StakingToken | ||
*/ | ||
function stake(address _beneficiary, uint256 _amount) external; | ||
|
||
/** | ||
* @dev Withdraws stake from pool and claims any unlocked rewards. | ||
* Note, this function is costly - the args for _claimRewards | ||
* should be determined off chain and then passed to other fn | ||
*/ | ||
function exit() external; | ||
|
||
/** | ||
* @dev Withdraws stake from pool and claims any unlocked rewards. | ||
* @param _first Index of the first array element to claim | ||
* @param _last Index of the last array element to claim | ||
*/ | ||
function exit(uint256 _first, uint256 _last) external; | ||
|
||
/** | ||
* @dev Withdraws given stake amount from the pool | ||
* @param _amount Units of the staked token to withdraw | ||
*/ | ||
function withdraw(uint256 _amount) external; | ||
|
||
/** | ||
* @dev Claims only the tokens that have been immediately unlocked, not including | ||
* those that are in the lockers. | ||
*/ | ||
function claimReward() external; | ||
|
||
/** | ||
* @dev Claims all unlocked rewards for sender. | ||
* Note, this function is costly - the args for _claimRewards | ||
* should be determined off chain and then passed to other fn | ||
*/ | ||
function claimRewards() external; | ||
|
||
/** | ||
* @dev Claims all unlocked rewards for sender. Both immediately unlocked | ||
* rewards and also locked rewards past their time lock. | ||
* @param _first Index of the first array element to claim | ||
* @param _last Index of the last array element to claim | ||
*/ | ||
function claimRewards(uint256 _first, uint256 _last) external; | ||
|
||
/** | ||
* @dev Pokes a given account to reset the boost | ||
*/ | ||
function pokeBoost(address _account) external; | ||
|
||
/** | ||
* @dev Gets the RewardsToken | ||
*/ | ||
function getRewardToken() external view returns (IERC20); | ||
|
||
/** | ||
* @dev Gets the last applicable timestamp for this reward period | ||
*/ | ||
function lastTimeRewardApplicable() external view returns (uint256); | ||
|
||
/** | ||
* @dev Calculates the amount of unclaimed rewards per token since last update, | ||
* and sums with stored to give the new cumulative reward per token | ||
* @return 'Reward' per staked token | ||
*/ | ||
function rewardPerToken() external view returns (uint256); | ||
|
||
/** | ||
* @dev Returned the units of IMMEDIATELY claimable rewards a user has to receive. Note - this | ||
* does NOT include the majority of rewards which will be locked up. | ||
* @param _account User address | ||
* @return Total reward amount earned | ||
*/ | ||
function earned(address _account) external view returns (uint256); | ||
|
||
/** | ||
* @dev Calculates all unclaimed reward data, finding both immediately unlocked rewards | ||
* and those that have passed their time lock. | ||
* @param _account User address | ||
* @return amount Total units of unclaimed rewards | ||
* @return first Index of the first userReward that has unlocked | ||
* @return last Index of the last userReward that has unlocked | ||
*/ | ||
function unclaimedRewards(address _account) external view returns (uint256 amount, uint256 first, uint256 last); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,37 @@ | ||
pragma solidity 0.5.16; | ||
|
||
/** | ||
* @title ISavingsContract | ||
*/ | ||
interface ISavingsContract { | ||
|
||
/** @dev Manager privs */ | ||
interface ISavingsContractV1 { | ||
function depositInterest(uint256 _amount) external; | ||
|
||
/** @dev Saver privs */ | ||
function depositSavings(uint256 _amount) external returns (uint256 creditsIssued); | ||
function redeem(uint256 _amount) external returns (uint256 massetReturned); | ||
|
||
/** @dev Getters */ | ||
function exchangeRate() external view returns (uint256); | ||
function creditBalances(address) external view returns (uint256); | ||
} | ||
|
||
interface ISavingsContractV2 { | ||
|
||
// DEPRECATED but still backwards compatible | ||
function redeem(uint256 _amount) external returns (uint256 massetReturned); | ||
function creditBalances(address) external view returns (uint256); // V1 & V2 (use balanceOf) | ||
|
||
// -------------------------------------------- | ||
|
||
function depositInterest(uint256 _amount) external; // V1 & V2 | ||
|
||
function depositSavings(uint256 _amount) external returns (uint256 creditsIssued); // V1 & V2 | ||
function depositSavings(uint256 _amount, address _beneficiary) external returns (uint256 creditsIssued); // V2 | ||
|
||
function redeemCredits(uint256 _amount) external returns (uint256 underlyingReturned); // V2 | ||
function redeemUnderlying(uint256 _amount) external returns (uint256 creditsBurned); // V2 | ||
|
||
function exchangeRate() external view returns (uint256); // V1 & V2 | ||
|
||
function balanceOfUnderlying(address _user) external view returns (uint256 balance); // V2 | ||
|
||
function underlyingToCredits(uint256 _credits) external view returns (uint256 underlying); // V2 | ||
function creditsToUnderlying(uint256 _underlying) external view returns (uint256 credits); // V2 | ||
|
||
} |
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
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 { | ||
InitializableModule2._initialize(_nexus); | ||
rewardsDistributor = _rewardsDistributor; | ||
} | ||
|
||
/** | ||
* @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
Oops, something went wrong.