RewardController
Last updated
Last updated
Inherits: , IncreAccessControl, Pausable, ReentrancyGuard
Author: webthethird
Base contract for storing and updating reward info for multiple reward tokens, each with
a gradually decreasing emission rate, based on an initial inflation rate, reduction factor, and time elapsed
a list of markets for which the reward token is distributed
a list of weights representing the percentage of rewards that go to each market
Maximum inflation rate, applies to all reward tokens
Minimum reduction factor, applies to all reward tokens
Maximum number of reward tokens allowed
100% in basis points
List of reward token addresses
Length must be <= MAX_REWARD_TOKENS
Info for each registered reward token
Mapping from reward token to reward weights for each market
Market reward weights are basis points, i.e., 100 = 1%, 10000 = 100%
Gets the maximum allowed inflation rate for a reward token
Returns
<none>
uint256
Maximum allowed inflation rate
Gets the minimum allowed reduction factor for a reward token
Returns
<none>
uint256
Minimum allowed reduction factor
Gets the maximum allowed number of reward tokens
Returns
<none>
uint256
Maximum allowed number of reward tokens
Returns the full list of reward tokens
Returns
<none>
address[]
Array of reward token addresses
Gets the number of reward tokens
Returns
<none>
uint256
Number of reward tokens
Gets the timestamp when a reward token was registered
Parameters
rewardToken
address
Address of the reward token
Returns
<none>
uint256
Timestamp when the reward token was registered
Gets the inflation rate of a reward token (w/o factoring in reduction factor)
Parameters
rewardToken
address
Address of the reward token
Returns
<none>
uint256
Initial inflation rate of the reward token
Gets the current inflation rate of a reward token (factoring in reduction factor)
inflationRate = initialInflationRate / reductionFactor^((block.timestamp - initialTimestamp) / secondsPerYear)
Parameters
rewardToken
address
Address of the reward token
Returns
<none>
uint256
Current inflation rate of the reward token
Gets the reduction factor of a reward token
Parameters
rewardToken
address
Address of the reward token
Returns
<none>
uint256
Reduction factor of the reward token
Gets the reward weight of a given market for a reward token
Parameters
rewardToken
address
Address of the reward token
market
address
Address of the market
Returns
<none>
uint256
The reward weight of the market in basis points
Gets the list of all markets receiving a given reward token
Parameters
rewardToken
address
Address of the reward token
Returns
<none>
address[]
Array of market addresses
Gets whether a reward token is paused
Parameters
rewardToken
address
Address of the reward token
Returns
<none>
bool
True if the reward token is paused, false otherwise
Sets the market addresses and reward weights for a reward token
Only callable by Governance
Parameters
rewardToken
address
Address of the reward token
markets
address[]
List of market addresses to receive rewards
weights
uint256[]
List of weights for each market
Sets the initial inflation rate used to calculate emissions over time for a given reward token
Only callable by Governance
Parameters
rewardToken
address
Address of the reward token
newInitialInflationRate
uint88
The new inflation rate in tokens/year, scaled by 1e18
Sets the reduction factor used to reduce emissions over time for a given reward token
Only callable by Governance
Parameters
rewardToken
address
Address of the reward token
newReductionFactor
uint88
The new reduction factor, scaled by 1e18
Pause the contract
Can only be called by Emergency Admin
Unpause the contract
Can only be called by Emergency Admin
Pauses/unpauses the reward accrual for a particular reward token
Only callable by Emergency Admin
Parameters
_rewardToken
address
Address of the reward token
Pauses/unpauses the reward accrual for a particular reward token
Does not pause gradual reduction of inflation rate over time due to reduction factor
Parameters
_rewardToken
address
Address of the reward token
Updates the reward accumulators for a given market
Executes when any of the following values are changed:
initial inflation rate per token,
reduction factor per token,
reward weights per market per token,
liquidity in the market
Parameters
market
address
Address of the market
Gets the number of markets to be used for reward distribution
Markets are the perpetual markets (for the PerpRewardDistributor) or staked tokens (for the SafetyModule)
Returns
<none>
uint256
Number of markets
Returns the current position of the user in the market (i.e., perpetual market or staked token)
Parameters
user
address
Address of the user
market
address
Address of the market
Returns
<none>
uint256
Current position of the user in the market
Gets the address of a market at a given index
Markets are the perpetual markets (for the PerpRewardDistributor) or staked tokens (for the SafetyModule)
Parameters
idx
uint256
Index of the market
Returns
<none>
address
Address of the market
Gets the index of an allowlisted market
Markets are the perpetual markets (for the PerpRewardDistributor) or staked tokens (for the SafetyModule)
Parameters
i
uint256
Index of the market in the allowlist ClearingHouse.ids
(for the PerpRewardDistributor) or stakingTokens
(for the SafetyModule)
Returns
<none>
uint256
Index of the market in the market list
Data structure containing essential info for each reward token
Properties
token
IERC20Metadata
Address of the reward token
paused
bool
Whether the reward token accrual is paused
initialTimestamp
uint80
Time when the reward token was added
initialInflationRate
uint88
Initial rate of reward token emission per year
reductionFactor
uint88
Factor by which the inflation rate is reduced each year
marketAddresses
address[]
List of markets for which the reward token is distributed