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
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
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
newRewards = user.lpBalance x (global.cumRewardPerLpToken - user.cumRewardPerLpToken) x user.rewardMultiplier
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
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 to a user for a given staked token
Assumes stake position hasn't changed since last accrual, since updating rewards due to changes in stake position is handled by updatePosition
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