Delegator Factory
Contract in charge of generating Delegator contracts, handling delegations and CTX balance map, rewards.. Uses Open Zeppelin Library.
Code
Address
Mainnet
Contract | Address |
---|---|
DelegatorFactory | 0x70236b36f86AB4bd557Fe9934E1246537B472918 |
Rinkeby
Contract | Address |
---|---|
DelegatorFactory | 0x0aafdB19021a3a87A510dD4db7dce62318b49Cd1 |
Public Variables
Address of the staking governance token.
Address of the reward token.
Minimum wait time before removing stake.
Tracks the period where users stop earning rewards.
Tracks the reward rate that users can earn.
How long the rewards lasts, it updates when more rewards are added.
Last time rewards were updated.
Amount of reward calculated per token stored.
Track the rewards paid to users.
Tracks the user rewards.
Tracks the address of a delegatee with a delegator contract address.
Tracks the delegator contract address from delegatee address.
Tracks if address is an official delegator.
Tracks minimum wait time the account has to wait before removing stake.
Private Variables
Tracks the total supply of staked tokens.
Tracks the amount of staked tokens per user.
Events
Events are called each time the state changes on the contract.
An event emitted when a Delegator is created.
An event emitted when a user has staked and delegated.
An event emitted when a user removes stake and undelegated.
An event emitted when the minimum wait time is updated.
An event emitted when a reward is added.
An event emitted when reward is paid to a user.
An event emitted when the reward duration is updated.
Modifiers
updateReward
Updates the reward and time on call.
Read-Only Functions
totalSupply
Returns the total amount of staked tokens.
balanceOf
Returns the amount of staked tokens from specific user.
getRewardForDuration
Returns reward rate for a duration.
lastTimeRewardApplicable
Returns the minimum between current block timestamp or the finish period of rewards.
rewardPerToken
Returns the calculated reward per token deposited.
earned
Returns the amount of reward tokens a user has earned.
min
Returns the minimum between two variables.
State-Changing Functions
constructor
Called once the contract it's deployed, transfers ownership to timelock.
notifyRewardAmount
Notifies the contract that reward has been added to be given. Only owner can call it. Increases duration of rewards
setRewardsDuration
Updates the reward duration. Only owner can call it.
getReward
Transfers to the caller the current amount of rewards tokens earned. Update rewards on call.
createDelegator
Creates a new delegator contract that delegates all votes to delegatee_. Only one delegator contract pointing to the same delegatee can exist.
stake
Stakes to delegator the amount specified. Delegator must be valid and amount has to be greater than 0. amount_ is transferred to the delegator contract and staker starts earning rewards if active. Update rewards on call.
withdraw
Removes amount from delegator. Delegator must be valid and amount has to be greater than 0. amount must be <= that current user stake. amount is transferred from the delegator contract to the staker. Update rewards on call. Requires that at least waitTime has passed since delegation to unDelegate.
updateWaitTime
Updates the min wait time between delegation and unDelegation.