Skip to content

Commit

Permalink
Merge pull request #41 from VenusProtocol/fix/cleanup
Browse files Browse the repository at this point in the history
[VEN-2091]: Fixes and Cleanup
  • Loading branch information
coreyar authored Dec 11, 2023
2 parents d7a99c2 + 4d69337 commit 3080568
Show file tree
Hide file tree
Showing 7 changed files with 626 additions and 495 deletions.
23 changes: 22 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,26 @@ jobs:
- name: "Test the contracts and generate the coverage report"
run: "npx hardhat coverage"

- name: Code Coverage Report
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: coverage/**/cobertura-coverage.xml
badge: true
fail_below_min: false
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: "50 80"

- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md

docgen:
name: Docgen
runs-on: ubuntu-latest
Expand Down Expand Up @@ -95,10 +115,11 @@ jobs:
- name: Export deployments
run: |
for NETWORK in bsctestnet bscmainnet ethereum sepolia; do
yarn hardhat export --network ${NETWORK} --export ./deployments/${NETWORK}.json
EXPORT=true yarn hardhat export --network ${NETWORK} --export ./deployments/${NETWORK}.json
jq -M '{name, chainId, addresses: .contracts | map_values(.address)}' ./deployments/${NETWORK}.json > ./deployments/${NETWORK}_addresses.json
done
yarn prettier
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "feat: updating deployment files"
Expand Down
2 changes: 1 addition & 1 deletion .solcover.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
istanbulReporter: ["html", "lcov"],
istanbulReporter: ["html", "lcov", "cobertura"],
providerOptions: {
mnemonic: process.env.MNEMONIC,
},
Expand Down
48 changes: 13 additions & 35 deletions deploy/1-deploy.ts
Original file line number Diff line number Diff line change
@@ -1,52 +1,28 @@
import mainnetDeployments from "@venusprotocol/venus-protocol/networks/mainnet.json";
import testnetDeployments from "@venusprotocol/venus-protocol/networks/testnet.json";
import hre, { ethers } from "hardhat";
import { HardhatRuntimeEnvironment } from "hardhat/types";

const ADDRESSES: any = {
bsctestnet: {
vBNBAddress: testnetDeployments.Contracts.vBNB,
comptroller: testnetDeployments.Contracts.Unitroller,
WBNBAddress: "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd",
timelock: testnetDeployments.Contracts.Timelock,
acm: "0x45f8a08F534f34A97187626E05d4b6648Eeaa9AA",
},
bscmainnet: {
vBNBAddress: mainnetDeployments.Contracts.vBNB,
comptroller: mainnetDeployments.Contracts.Unitroller,
WBNBAddress: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
timelock: mainnetDeployments.Contracts.Timelock,
acm: "0x4788629ABc6cFCA10F9f969efdEAa1cF70c23555",
},
sepolia: {
vBNBAddress: ethers.constants.AddressZero,
comptroller: ethers.constants.AddressZero,
WBNBAddress: ethers.constants.AddressZero,
timelock: ethers.constants.AddressZero,
acm: ethers.constants.AddressZero,
},
};

