Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions contracts/CErc20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ contract CErc20 is CToken, CErc20Interface {
require(success, "TOKEN_TRANSFER_OUT_FAILED");
}

// TODO: delete
/**
* @notice Admin call to delegate the votes of the COMP-like underlying
* @param compLikeDelegatee The address to delegate votes to
Expand Down
2 changes: 2 additions & 0 deletions contracts/CErc20Immutable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ pragma solidity ^0.5.16;

import "./CErc20.sol";

// TODO: need to figure if this is useful for Canto Lending market (probably useful)

/**
* @title Compound's CErc20Immutable Contract
* @notice CTokens which wrap an EIP-20 underlying and are immutable
Expand Down
3 changes: 3 additions & 0 deletions contracts/Comptroller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,8 @@ contract Comptroller is ComptrollerV7Storage, ComptrollerInterface, ComptrollerE
* @param amount The amount of COMP to (possibly) transfer
* @return The amount of COMP which was NOT transferred to the user
*/

//TODO: Modify this function to grant CANTO Tokens
function grantCompInternal(address user, uint amount) internal returns (uint) {
Comp comp = Comp(getCompAddress());
uint compRemaining = comp.balanceOf(address(this));
Expand Down Expand Up @@ -1461,6 +1463,7 @@ contract Comptroller is ComptrollerV7Storage, ComptrollerInterface, ComptrollerE
* @notice Return the address of the COMP token
* @return The address of COMP
*/
//TODO: Edit this to the address of the contract with CANTO Tokens
function getCompAddress() public view returns (address) {
return 0xc00e94Cb662C3520282E6f5717214004A7f26888;
}
Expand Down
9 changes: 7 additions & 2 deletions contracts/ComptrollerG7.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import "./ComptrollerStorage.sol";
import "./Unitroller.sol";
import "./Governance/Comp.sol";

// TODO: need to confirm that g7 is latest comptroller; why are there still commits being made on original Comptroller - https://github.com/compound-finance/compound-protocol/commits/master/contracts/Comptroller.sol

/**
* @title Compound's Comptroller Contract
* @author Compound
Expand Down Expand Up @@ -551,7 +553,7 @@ contract ComptrollerG7 is ComptrollerV5Storage, ComptrollerInterface, Comptrolle

// Keep the flywheel moving
updateCompSupplyIndex(cTokenCollateral);
distributeSupplierComp(cTokenCollateral, borrower);
distributeSupplierComp(cTokenCollateral, borrower); // TODO: why is suppliercomp distributed to borrower
distributeSupplierComp(cTokenCollateral, liquidator);

return uint(Error.NO_ERROR);
Expand Down Expand Up @@ -1090,7 +1092,8 @@ contract ComptrollerG7 is ComptrollerV5Storage, ComptrollerInterface, Comptrolle
emit CompSpeedUpdated(cToken, compSpeed);
}
}


// TODO: need to understand where the drip tokens are being created; what functions are distributing them?
/**
* @notice Accrue COMP to the market by updating the supply index
* @param cToken The market whose supply index to update
Expand Down Expand Up @@ -1247,6 +1250,7 @@ contract ComptrollerG7 is ComptrollerV5Storage, ComptrollerInterface, Comptrolle
}
}

// TODO: need to change this transfer Canto instead of Comp
/**
* @notice Transfer COMP to the user
* @dev Note: If there is not enough COMP, we do not perform the transfer all.
Expand Down Expand Up @@ -1323,6 +1327,7 @@ contract ComptrollerG7 is ComptrollerV5Storage, ComptrollerInterface, Comptrolle
return block.number;
}

// TODO: modify this to the Canto Address
/**
* @notice Return the address of the COMP token
* @return The address of COMP
Expand Down
2 changes: 2 additions & 0 deletions contracts/Governance/Comp.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
pragma solidity ^0.5.16;
pragma experimental ABIEncoderV2;

// TODO: delete this file; may need to create an EIP-20 interface for Canto token

contract Comp {
/// @notice EIP-20 token name for this token
string public constant name = "Compound";
Expand Down
41 changes: 39 additions & 2 deletions contracts/Governance/GovernorBravoDelegateG2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import "./GovernorBravoInterfaces.sol";

contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoEvents {

/*
TODO: remove all constants related to creating and approving proposals

/// @notice The name of this contract
string public constant name = "Compound Governor Bravo";

Expand All @@ -28,13 +31,16 @@ contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoE

/// @notice The number of votes in support of a proposal required in order for a quorum to be reached and for a vote to succeed
uint public constant quorumVotes = 400000e18; // 400,000 = 4% of Comp
*/

/// @notice The maximum number of actions that can be included in a proposal
uint public constant proposalMaxOperations = 10; // 10 actions


// TODO: figure out if we need DOMAIN_TYPEHASH
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");

// TODO: delete BALLOT_TYPEHASH
/// @notice The EIP-712 typehash for the ballot struct used by the contract
bytes32 public constant BALLOT_TYPEHASH = keccak256("Ballot(uint256 proposalId,uint8 support)");

Expand All @@ -50,16 +56,26 @@ contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoE
require(address(timelock) == address(0), "GovernorBravo::initialize: can only initialize once");
require(msg.sender == admin, "GovernorBravo::initialize: admin only");
require(timelock_ != address(0), "GovernorBravo::initialize: invalid timelock address");

// TODO: replace comp initialization with canto initialization
require(comp_ != address(0), "GovernorBravo::initialize: invalid comp address");

/*
TODO: remove all checks for voting and proposal thresholds
require(votingPeriod_ >= MIN_VOTING_PERIOD && votingPeriod_ <= MAX_VOTING_PERIOD, "GovernorBravo::initialize: invalid voting period");
require(votingDelay_ >= MIN_VOTING_DELAY && votingDelay_ <= MAX_VOTING_DELAY, "GovernorBravo::initialize: invalid voting delay");
require(proposalThreshold_ >= MIN_PROPOSAL_THRESHOLD && proposalThreshold_ <= MAX_PROPOSAL_THRESHOLD, "GovernorBravo::initialize: invalid proposal threshold");
*/

timelock = TimelockInterface(timelock_);
// TODO: replace comp and CompInterface with Canto declaration
comp = CompInterface(comp_);
/*
TODO: delete these; no need for voting logic
votingPeriod = votingPeriod_;
votingDelay = votingDelay_;
proposalThreshold = proposalThreshold_;
*/
}

