-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added test framework with minimal deploy script #17
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ contracts* | |
typechain-types | ||
out | ||
lib | ||
script |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
RPC_URL= | ||
ETHERSCAN_API_KEY= | ||
DEPLOYER_ADDRESS= | ||
DEPLOYER_PRIVATE_KEY= | ||
|
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; | ||
} |
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( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it possible to avoid setting a PK in the env? Would prefer to let foundry manage the wallet instead. We run across this often, and i remember there's a limitation with calling scripts in tests. maybe this is something we can create an issue for. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added an issue: #18 |
||
"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(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey @jferas how confident are we that these are the constants we're going live with? should we put a TODO here (or better, an issue to verify these initialization params)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a TODO: 5c79b52
Also added an issue: #19