Skip to content

Instantly share code, notes, and snippets.

@Callum-A
Last active July 14, 2022 20:56
Show Gist options
  • Save Callum-A/53319b415246a89cade7e656fc8ff01d to your computer and use it in GitHub Desktop.
Save Callum-A/53319b415246a89cade7e656fc8ff01d to your computer and use it in GitHub Desktop.

CW-Multi-Voting

Contract Description

This contract implements the voting contract interface (via voting_query), it allows a DAO to use multiple voting contracts with different weightings. For example my DAO has a core-team which is a cw4-voting and the rest of the community via the DAOs token cw20-staked-balance-voting. We would like the core team to hold enough power to get the vote most of the way, however the community can always reject the core team. Lets model this using a 49%, 51% model, where the community has 51%.

This would be stored in the contract as:

cw20-staked-balance-voting-address -> 0.51

cw4-voting -> 0.49

Weighting

The powers will now need to be weighted accordingly:

Our cw4-group has a total weight of 2, (assume 2 members with 1 weight each).

Our cw20 has a total weight of 100, (assume 100 tokens to 2 people).

We can achieve this using percentages of each contracts VP, shown in the example below:

Token Weighting

There are two token holders, one holds 10, one holds 90. (Total 100)

Token Holder A % vote share = 10 / 100 = 10% = 0.1

Token Holder B % vote share = 90 / 100 = 90% = 0.9

Now we can apply the weights (51% to the token):

10% * 51% = 5.1% (this is their multi-voting power) 90% * 51% = 45.9%

Their total should come to 51%

5.1% + 45.9% = 51%

Multsig Weighting

Now we can do the same for the multisig, lets assume two multisig members with 1 weight each:

Multisig Member A % vote share = 1 / 2 = 50% = 0.5

Multisig Member B % vote share = 1 / 2 = 50% = 0.5

Now we can apply the weights (49% to the multisig)

50% * 49% = 24.5% 50% * 49% = 24.5%

Their total should come to 49%

24.5% + 24.5% = 49%

These totals give us our 100% voting power:

51% + 49% = 100%

NOTICE

This will probably need an accuracy factor such as 2^6 to multiply the numerators by to ensure we dont drop fractional votes. image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment