stake(uint256) :
This function allows a user to stake a certain amount of tokens to the contract. It works by calling the _stakeTo() function, which takes three parameters: the sender, the recipient, and the amount of tokens to be staked. The sender and recipient are both set to the sender, meaning that the user is staking the tokens to themselves. (autogenerated documentation)
stakeTo(address,uint256) :
This function allows a user to stake a certain amount of tokens to a specified recipient. It works by calling the _stakeTo() function, which takes the sender's address, the recipient's address, and the amount of tokens to be staked as parameters. The function then transfers the specified amount of tokens from the sender to the recipient. (autogenerated documentation)
_stakeTo(address,address,uint256) :
This function is used to stake tokens to a recipient. It first checks if the recipient has any existing stake, and if not, sets the starting index for the staker. It then updates the trackers for the recipient, computes the pending stakes, and adds the amount to the stake and cumulative stake. Finally, it transfers the amount from the sender to the contract and emits an event. (autogenerated documentation)
requestUnstake(uint256) :
This function allows a voter to request to unstake a certain amount of tokens from their account. It requires that the voter has enough tokens to unstake and that they are not in an active reveal phase. It then updates the trackers associated with the voter, subtracts the amount from the cumulative stake, and sets the pending unstake amount and the unstake request time in the voter's storage. Finally, it emits an event to notify that the unstake request has been made. (autogenerated documentation)
executeUnstake() :
This function allows a voter to unstake their tokens from the voting contract. It requires that the unstake request time has passed and that the voter has tokens to unstake. If these conditions are met, the function will transfer the tokens to the voter and emit an ExecutedUnstake event. (autogenerated documentation)
withdrawRewards() :
This function allows a user to withdraw rewards from a contract. It takes the sender's address as an argument and returns the amount of rewards that the sender has earned. The function works by calculating the amount of rewards that the sender has earned and then transferring them to the sender's address. (autogenerated documentation)
_withdrawRewards(address,address) :
This function allows a voter to withdraw their rewards from the voting contract. It takes two parameters, the address of the voter and the address of the recipient. It first updates the trackers associated with the voter, then it calculates the amount of tokens to mint for the voter's outstanding rewards. If the amount of tokens to mint is greater than 0, it mints the tokens to the recipient and emits an event to track the withdrawal. Finally, it returns the amount of tokens minted. (autogenerated documentation)
withdrawAndRestake() :
This function allows a delegate to withdraw their rewards from a voter and restake them back to the same voter. It first gets the voter associated with the delegate from the getVoterFromDelegate() function, then calls the _withdrawRewards() function to withdraw the rewards from the voter and the delegate address. Finally, it calls the _stakeTo() function to restake the rewards back to the voter. (autogenerated documentation)
setDelegate(address) :
This function allows a user to set a delegate address for their voter stake. It takes an address as an argument and sets the delegate address for the voter stake associated with the message sender. It then emits an event to notify that the delegate address has been set. (autogenerated documentation)
setDelegator(address) :
This function allows a user to set a delegator for their account. It takes an address as an argument and sets the delegator for the user's account to the address provided. The function then emits an event, DelegatorSet, which contains the user's address and the address of the delegator. (autogenerated documentation)
setEmissionRate(uint256) :
This function allows the owner of the contract to set a new emission rate for the token. The emission rate is the amount of tokens that will be created and distributed each time the reward function is called. The function first updates the reward function with an address of 0, then sets the new emission rate, and finally emits an event to notify that the new emission rate has been set. (autogenerated documentation)
setUnstakeCoolDown(uint64) :
This function allows the owner of the contract to set a new unstake cool down period. This period is the amount of time that must pass before a user can unstake their tokens from the contract. When the function is called, the new unstake cool down period is set and an event is emitted to notify other users of the change. (autogenerated documentation)
_updateTrackers(address) :
This function updates the trackers associated with a given voter address. It does this by calling the _updateReward() function, which updates the reward associated with the voter address. This ensures that the voter is rewarded for their vote, and that the trackers are kept up to date. (autogenerated documentation)
getVoterPendingStake(address,uint256) :
This function retrieves the pending stake of a voter for a given round. It does this by accessing the voterStakes mapping, which stores the pending stakes of each voter for each round. The function takes in the address of the voter and the round ID as parameters, and returns the pending stake of the voter for that round. (autogenerated documentation)
getVoterFromDelegate(address) :
This function is used to retrieve the address of a voter from a delegate address. It works by first checking if the caller address is a delegate address and if it is, it then checks if the delegate address is associated with a staker address in the delegateToStaker mapping. If it is, it then checks if the delegate address associated with the staker address is the same as the caller address. If all these conditions are met, the function returns the staker address associated with the delegate address. Otherwise, it returns the caller address. (autogenerated documentation)
outstandingRewards(address) :
This function calculates the outstanding rewards for a given voter address. It does this by taking the voter's stake multiplied by the difference between the reward per token and the rewards paid per token, and then adding the outstanding rewards. The result is returned as a uint256. (autogenerated documentation)
rewardPerToken() :
This function returns the reward per token for a given stake. It works by calculating the reward per token stored, plus the amount of time since the last update multiplied by the emission rate and divided by the cumulative stake. (autogenerated documentation)
getVoterStakePostUpdate(address) :
This function updates the voterStakes mapping for a given voter address and returns the updated stake amount. It works by first calling the _updateTrackers() function to update the voterStakes mapping with the latest stake amount, and then returning the updated stake amount from the mapping. (autogenerated documentation)
getCurrentTime() :
This function is a public view function that returns the current block timestamp in the form of a uint256. It works by accessing the block timestamp from the blockchain and returning it as an output. (autogenerated documentation)
_computePendingStakes(address,uint256) :
This function is used to compute the pending stakes of a voter. It takes in the address of the voter and the amount of stake as parameters. It then sets the pending stake of the voter for the given roundId to the amount provided. This allows the voter to have a pending stake for the given roundId which can be used to calculate the total stake of the voter. (autogenerated documentation)
_setPendingStake(address,uint256,uint256) :
This function is used to set the pending stake of a voter in a given round. It takes in the address of the voter, the round ID, and the amount of stake as parameters. It then updates the voterStakes mapping, which stores the total stake and pending stake of each voter, by adding the given amount to the pending stake of the voter in the given round. (autogenerated documentation)
_inActiveReveal() :
This function is an internal view function that returns a boolean value of false. It is used to indicate that the Reveal contract is not active. (autogenerated documentation)
_getStartingIndexForStaker() :
This function is an internal view function that returns the starting index for a staker. It is used to determine the starting index for a staker when looping through a list of stakers. The function returns a uint64 value which is the starting index for the staker. (autogenerated documentation)
_updateReward(address) :
This function updates the reward per token for a given voter address. It first calculates the new reward per token using the rewardPerToken() function. It then stores the new reward per token in the rewardPerTokenStored variable and updates the lastUpdateTime variable with the current time. If a voter address is provided, it then calculates the outstanding rewards for that voter address and stores it in the voterStakes mapping. Finally, it emits an UpdatedReward event with the voter address, new reward per token, and last update time. (autogenerated documentation)