VaultManagerLib

Git Source

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

NameTypeDescription
$VaultStorageStorage pointer to the VaultStorage struct.

pauseStaking

Pauses staking functionality on a specific vault

function pauseStaking(VaultStorage storage $, address asset) external;

Parameters

NameTypeDescription
$VaultStorageStorage pointer to the VaultStorage struct.
assetaddressaddress 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

NameTypeDescription
$VaultStorageStorage pointer to the VaultStorage struct.
assetaddressaddress of the asset to un-pause the vault for.

pauseOldStaking

Pauses staking functionality on an old vault

function pauseOldStaking(address _vault) external;

Parameters

NameTypeDescription
_vaultaddressaddress of the vault to pause

unpauseOldStaking

Un-pauses staking functionality on an old vault

function unpauseOldStaking(address _vault) external;

Parameters

NameTypeDescription
_vaultaddressaddress 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

NameTypeDescription
$VaultStorageStorage pointer to the VaultStorage struct.
tokenaddressaddress of the reward token to update the whitelist status for.
whitelistedboolNew 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

NameTypeDescription
$VaultStorageStorage pointer to the VaultStorage struct.
_stakingTokenaddressaddress of the asset to add the reward to.
_rewardsTokenaddressaddress of the reward token to add.
_rewardsDurationuint256

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

NameTypeDescription
$VaultStorageStorage pointer to the VaultStorage struct.
newDurationuint256New rewards duration.

recoverERC20FromVault

Recovers ERC20 tokens from a vault.

function recoverERC20FromVault(
    VaultStorage storage $,
    address _asset,
    address _to,
    address _token,
    uint256 _amount
) external;

Parameters

NameTypeDescription
$VaultStorageStorage pointer to the VaultStorage struct.
_assetaddressaddress of the asset to recover from.
_toaddressaddress to recover the tokens to.
_tokenaddressaddress of the token to recover.
_amountuint256uint256 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

NameTypeDescription
_vaultaddressaddress of the asset to recover from.
_toaddressaddress to recover the tokens to.
_tokenaddressaddress of the token to recover.
_amountuint256uint256 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

NameTypeDescription
$VaultStorageStorage pointer to the VaultStorage struct.
_stakingTokenaddressaddress of the asset to update the rewards duration for.
_rewardsTokenaddressaddress of the reward token to update the rewards duration for.
_rewardsDurationuint256New rewards duration.

setVaultRegistrationPauseStatus

Pauses or unpauses the registration of new vaults.

function setVaultRegistrationPauseStatus(VaultStorage storage $, bool pause)
    external;

Parameters

NameTypeDescription
$VaultStorageStorage pointer to the VaultStorage struct.
pauseboolFlag to pause or unpause vault registration.

claimLostRewardsOnVault

Claims lost rewards from a vault.

function claimLostRewardsOnVault(VaultStorage storage $, address _asset)
    external;

Parameters

NameTypeDescription
$VaultStorageStorage pointer to the VaultStorage struct.
_assetaddressaddress 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

NameTypeDescription
$VaultStorageStorage pointer to the VaultStorage struct.
_stakingTokenaddressaddress The asset to add the reward to.
_rewardsTokenaddressaddress The the reward token to add.
_amountuint256uint256 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

NameTypeDescription
$VaultStorageStorage pointer to the VaultStorage struct.
assetaddressaddress of the asset to register a vault for.

Returns

NameTypeDescription
<none>addressaddress 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

NameTypeDescription
$VaultStorageStorage pointer to the VaultStorage struct.
tokenaddressaddress of the token to check.

Returns

NameTypeDescription
<none>boolbool 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

NameTypeDescription
pausedVaultRegistrationboolFlag to pause or unpause vault registration
vaultRegistrymapping(address => IInfraredVault)
whitelistedRewardTokensEnumerableSet.AddressSetSet of whitelisted reward tokens that can be called into.
rewardsDurationuint256Default duration for rewards
vaultVersionsmapping(address => uint8)