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

NameTypeDescription

reward

address

Address of the reward token

Return Values

NameTypeDescription

[0]

uint256

uint256 : Last update timestamp

totalAssets

function totalAssets() public view returns (uint256)

Get the total amount of assets staked

Return Values

NameTypeDescription

[0]

uint256

uint256 : Total amount of assets staked

getCurrentIndex

function getCurrentIndex() external view returns (uint256)

Get the current index to convert between balance and scaled balances

Return Values

NameTypeDescription

[0]

uint256

uint256 : Current index

getRewardList

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

Get the list of all reward tokens

Return Values

NameTypeDescription

[0]

address[]

address[] : List of reward tokens

userCurrentStakedAmount

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

Get the current amount staked by an user

Parameters

NameTypeDescription

user

address

Address of the user

Return Values

NameTypeDescription

[0]

uint256

uint256 : Current amount staked

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

NameTypeDescription

reward

address

Address of the reward token

user

address

Address of the user

Return Values

NameTypeDescription

[0]

struct DullahanRewardsStaking.UserRewardState

UserRewardState : User reward state

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

NameTypeDescription

reward

address

Address of the reward token

user

address

Address of the user

Return Values

NameTypeDescription

[0]

uint256

uint256 : amount of rewards accured

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

NameTypeDescription

user

address

Address of the user

Return Values

NameTypeDescription

[0]

struct DullahanRewardsStaking.UserClaimableRewards[]

UserClaimableRewards[] : Amounts of rewards claimable by reward token

stake

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

Stake Vault shares

Parameters

NameTypeDescription

amount

uint256

Amount to stake

receiver

address

Address of the address to stake for

Return Values

NameTypeDescription

[0]

uint256

uint256 : scaled amount for the deposit

_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

NameTypeDescription

caller

address

amount

uint256

Amount to stake

receiver

address

Address of the caller to pull token from

Return Values

NameTypeDescription

[0]

uint256

uint256 : scaled amount for the deposit

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

NameTypeDescription

scaledAmount

uint256

Scaled amount ot unstake

receiver

address

Address to receive the shares

Return Values

NameTypeDescription

[0]

uint256

uint256 : amount unstaked

claimRewards

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

Claim the accrued rewards for a given reward token

Parameters

NameTypeDescription

reward

address

Address of the reward token

receiver

address

Address to receive the rewards

Return Values

NameTypeDescription

[0]

uint256

uint256 : Amount of rewards claimed

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

NameTypeDescription

reward

address

Address of the reward token

user

address

Address that accrued the rewards

receiver

address

Address to receive the rewards

Return Values

NameTypeDescription

[0]

uint256

uint256 : Amount of rewards claimed

claimAllRewards

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

Claim all accrued rewards for all reward tokens

Parameters

NameTypeDescription

receiver

address

Address to receive the rewards

Return Values

NameTypeDescription

[0]

struct DullahanRewardsStaking.UserClaimedRewards[]

UserClaimedRewards[] : Amounts of reward claimed

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

NameTypeDescription

user

address

Address that accrued the rewards

receiver

address

Address to receive the rewards

Return Values

NameTypeDescription

[0]

struct DullahanRewardsStaking.UserClaimedRewards[]

UserClaimedRewards[] : Amounts of reward claimed

updateRewardState

function updateRewardState(address reward) external

Update the reward state for a given reward token

Parameters

NameTypeDescription

reward

address

Address of the reward token

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

NameTypeDescription

rewardToken

address

Address of the reward token

amount

uint256

Amount to queue

Return Values

NameTypeDescription

[0]

bool

bool : success

_updateRewardDistribution

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

Update the disitrubtion parameters for a given reward token

Parameters

NameTypeDescription

rewardToken

address

Address of the reward token

state

struct DullahanRewardsStaking.RewardState

State of the reward token

rewardAmount

uint256

Total amount ot distribute

_getCurrentIndex

function _getCurrentIndex() internal view returns (uint256)

Get the current index to convert between balance and scaled balances

Return Values

NameTypeDescription

[0]

uint256

uint256 : Current index

_getNewRewardPerToken

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

Calculate the new rewardPerToken value for a reward token distribution

Parameters

NameTypeDescription

reward

address

Address of the reward token

Return Values

NameTypeDescription

[0]

uint256

uint256 : new rewardPerToken value

_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

NameTypeDescription

reward

address

Address of the reward token

user

address

Address of the user

currentRewardPerToken

uint256

Return Values

NameTypeDescription

[0]

uint256

uint256 : Accrued rewards amount for the user

_updateRewardState

function _updateRewardState(address reward) internal

Update the reward token distribution state

Parameters

NameTypeDescription

reward

address

Address of the reward token

_updateUserRewardState

function _updateUserRewardState(address reward, address user) internal

Update the user reward state for a given reward token

Parameters

NameTypeDescription

reward

address

Address of the reward token

user

address

Address of the user

_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

NameTypeDescription

user

address

Address of the user

_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

NameTypeDescription

reward

address

Address of reward token

user

address

Address of the user

receiver

address

Address to receive the rewards

Return Values

NameTypeDescription

[0]

uint256

uint256 : claimed amount

_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

NameTypeDescription

user

address

Address of the user

receiver

address

Address to receive the rewards

Return Values

NameTypeDescription

[0]

struct DullahanRewardsStaking.UserClaimedRewards[]

UserClaimedRewards[] : list of claimed rewards

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

NameTypeDescription

depositor

address

Address to deposit rewards

removeRewardDepositor

function removeRewardDepositor(address depositor) external

Remove an address from the lsit of allowed reward depositors

Parameters

NameTypeDescription

depositor

address

Address to deposit rewards

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

NameTypeDescription

user

address

Address of the user

claimer

address

Address of the allowed claimer

safe128

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

Last updated