TokenStake
Methods
DEFAULT_ADMIN_ROLE
Returns
_0
bytes32
undefined
claimRewards
Claim accumulated rewards.
See {_claimRewards}. Override that to implement custom logic. See {_calculateRewards} for reward-calculation logic.
contractType
Returns the module type of the contract.
Returns
_0
bytes32
undefined
contractURI
Returns the contract metadata URI.
Returns
_0
string
undefined
contractVersion
Returns the version of the contract.
Returns
_0
uint8
undefined
depositRewardTokens
Admin deposits reward tokens.
Parameters
_amount
uint256
undefined
getRewardRatio
Returns
_numerator
uint256
undefined
_denominator
uint256
undefined
getRewardTokenBalance
View total rewards available in the staking contract.
Returns
_0
uint256
undefined
getRoleAdmin
Returns the admin role that controls the specified role.
See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.
Parameters
role
bytes32
keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
Returns
_0
bytes32
undefined
getRoleMember
Returns the role-member from a list of members for a role, at a given index.
Returns member
who has role
, at index
of role-members list. See struct {RoleMembers}, and mapping {roleMembers}
Parameters
role
bytes32
keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
index
uint256
Index in list of current members for the role.
Returns
member
address
Address of account that has role
getRoleMemberCount
Returns total number of accounts that have a role.
Returns count
of accounts that have role
. See struct {RoleMembers}, and mapping {roleMembers}
Parameters
role
bytes32
keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
Returns
count
uint256
Total number of accounts that have role
getStakeInfo
View amount staked and rewards for a user.
Parameters
_staker
address
Address for which to calculated rewards.
Returns
_tokensStaked
uint256
Amount of tokens staked.
_rewards
uint256
Available reward amount.
getTimeUnit
Returns
_timeUnit
uint256
undefined
grantRole
Grants a role to an account, if not previously granted.
Caller must have admin role for the role
. Emits {RoleGranted Event}.
Parameters
role
bytes32
keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
account
address
Address of the account to which the role is being granted.
hasRole
Checks whether an account has a particular role.
Returns true
if account
has been granted role
.
Parameters
role
bytes32
keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
account
address
Address of the account for which the role is being checked.
Returns
_0
bool
undefined
hasRoleWithSwitch
Checks whether an account has a particular role; role restrictions can be swtiched on and off.
Returns true
if account
has been granted role
. Role restrictions can be swtiched on and off: - If address(0) has ROLE, then the ROLE restrictions don't apply. - If address(0) does not have ROLE, then the ROLE restrictions will apply.
Parameters
role
bytes32
keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
account
address
Address of the account for which the role is being checked.
Returns
_0
bool
undefined
initialize
Initiliazes the contract, like a constructor.
Parameters
_defaultAdmin
address
undefined
_contractURI
string
undefined
_trustedForwarders
address[]
undefined
_rewardToken
address
undefined
_stakingToken
address
undefined
_timeUnit
uint256
undefined
_rewardRatioNumerator
uint256
undefined
_rewardRatioDenominator
uint256
undefined
isTrustedForwarder
Parameters
forwarder
address
undefined
Returns
_0
bool
undefined
multicall
Receives and executes a batch of function calls on this contract.
Parameters
data
bytes[]
undefined
Returns
results
bytes[]
undefined
renounceRole
Revokes role from the account.
Caller must have the role
, with caller being the same as account
. Emits {RoleRevoked Event}.
Parameters
role
bytes32
keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
account
address
Address of the account from which the role is being revoked.
revokeRole
Revokes role from an account.
Caller must have admin role for the role
. Emits {RoleRevoked Event}.
Parameters
role
bytes32
keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
account
address
Address of the account from which the role is being revoked.
rewardToken
ERC20 Reward Token address. See {_mintRewards} below.
Returns
_0
address
undefined
rewardTokenDecimals
Returns
_0
uint256
undefined
setContractURI
Lets a contract admin set the URI for contract-level metadata.
Caller should be authorized to setup contractURI, e.g. contract admin. See {_canSetContractURI}. Emits {ContractURIUpdated Event}.
Parameters
_uri
string
keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
setRewardRatio
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
_numerator
uint256
Reward ratio numerator.
_denominator
uint256
Reward ratio denominator.
setTimeUnit
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
_timeUnit
uint256
New time unit.
stake
Stake ERC20 Tokens.
See {_stake}. Override that to implement custom logic.
Parameters
_amount
uint256
Amount to stake.
stakers
Parameters
_0
address
undefined
Returns
amountStaked
uint256
undefined
timeOfLastUpdate
uint256
undefined
unclaimedRewards
uint256
undefined
conditionIdOflastUpdate
uint256
undefined
stakersArray
Parameters
_0
uint256
undefined
Returns
_0
address
undefined
stakingToken
Returns
_0
address
undefined
stakingTokenBalance
Returns
_0
uint256
undefined
stakingTokenDecimals
Returns
_0
uint256
undefined
withdraw
Withdraw staked ERC20 tokens.
See {_withdraw}. Override that to implement custom logic.
Parameters
_amount
uint256
Amount to withdraw.
withdrawRewardTokens
Admin can withdraw excess reward tokens.
Parameters
_amount
uint256
undefined
Events
ContractURIUpdated
Parameters
prevURI
string
undefined
newURI
string
undefined
Initialized
Parameters
version
uint8
undefined
RewardTokensDepositedByAdmin
Parameters
_amount
uint256
undefined
RewardTokensWithdrawnByAdmin
Parameters
_amount
uint256
undefined
RewardsClaimed
Parameters
staker indexed
address
undefined
rewardAmount
uint256
undefined
RoleAdminChanged
Parameters
role indexed
bytes32
undefined
previousAdminRole indexed
bytes32
undefined
newAdminRole indexed
bytes32
undefined
RoleGranted
Parameters
role indexed
bytes32
undefined
account indexed
address
undefined
sender indexed
address
undefined
RoleRevoked
Parameters
role indexed
bytes32
undefined
account indexed
address
undefined
sender indexed
address
undefined
TokensStaked
Parameters
staker indexed
address
undefined
amount
uint256
undefined
TokensWithdrawn
Parameters
staker indexed
address
undefined
amount
uint256
undefined
UpdatedMinStakeAmount
Parameters
oldAmount
uint256
undefined
newAmount
uint256
undefined
UpdatedRewardRatio
Parameters
oldNumerator
uint256
undefined
newNumerator
uint256
undefined
oldDenominator
uint256
undefined
newDenominator
uint256
undefined
UpdatedTimeUnit
Parameters
oldTimeUnit
uint256
undefined
newTimeUnit
uint256
undefined
Last updated