VaultMining

Git Source

Inherits: IVaultMining, OwnableInternal, ReentrancyGuard

State Variables

VAULT_REGISTRY

Address of the vault registry

address internal immutable VAULT_REGISTRY;

PREMIA

Address of the PREMIA token

address internal immutable PREMIA;

VX_PREMIA

Address of the vxPremia token

address internal immutable VX_PREMIA;

OPTION_REWARD

Address of the PREMIA physically settled options

address internal immutable OPTION_REWARD;

DEFAULT_VOTE_MULTIPLIER

If vote multiplier is zero or not set, we use this value instead

UD60x18 private constant DEFAULT_VOTE_MULTIPLIER = ONE;

Functions

constructor

constructor(address vaultRegistry, address premia, address vxPremia, address optionReward);

addRewards

Add rewards to the contract

function addRewards(UD60x18 amount) external nonReentrant;

getRewardsAvailable

Return amount of rewards not yet allocated

function getRewardsAvailable() external view returns (UD60x18);

getPendingVaultRewards

Return amount of pending rewards (not yet allocated) for a specific vault

function getPendingVaultRewards(address vault) external view returns (UD60x18);

_calculatePendingVaultRewardAmount

Calculate amount of rewards to allocate to the vault since last update

function _calculatePendingVaultRewardAmount(
    VaultMiningStorage.Layout storage l,
    VaultInfo storage vInfo,
    UD60x18 rewardAmount
) internal view returns (UD60x18);

getUserRewards

Return the amount of user rewards already allocated and available to claim. This only account for l.userRewards[user] and does NOT include pending reward updates.

function getUserRewards(address user) external view returns (UD60x18);

_calculateRewardsUpdate

Calculate the amount of rewards to allocate across all vaults since last update

function _calculateRewardsUpdate(VaultMiningStorage.Layout storage l) internal view returns (UD60x18 rewardAmount);

_calculateAccRewardsPerShare

Calculate the new accRewardsPerShare for a vault, based on total rewards to allocate, and share of rewards that vault should get

function _calculateAccRewardsPerShare(
    VaultMiningStorage.Layout storage l,
    VaultInfo storage vInfo,
    UD60x18 rewardAmount
) internal view returns (UD60x18 accRewardsPerShare);

getPendingUserRewardsFromVault

Return amount of pending rewards (not yet claimed) for a user for a vault This DOES NOT account for l.userRewards[user] and only account for pending rewards of given vault

function getPendingUserRewardsFromVault(address user, address vault) external view returns (UD60x18);

getTotalUserRewards

Return amount of total rewards (not yet claimed) for a user. This accounts for l.userRewards[user] and pending rewards of all vaults

function getTotalUserRewards(address user) external view returns (UD60x18);

getTotalVotes

Return the total amount of votes across all vaults (Used to calculate share of rewards allocation for each vault)

function getTotalVotes() external view returns (UD60x18);

getVaultInfo

Return internal variables for a vault

function getVaultInfo(address vault) external view returns (VaultInfo memory);

getUserInfo

Return internal variables for a user, on a specific vault

function getUserInfo(address user, address vault) external view returns (UserInfo memory);

getRewardsPerYear

Get the amount of rewards emitted per year

function getRewardsPerYear() external view returns (UD60x18);

setRewardsPerYear

Update the yearly emission rate of rewards

function setRewardsPerYear(UD60x18 rewardsPerYear) external onlyOwner;

getVoteMultiplier

Get the vote multiplier for a given vault

function getVoteMultiplier(address vault) external view returns (UD60x18);

setVoteMultiplier

Sets the vote multiplier for a specific vault

function setVoteMultiplier(address vault, UD60x18 voteMultiplier) external onlyOwner;

_setVoteMultiplier

function _setVoteMultiplier(address vault, UD60x18 voteMultiplier) internal;

addDualMiningPool

Add a dual mining pool for a specific vault

function addDualMiningPool(address vault, address dualMining) external onlyOwner;

removeDualMiningPool

Removes a dual mining pool from a specific vault

function removeDualMiningPool(address vault, address dualMining) external onlyOwner;

getDualMiningPools

Return list of dual mining pools for a given vault

function getDualMiningPools(address vault) public view returns (address[] memory);

previewOptionParams

OptionReward.previewOptionParams wrapper, returns the params for the option reward token. Note that the on-chain price is constantly updating, therefore, the strike price returned may not be the same as the strike price at the time of underwriting.

function previewOptionParams() external view returns (UD60x18 strike, uint64 maturity);

Returns

NameTypeDescription
strikeUD60x18the option strike price (18 decimals)
maturityuint64the option maturity timestamp

claimAll

Allocate pending rewards for a list of vaults, and claim max amount of rewards possible.

function claimAll(address[] calldata vaults) external nonReentrant;

claim

Allocate pending rewards for a list of vaults, and claim given amount of rewards.

function claim(address[] calldata vaults, UD60x18 amount) external nonReentrant;

Parameters

NameTypeDescription
vaultsaddress[]The vaults for which to trigger allocation of pending rewards
amountUD60x18The amount of rewards to claim.

_claimDualMiningRewards

Claim rewards from all dualMining contracts of given vaults

function _claimDualMiningRewards(address user, address[] calldata vaults) internal;

_claimRewards

Claim option rewards

function _claimRewards(VaultMiningStorage.Layout storage l, address user, UD60x18 amount) internal;

updateVaults

Trigger an update for all vaults

function updateVaults() public nonReentrant;

updateUser

Trigger an update for a user on a specific vault This needs to be called by the vault, anytime the user's shares change Can only be called by a vault registered on the VaultRegistry

function updateUser(address user, UD60x18 newUserShares, UD60x18 newTotalShares, UD60x18) external nonReentrant;

Parameters

NameTypeDescription
useraddressThe user to update
newUserSharesUD60x18The new amount of shares for the user
newTotalSharesUD60x18The new amount of total shares for the vault
<none>UD60x18

updateVault

Trigger an update for a vault

function updateVault(address vault) public nonReentrant;

_allocatePendingRewards

Allocate pending rewards from global reward emission

function _allocatePendingRewards(VaultMiningStorage.Layout storage l) internal;

_updateVault

function _updateVault(address vault, UD60x18 newTotalShares) internal returns (UD60x18 vaultRewards);

updateUser

Trigger an update for a user on a specific vault This needs to be called by the vault, anytime the user's shares change Can only be called by a vault registered on the VaultRegistry

function updateUser(address user, address vault) external nonReentrant;

Parameters

NameTypeDescription
useraddressThe user to update
vaultaddress

_updateUser

Update user rewards for a specific vault

function _updateUser(address user, address vault) internal;

_updateUser

Update user rewards for a list of vaults

function _updateUser(address user, address[] calldata vaults) internal;

_updateUser

Update user rewards for a specific vault

function _updateUser(address user, address vault, UD60x18 newUserShares, UD60x18 newTotalShares) internal;

_updateVaultAllocation

Update vault allocation based on votes and vote multiplier

function _updateVaultAllocation(VaultMiningStorage.Layout storage l, address vault) internal virtual;

_setVaultVotes

Set new vault votes, scaled by vote multiplier

function _setVaultVotes(VaultMiningStorage.Layout storage l, VaultVotes memory data) internal;

_revertIfNotVault

Revert if addr is not a vault

function _revertIfNotVault(address addr) internal view;