Skip to content
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
wants to merge 131 commits into
base: v2.1
Choose a base branch
from
Open

Governance 2.0 (REP + DXD) #309

wants to merge 131 commits into from

Conversation

MiltonTulli
Copy link
Member

@MiltonTulli MiltonTulli commented Feb 10, 2023

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: a DAOReputation token and a DXDInfluence 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

  • Maximum commitment time defined by governance.
  • ERC20SnapshotUpgradeable & OwnableUpgradeable.
  • Non transferable.
  • Mints/burns influence equivalence for each DXD staked/withdrawn.
  • A stake commitment can be increased before completion.
  • Early withdrawals with penalization.
  • 1 DXD = 1 stDXD
  • The user who staked can decide to withdraw the stake or leave it in the contract after the commitment is completed. The DXD Influence will remain active till the stake is withdrawn.

DXDInfluence.sol

  • It is owned by the DXDStake contract, which has permission to mint and burn influence.
  • It's not ERC20, but it exposes balanceOf(), balanceOfAt(), totalSupply(), totalSupplyAt() and decimals(). Influence balance cannot be transferred.
  • Each stake change is snapshotted and notified to the Voting Power Token contract.
  • The influence formula consists of a linear and an exponential term: 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 and b 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:

  1. non monotonic, monotonically non-decreasing or monotonically decreasing.
  2. convex, concave or linear (b = 0).
  3. always positive, always negative or a combination of both.

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 modifying k. On the other hand, a and b can be modified at any time by governance, because we can simply store sum(stake.tc) and sum(stake.tc^k) and later calculate the final influence value on the fly.

MiltonTulli and others added 30 commits January 24, 2023 11:26
@AugustoL AugustoL changed the title dxdao-contracts v2.1 Governance 2.0 (REP + DXD) Mar 7, 2023
contracts/dao/DAOReputation.sol Outdated Show resolved Hide resolved
contracts/dao/DAOReputation.sol Outdated Show resolved Hide resolved
contracts/dao/VotingPower.sol Outdated Show resolved Hide resolved
contracts/dao/VotingPower.sol Outdated Show resolved Hide resolved
contracts/dao/VotingPower.sol Outdated Show resolved Hide resolved
contracts/dao/VotingPower.sol Outdated Show resolved Hide resolved
contracts/dao/VotingPower.sol Outdated Show resolved Hide resolved
contracts/dao/VotingPower.sol Outdated Show resolved Hide resolved
contracts/dao/VotingPower.sol Outdated Show resolved Hide resolved
@MiltonTulli MiltonTulli requested a review from fnanni-0 March 10, 2023 15:24
@fnanni-0
Copy link
Contributor

Thanks @MiltonTulli, the changes look good!

@MiltonTulli MiltonTulli marked this pull request as ready for review May 9, 2023 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants