Skip to content

Commit

Permalink
feat: add government deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyar committed Sep 26, 2023
1 parent acf7475 commit 8041359
Show file tree
Hide file tree
Showing 8 changed files with 143 additions and 7 deletions.
10 changes: 10 additions & 0 deletions copy_contracts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ rm -rf contracts/oracle/contracts/test
mkdir -p ./contracts/protocol
cp -rf ./node_modules/@venusprotocol/venus-protocol/contracts/ ./contracts/protocol/contracts
rm -rf contracts/protocol/contracts/test
# Keep Access control interfacce
mv contracts/protocol/contracts/Governance/IAccessControlManager.sol contracts/protocol/contracts/IAccessControlManager.sol
rm -rf contracts/protocol/contracts/Governance
mkdir contracts/protocol/contracts/Governance
mv contracts/protocol/contracts/IAccessControlManager.sol contracts/protocol/contracts/Governance/IAccessControlManager.sol
rm -rf contracts/protocol/contracts/Lens/VenusLens.sol

mkdir -p ./contracts/mocks
cp -rf ./mocks/ ./contracts/mocks/contracts

mkdir -p ./contracts/governance
cp -rf ./node_modules/@venusprotocol/governance-contracts/contracts/ ./contracts/governance/contracts
rm -rf contracts/governance/contracts/test
19 changes: 19 additions & 0 deletions deploy/017-vaults.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { DeployFunction } from 'hardhat-deploy/types';
import { HardhatRuntimeEnvironment } from 'hardhat/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, getNamedAccounts } = hre;
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();

await deploy('XVSVault', {
from: deployer,
args: [],
log: true,
autoMine: true,
});
};

func.tags = ['Governance'];

export default func;
66 changes: 66 additions & 0 deletions deploy/018-governance.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { ethers } from 'hardhat';
import { DeployFunction } from 'hardhat-deploy/types';
import { HardhatRuntimeEnvironment } from 'hardhat/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, getNamedAccounts } = hre;
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();

const timelockDeployment = await deploy('Timelock', {
from: deployer,
args: [deployer, 3600],
log: true,
autoMine: true,
});

const governorBravoDelegateDeployment = await deploy('GovernorBravoDelegate', {
from: deployer,
args: [],
log: true,
autoMine: true,
});

const xvsVault = await ethers.getContract('XVSVault');

const governorBravoDelegate = await ethers.getContractAt(
'GovernorBravoDelegate',
governorBravoDelegateDeployment.address,
);
const minVotingDelay = await governorBravoDelegate.MIN_VOTING_DELAY();
const minVotingPeriod = await governorBravoDelegate.MIN_VOTING_PERIOD();
const minProposalThreshold = await governorBravoDelegate.MIN_PROPOSAL_THRESHOLD();
const proposalConfigs = [
{
votingDelay: minVotingDelay.add(3),
votingPeriod: minVotingPeriod.add(3),
proposalThreshold: minProposalThreshold.add(3),
},
{
votingDelay: minVotingDelay.add(2),
votingPeriod: minVotingPeriod.add(2),
proposalThreshold: minProposalThreshold.add(2),
},
{
votingDelay: minVotingDelay.add(1),
votingPeriod: minVotingPeriod.add(1),
proposalThreshold: minProposalThreshold.add(1),
},
];
const timelocks = [
timelockDeployment.address,
timelockDeployment.address,
timelockDeployment.address,
];
// await deploy("GovernorBravoDelegator", {
// from: deployer,
// args: [timelockDeployment.address, xvsVault.address, deployer, governorBravoDelegate.address, 30, 30, 100, deployer],
// log: true,
// autoMine: true,
// });
await governorBravoDelegate.initialize(xvsVault.address, proposalConfigs, timelocks, deployer);
};

func.tags = ['Governance'];

export default func;
29 changes: 29 additions & 0 deletions deploy/019-governance-access-control.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// import accessControll from '@venusprotocol/governance-contracts/dist/deploy/001-access-control';
// export default accessControll;
import { ethers } from 'hardhat';
import { DeployFunction } from 'hardhat-deploy/types';
import { HardhatRuntimeEnvironment } from 'hardhat/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, getNamedAccounts } = hre;
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();

