Skip to content
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

refactor: use address from npm packages #108

Merged
merged 8 commits into from
Dec 7, 2023
Merged
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
11 changes: 10 additions & 1 deletion copy_contracts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,19 @@ mkdir -p ./contracts/protocol
cp -rf ./node_modules/@venusprotocol/venus-protocol/contracts/ ./contracts/protocol/contracts
rm -rf contracts/protocol/contracts/test

mkdir -p ./contracts/protocol-reserve
cp -rf ./node_modules/@venusprotocol/protocol-reserve/contracts/ ./contracts/protocol-reserve/contracts
rm -rf contracts/protocol-reserve/contracts/Test

mkdir -p ./contracts/governance/contracts/Governance
mkdir -p ./contracts/governance/contracts/legacy
mkdir -p ./contracts/governance/contracts/test
Comment on lines +21 to +25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double checking if these Test contracts are something you want to keep

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we need this because the regular timelock delays are too long. This allows us to customize them


cp -rf ./node_modules/@venusprotocol/governance-contracts/contracts/legacy ./contracts/governance/contracts
cp ./node_modules/@venusprotocol/governance-contracts/contracts/Governance/GovernorBravoInterfaces.sol ./contracts/governance/contracts/Governance/GovernorBravoInterfaces.sol
cp ./node_modules/@venusprotocol/governance-contracts/contracts/test/TestTimelockV8.sol ./contracts/governance/contracts/test/TestTimelockV8.sol
cp -rf ./node_modules/@venusprotocol/governance-contracts/contracts/Governance ./contracts/governance/contracts
rm ./contracts/governance/contracts/Governance/AccessControlManager.sol
rm ./contracts/governance/contracts/Governance/Timelock.sol

rm -rf contracts/protocol/contracts/Lens/VenusLens.sol

Expand Down
53 changes: 50 additions & 3 deletions deploy/000-governance-access-control.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,62 @@
import accessControl from '@venusprotocol/governance-contracts/dist/deploy/001-access-control';
import accessControl from '@venusprotocol/governance-contracts/dist/deploy/002-access-control';
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 networkName = hre.network.name;

