Skip to content

Commit

Permalink
Add Comp and Governor Alpha Contracts [Release Candidate 2]
Browse files Browse the repository at this point in the history
This patch adds the Comp Token and Governor Alpha contracts. The Comp token represents the administrative rights of the protocol, divided into 10,000,000 fungible tokens. These tokens have governance rights in the Governor contract, which in turn will become the admin of the Compound Timelock that administers the Compound Comptroller and cToken contracts.

The Comp Token is a basic Erc-20 with an ability to delegate to third parties. The goal of delegation is that an account could delegate his/her voting rights in the Governor to a hot-wallet or trusted third-party which is paying closer attention to governance proposals.

The Governor Alpha system is a simple vote-based governor which allows Comp Token holders to propose and ratify specific Ethereum actions. For instance, a user with sufficient tokens could propose supporting a new market in the Compound Comptroller. All Comp Token delegees will then have the ability over some period to vote on that proposal, and if its ratified, it can be automatically executed (through the Compound Timelock).

Delegation is unique in the fact it's tracked by block, forever, for each account. This allows us to say "how many delegated votes existed for X account at block Y." We then say that your votes for a given proposal are the amount of votes you had delegated at the time the proposal was created. In this way, we prevent sybil attacks without forcing users to lock tokens before voting.

Patch Notes 1:

Reduced storage typing to prevent potentially unsafe downcasts. These sizes are enforced due to the limited total number of Comp tokens (10MM tokens with 18 decimal precision).
A proposal cannot be queued if an identical action already exists in the Timelock. This will prevent two proposals with identical actions from conflicting and explicitly make it impossible to ever enqueue a proposal that itself has two identical proposals.
We add more scenarios and formal analysis tests.
Patch Notes 2:

This patch builds our official release candidates for the Comp and Governor Alpha systems. We make a number of minor changes from the 2.5 Alpha 2 version, including:

Change proposal and quorum thresholds to 1% and 4% respectively
Make a number of cosmetic changes and updates to events
Add test-net deployments [Ropsten, Goerli]
Add additional unit tests, scenarios and formal verification
Upgrade saddle to include saddle console
Upgrade Docker for newest version

Patch Notes 3:

This patch includes minor updates:

* Bump to Solidity 0.5.16
* Increase coverage of formal verification
* Add updated Ropsten deployment
* Add tBTC token
* Rename Comp token to simply "Compound"
  • Loading branch information
hayesgm committed Feb 26, 2020
1 parent 55729b3 commit 63c992c
Show file tree
Hide file tree
Showing 85 changed files with 17,446 additions and 6,530 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
steps:
- run:
|
sudo wget https://github.com/ethereum/solidity/releases/download/v0.5.13/solc-static-linux -O /usr/local/bin/solc
sudo wget https://github.com/ethereum/solidity/releases/download/v0.5.16/solc-static-linux -O /usr/local/bin/solc
sudo chmod +x /usr/local/bin/solc
- checkout
- restore_cache:
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
steps:
- run:
|
sudo wget https://github.com/ethereum/solidity/releases/download/v0.5.13/solc-static-linux -O /usr/local/bin/solc
sudo wget https://github.com/ethereum/solidity/releases/download/v0.5.16/solc-static-linux -O /usr/local/bin/solc
sudo chmod +x /usr/local/bin/solc
- checkout
- restore_cache:
Expand Down
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ junit.xml
.build
.last_confs
.git
script/certora
script/certora
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ spec/certora/Governor/%.cvl:
spec/certora/contracts/GovernorAlphaCertora.sol \
spec/certora/contracts/TimelockCertora.sol \
spec/certora/contracts/CompCertora.sol \
--settings -assumeUnwindCond,-enableWildcardInlining=false \
--solc_args "'--evm-version istanbul'" \
--link \
GovernorAlphaCertora:timelock=TimelockCertora \
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,15 @@ Formal Verification Specs
-------------------------

