IMultiRewards

Git Source

Functions

totalSupply

Returns the total amount of staked tokens in the contract

function totalSupply() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256uint256 The total supply of staked tokens

stake

Stakes tokens into the contract

Transfers amount of staking tokens from the user to this contract

function stake(uint256 amount) external;

Parameters

NameTypeDescription
amountuint256The amount of tokens to stake

withdraw

Withdraws staked tokens from the contract

Transfers amount of staking tokens back to the user

function withdraw(uint256 amount) external;

Parameters

NameTypeDescription
amountuint256The amount of tokens to withdraw

getReward

Claims all pending rewards for the caller

Transfers all accrued rewards to the caller

function getReward() external;

exit

Withdraws all staked tokens and claims pending rewards

Combines withdraw and getReward operations

function exit() external;

balanceOf

Returns the balance of staked tokens for the given account

function balanceOf(address account) external view returns (uint256);

Parameters

NameTypeDescription
accountaddressThe account to get the balance for

Returns

NameTypeDescription
<none>uint256The balance of staked tokens

lastTimeRewardApplicable

Calculates the last time reward is applicable for a given rewards token

function lastTimeRewardApplicable(address _rewardsToken)
    external
    view
    returns (uint256);

Parameters

NameTypeDescription
_rewardsTokenaddressThe address of the rewards token

Returns

NameTypeDescription
<none>uint256The timestamp when the reward was last applicable

rewardPerToken

Calculates the reward per token for a given rewards token

function rewardPerToken(address _rewardsToken)
    external
    view
    returns (uint256);

Parameters

NameTypeDescription
_rewardsTokenaddressThe address of the rewards token

Returns

NameTypeDescription
<none>uint256The reward amount per token

earned

Calculates the earned rewards for a given account and rewards token

function earned(address account, address _rewardsToken)
    external
    view
    returns (uint256);

Parameters

NameTypeDescription
accountaddressThe address of the account
_rewardsTokenaddressThe address of the rewards token

Returns

NameTypeDescription
<none>uint256The amount of rewards earned

getRewardForDuration

Calculates the total reward for the duration of a given rewards token

function getRewardForDuration(address _rewardsToken)
    external
    view
    returns (uint256);

Parameters

NameTypeDescription
_rewardsTokenaddressThe address of the rewards token

Returns

NameTypeDescription
<none>uint256The total reward amount for the duration of a given rewards token

rewardData

Gets the reward data for a given rewards token

function rewardData(address _rewardsToken)
    external
    view
    returns (
        address rewardsDistributor,
        uint256 rewardsDuration,
        uint256 periodFinish,
        uint256 rewardRate,
        uint256 lastUpdateTime,
        uint256 rewardPerTokenStored,
        uint256 rewardResidual
    );

Parameters

NameTypeDescription
_rewardsTokenaddressThe address of the rewards token

Returns

NameTypeDescription
rewardsDistributoraddressThe address authorized to distribute rewards
rewardsDurationuint256The duration of the reward period
periodFinishuint256The timestamp when rewards finish
rewardRateuint256The rate of rewards distributed per second
lastUpdateTimeuint256The last time rewards were updated
rewardPerTokenStoreduint256The last calculated reward per token
rewardResidualuint256

rewardTokens

Returns the reward token address at a specific index

function rewardTokens(uint256 index) external view returns (address);

Parameters

NameTypeDescription
indexuint256The index in the reward tokens array

Returns

NameTypeDescription
<none>addressThe address of the reward token at the given index

getRewardForUser

Claims all pending rewards for a specified user

Iterates through all reward tokens and transfers any accrued rewards to the user

function getRewardForUser(address _user) external;

Parameters

NameTypeDescription
_useraddressThe address of the user to claim rewards for

Events

Staked

Emitted when tokens are staked

event Staked(address indexed user, uint256 amount);

Parameters

NameTypeDescription
useraddressThe address of the user who staked
amountuint256The amount of tokens staked

Withdrawn

Emitted when tokens are withdrawn

event Withdrawn(address indexed user, uint256 amount);

Parameters

NameTypeDescription
useraddressThe address of the user who withdrew
amountuint256The amount of tokens withdrawn

RewardPaid

Emitted when rewards are claimed

event RewardPaid(
    address indexed user, address indexed rewardsToken, uint256 reward
);

Parameters

NameTypeDescription
useraddressThe address of the user claiming the reward
rewardsTokenaddressThe address of the reward token
rewarduint256The amount of rewards claimed

RewardAdded

Emitted when rewards are added to the contract

event RewardAdded(address indexed rewardsToken, uint256 reward);

Parameters

NameTypeDescription
rewardsTokenaddressThe address of the reward token
rewarduint256The amount of rewards added

RewardsDistributorUpdated

Emitted when a rewards distributor is updaRewardAddedd

event RewardsDistributorUpdated(
    address indexed rewardsToken, address indexed newDistributor
);

Parameters

NameTypeDescription
rewardsTokenaddressThe address of the reward token
newDistributoraddressThe address of the new distributor

RewardsDurationUpdated

Emitted when the rewards duration for a token is updated

event RewardsDurationUpdated(address token, uint256 newDuration);

Parameters

NameTypeDescription
tokenaddressThe reward token address whose duration was updated
newDurationuint256The new duration set for the rewards period

Recovered

Emitted when tokens are recovered from the contract

event Recovered(address token, uint256 amount);

Parameters

NameTypeDescription
tokenaddressThe address of the token that was recovered
amountuint256The amount of tokens that were recovered

RewardStored

Emitted when new reward data is stored

event RewardStored(address rewardsToken, uint256 rewardsDuration);

Parameters

NameTypeDescription
rewardsTokenaddressThe address of the reward token
rewardsDurationuint256The duration set for the reward period

Structs

Reward

Reward data for a particular reward token

Struct containing all relevant information for reward distribution

struct Reward {
    address rewardsDistributor;
    uint256 rewardsDuration;
    uint256 periodFinish;
    uint256 rewardRate;
    uint256 lastUpdateTime;
    uint256 rewardPerTokenStored;
    uint256 rewardResidual;
}