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

function initialize(address _knine, address _admin) public

For the initializer role only

Initializer function, not called after initialization.

start

function start(
uint256 startTime,
uint256 rps
) external

Starts staking contract (setting the global start time and primary RPS).

emergencyStop

function emergencyStop() external

Global contract stopping method.

withdrawExcessReward

function withdrawExcessReward() external

Withdraw excess reward from excessReward.

withdrawStockTokens

function withdrawStockTokens(address token) external

Withdraw excess tokens (not reward) from the contract.

Default Admin and Admin Functions

setRPS

function setRPS(uint256 value) external

Set a new reward per second value.

setMaxMultiplier

function setMaxMultiplier(uint256 value) external

Set the maximum multiplier value.

input value should be multiplied by 10^18

User Functions

deposit

function deposit(uint256 amount, uint8 lockDuration) external

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

function increaseLockup(uint8 lockDuration) external

Increasing the lockup.

For lockDuration - input the number of months for lockup, the lock period will restart

withdraw

function withdraw(bool isLocked) external 

Withdrawing a deposit.

  • isLocked == true - withdrawal of a locked deposit (which lockup period has ended)

  • isLocked==false - withdrawal of a non-locked deposit

claimRewards

function claimRewards(bool isLocked) public

Claiming rewards.

  • isLocked == true - withdrawal of a locked deposit (which lockup period has ended)

  • isLocked==false - withdrawal of a non-locked deposit

claimTotalRewards

function claimTotalRewards() external

Claiming all available rewards from both deposits at once.

View Functions

pendingRewards

function pendingRewards(
address user
) public view returns (uint256, uint256) 

Show accumulated rewards by user address.

  • the first value is a locked deposit rewards

  • the second value is a non-locked deposit rewards

userDeposits

function userDeposits(
address user
) external view returns (UserInfo[2] memory)

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