diff --git a/copy_contracts.sh b/copy_contracts.sh index 373891d1..f79869b9 100755 --- a/copy_contracts.sh +++ b/copy_contracts.sh @@ -16,10 +16,18 @@ 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 + cp -rf ./node_modules/@venusprotocol/governance-contracts/contracts/legacy ./contracts/governance/contracts +cp ./node_modules/@venusprotocol/governance-contracts/contracts/test/TestTimelockV8.sol ./contracts/governance/contracts/test/TestTimelockV8.sol cp ./node_modules/@venusprotocol/governance-contracts/contracts/Governance/GovernorBravoInterfaces.sol ./contracts/governance/contracts/Governance/GovernorBravoInterfaces.sol +cp ./node_modules/@venusprotocol/governance-contracts/contracts/Governance/TimelockV8.sol ./contracts/governance/contracts/Governance/TimelockV8.sol rm -rf contracts/protocol/contracts/Lens/VenusLens.sol diff --git a/deploy/000-governance-access-control.ts b/deploy/000-governance-access-control.ts index 593a6cb1..99cc6234 100644 --- a/deploy/000-governance-access-control.ts +++ b/deploy/000-governance-access-control.ts @@ -1,18 +1,10 @@ -import accessControl from '@venusprotocol/governance-contracts/dist/deploy/001-access-control'; +import timelock from '@venusprotocol/governance-contracts/dist/deploy/001-timelock'; +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(); - - await deploy('Timelock', { - from: deployer, - args: [deployer, 3600], - log: true, - autoMine: true, - }); + await timelock(hre); await accessControl(hre); }; diff --git a/deploy/003-configure-feeds.ts b/deploy/003-configure-feeds.ts index 7d1796ea..c6e81895 100644 --- a/deploy/003-configure-feeds.ts +++ b/deploy/003-configure-feeds.ts @@ -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; diff --git a/deploy/018-governance.ts b/deploy/018-governance.ts index 300a5a94..8dc22dab 100644 --- a/deploy/018-governance.ts +++ b/deploy/018-governance.ts @@ -8,18 +8,10 @@ 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('CriticalTimelock'); const xvsVault = await ethers.getContract('XVSVaultProxy'); - await deploy('GovernorAlphaTimelock', { - contract: 'Timelock', - from: deployer, - args: [deployer, 3600], - log: true, - autoMine: true, - }); - - const governorAlphaTimelock = await ethers.getContract('GovernorAlphaTimelock'); + const governorAlphaTimelock = await ethers.getContract('CriticalTimelock'); await deploy('GovernorAlpha', { from: deployer, args: [governorAlphaTimelock.address, xvsVault.address, deployer], @@ -47,15 +39,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { await governorAlpha.__acceptAdmin(); - await deploy('GovernorAlpha2Timelock', { - contract: 'Timelock', - from: deployer, - args: [deployer, 3600], - log: true, - autoMine: true, - }); - - const governorAlpha2Timelock = await ethers.getContract('GovernorAlpha2Timelock'); + const governorAlpha2Timelock = await ethers.getContract('CriticalTimelock'); await deploy('GovernorAlpha2', { from: deployer, diff --git a/hardhat.config.ts b/hardhat.config.ts index 7f567f0a..2dc0d1d7 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -92,7 +92,6 @@ const config: HardhatUserConfig = { paths: [ '@venusprotocol/governance-contracts/contracts/Governance/Timelock.sol', '@venusprotocol/governance-contracts/contracts/Governance/GovernorBravoDelegate.sol', - '@venusprotocol/governance-contracts/contracts/Governance/GovernorBravoDelegator.sol', ], }, mocha: { diff --git a/package.json b/package.json index d1216fcb..a6ed82fc 100644 --- a/package.json +++ b/package.json @@ -48,9 +48,9 @@ "@types/node": "^20.5.9", "@typescript-eslint/eslint-plugin": "^5.40.1", "@typescript-eslint/parser": "^5.40.1", - "@venusprotocol/governance-contracts": "^1.4.0-dev.6", + "@venusprotocol/governance-contracts": "^1.4.0-dev.7", "@venusprotocol/isolated-pools": "^2.3.0-dev.4", - "@venusprotocol/oracle": "^1.7.3-dev.1", + "@venusprotocol/oracle": "^1.8.0-dev.5", "@venusprotocol/venus-protocol": "^6.1.0-dev.5", "assemblyscript": "0.19.23", "chai": "^4.3.6", @@ -86,5 +86,8 @@ "packageManager": "yarn@3.2.2", "_moduleAliases": { "@nomiclabs/hardhat-ethers": "node_modules/hardhat-deploy-ethers" + }, + "dependencies": { + "@venusprotocol/protocol-reserve": "^1.1.0" } } diff --git a/patches/@venusprotocol+governance-contracts+1.4.0-dev.6.patch b/patches/@venusprotocol+governance-contracts+1.4.0-dev.6.patch deleted file mode 100644 index 5bace989..00000000 --- a/patches/@venusprotocol+governance-contracts+1.4.0-dev.6.patch +++ /dev/null @@ -1,133 +0,0 @@ -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; -diff --git a/node_modules/@venusprotocol/governance-contracts/contracts/legacy/GovernorBravoDelegator.sol b/node_modules/@venusprotocol/governance-contracts/contracts/legacy/GovernorBravoDelegator.sol -new file mode 100644 -index 0000000..4323517 ---- /dev/null -+++ b/node_modules/@venusprotocol/governance-contracts/contracts/legacy/GovernorBravoDelegator.sol -@@ -0,0 +1,97 @@ -+pragma solidity ^0.5.16; -+pragma experimental ABIEncoderV2; -+ -+import "./GovernorBravoInterfaces.sol"; -+ -+/** -+ * @title GovernorBravoDelegator -+ * @author Venus -+ * @notice The `GovernorBravoDelegator` contract. -+ */ -+contract GovernorBravoDelegatorV1 is GovernorBravoDelegatorStorage, GovernorBravoEventsV1 { -+ constructor( -+ address timelock_, -+ address xvsVault_, -+ address admin_, -+ address implementation_, -+ uint votingPeriod_, -+ uint votingDelay_, -+ uint proposalThreshold_, -+ address guardian_ -+ ) public { -+ // Admin set to msg.sender for initialization -+ admin = msg.sender; -+ -+ delegateTo( -+ implementation_, -+ abi.encodeWithSignature( -+ "initialize(address,address,uint256,uint256,uint256,address)", -+ timelock_, -+ xvsVault_, -+ votingPeriod_, -+ votingDelay_, -+ proposalThreshold_, -+ guardian_ -+ ) -+ ); -+ -+ _setImplementation(implementation_); -+ -+ admin = admin_; -+ } -+ -+ /** -+ * @notice Called by the admin to update the implementation of the delegator -+ * @param implementation_ The address of the new implementation for delegation -+ */ -+ function _setImplementation(address implementation_) public { -+ require(msg.sender == admin, "GovernorBravoDelegator::_setImplementation: admin only"); -+ require( -+ implementation_ != address(0), -+ "GovernorBravoDelegator::_setImplementation: invalid implementation address" -+ ); -+ -+ address oldImplementation = implementation; -+ implementation = implementation_; -+ -+ emit NewImplementation(oldImplementation, implementation); -+ } -+ -+ /** -+ * @notice Internal method to delegate execution to another contract -+ * @dev It returns to the external caller whatever the implementation returns or forwards reverts -+ * @param callee The contract to delegatecall -+ * @param data The raw data to delegatecall -+ */ -+ function delegateTo(address callee, bytes memory data) internal { -+ (bool success, bytes memory returnData) = callee.delegatecall(data); -+ assembly { -+ if eq(success, 0) { -+ revert(add(returnData, 0x20), returndatasize) -+ } -+ } -+ } -+ -+ /** -+ * @dev Delegates execution to an implementation contract. -+ * It returns to the external caller whatever the implementation returns -+ * or forwards reverts. -+ */ -+ function() external payable { -+ // delegate all other functions to current implementation -+ (bool success, ) = implementation.delegatecall(msg.data); -+ -+ assembly { -+ let free_mem_ptr := mload(0x40) -+ returndatacopy(free_mem_ptr, 0, returndatasize) -+ -+ switch success -+ case 0 { -+ revert(free_mem_ptr, returndatasize) -+ } -+ default { -+ return(free_mem_ptr, returndatasize) -+ } -+ } -+ } -+} diff --git a/patches/@venusprotocol+governance-contracts+1.4.0-dev.7.patch b/patches/@venusprotocol+governance-contracts+1.4.0-dev.7.patch new file mode 100644 index 00000000..ecedc1b8 --- /dev/null +++ b/patches/@venusprotocol+governance-contracts+1.4.0-dev.7.patch @@ -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; diff --git a/subgraphs/venus/config/index.ts b/subgraphs/venus/config/index.ts index cc931b43..169ec6c3 100644 --- a/subgraphs/venus/config/index.ts +++ b/subgraphs/venus/config/index.ts @@ -21,19 +21,16 @@ const main = () => { network: 'hardhat', comptrollerAddress: '0x94d1820b2D1c7c7452A163983Dc888CEC546b77D', startBlock: '0', - vBnbAddress: '0xA07c5b74C9B40447a954e1466938b865b6BBea36', }, chapel: { network: 'chapel', comptrollerAddress: bscTestnetCoreDeployments.Contracts.Comptroller, startBlock: '2470000', - vBnbAddress: bscTestnetCoreDeployments.Contracts.vBNB, }, bsc: { network: 'bsc', comptrollerAddress: bscMainnetCoreDeployments.Contracts.Comptroller, startBlock: '2470000', - vBnbAddress: bscMainnetCoreDeployments.Contracts.vBNB, }, }; diff --git a/subgraphs/venus/src/constants/addresses.ts b/subgraphs/venus/src/constants/addresses.ts index c8f66fb0..2dec04b2 100644 --- a/subgraphs/venus/src/constants/addresses.ts +++ b/subgraphs/venus/src/constants/addresses.ts @@ -1,10 +1,6 @@ import { Address } from '@graphprotocol/graph-ts'; -import { - comptrollerAddress as comptrollerAddressString, - vBnbAddress as vBnbAddressString, -} from './config'; +import { comptrollerAddress as comptrollerAddressString } from './config'; -export const vBnbAddress = Address.fromString(vBnbAddressString); export const comptrollerAddress = Address.fromString(comptrollerAddressString); export const nullAddress = Address.fromString('0x0000000000000000000000000000000000000000'); diff --git a/subgraphs/venus/src/constants/config-template b/subgraphs/venus/src/constants/config-template index d5af8f52..e68ec726 100644 --- a/subgraphs/venus/src/constants/config-template +++ b/subgraphs/venus/src/constants/config-template @@ -1,4 +1,3 @@ // Use yarn prepare commands to generate config typescript file per env -export const vBnbAddress = '{{ vBnbAddress }}'; export const comptrollerAddress = '{{ comptrollerAddress }}'; diff --git a/yarn.lock b/yarn.lock index 63dbccb6..02a184b9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4306,7 +4306,7 @@ __metadata: languageName: node linkType: hard -"@venusprotocol/governance-contracts@npm:^1.4.0-dev.2, @venusprotocol/governance-contracts@npm:^1.4.0-dev.6": +"@venusprotocol/governance-contracts@npm:^1.4.0-dev.2": version: 1.4.0-dev.6 resolution: "@venusprotocol/governance-contracts@npm:1.4.0-dev.6" dependencies: @@ -4317,6 +4317,17 @@ __metadata: languageName: node linkType: hard +"@venusprotocol/governance-contracts@npm:^1.4.0-dev.7": + version: 1.4.0-dev.7 + resolution: "@venusprotocol/governance-contracts@npm:1.4.0-dev.7" + dependencies: + "@venusprotocol/solidity-utilities": ^1.1.0 + hardhat-deploy-ethers: ^0.3.0-beta.13 + module-alias: ^2.2.2 + checksum: cc6aead9facf41d638b93306fa2a8b85d43f260d0a0d1f6977ea57ac6d409405cc70e71158f16bb058319de291d685af974ce8a76a60e7b3d719dd2c53b6ba8d + languageName: node + linkType: hard + "@venusprotocol/isolated-pools@npm:^2.3.0-dev.4": version: 2.3.0-dev.4 resolution: "@venusprotocol/isolated-pools@npm:2.3.0-dev.4" @@ -4333,9 +4344,9 @@ __metadata: languageName: node linkType: hard -"@venusprotocol/oracle@npm:^1.7.3-dev.1": - version: 1.7.3 - resolution: "@venusprotocol/oracle@npm:1.7.3" +"@venusprotocol/oracle@npm:^1.8.0-dev.5": + version: 1.8.0-dev.5 + resolution: "@venusprotocol/oracle@npm:1.8.0-dev.5" dependencies: "@chainlink/contracts": ^0.5.1 "@defi-wonderland/smock": ^2.3.4 @@ -4349,7 +4360,7 @@ __metadata: hardhat-deploy: ^0.11.14 module-alias: ^2.2.2 solidity-docgen: ^0.6.0-beta.29 - checksum: 4187974f762fe1082db449acf2edd2d9d94feec76fab88a50d0eb5de44d12baf80381e365e71b2784c12a0e0941630c37b81d23cea01ec4b4a6f549a90457803 + checksum: 32e1dc6aca38bc5c7b3cc205be4b07ce097a2905f9d565ef867056945b6617a7e9480b0177f31dc5ccff524f7fcc815e10cf19fa5fe8c274b459d48abd5123d9 languageName: node linkType: hard @@ -4370,6 +4381,23 @@ __metadata: languageName: node linkType: hard +"@venusprotocol/protocol-reserve@npm:^1.1.0": + version: 1.1.0 + resolution: "@venusprotocol/protocol-reserve@npm:1.1.0" + dependencies: + "@nomiclabs/hardhat-ethers": ^2.2.3 + "@openzeppelin/contracts": ^4.8.3 + "@openzeppelin/contracts-upgradeable": ^4.8.3 + "@openzeppelin/hardhat-upgrades": ^1.21.0 + "@solidity-parser/parser": ^0.13.2 + "@venusprotocol/solidity-utilities": ^1.0.1 + ethers: ^5.7.0 + hardhat-deploy: ^0.11.14 + module-alias: ^2.2.2 + checksum: 86e2da20ddb3824603c1f5e0931cc4715cd442624a03cc0fed7633ecbb5f2cab9a04ca5dcec805a4d9b0e04904799286210299f39935034f9fe85155f7b56da3 + languageName: node + linkType: hard + "@venusprotocol/solidity-utilities@npm:^1.0.1, @venusprotocol/solidity-utilities@npm:^1.1.0": version: 1.1.0 resolution: "@venusprotocol/solidity-utilities@npm:1.1.0" @@ -14610,9 +14638,10 @@ __metadata: "@types/node": ^20.5.9 "@typescript-eslint/eslint-plugin": ^5.40.1 "@typescript-eslint/parser": ^5.40.1 - "@venusprotocol/governance-contracts": ^1.4.0-dev.6 + "@venusprotocol/governance-contracts": ^1.4.0-dev.7 "@venusprotocol/isolated-pools": ^2.3.0-dev.4 - "@venusprotocol/oracle": ^1.7.3-dev.1 + "@venusprotocol/oracle": ^1.8.0-dev.5 + "@venusprotocol/protocol-reserve": ^1.1.0 "@venusprotocol/venus-protocol": ^6.1.0-dev.5 assemblyscript: 0.19.23 chai: ^4.3.6