DullahanRewardsStaking

UserRewardState

struct UserRewardState {
  uint256 lastRewardPerToken;
  uint256 accruedRewards;
}

RewardState

struct RewardState {
  uint256 rewardPerToken;
  uint128 lastUpdate;
  uint128 distributionEndTimestamp;
  uint256 ratePerSecond;
  uint256 currentRewardAmount;
  uint256 queuedRewardAmount;
  mapping(address => struct DullahanRewardsStaking.UserRewardState) userStates;
}

UserClaimableRewards

struct UserClaimableRewards {
  address reward;
  uint256 claimableAmount;
}

UserClaimedRewards

struct UserClaimedRewards {
  address reward;
  uint256 amount;
}

initialized

bool initialized

Is the contract initialized

vault

address vault

Address of the Dullahan Vault

totalScaledAmount

uint256 totalScaledAmount

Total scaled deposited amount

userScaledBalances

mapping(address => uint256) userScaledBalances

User scaled deposits

rewardList

address[] rewardList

Address of tokens used in reward distributions

rewardStates

mapping(address => struct DullahanRewardsStaking.RewardState) rewardStates

Reward state for each reward token

rewardDepositors

mapping(address => bool) rewardDepositors

Addresses allowed to deposit rewards

allowedClaimer

mapping(address => address) allowedClaimer

Addresses allowed to claim for another user

Initialized

event Initialized()

Event emitted when the contract is initialized

Staked

event Staked(address caller, address receiver, uint256 amount, uint256 scaledAmount)

Event emitted when staking

Unstaked

event Unstaked(address owner, address receiver, uint256 amount, uint256 scaledAmount)

Event emitted when unstaking

ClaimedRewards

event ClaimedRewards(address reward, address user, address receiver, uint256 amount)

Event emitted when rewards are claimed

SetUserAllowedClaimer

event SetUserAllowedClaimer(address user, address claimer)

Event emitted when a new Claimer is set for an user

NewRewards

event NewRewards(address rewardToken, uint256 amount, uint256 endTimestamp)

Event emitted when a new reward is added

AddedRewardDepositor

event AddedRewardDepositor(address depositor)

Event emitted when a new reward depositor is added

RemovedRewardDepositor

event RemovedRewardDepositor(address depositor)

Event emitted when a reward depositor is removed

onlyRewardDepositors

modifier onlyRewardDepositors()

Check that the caller is allowed to deposit rewards

isInitialized

modifier isInitialized()

Check that the contract is initalized

constructor

constructor(address _vault) public

init

function init() external

lastRewardUpdateTimestamp

function lastRewardUpdateTimestamp(address reward) public view returns (uint256)

Get the last update timestamp for a reward token

Parameters

Return Values

totalAssets

function totalAssets() public view returns (uint256)

Get the total amount of assets staked

Return Values

getCurrentIndex

function getCurrentIndex() external view returns (uint256)

Get the current index to convert between balance and scaled balances

Return Values

getRewardList

function getRewardList() public view returns (address[])

Get the list of all reward tokens

Return Values

userCurrentStakedAmount

function userCurrentStakedAmount(address user) public view returns (uint256)

Get the current amount staked by an user

Parameters

Return Values

getUserRewardState

function getUserRewardState(address reward, address user) external view returns (struct DullahanRewardsStaking.UserRewardState)

Get the current reward state of an user for a given reward token

Parameters

Return Values

getUserAccruedRewards

function getUserAccruedRewards(address reward, address user) external view returns (uint256)

Get the current amount of rewards accrued by an user for a given reward token

Parameters

Return Values

getUserTotalClaimableRewards

function getUserTotalClaimableRewards(address user) external view returns (struct DullahanRewardsStaking.UserClaimableRewards[])

Get all current claimable amount of rewards for all reward tokens for a given user

Parameters

Return Values

stake

function stake(uint256 amount, address receiver) external returns (uint256)

Stake Vault shares

