-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Governance 2.0 (REP + DXD) #309
Open
MiltonTulli
wants to merge
131
commits into
v2.1
Choose a base branch
from
feat/voting-power
base: v2.1
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature/vp token
Feat/dxdstake
…alTokens from weight getters
Fix token weights
Use voting power for scheme and voting machine
…upgradeable-4.4.0 refactor: rollback to oz upgradeable 4.4.0
refactor: only allow owner to withdraw his stake
test: fix dxd staking
fnanni-0
reviewed
Mar 9, 2023
Thanks @MiltonTulli, the changes look good! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
With the changes proposed here, DXdao will be able to be governed both by REP holders and DXD holders. How much voting power a user will have to vote on proposals will be a a combination of both tokens balances. How this balances are combined is explained below.
VotingPower.sol
This contract provides a function to determine the balance (or voting power percent) of a specific holder based on the relative
weights
of two different ERC20Snapshot tokens: aDAOReputation
token and aDXDInfluence
token. Voting Power itself is ERC20Snapshot and it contains a snapshot for each snapshot of the underlying tokens. The voting power balance will equal:voting power = DAOReputation_weight.(DAOReputation_balanceOf / DAOReputation_totalSupply) +
DXDInfluence_weight.(DXDInfluence_balanceOf / DXDInfluence_totalSupply)
Balances are normalize by dividing them by the respective token total supply. The weights of the underlying tokens are managed by governance. Additionally, the contract sets a minimum requirement for the total amount of DXDInfluence tokens that must be locked in order to apply configurable weight to the DXDInfluence token.
DXDStake.sol
DXDInfluence.sol
balanceOf()
,balanceOfAt()
,totalSupply()
,totalSupplyAt()
anddecimals()
. Influence balance cannot be transferred.stake.a.tc + stake.b.tc^k
, where:stake
is the DXD amount staked in the DXDStake contract. A user can have many stakes.tc
is the time commitment of the given stake amount. A user can stake different as many times as he wishes with the same or different time commitments.a
andb
are mutable, rational numbers defined by governance.k
is an immutable, rational number.More about the influence formula and its implementation
The idea behind using a complex formula to calculate the influence a DXD staker should have on the DAO governance, is to give more voting power to holders who commit to invest in DXDao in the long term. Someone who will hold DXD for 3 years should probably have more voting power than someone who just got DXD and might sell soon. In other words, the longer someone locks their DXD, the more voting power they will get.
However, using a linear function might be either too unfair to short term holders or to long term holders. Should a 4-years holder have double the influence of a 2-years holder? With the formula proposed here, the DAO can have a lot of flexibility regarding how much governance influence someone has for each additional second they commit to stake DXD.
The formula
Let's define influence as
i(t) = a.t + b.t^k
, where a, b and k are rational numbers and 0 < t < t_max. Depending on how a, b, k and t_max are defined,i(t)
will have the following properties:a, b, k and t_max should be defined so that the influence is a positive, convex or concave, monotonically non-decreasing function (i.e. the longer you stake, the more influence you get). This is NOT enforced at the smart contract level, but must be taken care of by the owner of the contract, i.e. the DAO. Wrong parameter setups, except for k and possibly t_max, can be reverted and do not break the contract but could make some balanceOfAt revert. Play around with the formula here (x is time expressed in seconds).
The implementation
Let's redefine
i(t)
as:influence(tc, account) = sum(stake.a.tc + stake.b.tc^k)
over all stakes for a given account, where tc: time commitment of each stake.This can be rearranged as:
influence(tc, account) = a * sum(stake.tc) + b * sum(stake.tc^k)
From this we can conclude that
k
has to be immutable, because otherwise an immense amount of computation would be needed to recalculate user's balances after modifyingk
. On the other hand,a
andb
can be modified at any time by governance, because we can simply storesum(stake.tc)
andsum(stake.tc^k)
and later calculate the final influence value on the fly.