VaultManagerLib
Library for managing:
- Vault registration
- Vault pausing
- Reward token whitelisting
- Default reward duration
Functions
vaultRegistrationNotPaused
Modifier to check if vault registration is paused.
modifier vaultRegistrationNotPaused(VaultStorage storage $);
Parameters
Name | Type | Description |
---|---|---|
$ | VaultStorage | Storage pointer to the VaultStorage struct. |
pauseStaking
Pauses staking functionality on a specific vault
function pauseStaking(VaultStorage storage $, address asset) external;
Parameters
Name | Type | Description |
---|---|---|
$ | VaultStorage | Storage pointer to the VaultStorage struct. |
asset | address | address of the asset to pause the vault for. |
unpauseStaking
Un-pauses staking functionality on a specific vault
function unpauseStaking(VaultStorage storage $, address asset) external;
Parameters
Name | Type | Description |
---|---|---|
$ | VaultStorage | Storage pointer to the VaultStorage struct. |
asset | address | address of the asset to un-pause the vault for. |
pauseOldStaking
Pauses staking functionality on an old vault
function pauseOldStaking(address _vault) external;
Parameters
Name | Type | Description |
---|---|---|
_vault | address | address of the vault to pause |
unpauseOldStaking
Un-pauses staking functionality on an old vault
function unpauseOldStaking(address _vault) external;
Parameters
Name | Type | Description |
---|---|---|
_vault | address | address of the vault to un-pause |
updateWhitelistedRewardTokens
Updates the whitelist status of a reward token.
function updateWhitelistedRewardTokens(
VaultStorage storage $,
address token,
bool whitelisted
) external;
Parameters
Name | Type | Description |
---|---|---|
$ | VaultStorage | Storage pointer to the VaultStorage struct. |
token | address | address of the reward token to update the whitelist status for. |
whitelisted | bool | New whitelist status for the reward token. |
addReward
Adds a reward to a vault, if the reward token is whitelisted.
function addReward(
VaultStorage storage $,
address _stakingToken,
address _rewardsToken,
uint256 _rewardsDuration
) external;
Parameters
Name | Type | Description |
---|---|---|
$ | VaultStorage | Storage pointer to the VaultStorage struct. |
_stakingToken | address | address of the asset to add the reward to. |
_rewardsToken | address | address of the reward token to add. |
_rewardsDuration | uint256 |
removeReward
function removeReward(
VaultStorage storage $,
address _stakingToken,
address _rewardsToken
) external;
updateRewardsDuration
Updates the global rewards duration for new vaults.
The rewards duration is used as the default duration for new vaults. Existing vaults will not be affected by this change.
function updateRewardsDuration(VaultStorage storage $, uint256 newDuration)
external;
Parameters
Name | Type | Description |
---|---|---|
$ | VaultStorage | Storage pointer to the VaultStorage struct. |
newDuration | uint256 | New rewards duration. |
recoverERC20FromVault
Recovers ERC20 tokens from a vault.
function recoverERC20FromVault(
VaultStorage storage $,
address _asset,
address _to,
address _token,
uint256 _amount
) external;
Parameters
Name | Type | Description |
---|---|---|
$ | VaultStorage | Storage pointer to the VaultStorage struct. |
_asset | address | address of the asset to recover from. |
_to | address | address to recover the tokens to. |
_token | address | address of the token to recover. |
_amount | uint256 | uint256 amount of tokens to recover. |
recoverERC20FromOldVault
Recovers ERC20 tokens from old vault.
removes reward token, cutting user claims. This should be a one time last ditch call for recovery after all users exited
function recoverERC20FromOldVault(
address _vault,
address _to,
address _token,
uint256 _amount
) external;
Parameters
Name | Type | Description |
---|---|---|
_vault | address | address of the asset to recover from. |
_to | address | address to recover the tokens to. |
_token | address | address of the token to recover. |
_amount | uint256 | uint256 amount of tokens to recover. |
updateRewardsDurationForVault
Updates the rewards duration for a specific reward token on a vault.
function updateRewardsDurationForVault(
VaultStorage storage $,
address _stakingToken,
address _rewardsToken,
uint256 _rewardsDuration
) external;
Parameters
Name | Type | Description |
---|---|---|
$ | VaultStorage | Storage pointer to the VaultStorage struct. |
_stakingToken | address | address of the asset to update the rewards duration for. |
_rewardsToken | address | address of the reward token to update the rewards duration for. |
_rewardsDuration | uint256 | New rewards duration. |
setVaultRegistrationPauseStatus
Pauses or unpauses the registration of new vaults.
function setVaultRegistrationPauseStatus(VaultStorage storage $, bool pause)
external;
Parameters
Name | Type | Description |
---|---|---|
$ | VaultStorage | Storage pointer to the VaultStorage struct. |
pause | bool | Flag to pause or unpause vault registration. |
claimLostRewardsOnVault
Claims lost rewards from a vault.
function claimLostRewardsOnVault(VaultStorage storage $, address _asset)
external;
Parameters
Name | Type | Description |
---|---|---|
$ | VaultStorage | Storage pointer to the VaultStorage struct. |
_asset | address | address of the asset to claim lost rewards from. |
addIncentives
Adds a reward to a vault, if the reward token is whitelisted.
function addIncentives(
VaultStorage storage $,
address _stakingToken,
address _rewardsToken,
uint256 _amount
) external;
Parameters
Name | Type | Description |
---|---|---|
$ | VaultStorage | Storage pointer to the VaultStorage struct. |
_stakingToken | address | address The asset to add the reward to. |
_rewardsToken | address | address The the reward token to add. |
_amount | uint256 | uint256 amount of the reward token to add. |
registerVault
Registers a new vault for a specific asset.
function registerVault(VaultStorage storage $, address asset)
external
vaultRegistrationNotPaused($)
returns (address);
Parameters
Name | Type | Description |
---|---|---|
$ | VaultStorage | Storage pointer to the VaultStorage struct. |
asset | address | address of the asset to register a vault for. |
Returns
Name | Type | Description |
---|---|---|
<none> | address | address of the newly created vault. |
isWhitelisted
Checks if a token is whitelisted as a reward token.
function isWhitelisted(VaultStorage storage $, address token)
public
view
returns (bool);
Parameters
Name | Type | Description |
---|---|---|
$ | VaultStorage | Storage pointer to the VaultStorage struct. |
token | address | address of the token to check. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool indicating if the token is whitelisted. |
Structs
VaultStorage
Storage structure for the VaultManagerLib
struct VaultStorage {
bool pausedVaultRegistration;
mapping(address => IInfraredVault) vaultRegistry;
EnumerableSet.AddressSet whitelistedRewardTokens;
uint256 rewardsDuration;
mapping(address => uint8) vaultVersions;
}
Properties
Name | Type | Description |
---|---|---|
pausedVaultRegistration | bool | Flag to pause or unpause vault registration |
vaultRegistry | mapping(address => IInfraredVault) | |
whitelistedRewardTokens | EnumerableSet.AddressSet | Set of whitelisted reward tokens that can be called into. |
rewardsDuration | uint256 | Default duration for rewards |
vaultVersions | mapping(address => uint8) |