ILM_PC_Staking_v1.sol
Functions
getStakingToken
Returns address of the token users can stake.
function getStakingToken() external view returns (address);
Returns
<none>
address
The address of the token.
getTotalSupply
Returns the total supply of staked tokens of this contract.
function getTotalSupply() external view returns (uint);
Returns
<none>
uint256
The total supply of staked tokens.
getRewardRate
Returns how much Tokens will be distributed per second to all users that staked in this contract.
function getRewardRate() external view returns (uint);
Returns
<none>
uint256
The reward rate.
getRewardsEnd
Returns when the rewards will not be distributed anymore.
function getRewardsEnd() external view returns (uint);
Returns
<none>
uint256
The timestamp of when the rewards will end.
getBalance
Returns the amount of tokens a user staked in this contract.
function getBalance(address user) external view returns (uint);
Parameters
user
address
The address of a user that staked.
getEarned
Returns the amount of tokens earned up until now by the current stake of a user.
function getEarned(address user) external view returns (uint);
Parameters
user
address
The address of a user that staked.
Returns
<none>
uint256
The amount of tokens earned.
getEstimatedReward
Returns a estimation of how much rewards will be earned with the current state of the staking contract.
This calculation uses the current reward rate and the current totalSupply to calculate the rewards.
the estimated result could be 0 if the estimated rewards are not high enough.
function getEstimatedReward(uint amount, uint duration)
external
view
returns (uint);
Parameters
amount
uint256
How much token are staked.
duration
uint256
How long the tokens will be staked.
Returns
<none>
uint256
The estimated amount of tokens earned.
getRewardValue
Returns the reward value.
function getRewardValue() external view returns (uint);
Returns
<none>
uint256
The reward value.
getLastUpdate
Returns the timestamp of last state change.
function getLastUpdate() external view returns (uint);
Returns
<none>
uint256
The timestamp of last state change.
stake
Stake a specified amount of tokens to earn rewards.
Should tokens already be staked, then the sending address will collect the rewards up until this point.
Fee on transfer tokens are currently not supported.
function stake(uint amount) external;
Parameters
amount
uint256
How much token should be staked.
unstake
Unstake a specified amount of tokens and collect rewards.
Reaps the rewards collected up to this point for the msg.Sender().
Fee on transfer tokens are currently not supported.
function unstake(uint amount) external;
Parameters
amount
uint256
How much token should be unstaked.
claimRewards
Collects the rewards that are earned up until now.
Reaps the rewards collected up to this point for the msg.Sender().
function claimRewards() external;
setRewards
Sets the rewards that are to be distributed.
Equally distributes the reward amount over the given time period.
function setRewards(uint amount, uint duration) external;
Parameters
amount
uint256
How much token should be distributed.
duration
uint256
How much time it will take to distribute the token.
Events
RewardSet
Event emitted when a reward is added.
event RewardSet(
uint rewardAmount, uint duration, uint newRewardRate, uint newRewardsEnd
);
Parameters
rewardAmount
uint256
The amount of tokens to distribute.
duration
uint256
The duration of the reward period.
newRewardRate
uint256
The new reward rate.
newRewardsEnd
uint256
The new timestamp of when the rewards will end.
Staked
Event emitted when a user stakes an amount.
event Staked(address indexed user, uint amount);
Parameters
user
address
The address of the user.
amount
uint256
The amount of tokens staked.
Unstaked
Event emitted when a user unstakes an amount.
event Unstaked(address indexed user, uint amount);
Parameters
user
address
The address of the user.
amount
uint256
The amount of tokens unstaked.
RewardsDistributed
Event emitted when a user receives Rewards.
event RewardsDistributed(address indexed user, uint amount);
Parameters
user
address
The address of the user.
amount
uint256
The amount of tokens earned.
Updated
Event emitted for each major change of state.
event Updated(
address indexed triggerAddress,
uint rewardValue,
uint lastUpdate,
uint earnedRewards
);
Parameters
triggerAddress
address
Address of user if state change was triggered by a staking action. Else can be zero.
rewardValue
uint256
Variable necessary to calculate how much rewards a staker is eligible for.
lastUpdate
uint256
Timestamp of last state change.
earnedRewards
uint256
How much a user earned up to point of state change.
StakingTokenSet
Event emitted when staking token is set.
event StakingTokenSet(address indexed token);
Parameters
token
address
Address of token that can be staked.
Errors
Module__LM_PC_Staking_v1__InvalidStakingToken
Given staking token address is invalid.
error Module__LM_PC_Staking_v1__InvalidStakingToken();
Module__LM_PC_Staking_v1__InvalidDuration
Given Duration is invalid.
error Module__LM_PC_Staking_v1__InvalidDuration();
Module__LM_PC_Staking_v1__InvalidRewardRate
The calculated Reward rate is too low to be used.
error Module__LM_PC_Staking_v1__InvalidRewardRate();
Last updated