Comment on page
DullahanRewardsStaking
struct UserRewardState {
uint256 lastRewardPerToken;
uint256 accruedRewards;
}
struct RewardState {
uint256 rewardPerToken;
uint128 lastUpdate;
uint128 distributionEndTimestamp;
uint256 ratePerSecond;
uint256 currentRewardAmount;
uint256 queuedRewardAmount;
mapping(address => struct DullahanRewardsStaking.UserRewardState) userStates;
}
struct UserClaimableRewards {
address reward;
uint256 claimableAmount;
}
struct UserClaimedRewards {
address reward;
uint256 amount;
}
bool initialized
Is the contract initialized
address vault
Address of the Dullahan Vault
uint256 totalScaledAmount
Total scaled deposited amount
mapping(address => uint256) userScaledBalances
User scaled deposits
address[] rewardList
Address of tokens used in reward distributions
mapping(address => struct DullahanRewardsStaking.RewardState) rewardStates
Reward state for each reward token
mapping(address => bool) rewardDepositors
Addresses allowed to deposit rewards
mapping(address => address) allowedClaimer
Addresses allowed to claim for another user
event Initialized()
Event emitted when the contract is initialized
event Staked(address caller, address receiver, uint256 amount, uint256 scaledAmount)
Event emitted when staking
event Unstaked(address owner, address receiver, uint256 amount, uint256 scaledAmount)
Event emitted when unstaking
event ClaimedRewards(address reward, address user, address receiver, uint256 amount)
Event emitted when rewards are claimed
event SetUserAllowedClaimer(address user, address claimer)
Event emitted when a new Claimer is set for an user
event NewRewards(address rewardToken, uint256 amount, uint256 endTimestamp)
Event emitted when a new reward is added
event AddedRewardDepositor(address depositor)
Event emitted when a new reward depositor is added
event RemovedRewardDepositor(address depositor)
Event emitted when a reward depositor is removed
modifier onlyRewardDepositors()
Check that the caller is allowed to deposit rewards
modifier isInitialized()
Check that the contract is initalized
constructor(address _vault) public
function init() external
function lastRewardUpdateTimestamp(address reward) public view returns (uint256)
Get the last update timestamp for a reward token
Name | Type | Description |
---|---|---|
reward | address | Address of the reward token |
Name | Type | Description |
---|---|---|
[0] | uint256 | uint256 : Last update timestamp |
function totalAssets() public view returns (uint256)
Get the total amount of assets staked
Name | Type | Description |
---|---|---|
[0] | uint256 | uint256 : Total amount of assets staked |
function getCurrentIndex() external view returns (uint256)
Get the current index to convert between balance and scaled balances
Name | Type | Description |
---|---|---|
[0] | uint256 | uint256 : Current index |
function getRewardList() public view returns (address[])
Get the list of all reward tokens
Name | Type | Description |
---|---|---|
[0] | address[] | address[] : List of reward tokens |
function userCurrentStakedAmount(address user) public view returns (uint256)
Get the current amount staked by an user
Name | Type | Description |
---|---|---|
user | address | Address of the user |
Name | Type | Description |
---|---|---|
[0] | uint256 | uint256 : Current amount staked |
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
Name | Type | Description |
---|---|---|
reward | address | Address of the reward token |
user | address | Address of the user |
Name | Type | Description |
---|---|---|
[0] | struct DullahanRewardsStaking.UserRewardState | UserRewardState : User reward state |
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
Name | Type | Description |
---|---|---|
reward | address | Address of the reward token |
user | address | Address of the user |
Name | Type | Description |
---|---|---|
[0] | uint256 | uint256 : amount of rewards accured |
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
Name | Type | Description |
---|---|---|
user | address | Address of the user |
Name | Type | Description |
---|---|---|
[0] | struct DullahanRewardsStaking.UserClaimableRewards[] | UserClaimableRewards[] : Amounts of rewards claimable by reward token |
function stake(uint256 amount, address receiver) external returns (uint256)
Stake Vault shares
Name | Type | Description |
---|---|---|
amount | uint256 | Amount to stake |
receiver | address | Address of the address to stake for |
Name | Type | Description |
---|---|---|
[0] | uint256 | uint256 : scaled amount for the deposit |
function _stake(address caller, uint256 amount, address receiver) internal returns (uint256)
Pull the ScalingERC20 token & stake in this contract & tracks the correct scaled amount
Name | Type | Description |
---|---|---|
caller | address | ​ |
amount | uint256 | Amount to stake |
receiver | address | Address of the caller to pull token from |
Name | Type | Description |
---|---|---|
[0] | uint256 | uint256 : scaled amount for the deposit |
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
Name | Type | Description |
---|---|---|
scaledAmount | uint256 | Scaled amount ot unstake |
receiver | address | Address to receive the shares |
Name | Type | Description |
---|---|---|
[0] | uint256 | uint256 : amount unstaked |
function claimRewards(address reward, address receiver) external returns (uint256)
Claim the accrued rewards for a given reward token
Name | Type | Description |
---|---|---|
reward | address | Address of the reward token |
receiver | address | Address to receive the rewards |
Name | Type | Description |
---|---|---|
[0] | uint256 | uint256 : Amount of rewards claimed |
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
Name | Type | Description |
---|---|---|
reward | address | Address of the reward token |
user | address | Address that accrued the rewards |
receiver | address | Address to receive the rewards |
Name | Type | Description |
---|---|---|
[0] | uint256 | uint256 : Amount of rewards claimed |
function claimAllRewards(address receiver) external returns (struct DullahanRewardsStaking.UserClaimedRewards[])
Claim all accrued rewards for all reward tokens
Name | Type | Description |
---|---|---|
receiver | address | Address to receive the rewards |
Name | Type | Description |
---|---|---|
[0] | struct DullahanRewardsStaking.UserClaimedRewards[] | UserClaimedRewards[] : Amounts of reward claimed |
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
Name | Type | Description |
---|---|---|
user | address | Address that accrued the rewards |
receiver | address | Address to receive the rewards |
Name | Type | Description |
---|---|---|
[0] | struct DullahanRewardsStaking.UserClaimedRewards[] | UserClaimedRewards[] : Amounts of reward claimed |
function updateRewardState(address reward) external
Update the reward state for a given reward token
Name | Type | Description |
---|---|---|
reward | address | Address of the reward token |
function updateAllRewardState() external
Update the reward state for all reward tokens
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
Name | Type | Description |
---|---|---|
rewardToken | address | Address of the reward token |
amount | uint256 | Amount to queue |
Name | Type | Description |
---|---|---|
[0] | bool | bool : success |
function _updateRewardDistribution(address rewardToken, struct DullahanRewardsStaking.RewardState state, uint256 rewardAmount) internal
Update the disitrubtion parameters for a given reward token
Name | Type | Description |
---|---|---|
rewardToken | address | Address of the reward token |
state | struct DullahanRewardsStaking.RewardState | State of the reward token |
rewardAmount | uint256 | Total amount ot distribute |
function _getCurrentIndex() internal view returns (uint256)
Get the current index to convert between balance and scaled balances
Name | Type | Description |
---|---|---|
[0] | uint256 | uint256 : Current index |
function _getNewRewardPerToken(address reward) internal view returns (uint256)
Calculate the new rewardPerToken value for a reward token distribution
Name | Type | Description |
---|---|---|
reward | address | Address of the reward token |
Name | Type | Description |
---|---|---|
[0] | uint256 | uint256 : new rewardPerToken value |
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
Name | Type | Description |
---|---|---|
reward | address | Address of the reward token |
user | address | Address of the user |
currentRewardPerToken | uint256 | ​ |
Name | Type | Description |
---|---|---|
[0] | uint256 | uint256 : Accrued rewards amount for the user |
function _updateRewardState(address reward) internal
Update the reward token distribution state
Name | Type | Description |
---|---|---|
reward | address | Address of the reward token |
function _updateUserRewardState(address reward, address user) internal
Update the user reward state for a given reward token
Name | Type | Description |
---|---|---|
reward | address | Address of the reward token |
user | address | Address of the user |
function _updateAllRewardStates() internal
Update the reward state for all the reward tokens
function _updateAllUserRewardStates(address user) internal
Update the reward state of the given user for all the reward tokens
Name | Type | Description |
---|---|---|
user | address | Address of the user |
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