SafetyModule
Inherits: ISafetyModule, IncreAccessControl, Pausable, ReentrancyGuard
Author: webthethird
Handles reward accrual and distribution for staked tokens, and allows governance to auction a percentage of user funds in the event of an insolvency in the vault
State Variables
governance
Address of the governance contract
auctionModule
Address of the auction module, which sells user funds in the event of an insolvency
smRewardDistributor
Address of the SMRewardDistributor contract, which distributes rewards to stakers
stakedTokens
Array of staked tokens that are registered with the SafetyModule
stakedTokenByAuctionId
Mapping from auction ID to staked token that was slashed for the auction
Functions
onlyAuctionModule
Modifier for functions that can only be called by the AuctionModule contract, i.e., auctionEnded
constructor
SafetyModule constructor
Parameters
Name | Type | Description |
---|---|---|
|
| Address of the auction module, which sells user funds in the event of an insolvency |
|
| Address of the SMRewardDistributor contract, which distributes rewards to stakers |
|
| Address of the governance contract, where unsold StakedToken funds are sent if there are no stakers |
getStakedTokens
Returns the full list of staked tokens registered in the SafetyModule
Returns
Name | Type | Description |
---|---|---|
|
| Array of StakedToken contracts |
getNumStakedTokens
Gets the number of staked tokens registered in the SafetyModule
Returns
Name | Type | Description |
---|---|---|
|
| Number of staked tokens |
getStakedTokenIdx
Returns the index of the staked token in the stakedTokens
array
Reverts with SafetyModule_InvalidStakedToken
if the staked token is not registered
Parameters
Name | Type | Description |
---|---|---|
|
| Address of the staked token |
Returns
Name | Type | Description |
---|---|---|
|
| Index of the staked token in the |
auctionEnded
Called by the AuctionModule when an auction ends, and returns the remaining balance of underlying tokens from the auction to the StakedToken
Only callable by the auction module
Parameters
Name | Type | Description |
---|---|---|
|
| ID of the auction |
|
| Amount of underlying tokens remaining from the auction |
slashAndStartAuction
Slashes a portion of all users' staked tokens, capped by maxPercentUserLoss, then transfers the underlying tokens to the AuctionModule and starts an auction to sell them
Only callable by governance
Parameters
Name | Type | Description |
---|---|---|
|
| Address of the staked token to slash |
|
| Number of lots in the auction |
|
| Fixed price of each lot in the auction |
|
| Initial number of underlying tokens in each lot |
|
| Amount of staked tokens to slash |
|
| Amount of tokens by which the lot size increases each period |
|
| Number of seconds between each lot size increase |
|
| Number of seconds before the auction ends if all lots are not sold |
Returns
Name | Type | Description |
---|---|---|
|
| ID of the auction |
terminateAuction
Terminates an auction early and returns any remaining underlying tokens to the StakedToken
Only callable by governance
Parameters
Name | Type | Description |
---|---|---|
|
| ID of the auction |
withdrawFundsRaisedFromAuction
Sends payment tokens raised in auctions from the AuctionModule to the governance treasury
Only callable by governance
Parameters
Name | Type | Description |
---|---|---|
|
| Amount of payment tokens to withdraw |
setAuctionModule
Sets the address of the AuctionModule contract
Only callable by governance
Parameters
Name | Type | Description |
---|---|---|
|
| Address of the AuctionModule contract |
setRewardDistributor
Sets the address of the SMRewardDistributor contract
Only callable by governance
Parameters
Name | Type | Description |
---|---|---|
|
| Address of the SMRewardDistributor contract |
addStakedToken
Adds a new staked token to the SafetyModule's stakedTokens array
Only callable by governance, reverts if the staked token is already registered
Parameters
Name | Type | Description |
---|---|---|
|
| Address of the new staked token |
pause
Pause the contract
Only callable by governance
unpause
Unpause the contract
Only callable by governance
_returnFunds
_settleSlashing
Last updated