SMRewardDistributor
Inherits: RewardDistributor, ISMRewardDistributor
Author: webthethird
Reward distributor for the Safety Module
State Variables
safetyModule
The SafetyModule contract which stores the list of StakedTokens and can call updatePosition
_maxRewardMultiplier
The maximum reward multiplier, scaled by 1e18
_smoothingValue
The smoothing value, scaled by 1e18
The higher the value, the slower the multiplier approaches its max
_multiplierStartTimeByUser
The starting timestamp used to calculate the user's reward multiplier for a given staked token
First address is user, second is staked token
Functions
onlySafetyModule
Modifier for functions that should only be called by the SafetyModule, i.e., initMarketStartTime
constructor
SafetyModule constructor
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the SafetyModule contract |
|
| The maximum reward multiplier, scaled by 1e18 |
|
| The smoothing value, scaled by 1e18 |
|
| The address of the EcosystemReserve contract, where reward tokens are stored |
updatePosition
Accrues rewards and updates the stored stake position of a user and the total tokens staked
Only callable by a registered StakedToken, executes whenever a user's stake is updated for any reason
Parameters
Name | Type | Description |
---|---|---|
|
| Address of the staked token in |
|
| Address of the staker |
getMaxRewardMultiplier
Gets the maximum reward multiplier set by governance
Returns
Name | Type | Description |
---|---|---|
|
| Maximum reward multiplier, scaled by 1e18 |
getSmoothingValue
Gets the smoothing value set by governance
Returns
Name | Type | Description |
---|---|---|
|
| Smoothing value, scaled by 1e18 |
multiplierStartTimeByUser
Gets the starting timestamp used to calculate the user's reward multiplier for a given staked token
This value is updated whenever updatePosition
is called, according to the user's change in stake
Parameters
Name | Type | Description |
---|---|---|
|
| Address of the user |
|
| Address of the staked token |
Returns
Name | Type | Description |
---|---|---|
|
| User's multiplier starting timestamp |
paused
Indicates whether claiming rewards is currently paused
Contract is paused if either this contract or the SafetyModule has been paused
Returns
Name | Type | Description |
---|---|---|
|
| True if paused, false otherwise |
computeRewardMultiplier
Computes the user's reward multiplier for the given staked token
Based on the max multiplier, smoothing factor and time since last withdrawal (or first deposit)
Parameters
Name | Type | Description |
---|---|---|
|
| Address of the staker |
|
| Address of staked token earning rewards |
Returns
Name | Type | Description |
---|---|---|
|
| User's reward multiplier, scaled by 1e18 |
initMarketStartTime
Sets the start time for accruing rewards to a market which has not been initialized yet
Can only be called by the SafetyModule
Parameters
Name | Type | Description |
---|---|---|
|
| Address of the market (i.e., perpetual market or staking token) |
setSafetyModule
Replaces the SafetyModule contract
Only callable by governance
Parameters
Name | Type | Description |
---|---|---|
|
| Address of the new SafetyModule contract |
setMaxRewardMultiplier
Sets the maximum reward multiplier
Only callable by governance, reverts if the new value is less than 1e18 (100%) or greater than 10e18 (1000%)
Parameters
Name | Type | Description |
---|---|---|
|
| New maximum reward multiplier, scaled by 1e18 |
setSmoothingValue
Sets the smoothing value used in calculating the reward multiplier
Only callable by governance, reverts if the new value is less than 10e18 or greater than 100e18
Parameters
Name | Type | Description |
---|---|---|
|
| New smoothing value, scaled by 1e18 |
pause
Pause the contract
Only callable by governance
unpause
Unpause the contract
Only callable by governance
togglePausedReward
Pauses/unpauses the reward accrual for a particular reward token
Only callable by governance
Parameters
Name | Type | Description |
---|---|---|
|
| Address of the reward token |
_getNumMarkets
_getMarketAddress
_getMarketIdx
_getCurrentPosition
Returns the user's staked token balance
Parameters
Name | Type | Description |
---|---|---|
|
| Address of the user |
|
| Address of the staked token |
Returns
Name | Type | Description |
---|---|---|
|
| Current balance of the user in the staked token |
_accrueRewards
Accrues rewards and updates the stored stake position of a user and the total tokens staked
Called by updatePosition
, which can only be called by a StakedToken when a user's stake changes, and claimRewards
, which always passes msg.sender
as the user
Parameters
Name | Type | Description |
---|---|---|
|
| Address of the token in |
|
| Address of the user |
_registerPosition
Registers a user's pre-existing position for a given market
User should have a position predating this contract's deployment, which can only be registered once
Parameters
Name | Type | Description |
---|---|---|
|
| Address of the user to register |
|
| Address of the market for which to register the user's position |
Last updated