/**
Expand All @@ -71,6 +87,8 @@ contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoE
* @param description String description of the proposal
* @return Proposal id of new proposal
*/
/**
TODO: delete this propose function; proposals will be sent from off-chain and directly to the queue function below
function propose(address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas, string memory description) public returns (uint) {
// Reject proposals before initiating as Governor
require(initialProposalId != 0, "GovernorBravo::propose: Governor Bravo not active");
Expand Down Expand Up @@ -114,6 +132,7 @@ contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoE
emit ProposalCreated(newProposal.id, msg.sender, targets, values, signatures, calldatas, startBlock, endBlock, description);
return newProposal.id;
}
*/

/**
* @notice Queues a proposal of state succeeded
Expand All @@ -122,6 +141,7 @@ contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoE
function queue(uint proposalId) external {
require(state(proposalId) == ProposalState.Succeeded, "GovernorBravo::queue: proposal can only be queued if it is succeeded");
Proposal storage proposal = proposals[proposalId];
// TODO: need to look into definition of timelock delay - make sure it meets our requirements
uint eta = add256(block.timestamp, timelock.delay());
for (uint i = 0; i < proposal.targets.length; i++) {
queueOrRevertInternal(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], eta);
Expand Down Expand Up @@ -154,6 +174,8 @@ contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoE
* @param proposalId The id of the proposal to cancel
*/
function cancel(uint proposalId) external {
// TODO: only admin can cancel contracts; change logic here accordingly

require(state(proposalId) != ProposalState.Executed, "GovernorBravo::cancel: cannot cancel executed proposal");

Proposal storage proposal = proposals[proposalId];
Expand Down Expand Up @@ -187,6 +209,7 @@ contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoE
return (p.targets, p.values, p.signatures, p.calldatas);
}

