DualMining

Git Source

Inherits: IDualMining, ReentrancyGuard

State Variables

VAULT_MINING

address internal immutable VAULT_MINING;

Functions

constructor

constructor(address vaultMining);

init

Initialize dual mining. Can only be called by VAULT_MINING contract

function init(UD60x18 initialParentAccRewardsPerShare) external nonReentrant;

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);

updatePool

Trigger an update for this mining pool. Can only be called by VAULT_MINING contract

function updatePool(UD60x18 poolRewards, UD60x18 accRewardsPerShare) external nonReentrant;

_updatePool

function _updatePool(DualMiningStorage.Layout storage l, UD60x18 parentPoolRewards, UD60x18 accRewardsPerShare)
    internal;

updateUser

Trigger an update for a specific user. Can only be called by VAULT_MINING contract

function updateUser(
    address user,
    UD60x18 oldShares,
    UD60x18 oldRewardDebt,
    UD60x18 parentPoolRewards,
    UD60x18 parentUserRewards,
    UD60x18 accRewardsPerShare
) external nonReentrant;

_calculateUserRewardToSubtract

Calculate user reward accumulated in parent contract before the start of the emission in this contract.

function _calculateUserRewardToSubtract(
    DualMiningStorage.Layout storage l,
    IDualMining.UserInfo storage uInfo,
    UD60x18 oldShares,
    UD60x18 oldRewardDebt,
    UD60x18 accRewardsPerShare
) internal view returns (UD60x18);

claim

Claim rewards. Can only be called by VAULT_MINING contract

The claim is done through VAULT_MINING, as we need to trigger updates through VAULT_MINING before being able to claim the rewards anyway.

function claim(address user) external nonReentrant;

Parameters

NameTypeDescription
useraddressThe user for which to claim

getPendingUserRewards

Return amount of pending rewards (not yet claimed) for the given user

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

getUserInfo

Return internal variables for the given user

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

_calculateRewardsUpdate

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

_revertIfNotVaultMining

function _revertIfNotVaultMining(address caller) internal view;

_revertIfNotInitialized

function _revertIfNotInitialized(DualMiningStorage.Layout storage l) internal view;

_revertIfInitialized

function _revertIfInitialized(DualMiningStorage.Layout storage l) internal view;

_revertIfMiningEnded

function _revertIfMiningEnded(DualMiningStorage.Layout storage l) internal view;

_revertIfNoMiningRewards

function _revertIfNoMiningRewards(DualMiningStorage.Layout storage l) internal view;