await deploy('Timelock', {
const delayConfig = {
hardhat: {
normal: 600,
fast: 300,
critical: 100,
},
bscmainnet: {
normal: 172800,
fast: 21600,
critical: 3600,
},
bsctestnet: {
normal: 600,
fast: 300,
critical: 100,
},
sepolia: {
normal: 600,
fast: 300,
critical: 100,
},
ethereum: {
normal: 172800,
fast: 21600,
critical: 3600,
},
};

await deploy("NormalTimelock", {
contract: "TestTimelockV8",
from: deployer,
args: [deployer, delayConfig[networkName].normal],
log: true,
autoMine: true,
});

await deploy("FastTrackTimelock", {
contract: "TestTimelockV8",
from: deployer,
args: [deployer, delayConfig[networkName].fast],
log: true,
autoMine: true,
});

await deploy("CriticalTimelock", {
contract: "TestTimelockV8",
from: deployer,
args: [deployer, 3600],
args: [deployer, delayConfig[networkName].critical],
log: true,
autoMine: true,
});
Expand Down
2 changes: 1 addition & 1 deletion deploy/003-configure-feeds.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import configureFeeds from '@venusprotocol/oracle/dist/deploy/2-configure-feeds';
import configureFeeds from '@venusprotocol/oracle/dist/deploy/3-configure-feeds';

export default configureFeeds;
18 changes: 5 additions & 13 deletions deploy/018-governance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployer } = await getNamedAccounts();
const signers = await ethers.getSigners();

const timelock = await ethers.getContract('Timelock');
const timelock = await ethers.getContract('NormalTimelock');
const xvsVault = await ethers.getContract('XVSVaultProxy');

await deploy('GovernorAlphaTimelock', {
contract: 'Timelock',
contract: 'TestTimelockV8',
from: deployer,
args: [deployer, 3600],
log: true,
Expand Down Expand Up @@ -48,7 +48,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
await governorAlpha.__acceptAdmin();

await deploy('GovernorAlpha2Timelock', {
contract: 'Timelock',
contract: 'TestTimelockV8',
from: deployer,
args: [deployer, 3600],
log: true,
Expand Down Expand Up @@ -96,8 +96,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
});

await deploy('GovernorBravoDelegateV2', {
contract:
'@venusprotocol/governance-contracts/contracts/Governance/GovernorBravoDelegate.sol:GovernorBravoDelegate',
contract: 'GovernorBravoDelegate',
from: deployer,
args: [],
log: true,
Expand All @@ -110,7 +109,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const minVotingPeriod = await governorBravoDelegate.MIN_VOTING_PERIOD();
const minProposalThreshold = await governorBravoDelegate.MIN_PROPOSAL_THRESHOLD();

await deploy('GovernorBravoDelegatorV1', {
await deploy('GovernorBravoDelegator', {
from: deployer,
args: [
timelock.address,
Expand All @@ -125,13 +124,6 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
log: true,
autoMine: true,
});

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

func.tags = ['Governance'];
Expand Down
17 changes: 5 additions & 12 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const compilers = {
}
},
{
version: '0.8.17',
version: '0.6.6',
settings: {
optimizer: {
enabled: true,
Expand All @@ -47,7 +47,7 @@ const compilers = {
},
},
{
version: '0.8.13',
version: '0.8.17',
settings: {
optimizer: {
enabled: true,
Expand All @@ -60,18 +60,18 @@ const compilers = {
},
},
{
version: '0.6.6',
version: '0.8.20',
settings: {
optimizer: {
enabled: !process.env.CI,
enabled: true,
},
outputSelection: {
'*': {
'*': ['storageLayout'],
},
},
},
},
}
],
}

Expand All @@ -88,13 +88,6 @@ const config: HardhatUserConfig = {
sources: `${__dirname}/contracts`,
artifacts: `${__dirname}/artifacts`,
},
dependencyCompiler: {
paths: [
'@venusprotocol/governance-contracts/contracts/Governance/Timelock.sol',
'@venusprotocol/governance-contracts/contracts/Governance/GovernorBravoDelegate.sol',
'@venusprotocol/governance-contracts/contracts/Governance/GovernorBravoDelegator.sol',
],
},
mocha: {
timeout: 100000000
},
Expand Down
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@
"@typechain/hardhat": "^6.1.2",
"@types/mocha": "^9.1.1",
"@types/mustache": "^4.2.1",
"@types/node": "^20.5.9",
"@typescript-eslint/eslint-plugin": "^5.40.1",
"@typescript-eslint/parser": "^5.40.1",
"@venusprotocol/governance-contracts": "^1.3.0",
"@venusprotocol/isolated-pools": "2.1.0-dev.2",
"@venusprotocol/oracle": "^1.7.3-dev.1",
"@venusprotocol/governance-contracts": "^1.4.0-dev.9",
"@venusprotocol/isolated-pools": "^2.3.0-dev.4",
"@venusprotocol/oracle": "^1.8.0-dev.5",
"@venusprotocol/venus-protocol": "^6.1.0-dev.5",
"assemblyscript": "0.19.23",
"chai": "^4.3.6",
"eslint": "^8.25.0",
Expand Down Expand Up @@ -84,5 +86,8 @@
"packageManager": "yarn@3.2.2",
"_moduleAliases": {
"@nomiclabs/hardhat-ethers": "node_modules/hardhat-deploy-ethers"
},
"dependencies": {
"@venusprotocol/protocol-reserve": "^1.1.0"
}
}
133 changes: 0 additions & 133 deletions patches/@venusprotocol+governance-contracts+1.3.0.patch

This file was deleted.

30 changes: 30 additions & 0 deletions patches/@venusprotocol+governance-contracts+1.4.0-dev.9.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
diff --git a/node_modules/@venusprotocol/governance-contracts/contracts/legacy/GovernorAlpha.sol b/node_modules/@venusprotocol/governance-contracts/contracts/legacy/GovernorAlpha.sol
index fca5350..4713034 100644
--- a/node_modules/@venusprotocol/governance-contracts/contracts/legacy/GovernorAlpha.sol
+++ b/node_modules/@venusprotocol/governance-contracts/contracts/legacy/GovernorAlpha.sol
@@ -27,8 +27,8 @@ contract GovernorAlpha {

/// @notice The duration of voting on a proposal, in blocks
function votingPeriod() public pure returns (uint) {
- return (60 * 60 * 24 * 3) / 3;
- } // ~3 days in blocks (assuming 3s blocks)
+ return 100;
+ } // A reasonable amount of block suitable for testing

/// @notice The address of the Venus Protocol Timelock
TimelockInterface public timelock;
diff --git a/node_modules/@venusprotocol/governance-contracts/contracts/legacy/GovernorAlpha2.sol b/node_modules/@venusprotocol/governance-contracts/contracts/legacy/GovernorAlpha2.sol
index c009718..0e8e8ec 100644
--- a/node_modules/@venusprotocol/governance-contracts/contracts/legacy/GovernorAlpha2.sol
+++ b/node_modules/@venusprotocol/governance-contracts/contracts/legacy/GovernorAlpha2.sol
@@ -27,8 +27,8 @@ contract GovernorAlpha2 {

/// @notice The duration of voting on a proposal, in blocks
function votingPeriod() public pure returns (uint) {
- return (60 * 60 * 24 * 3) / 3;
- } // ~3 days in blocks (assuming 3s blocks)
+ return 100;
+ } // A reasonable amount of block suitable for testing

/// @notice The address of the Venus Protocol Timelock
TimelockInterface public timelock;
Loading
Loading