EmissionsController
Last updated
Last updated
Allows governors to vote on the weekly distribution of MTA
rewards. Rewards are distributed between n
"Dials" proportionately to the % of votes the dial receives.
Vote weight derives from multiple whitelisted "Staking contracts". Voters can distribute their vote across (0 <= n <= 16 dials), at 0.5% increments in voting weight.
Once their preferences are cast, each time their voting weight changes it is reflected here through a hook.
The staking contracts are capped at 10% of the weekly distribution.
Contracts are upgradable.
function getVotes (address account) public returns (uint256 votingPower)
Gets the users aggregate voting power across all voting contracts.
Voting power can be from staking or it could be delegated to the account.
function topLineEmission (uint32 epoch) public returns (uint256 emissionForEpoch)
Calculates top line distribution amount for the current epoch as per the polynomial (f(x)=A*(x/div)^3+B*(x/div)^2+C*(x/div)+D)
.
Values are effectively scaled to 1e12 to avoid integer overflow on pow.
function getDialRecipient (uint256 dialId) public returns (address recipient)
Gets a dial's recipient address.
function getDialVoteHistory (uint256 dialId) public returns (struct HistoricVotes[] voteHistory)
Gets a dial's weighted votes for each distribution period.
function getDialVotes () public returns (uint256[] dialVotes)
Gets the latest weighted votes for each dial. This will include disabled dials and their current weighted votes.
function getVoterPreferences (address voter) public returns (struct Preference[16] preferences)
Gets a voter's weights for each dial.
A dial identifier of 255 marks the end of the array. It should be ignored.
function addDial (address _recipient, uint8 _cap, bool _notify) external
Adds a new dial that can be voted on to receive weekly rewards. Callable by system governor.
function updateDial (uint256 _dialId, bool _disabled, bool _notify) external
Updates a dials recipient contract and/or disabled flag.
function addStakingContract (address _stakingContract) external
Adds a new contract to the list of approved staking contracts.
function donate (uint256[] _dialIds, uint256[] _amounts) external
Allows arbitrary reward donation to a dial on top of the weekly rewards.
function calculateRewards () external
Calculates the rewards to be distributed to each dial for the next weekly period.
Callable once an epoch has fully passed. Top level emission for the epoch is distributed proportionately to vote count with the following exceptions: - Disabled dials are ignored and votes not counted. - Dials with a cap are capped and their votes/emission removed (effectively redistributing rewards).
function distributeRewards (uint256[] _dialIds) external
Transfers all accrued rewards to dials and notifies them of the amount.
function pokeSources (address _voter) public
Re-cast a voters votes by retrieving balance across all staking contracts and updating lastSourcePoke
.
This would need to be called if a staking contract was added to the emissions controller when a voter already had voting power in the new staking contract and they had already set voting preferences.
function setVoterDialWeights (struct Preference[] _preferences) external
Allows a staker to cast their voting power across a number of dials.
A staker can proportion their voting power even if they currently have zero voting power. For example, they have delegated their votes. When they do have voting power (e.g. they undelegate), their set weights will proportion their voting power.
function moveVotingPowerHook (address from, address to, uint256 amount) external
Called by the staking contracts when a staker has modified voting power.
Parameter | Type | Description |
---|---|---|
Parameter | Type | Description |
---|---|---|
Parameter | Type | Description |
---|---|---|
Parameter | Type | Description |
---|---|---|
Parameter | Type | Description |
---|---|---|
Parameter | Type | Description |
---|---|---|
Parameter | Type | Description |
---|---|---|
Parameter | Type | Description |
---|---|---|
Parameter | Type | Description |
---|---|---|
Parameter | Type | Description |
---|---|---|
Parameter | Type | Description |
---|---|---|
Parameter | Type | Description |
---|---|---|
Parameter | Type | Description |
---|---|---|
account
address
For which to fetch voting power.
epoch
uint32
The number of weeks since 1 Jan 1970.
dialId
uint256
Dial identifier starting from 0.
dialId
uint256
Dial identifier starting from 0.
voter
address
Address of the voter that has set weights.
_recipient
address
Address of the contract that will receive rewards.
_cap
uint8
Cap where 0 = uncapped and 10 = 10%.
_notify
bool
If true, notifyRewardAmount
is called in the distributeRewards
function.
_dialId
uint256
Dial identifier which is the index of the dials array.
_disabled
bool
If true, no rewards will be distributed to this dial.
_notify
bool
If true, notifyRewardAmount
is called on the dial recipient contract.
_stakingContract
address
Address of the new staking contract
_dialIds
uint256[]
Dial identifiers that will receive donated rewards.
_amounts
uint256[]
Units of rewards to be sent to each dial including decimals.
_dialIds
uint256[]
Dial identifiers for which to distribute rewards.
_voter
address
Address of the voter for which to re-cast.
_preferences
struct Preference[]
Structs containing dialId & voting weights, with 0 <= n <= 16 entries.
from
address
Account that votes moved from. If a mint the account will be a zero address.
to
address
Account that votes moved to. If a burn the account will be a zero address.
amount
uint256
The number of votes moved including the decimal places.