Parameters

Return Values

_stake

function _stake(address caller, uint256 amount, address receiver) internal returns (uint256)

Pull the ScalingERC20 token & stake in this contract & tracks the correct scaled amount

Parameters

Return Values

unstake

function unstake(uint256 scaledAmount, address receiver) external returns (uint256)

Unstake Vault shares

Unstake ScalingERC20 shares based on the given scaled amount & send them to the receiver

Parameters

Return Values

claimRewards

function claimRewards(address reward, address receiver) external returns (uint256)

Claim the accrued rewards for a given reward token

Parameters

Return Values

claimRewardsForUser

function claimRewardsForUser(address reward, address user, address receiver) external returns (uint256)

Claim the accrued rewards for a given reward token on behalf of a given user

Parameters

Return Values

claimAllRewards

function claimAllRewards(address receiver) external returns (struct DullahanRewardsStaking.UserClaimedRewards[])

Claim all accrued rewards for all reward tokens

Parameters

Return Values

claimAllRewardsForUser

function claimAllRewardsForUser(address user, address receiver) external returns (struct DullahanRewardsStaking.UserClaimedRewards[])

Claim all accrued rewards for all reward tokens on behalf of a given user

Parameters

Return Values

updateRewardState

function updateRewardState(address reward) external

Update the reward state for a given reward token

Parameters

updateAllRewardState

function updateAllRewardState() external

Update the reward state for all reward tokens

queueRewards

function queueRewards(address rewardToken, uint256 amount) external returns (bool)

Add rewards to the disitribution queue

Set the amount of reward in the queue & push it to distribution if reaching the ratio

Parameters

Return Values

_updateRewardDistribution

function _updateRewardDistribution(address rewardToken, struct DullahanRewardsStaking.RewardState state, uint256 rewardAmount) internal

Update the disitrubtion parameters for a given reward token

Parameters

_getCurrentIndex

function _getCurrentIndex() internal view returns (uint256)

Get the current index to convert between balance and scaled balances

Return Values

_getNewRewardPerToken

function _getNewRewardPerToken(address reward) internal view returns (uint256)

Calculate the new rewardPerToken value for a reward token distribution

Parameters

Return Values

_getUserEarnedRewards

function _getUserEarnedRewards(address reward, address user, uint256 currentRewardPerToken) internal view returns (uint256)

Calculate the amount of rewards accrued by an user since last update for a reward token

Parameters

Return Values

_updateRewardState

function _updateRewardState(address reward) internal

Update the reward token distribution state

Parameters

_updateUserRewardState

function _updateUserRewardState(address reward, address user) internal

Update the user reward state for a given reward token

Parameters

_updateAllRewardStates

function _updateAllRewardStates() internal

Update the reward state for all the reward tokens

_updateAllUserRewardStates

function _updateAllUserRewardStates(address user) internal

Update the reward state of the given user for all the reward tokens

Parameters

_claimRewards

function _claimRewards(address reward, address user, address receiver) internal returns (uint256)

Claims rewards of an user for a given reward token and sends them to the receiver address

Parameters

Return Values

_claimAllRewards

function _claimAllRewards(address user, address receiver) internal returns (struct DullahanRewardsStaking.UserClaimedRewards[])

Claims all rewards of an user and sends them to the receiver address

Parameters

Return Values

pause

function pause() external

Pause the contract

unpause

function unpause() external

Unpause the contract

addRewardDepositor

function addRewardDepositor(address depositor) external

Add an address to the lsit of allowed reward depositors

Parameters

removeRewardDepositor

function removeRewardDepositor(address depositor) external

Remove an address from the lsit of allowed reward depositors

Parameters

setUserAllowedClaimer

function setUserAllowedClaimer(address user, address claimer) external

Sets a given address as allowed to claim rewards for a given user

Sets a given address as allowed to claim rewards for a given user

Parameters

safe128

function safe128(uint256 n) internal pure returns (uint128)

Last updated