Skip to main content

Staking20Upgradeable

Methods

claimRewards

function claimRewards() external nonpayable

Claim accumulated rewards.

See {_claimRewards}. Override that to implement custom logic. See {_calculateRewards} for reward-calculation logic.

getRewardRatio

function getRewardRatio() external view returns (uint256 _numerator, uint256 _denominator)

Returns

NameTypeDescription
_numeratoruint256undefined
_denominatoruint256undefined

getRewardTokenBalance

function getRewardTokenBalance() external view returns (uint256 _rewardsAvailableInContract)

View total rewards available in the staking contract.

Returns

NameTypeDescription
_rewardsAvailableInContractuint256undefined

getStakeInfo

function getStakeInfo(address _staker) external view returns (uint256 _tokensStaked, uint256 _rewards)

View amount staked and rewards for a user.

Parameters

NameTypeDescription
_stakeraddressAddress for which to calculated rewards.

Returns

NameTypeDescription
_tokensStakeduint256Amount of tokens staked.
_rewardsuint256Available reward amount.

getTimeUnit

function getTimeUnit() external view returns (uint256 _timeUnit)

Returns

NameTypeDescription
_timeUnituint256undefined

rewardTokenDecimals

function rewardTokenDecimals() external view returns (uint256)

Decimals of reward token.

Returns

NameTypeDescription
_0uint256undefined

setRewardRatio

function setRewardRatio(uint256 _numerator, uint256 _denominator) external nonpayable

Set rewards per unit of time. Interpreted as (numerator/denominator) rewards per second/per day/etc based on time-unit. For e.g., ratio of 1/20 would mean 1 reward token for every 20 tokens staked.

Only admin/authorized-account can call it.

Parameters

NameTypeDescription
_numeratoruint256Reward ratio numerator.
_denominatoruint256Reward ratio denominator.

setTimeUnit

function setTimeUnit(uint256 _timeUnit) external nonpayable

Set time unit. Set as a number of seconds. Could be specified as -- x 1 hours, x 1 days, etc.

Only admin/authorized-account can call it.

Parameters

NameTypeDescription
_timeUnituint256New time unit.

stake

function stake(uint256 _amount) external payable

Stake ERC20 Tokens.

See {_stake}. Override that to implement custom logic.

Parameters

NameTypeDescription
_amountuint256Amount to stake.

stakers

function stakers(address) external view returns (uint256 amountStaked, uint256 timeOfLastUpdate, uint256 unclaimedRewards, uint256 conditionIdOflastUpdate)

Mapping staker address to Staker struct. See {struct IStaking20.Staker}.

Parameters

NameTypeDescription
_0addressundefined

Returns

NameTypeDescription
amountStakeduint256undefined
timeOfLastUpdateuint256undefined
unclaimedRewardsuint256undefined
conditionIdOflastUpdateuint256undefined

stakersArray

function stakersArray(uint256) external view returns (address)

List of accounts that have staked that token-id.

Parameters

NameTypeDescription
_0uint256undefined

Returns

NameTypeDescription
_0addressundefined

stakingToken

function stakingToken() external view returns (address)

Address of ERC20 contract -- staked tokens belong to this contract.

Returns

NameTypeDescription
_0addressundefined

stakingTokenBalance

function stakingTokenBalance() external view returns (uint256)

Total amount of tokens staked in the contract.

Returns

NameTypeDescription
_0uint256undefined

stakingTokenDecimals

function stakingTokenDecimals() external view returns (uint256)

Decimals of staking token.

Returns

NameTypeDescription
_0uint256undefined

withdraw

function withdraw(uint256 _amount) external nonpayable

Withdraw staked ERC20 tokens.

See {_withdraw}. Override that to implement custom logic.

Parameters

NameTypeDescription
_amountuint256Amount to withdraw.

Events

Initialized

event Initialized(uint8 version)

Parameters

NameTypeDescription
versionuint8undefined

RewardsClaimed

event RewardsClaimed(address indexed staker, uint256 rewardAmount)

Parameters

NameTypeDescription
staker indexedaddressundefined
rewardAmountuint256undefined

TokensStaked

event TokensStaked(address indexed staker, uint256 amount)

Parameters

NameTypeDescription
staker indexedaddressundefined
amountuint256undefined

TokensWithdrawn

event TokensWithdrawn(address indexed staker, uint256 amount)

Parameters

NameTypeDescription
staker indexedaddressundefined
amountuint256undefined

UpdatedMinStakeAmount

event UpdatedMinStakeAmount(uint256 oldAmount, uint256 newAmount)

Parameters

NameTypeDescription
oldAmountuint256undefined
newAmountuint256undefined

UpdatedRewardRatio

event UpdatedRewardRatio(uint256 oldNumerator, uint256 newNumerator, uint256 oldDenominator, uint256 newDenominator)

Parameters

NameTypeDescription
oldNumeratoruint256undefined
newNumeratoruint256undefined
oldDenominatoruint256undefined
newDenominatoruint256undefined

UpdatedTimeUnit

event UpdatedTimeUnit(uint256 oldTimeUnit, uint256 newTimeUnit)

Parameters

NameTypeDescription
oldTimeUnituint256undefined
newTimeUnituint256undefined