Base pool contract used in all other pools. Users can stake tokens and get rewards based on the percentage of total staked tokens. After deployment, owner can send funds and then start the pool. When it's started a check is done to verify enough rewards are available. Users can claim their rewards at any point, as well as withdraw their stake. The owner can extend the pool by setting a new end time and sending more rewards if needed.
Rewards are kept track of using the accumulatedRewardMultiplier. This variable represents the accumulated reward per token staked from the start until now. Based on the difference between the accumulatedRewardMultiplier at the time of your stake and withdrawal, we calculate the amount of tokens you can claim.
For example, you enter when the accumulatedRewardMultiplier is 5 and exit at 20. You staked 100 tokens. Your reward is (20 - 5) * 100 = 1500 tokens.
RewardsPoolBase
Ownable
Context
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;
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 _contractStakeLimit; // Maximum amount of tokens that can be staked in total
string _name; // Name of the pool
Start the pool. Funds for rewards will be checked and staking will be opened.
uint256 _startTimestamp; // The start time of the pool
uint256 _endTimestamp; // The end time of the pool
uint256[] _rewardPerSecond; // Amount of rewards given per second
Cancels the scheduled start. Can only be done before the start.
Stake an amount of tokens
uint256 _tokenAmount; // The amount to be staked
Claim all your rewards, this will not remove your stake
Withdrawing a portion or all of staked tokens. This will not claim your rewards
uint256 _tokenAmount; // The amount to be withdrawn
Claim all rewards and withdraw all staked tokens. Exits from the rewards pool
Returns the amount of tokens the user has staked
address _userAddress; // The user to get the balance of
Updates the accumulated reward multipliers for everyone and each token
Checks if the staking has started
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
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
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
Returns the length of the owed tokens in the user info
address _userAddress;
Returns the length of the reward debt in the user info
address _userAddress;
Returns the amount of reward tokens
Returns the amount of previous campaigns
Extends the rewards period and updates the rates. When the current campaign is still going on, the extension will be scheduled and started when the campaign ends. The extension can be cancelled until it starts. After it starts, the rewards are locked in and cannot be withdraw.
uint256 _durationTime; // duration of the campaign (how many seconds the campaign will have)
uint256[] _rewardPerSecond; // array with new rewards per second for each token
Cancels the schedules extension
Calculates the available amount of reward tokens that are not locked
uint256 _rewardTokenIndex; // the index of the reward token to check
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
Withdraw excess rewards not needed for current campaign and extension
address _recipient; // The address to whom the rewards will be transferred
Returns the address of the current owner.
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.
Transfers ownership of the contract to a new account (newOwner
).
Can only be called by the current owner.
address newOwner;
uint256 startTimestamp;
uint256 endTimestamp;
uint256[] rewardsPerSecond;
address user;
uint256 amount;
address user;
uint256 amount;
address token;
address user;
uint256 amount;
address user;
uint256 amount;
uint256 newStartTimestamp;
uint256 newEndTimestamp;
uint256[] newRewardsPerSecond;
address previousOwner;
address newOwner;
uint256 firstStakedTimestamp;
uint256 amountStaked;
uint256[] rewardDebt;
uint256[] tokensOwed;
uint256 startTimestamp;
uint256 endTimestamp;
uint256[] rewardPerSecond;