module.exports = async ({ getNamedAccounts, deployments, network }: HardhatRuntimeEnvironment) => {
const func: DeployFunction = async ({ getNamedAccounts, deployments }: HardhatRuntimeEnvironment) => {

Check failure on line 4 in deploy/1-deploy.ts

View workflow job for this annotation

GitHub Actions / release

Cannot find name 'DeployFunction'.

Check failure on line 4 in deploy/1-deploy.ts

View workflow job for this annotation

GitHub Actions / release

Exported variable 'func' has or is using private name 'DeployFunction'.
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();

const networkName = network.name;

const { vBNBAddress, comptroller, WBNBAddress, timelock, acm } = ADDRESSES[networkName];
const vBNBAddress = (await ethers.getContract("vBNB")).address;
const comptrollerAddress = (await ethers.getContract("Unitroller")).address;
const WBNBAddress = (await ethers.getContract("WBNB")).address;
const timelockAddress = (await ethers.getContract("NormalTimelock")).address;
const acmAddress = (await ethers.getContract("AccessControlManager")).address;
const loopsLimit = 20;

await deploy("ProtocolShareReserve", {
from: deployer,
log: true,
deterministicDeployment: false,
args: [comptroller, WBNBAddress, vBNBAddress],
args: [comptrollerAddress, WBNBAddress, vBNBAddress],
proxy: {
owner: timelock,
owner: timelockAddress,
proxyContract: "OpenZeppelinTransparentProxy",
execute: {
methodName: "initialize",
args: [acm, loopsLimit],
args: [acmAddress, loopsLimit],
},
},
});
Expand All @@ -55,10 +31,12 @@ module.exports = async ({ getNamedAccounts, deployments, network }: HardhatRunti
const psrOwner = await psr.owner();

if (psrOwner === deployer) {
const tx = await psr.transferOwnership(ADDRESSES[networkName].timelock);
const tx = await psr.transferOwnership(timelockAddress);
await tx.wait();
console.log("Transferred ownership of PSR to Timelock");
}
};

module.exports.tags = ["deploy"];
func.tags = ["deploy"];

export default func;
30 changes: 28 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,39 @@ import "@nomiclabs/hardhat-ethers";
import "@nomiclabs/hardhat-etherscan";
import "@openzeppelin/hardhat-upgrades";
import "@typechain/hardhat";
import dotenv from "dotenv";
import "hardhat-deploy";
import "hardhat-gas-reporter";
import { HardhatUserConfig, task } from "hardhat/config";
import { HardhatUserConfig, extendConfig, task } from "hardhat/config";
import { HardhatConfig } from "hardhat/types";
import "solidity-coverage";
import "solidity-docgen";

require("dotenv").config();
dotenv.config();

const DEPLOYER_PRIVATE_KEY = process.env.DEPLOYER_PRIVATE_KEY;

const externalDeployments = {
bsctestnet: [
"node_modules/@venusprotocol/venus-protocol/deployments/bsctestnet",
"node_modules/@venusprotocol/governance-contracts/deployments/bsctestnet",
],
sepolia: [
"node_modules/@venusprotocol/venus-protocol/deployments/sepolia",
"node_modules/@venusprotocol/governance-contracts/deployments/sepolia",
],
bscmainnet: [
"node_modules/@venusprotocol/venus-protocol/deployments/bscmainnet",
"node_modules/@venusprotocol/governance-contracts/deployments/bscmainnet",
],
};

extendConfig((config: HardhatConfig) => {
if (process.env.EXPORT !== "true") {
config.external = { ...config.external, deployments: externalDeployments };
}
});

task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
const accounts = await hre.ethers.getSigners();

Expand Down Expand Up @@ -159,6 +182,9 @@ const config: HardhatUserConfig = {
cache: "./cache",
artifacts: "./artifacts",
},
external: {
deployments: {},
},
mocha: {
timeout: 200000000,
},
Expand Down
2 changes: 1 addition & 1 deletion tests/ProtocolShareReserve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ describe("ProtocolShareReserve: Tests", function () {

await protocolShareReserve.removeDistributionConfig(SCHEMA_PROTOCOL_RESERVE, ONE_ADDRESS);

expect(protocolShareReserve.distributionTargets(6)).to.have.reverted;
await expect(protocolShareReserve.distributionTargets(6)).to.have.reverted;
expect(await protocolShareReserve.totalDistributions()).to.be.equal(6);

await protocolShareReserve.addOrUpdateDistributionConfigs([
Expand Down
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"target": "es6",
"outDir": "dist",
"paths": {
"@nomiclabs/hardhat-ethers": ["node_modules/hardhat-deploy-ethers"],
"@nomiclabs/hardhat-ethers/types": ["hardhat-deploy-ethers/types"]
"@nomiclabs/hardhat-ethers": ["node_modules/hardhat-deploy-ethers"]
}
},
"exclude": ["node_modules"],
Expand Down
Loading

0 comments on commit 3080568

Please sign in to comment.