const acmDeployment = await deploy('AccessControlManager', {
from: deployer,
args: [],
log: true,
autoMine: true,
});

const acm = await ethers.getContractAt('AccessControlManager', acmDeployment.address);

console.log(
`Renouncing DEFAULT_ADMIN_ROLE from deployer (${deployer}) for ${hre.network.name} network`,
);
await acm.renounceRole(acm.DEFAULT_ADMIN_ROLE(), deployer);
};

func.tags = ['AccessControl'];

export default func;
2 changes: 1 addition & 1 deletion mocks/AccessControlManager.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@venusprotocol/governance-contracts/contracts/Governance/AccessControlManager.sol";
import "../../governance/contracts/Governance/AccessControlManager.sol";

contract AccessControlManagerScenario is AccessControlManager {}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"@types/mustache": "^4.2.1",
"@typescript-eslint/eslint-plugin": "^5.40.1",
"@typescript-eslint/parser": "^5.40.1",
"@venusprotocol/governance-contracts": "^1.0.0",
"@venusprotocol/governance-contracts": "^1.0.1-dev.5",
"@venusprotocol/isolated-pools": "2.1.0-dev.2",
"@venusprotocol/oracle": "^1.7.2",
"@venusprotocol/venus-protocol": "^3.1.0",
Expand Down
12 changes: 12 additions & 0 deletions patches/@venusprotocol+governance-contracts+1.0.1-dev.5.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/node_modules/@venusprotocol/governance-contracts/contracts/Governance/GovernorBravoDelegate.sol b/node_modules/@venusprotocol/governance-contracts/contracts/Governance/GovernorBravoDelegate.sol
index 7169423..bfe0b64 100644
--- a/node_modules/@venusprotocol/governance-contracts/contracts/Governance/GovernorBravoDelegate.sol
+++ b/node_modules/@venusprotocol/governance-contracts/contracts/Governance/GovernorBravoDelegate.sol
@@ -115,7 +115,6 @@ contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoE
address guardian_
) public {
require(address(proposalTimelocks[0]) == address(0), "GovernorBravo::initialize: cannot initialize twice");
- require(msg.sender == admin, "GovernorBravo::initialize: admin only");
require(xvsVault_ != address(0), "GovernorBravo::initialize: invalid xvs address");
require(guardian_ != address(0), "GovernorBravo::initialize: invalid guardian");
require(
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5062,10 +5062,10 @@ __metadata:
languageName: node
linkType: hard

"@venusprotocol/governance-contracts@npm:^1.0.0":
version: 1.0.0
resolution: "@venusprotocol/governance-contracts@npm:1.0.0"
checksum: 8df88f2e702da976861f6e409ab109dec24f8ac4e4e049da505ee36d36af6c2478bb4b6a2f3401f360578bd167512cb016227526bf81ebfdf3ca91ef473e7f87
"@venusprotocol/governance-contracts@npm:^1.0.1-dev.5":
version: 1.0.1-dev.5
resolution: "@venusprotocol/governance-contracts@npm:1.0.1-dev.5"
checksum: 271ae85b91f347b24d64f67ef716244c81e5144b0f0079607e3383c4bd360ce61ddce4858e7cc80c3d274dce185bcd3dc16e7a6fe395afc72a880c1ce7ed0671
languageName: node
linkType: hard

Expand Down Expand Up @@ -15760,7 +15760,7 @@ __metadata:
"@types/mustache": ^4.2.1
"@typescript-eslint/eslint-plugin": ^5.40.1
"@typescript-eslint/parser": ^5.40.1
"@venusprotocol/governance-contracts": ^1.0.0
"@venusprotocol/governance-contracts": ^1.0.1-dev.5
"@venusprotocol/isolated-pools": 2.1.0-dev.2
"@venusprotocol/oracle": ^1.7.2
"@venusprotocol/venus-protocol": ^3.1.0
Expand Down

0 comments on commit 8041359

Please sign in to comment.