-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added test framework with minimal deploy script (#17)
* Added test framework with minimal deploy script * forge fmt constant cleanup * Added TODO about constants
- Loading branch information
1 parent
9302835
commit 5309e98
Showing
6 changed files
with
115 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ contracts* | |
typechain-types | ||
out | ||
lib | ||
script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
RPC_URL= | ||
ETHERSCAN_API_KEY= | ||
DEPLOYER_ADDRESS= | ||
DEPLOYER_PRIVATE_KEY= | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// SPDX-License-Identifier: MIT | ||
// slither-disable-start reentrancy-benign | ||
pragma solidity 0.8.26; | ||
|
||
contract CompoundGovernorConstants { | ||
// TODO: Verify these values are correct for launch of the CompoundGovernor | ||
|
||
// These constants are taken from the existing GovernorBravoDelegate contract. | ||
|
||
uint48 INITIAL_VOTING_DELAY = 13_140; // The delay before voting takes place, in blocks | ||
uint32 INITIAL_VOTING_PERIOD = 19_710; // The duration of voting on a proposal, in blocks | ||
uint256 INITIAL_PROPOSAL_THRESHOLD = 25_000e18; // Votes required in order for a voter to become proposer | ||
uint256 INITIAL_QUORUM = 400_000e18; // 400,000 = 4% of Comp | ||
|
||
uint48 INITIAL_VOTE_EXTENSION = 7200; // Prevents sudden token moves before voting ends (2 days of blocks) | ||
|
||
// The address of the COMP token | ||
address COMP_TOKEN_ADDRESS = 0xc00e94Cb662C3520282E6f5717214004A7f26888; | ||
|
||
// The address of the Timelock | ||
address payable TIMELOCK_ADDRESS = payable(0x6d903f6003cca6255D85CcA4D3B5E5146dC33925); | ||
|
||
// The fork block for testing | ||
uint256 FORK_BLOCK = 20_885_000; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// slither-disable-start reentrancy-benign | ||
|
||
pragma solidity 0.8.26; | ||
|
||
import {Script} from "forge-std/Script.sol"; | ||
import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; | ||
import {IVotes} from "@openzeppelin/contracts/governance/utils/IVotes.sol"; | ||
import {ICompoundTimelock} from "@openzeppelin/contracts/vendor/compound/ICompoundTimelock.sol"; | ||
import {CompoundGovernor} from "contracts/CompoundGovernor.sol"; | ||
import {CompoundGovernorConstants} from "script/CompoundGovernorConstants.sol"; | ||
|
||
// Deploy script for the underlying implementation that will be used by both Governor proxies | ||
contract DeployCompoundGovernor is Script, CompoundGovernorConstants { | ||
uint256 deployerPrivateKey; | ||
|
||
function setUp() public virtual { | ||
// private key of the deployer (use the anvil default account #0 key, if no environment variable is set) | ||
deployerPrivateKey = vm.envOr( | ||
"DEPLOYER_PRIVATE_KEY", uint256(0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80) | ||
); | ||
} | ||
|
||
function run(address _owner) public returns (CompoundGovernor _governor) { | ||
vm.startBroadcast(deployerPrivateKey); | ||
|
||
// Deploy Governor implementation contract | ||
CompoundGovernor _implementation = new CompoundGovernor(); | ||
|
||
bytes memory _initData = abi.encodeCall( | ||
CompoundGovernor.initialize, | ||
( | ||
INITIAL_VOTING_DELAY, | ||
INITIAL_VOTING_PERIOD, | ||
INITIAL_PROPOSAL_THRESHOLD, | ||
IVotes(COMP_TOKEN_ADDRESS), | ||
INITIAL_QUORUM, | ||
ICompoundTimelock(TIMELOCK_ADDRESS), | ||
INITIAL_VOTE_EXTENSION, | ||
_owner | ||
) | ||
); | ||
TransparentUpgradeableProxy _proxy = | ||
new TransparentUpgradeableProxy(address(_implementation), address(this), _initData); | ||
_governor = CompoundGovernor(payable(address(_proxy))); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |