Skip to content

Latest commit

 

History

History
510 lines (252 loc) · 6.98 KB

NonCompoundingRewardsPool.md

File metadata and controls

510 lines (252 loc) · 6.98 KB

NonCompoundingRewardsPool

Staking pool with a time lock and throttled exit. Inherits all staking logic from RewardsPoolBase. Only allows exit at the end of the time lock and via the throttling mechanism.

Inheritance

NonCompoundingRewardsPool
StakeReceiverFeature
StakeReceiver
StakeTransfererFeature
StakeTransferer
ThrottledExitFeature
ThrottledExit
StakeLockingFeature
StakeLock
OnlyExitFeature
RewardsPoolBase
Ownable
Context

Variables

mapping(address => bool) receiversWhitelist;
uint256 nextAvailableExitTimestamp;
uint256 nextAvailableRoundExitVolume;
uint256 throttleRoundSeconds;
uint256 throttleRoundCap;
uint256 campaignEndTimestamp;
mapping(address => struct ThrottledExit.ExitInfo) exitInfo;
uint256 lockEndTimestamp;
uint256 PRECISION;
uint256 totalStaked;
uint256[] rewardPerSecond;
address[] rewardsTokens;
contract IERC20 stakingToken;
uint256 startTimestamp;
uint256 endTimestamp;
uint256 extensionDuration;
uint256[] extensionRewardPerSecond;
uint256[] accumulatedRewardMultiplier;
uint256 stakeLimit;
uint256 contractStakeLimit;
string name;
mapping(address => struct RewardsPoolBase.UserInfo) userInfo;
struct RewardsPoolBase.Campaign[] previousCampaigns;

Functions

constructor

contract IERC20 _stakingToken; // The token to stake

address[] _rewardsTokens; // The reward tokens

uint256 _stakeLimit; // Maximum amount of tokens that can be staked per user

uint256 _throttleRoundSeconds; // Seconds per throttle round

uint256 _throttleRoundCap; // Maximum tokens withdrawn per throttle round

uint256 _contractStakeLimit; // Maximum amount of tokens that can be staked in total

string _name; // Name of the pool

start

Start the pool and set locking and throttling parameters.

uint256 _startTimestamp; // The start time of the pool

uint256 _endTimestamp; // The end time of the pool

uint256[] _rewardPerSecond; // Amount of rewards given per second

withdraw

Not allowed

uint256 _tokenAmount; 

claim

Not allowed

exit

Requests a throttled exit from the pool and gives you a time from which you can withdraw your stake and rewards.

completeExit

Completes the throttled exit from the pool.

exitAndTransfer

Exits the pool and tranfer to another pool

address transferTo; // The new pool to tranfer to

extend

Not allowed

uint256 ; 
uint256[] ; 

delegateStake

Receives a stake from another pool

address _staker; // The address who will own the stake

uint256 _amount; // The amount to stake

setReceiverWhitelisted

Change whitelist status of a receiver pool to receive transfers.

address _receiver; // The pool address to whitelist

bool _whitelisted; // If it should be whitelisted or not

getPendingReward → uint256

Returns the amount of reward tokens that are pending for exit for this user

uint256 _tokenIndex; // The index of the reward to check

cancel

Cancels the scheduled start. Can only be done before the start.

stake

Stake an amount of tokens

uint256 _tokenAmount; // The amount to be staked

balanceOf → uint256

Returns the amount of tokens the user has staked

address _userAddress; // The user to get the balance of

updateRewardMultipliers

Updates the accumulated reward multipliers for everyone and each token

hasStakingStarted → bool

Checks if the staking has started

getUserRewardDebt → uint256

Returns the amount of reward debt of a specific token and user

address _userAddress; // the address of the updated user

uint256 _index; // index of the reward token to check

getUserOwedTokens → uint256

Returns the amount of reward owed of a specific token and user

address _userAddress; // the address of the updated user

uint256 _index; // index of the reward token to check

getUserAccumulatedReward → uint256

Calculates the reward at a specific time

address _userAddress; // the address of the user

uint256 _tokenIndex; // the index of the reward token you are interested

uint256 _time; // the time to check the reward at

getUserTokensOwedLength → uint256

Returns the length of the owed tokens in the user info

address _userAddress; 

getUserRewardDebtLength → uint256

Returns the length of the reward debt in the user info

address _userAddress; 

getRewardTokensCount → uint256

Returns the amount of reward tokens

getPreviousCampaignsCount → uint256

Returns the amount of previous campaigns

cancelExtension

Cancels the schedules extension

getAvailableBalance → uint256

Calculates the available amount of reward tokens that are not locked

uint256 _rewardTokenIndex; // the index of the reward token to check

withdrawTokens

Withdraw tokens other than the staking and reward token, for example rewards from liquidity mining

address _recipient; // The address to whom the rewards will be transferred

address _token; // The address of the rewards contract

withdrawExcessRewards

Withdraw excess rewards not needed for current campaign and extension

address _recipient; // The address to whom the rewards will be transferred

owner → address

Returns the address of the current owner.

renounceOwnership

Leaves the contract without owner. It will not be possible to call onlyOwner functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.

transferOwnership

Transfers ownership of the contract to a new account (newOwner). Can only be called by the current owner.

address newOwner; 

Events

ExitRequested

address user;
uint256 exitTimestamp;

ExitCompleted

address user;
uint256 stake;

Started

uint256 startTimestamp;
uint256 endTimestamp;
uint256[] rewardsPerSecond;

Staked

address user;
uint256 amount;

Claimed

address user;
uint256 amount;
address token;

Withdrawn

address user;
uint256 amount;

Exited

address user;
uint256 amount;

Extended

uint256 newStartTimestamp;
uint256 newEndTimestamp;
uint256[] newRewardsPerSecond;

OwnershipTransferred

address previousOwner;
address newOwner;

Structs

ExitInfo

uint256 exitTimestamp;
uint256 exitStake;
uint256[] rewards;

UserInfo

uint256 firstStakedTimestamp;
uint256 amountStaked;
uint256[] rewardDebt;
uint256[] tokensOwed;

Campaign

uint256 startTimestamp;
uint256 endTimestamp;
uint256[] rewardPerSecond;