Closed sichen1234 closed 3 years ago
This can be done as a parameter from command line using hardhat
See commits: https://github.com/opentaps/blockchain-carbon-accounting/commit/6f84285b6036ac49fd27b681d6b909ef7079c6d3 https://github.com/opentaps/blockchain-carbon-accounting/commit/600e98759d7d6a4b9f96ea9158df89e9224bf570
npx hardhat setQuorum --network localhost --contract [contractaddress] --value [newquorumvalue]
. Since the dCLM8 token has 18 decimal places, be sure to pad with zeros at the end of the number.I tried
$ npx hardhat setQuorum --network localhost --contract 0x610178dA211FEF7D417bC0e6FeD39F05609AD788 --value 500.000000000000000000
but got error
{ Error: invalid BigNumber string (argument="value", value="500.000000000000000000", code=INVALID_ARGUMENT, version=bignumber/5.1.0) at Logger.makeError (/Users/sichen/hyperledger/blockchain-carbon-accounting/net-emissions-token-network/node_modules/@ethersproject/logger/src.ts/index.ts:205:28) at Logger.throwError (/Users/sichen/hyperledger/blockchain-carbon-accounting/net-emissions-token-network/node_modules/@ethersproject/logger/src.ts/index.ts:217:20) at Logger.throwArgumentError (/Users/sichen/hyperledger/blockchain-carbon-accounting/net-emissions-token-network/node_modules/@ethersproject/logger/src.ts/index.ts:221:21) at Function.BigNumber.from (/Users/sichen/hyperledger/blockchain-carbon-accounting/net-emissions-token-network/node_modules/@ethersproject/bignumber/src.ts/bignumber.ts:240:27) at NumberCoder.encode (/Users/sichen/hyperledger/blockchain-carbon-accounting/net-emissions-token-network/node_modules/@ethersproject/abi/src.ts/coders/number.ts:25:27) at /Users/sichen/hyperledger/blockchain-carbon-accounting/net-emissions-token-network/node_modules/@ethersproject/abi/src.ts/coders/array.ts:71:19 at Array.forEach (<anonymous>) at Object.pack (/Users/sichen/hyperledger/blockchain-carbon-accounting/net-emissions-token-network/node_modules/@ethersproject/abi/src.ts/coders/array.ts:54:12) at TupleCoder.encode (/Users/sichen/hyperledger/blockchain-carbon-accounting/net-emissions-token-network/node_modules/@ethersproject/abi/src.ts/coders/tuple.ts:54:16) at AbiCoder.encode (/Users/sichen/hyperledger/blockchain-carbon-accounting/net-emissions-token-network/node_modules/@ethersproject/abi/src.ts/abi-coder.ts:112:15) reason: 'invalid BigNumber string', code: 'INVALID_ARGUMENT', argument: 'value', value: '500.000000000000000000' }
Can you give an example that works?
If I run npx hardhat getQuorum --network localhost --contract 0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9
immediately after npx hardhat node
I get the value 632000000000
which is 632 (or about sqrt(400000)) with 9 zeros.
If I want to lower quorum to 100 votes, I put 100 followed by 9 zeros: npx hardhat setQuorum --network localhost --contract 0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9 --value 100000000000
So I reduced my quroum to 100 votes, then had:
A second proposal was just "defeated" because it didn't have enough votes. Does "defeated" mean it didn't meet quorum threshold?
Defeated can either mean for votes < against votes or for votes < quorum. For example, here I lowered the quorum to 100, voted 98 votes on proposal 1, and it failed. I voted 100 votes for proposal 2 and it succeeded (although the reward calculation needs to be fixed since it just counts votes currently). Quorum is the minimum of for votes rather than minimum total votes on a proposal.
Implemented a new Quorum Failed state to distinguish between Defeated and not met Quorum. This is all working now.
The contract owner should have the ability to set quorum for voting on DAO proposals. A default could be set for all proposals during a period of time until changed.