RealYieldStaking Contract
The contract is responsible for staking KNINE tokens to receive BONE rewards. Two types of deposits (locked and non-locked) are available.
Variables
bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");
- admin role identifier.
IERC20 public KNINE;
- KNINE token address.
uint256 public maxLockMultiplier;
- maximum multiplier value (for 12-months lock), multiplied by 10^18 (must be stored this way for correct calculations).
uint256 public excessReward;
- extra amount of reward (in native). This extra amount appears from solidoty-specific integer division.
uint256 public totalStakers;
- number of unique stakers in the pool.
PoolInfo public poolInfo;
- general information on the reward pool in form of the PoolInfo struct (see below).
struct PoolInfo {
uint256 startTime;
- global contract start time.
uint256 endTime;
- global contract shutdown time.
uint256 periodFinish;
- time of the last or upcoming end of reward distribution.
uint256 lastUpdate;
- last update time.
uint256 rps;
- current reward per second distribution amount.
uint256 totalStaked;
- how many tokens are currently locked.
uint256 totalWeight;
- total weight of stakers in the pool.
uint256 acc;
- last updated accumulator value.
}
Events
event Deposited(
address user,
uint256 amount,
uint256 weight,
uint256 lockEnds
);
- upon deposit
call, returns:
The user's address,
The number of deposited tokens,
The new final weight of the user when his lock ends.
event LockIncreased(address user,uint256 newLockEnd, uint256 newWeight);
- upon increaseLockup
call, returns:
The user's address,
New lock end time,
New weight.
event Withdrawed(address user,uint256 amount);
- upon withdraw
call, returns:
The user’s address,
How many tokens user has withdrawn.
event ClaimedReward(address user,uint256 amount);
- upon claimTotalRewards
, claimRewards
and withdraw
call, returns:
The user's address,
The claimed reward amount.
Default Admin Functions
initialize
For the initializer role only
Initializer function, not called after initialization.
start
Starts staking contract (setting the global start time and primary RPS).
emergencyStop
Global contract stopping method.
withdrawExcessReward
Withdraw excess reward from excessReward.
withdrawStockTokens
Withdraw excess tokens (not reward) from the contract.
Default Admin and Admin Functions
setRPS
Set a new reward per second value.
setMaxMultiplier
Set the maximum multiplier value.
input value should be multiplied by 10^18
User Functions
deposit
Making a new deposit or adding to the current one with the ability to set a lockup.
For lockDuration
- input the number of months for a lockup, 0 means no lockup
increaseLockup
Increasing the lockup.
For lockDuration
- input the number of months for lockup, the lock period will restart
withdraw
Withdrawing a deposit.
isLocked == true
- withdrawal of a locked deposit (which lockup period has ended)isLocked==false
- withdrawal of a non-locked deposit
claimRewards
Claiming rewards.
isLocked == true
- withdrawal of a locked deposit (which lockup period has ended)isLocked==false
- withdrawal of a non-locked deposit
claimTotalRewards
Claiming all available rewards from both deposits at once.
View Functions
pendingRewards
Show accumulated rewards by user address.
the first value is a locked deposit rewards
the second value is a non-locked deposit rewards
userDeposits
Information on the user’s deposits in the UserInfo struct format.
the first value is a locked deposit rewards
the second value is a non-locked deposit rewards
UserInfo
struct UserInfo {
uint256 amount;
- number of staked tokens.
uint256 weight;
- deposit weight.
uint256 acc;
- last recorded battery value.
uint256 debt;
- last counted recorded reward.
uint256 lockEnd;
- when the lock ends (for unlocked deposits there will be 0).
}
Last updated