The Compound Protocol has a number of formal verification specifications, powered by [Certora](https://www.certora.com/). You can find details in the [spec/formal](https://github.com/compound-finance/compound-protocol/tree/master/spec/formal) folder. The Certora Verification Language (CVL) files included are specifications, which when with the Certora CLI tool, produce formal proofs (or counter-examples) that the code of a given contract exactly matches that specification.
=======
See the [Scenario Docs](https://github.com/compound-finance/money-market/tree/master/scenario/SCENARIO.md) on steps for using the repl.

Testing
-------
Contract tests are defined under the [tests directory](https://github.com/compound-finance/money-market/tree/master/tests). To run the tests run:

yarn test
>>>>>>> Compound Token and Governance (#519)
Code Coverage
-------------
Expand Down
2 changes: 1 addition & 1 deletion contracts/CDaiDelegate.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.12;
pragma solidity ^0.5.16;

import "./CErc20Delegate.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/CErc20.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.12;
pragma solidity ^0.5.16;

import "./CToken.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/CErc20Delegate.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.12;
pragma solidity ^0.5.16;

import "./CErc20.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/CErc20Delegator.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.12;
pragma solidity ^0.5.16;

import "./CTokenInterfaces.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/CErc20Immutable.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.12;
pragma solidity ^0.5.16;

import "./CErc20.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/CEther.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.12;
pragma solidity ^0.5.16;

import "./CToken.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/CToken.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.12;
pragma solidity ^0.5.16;

import "./ComptrollerInterface.sol";
import "./CTokenInterfaces.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/CTokenInterfaces.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.12;
pragma solidity ^0.5.16;

import "./ComptrollerInterface.sol";
import "./InterestRateModel.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/CarefulMath.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.12;
pragma solidity ^0.5.16;

/**
* @title Careful Math
Expand Down
2 changes: 1 addition & 1 deletion contracts/Comptroller.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.12;
pragma solidity ^0.5.16;

import "./CToken.sol";
import "./ErrorReporter.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/ComptrollerG1.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.12;
pragma solidity ^0.5.16;

import "./CToken.sol";
import "./ErrorReporter.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/ComptrollerInterface.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.12;
pragma solidity ^0.5.16;

interface ComptrollerInterface {
/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/ComptrollerStorage.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.12;
pragma solidity ^0.5.16;

import "./CToken.sol";
import "./PriceOracle.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/DAIInterestRateModel.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.12;
pragma solidity ^0.5.16;

import "./JumpRateModel.sol";
import "./SafeMath.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/EIP20Interface.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.12;
pragma solidity ^0.5.16;

/**
* @title ERC 20 Token Standard Interface
Expand Down
2 changes: 1 addition & 1 deletion contracts/EIP20NonStandardInterface.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.12;
pragma solidity ^0.5.16;

/**
* @title EIP20NonStandardInterface
Expand Down
2 changes: 1 addition & 1 deletion contracts/ErrorReporter.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.12;
pragma solidity ^0.5.16;

contract ComptrollerErrorReporter {
enum Error {
Expand Down
2 changes: 1 addition & 1 deletion contracts/Exponential.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.12;
pragma solidity ^0.5.16;

import "./CarefulMath.sol";

Expand Down
4 changes: 2 additions & 2 deletions contracts/Governance/Comp.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.12;
pragma solidity ^0.5.16;
pragma experimental ABIEncoderV2;

import "../EIP20Interface.sol";
Expand All @@ -10,7 +10,7 @@ import "../EIP20Interface.sol";
*/
contract Comp is EIP20Interface {
/// @notice EIP-20 token name for this token
string public constant name = "Compound Governance Token";
string public constant name = "Compound";

/// @notice EIP-20 token symbol for this token
string public constant symbol = "COMP";
Expand Down
4 changes: 2 additions & 2 deletions contracts/Governance/GovernorAlpha.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.12;
pragma solidity ^0.5.16;
pragma experimental ABIEncoderV2;

import "../SafeMath.sol";
Expand Down Expand Up @@ -36,7 +36,7 @@ contract GovernorAlpha {
function votingDelay() public pure returns (uint) { return 1; } // 1 block

/// @notice The duration of voting on a proposal, in blocks
function votingPeriod() public pure returns (uint) { return 17280; } // 3 days in blocks
function votingPeriod() public pure returns (uint) { return 17280; } // ~3 days in blocks (assuming 15s blocks)

/// @notice The address of the Compound Protocol Timelock
TimelockInterface public timelock;
Expand Down
2 changes: 1 addition & 1 deletion contracts/InterestRateModel.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.12;
pragma solidity ^0.5.16;

/**
* @title Compound's InterestRateModel Interface
Expand Down
2 changes: 1 addition & 1 deletion contracts/JumpRateModel.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.12;
pragma solidity ^0.5.16;

import "./InterestRateModel.sol";
import "./SafeMath.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/Maximillion.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.12;
pragma solidity ^0.5.16;

import "./CEther.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/PriceOracle.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.12;
pragma solidity ^0.5.16;

import "./CToken.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/PriceOracleProxy.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.12;
pragma solidity ^0.5.16;

import "./CErc20.sol";
import "./CToken.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/SafeMath.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.12;
pragma solidity ^0.5.16;

// From https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/math/Math.sol
// Subject to the MIT license.
Expand Down
2 changes: 1 addition & 1 deletion contracts/SimplePriceOracle.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.12;
pragma solidity ^0.5.16;

import "./PriceOracle.sol";
import "./CErc20.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/Timelock.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.12;
pragma solidity ^0.5.16;

import "./SafeMath.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/Unitroller.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.12;
pragma solidity ^0.5.16;

import "./ErrorReporter.sol";
import "./ComptrollerStorage.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/WhitePaperInterestRateModel.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.12;
pragma solidity ^0.5.16;

import "./InterestRateModel.sol";
import "./SafeMath.sol";
Expand Down
11 changes: 11 additions & 0 deletions networks/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"Base500bps_Slope1200bps": "0xa1046abfc2598F48C44Fb320d281d3F3c0733c9a",
"cSAI": "0xF5DCe57282A584D2746FaF1593d3121Fcac444dC",
"Timelock": "0x6d903f6003cca6255D85CcA4D3B5E5146dC33925",
"Base200bps_Slope1000bps": "0x0c3f8df27e1a00b47653fde878d68d35f00714c0",
"Base200bps_Slope3000bps": "0xBAE04CbF96391086dC643e842b517734E214D698",
"cREP": "0x158079Ee67Fce2f58472A96584A73C7Ab9AC95c1",
"ComptrollerG2": "0xf592eF673057a451c49c9433E278c5d59b56132c",
Expand Down Expand Up @@ -49,6 +50,7 @@
"Base500bps_Slope1200bps": 7710726,
"cSAI": 7710752,
"Timelock": 8722895,
"Base200bps_Slope1000bps": 9321474,
"Base200bps_Slope3000bps": 7710728,
"cREP": 7710755,
"ComptrollerG2": 8722898,
Expand Down Expand Up @@ -106,6 +108,7 @@
"Base500bps_Slope1200bps": "0x00000000000000000000000000000000000000000000000000b1a2bc2ec5000000000000000000000000000000000000000000000000000001aa535d3d0c0000",
"cSAI": "0x00000000000000000000000089d24a6b4ccb1b6faa2625fe562bdd9a232603590000000000000000000000003d9819210a31b4961b30ef54be2aed79b9c9cd3b000000000000000000000000a1046abfc2598f48c44fb320d281d3f3c0733c9a000000000000000000000000000000000000000000a56fa5b99019a5c800000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c436f6d706f756e6420446169000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000046344414900000000000000000000000000000000000000000000000000000000",
"Timelock": "0x0000000000000000000000008b8592e9570e96166336603a1b4bd1e8db20fa20000000000000000000000000000000000000000000000000000000000002a300",
"Base200bps_Slope1000bps": "0x00000000000000000000000000000000000000000000000000470de4df820000000000000000000000000000000000000000000000000000016345785d8a0000",
"Base200bps_Slope3000bps": "0x00000000000000000000000000000000000000000000000000470de4df8200000000000000000000000000000000000000000000000000000429d069189e0000",
"cREP": "0x0000000000000000000000001985365e9f78359a9b6ad760e32412f4a445e8620000000000000000000000003d9819210a31b4961b30ef54be2aed79b9c9cd3b000000000000000000000000bae04cbf96391086dc643e842b517734e214d698000000000000000000000000000000000000000000a56fa5b99019a5c800000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e436f6d706f756e6420417567757200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000046352455000000000000000000000000000000000000000000000000000000000",
"ComptrollerG2": "0x",
Expand Down Expand Up @@ -339,6 +342,14 @@
"slope": "200000000000000000",
"address": "0xc64C4cBA055eFA614CE01F4BAD8A9F519C4f8FaB"
},
"Base200bps_Slope1000bps": {
"name": "Base200bps_Slope1000bps",
"contract": "WhitePaperInterestRateModel",
"description": "WhitePaper baseRate=20000000000000000 multiplier=100000000000000000",
"base": "20000000000000000",
"slope": "100000000000000000",
"address": "0x0c3f8df27e1a00b47653fde878d68d35f00714c0"
},
"Base200bps_Slope3000bps": {
"name": "Base200bps_Slope3000bps",
"contract": "WhitePaperInterestRateModel",
Expand Down

0 comments on commit 63c992c

Please sign in to comment.