// TODO: delete getReceipt
/**
* @notice Gets the receipt for a voter on a given proposal
* @param proposalId the id of proposal
Expand All @@ -203,6 +226,8 @@ contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoE
* @return Proposal state
*/
function state(uint proposalId) public view returns (ProposalState) {
// TODO: remove all logic related to proposal voting from here
// TODO: delete PENDING, DEFEATED, Canceled, Active, Succeeded state logic
require(proposalCount >= proposalId && proposalId > initialProposalId, "GovernorBravo::state: invalid proposal id");
Proposal storage proposal = proposals[proposalId];
if (proposal.canceled) {
Expand All @@ -217,13 +242,15 @@ contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoE
return ProposalState.Succeeded;
} else if (proposal.executed) {
return ProposalState.Executed;
// TODO: when is the Expired state needed? why add a grace period?
} else if (block.timestamp >= add256(proposal.eta, timelock.GRACE_PERIOD())) {
return ProposalState.Expired;
} else {
return ProposalState.Queued;
}
}

// TODO: delete castVote
/**
* @notice Cast a vote for a proposal
* @param proposalId The id of the proposal to vote on
Expand All @@ -233,6 +260,7 @@ contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoE
emit VoteCast(msg.sender, proposalId, support, castVoteInternal(msg.sender, proposalId, support), "");
}

// TODO: delete castVoteWithReason
/**
* @notice Cast a vote for a proposal with a reason
* @param proposalId The id of the proposal to vote on
Expand All @@ -243,6 +271,7 @@ contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoE
emit VoteCast(msg.sender, proposalId, support, castVoteInternal(msg.sender, proposalId, support), reason);
}

// TODO: delete castVoteBySig
/**
* @notice Cast a vote for a proposal by signature
* @dev External function that accepts EIP-712 signatures for voting on proposals.
Expand All @@ -256,6 +285,7 @@ contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoE
emit VoteCast(signatory, proposalId, support, castVoteInternal(signatory, proposalId, support), "");
}

// TODO: delete castVoteInternal
/**
* @notice Internal function that caries out voting logic
* @param voter The voter that is casting their vote
Expand Down Expand Up @@ -285,7 +315,8 @@ contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoE

return votes;
}


// TODO: delete isWhitelisted
/**
* @notice View function which returns if an account is whitelisted
* @param account Account to check white list status of
Expand All @@ -295,6 +326,7 @@ contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoE
return (whitelistAccountExpirations[account] > now);
}

// TODO: delete _setVotingDelay
/**
* @notice Admin function for setting the voting delay
* @param newVotingDelay new voting delay, in blocks
Expand All @@ -308,6 +340,7 @@ contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoE
emit VotingDelaySet(oldVotingDelay,votingDelay);
}

// TODO: delete _setVotingPeriod
/**
* @notice Admin function for setting the voting period
* @param newVotingPeriod new voting period, in blocks
Expand All @@ -321,6 +354,7 @@ contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoE
emit VotingPeriodSet(oldVotingPeriod, votingPeriod);
}

// TODO: delete _setProposalThreshold
/**
* @notice Admin function for setting the proposal threshold
* @dev newProposalThreshold must be greater than the hardcoded min
Expand All @@ -335,6 +369,7 @@ contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoE
emit ProposalThresholdSet(oldProposalThreshold, proposalThreshold);
}

// TODO: delete _setWhitelistAccountExpiration
/**
* @notice Admin function for setting the whitelist expiration as a timestamp for an account. Whitelist status allows accounts to propose without meeting threshold
* @param account Account address to set whitelist expiration for
Expand All @@ -347,6 +382,7 @@ contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoE
emit WhitelistAccountExpirationSet(account, expiration);
}

// TODO: delete _setWhitelistGuardian
/**
* @notice Admin function for setting the whitelistGuardian. WhitelistGuardian can cancel proposals from whitelisted addresses
* @param account Account to set whitelistGuardian to (0x0 to remove whitelistGuardian)
Expand All @@ -359,6 +395,7 @@ contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoE
emit WhitelistGuardianSet(oldGuardian, whitelistGuardian);
}

// TODO: delete _initiate
/**
* @notice Initiate the GovernorBravo contract
* @dev Admin only. Sets initial proposal id which initiates the contract, ensuring a continuous proposal id count
Expand Down
Loading