Skip to content

Commit

Permalink
Merge pull request #99 from VenusProtocol/feat/VEN-2686
Browse files Browse the repository at this point in the history
[VEN-2686]: PSR deployment on zksync sepolia
GitGuru7 authored Aug 14, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 55b693f + 1f44f5c commit 7f76f6d
Showing 20 changed files with 6,778 additions and 58 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ DEPLOYER_PRIVATE_KEY=
#ARCHIVE_NODE_opbnbmainnet=https://opbnb-mainnet.nodereal.io/v1/<YOUR_KEY_HERE>
#ARCHIVE_NODE_arbitrumsepolia=https://sepolia-rollup.arbitrum.io/rpc
#ARCHIVE_NODE_arbitrumone=https://open-platform.nodereal.io/<YOUR_KEY_HERE>/arbitrum-nitro/
#ARCHIVE_NODE_zksyncsepolia=https://zksync-sepolia.g.alchemy.com/v2/<YOUR_KEY_HERE>

ETHERSCAN_API_KEY=
REPORT_GAS=
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -4,8 +4,10 @@
**/.coverage_cache
**/.coverage_contracts
**/artifacts
**/artifacts-zk
**/build
**/cache
**/cache-zk
**/coverage
**/dist
**/node_modules
3 changes: 2 additions & 1 deletion .eslinttsconfigrc
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
"jest.config.js",
"saddle.config.js",
"docgen-templates",
"commitlint.config.js"
"commitlint.config.js",
"./hardhat.config.zksync.ts"
]
}
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -141,6 +141,10 @@ jobs:
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
for NETWORK in zksyncsepolia; do
EXPORT=true yarn hardhat export --network ${NETWORK} --export ./deployments/${NETWORK}.json --config hardhat.config.zksync.ts
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -6,8 +6,10 @@
!.yarn/sdks
!.yarn/versions
**/artifacts
**/artifacts-zk
**/build
**/cache
**/cache-zk
**/coverage
**/.coverage_artifacts
**/.coverage_cache
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -4,8 +4,10 @@
**/.coverage_cache
**/.coverage_contracts
**/artifacts
**/artifacts-zk
**/build
**/cache
**/cache-zk
**/coverage
**/dist
**/node_modules
11 changes: 10 additions & 1 deletion deploy/001-psr.ts
Original file line number Diff line number Diff line change
@@ -19,18 +19,27 @@ const func: DeployFunction = async ({
const acmAddress = (await ethers.getContractOrNull("AccessControlManager"))?.address || ADDRESS_ONE;
const loopsLimit = 20;

const defaultProxyAdmin = await hre.artifacts.readArtifact(
"hardhat-deploy/solc_0.8/openzeppelin/proxy/transparent/ProxyAdmin.sol:ProxyAdmin",
);

await deploy("ProtocolShareReserve", {
from: deployer,
log: true,
deterministicDeployment: false,
args: [comptrollerAddress, WBNBAddress, vBNBAddress],
skipIfAlreadyDeployed: true,
proxy: {
owner: live ? timelockAddress : deployer,
proxyContract: "OpenZeppelinTransparentProxy",
proxyContract: "OptimizedTransparentUpgradeableProxy",
execute: {
methodName: "initialize",
args: [acmAddress, loopsLimit],
},
viaAdminContract: {
name: "DefaultProxyAdmin",
artifact: defaultProxyAdmin,
},
},
});

2,023 changes: 2,023 additions & 0 deletions deployments/zksyncsepolia.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions deployments/zksyncsepolia/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
300
257 changes: 257 additions & 0 deletions deployments/zksyncsepolia/DefaultProxyAdmin.json

Large diffs are not rendered by default.

1,125 changes: 1,125 additions & 0 deletions deployments/zksyncsepolia/ProtocolShareReserve.json

Large diffs are not rendered by default.

1,359 changes: 1,359 additions & 0 deletions deployments/zksyncsepolia/ProtocolShareReserve_Implementation.json

Large diffs are not rendered by default.

346 changes: 346 additions & 0 deletions deployments/zksyncsepolia/ProtocolShareReserve_Proxy.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions deployments/zksyncsepolia_addresses.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "zksyncsepolia",
"chainId": "300",
"addresses": {
"DefaultProxyAdmin": "0x18E44f588a4DcF2F7145d35A5C226e129040b6D3",
"ProtocolShareReserve": "0x5722B43BD91fAaDC4E7f384F4d6Fb32456Ec5ffB",
"ProtocolShareReserve_Implementation": "0x817F19DC65bBe7f87b6941aa11637A1744E4fdD6",
"ProtocolShareReserve_Proxy": "0x5722B43BD91fAaDC4E7f384F4d6Fb32456Ec5ffB"
}
}
7 changes: 7 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ import "@nomiclabs/hardhat-etherscan";
import "@openzeppelin/hardhat-upgrades";
import "@typechain/hardhat";
import dotenv from "dotenv";
import "hardhat-dependency-compiler";
import "hardhat-deploy";
import "hardhat-gas-reporter";
import { HardhatUserConfig, extendConfig, task } from "hardhat/config";
@@ -278,6 +279,12 @@ const config: HardhatUserConfig = {
pages: "files",
templates: "docgen-templates",
},
dependencyCompiler: {
paths: [
"hardhat-deploy/solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol",
"hardhat-deploy/solc_0.8/openzeppelin/proxy/transparent/ProxyAdmin.sol",
],
},
};

export default config;
123 changes: 123 additions & 0 deletions hardhat.config.zksync.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import "module-alias/register";

import "@matterlabs/hardhat-zksync";
import "@matterlabs/hardhat-zksync-solc";
import "@matterlabs/hardhat-zksync-verify";
import "@nomicfoundation/hardhat-chai-matchers";
import "@nomiclabs/hardhat-ethers";
import "@typechain/hardhat";
import "hardhat-dependency-compiler";
import "hardhat-deploy";
import { HardhatUserConfig, extendConfig, task } from "hardhat/config";
import { HardhatConfig } from "hardhat/types";

require("dotenv").config();

Check warning on line 14 in hardhat.config.zksync.ts

GitHub Actions / Lint

Require statement not part of import statement

const DEPLOYER_PRIVATE_KEY = process.env.DEPLOYER_PRIVATE_KEY;
const externalDeployments = {
zksyncsepolia: ["node_modules/@venusprotocol/governance-contracts/deployments/zksyncsepolia"],
};
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();

for (const account of accounts) {
console.log(account.address);
}
});

function isFork() {
return process.env.FORK === "true"
? {
allowUnlimitedContractSize: false,
loggingEnabled: false,
forking: {
url:
process.env[`ARCHIVE_NODE_${process.env.FORKED_NETWORK}`] ||
"https://data-seed-prebsc-1-s1.binance.org:8545",
blockNumber: 21068448,
},
accounts: {
accountsBalance: "1000000000000000000",
},
live: false,
zksync: true,
}
: {
allowUnlimitedContractSize: true,
loggingEnabled: false,
live: false,
zksync: true,
};
}

const config: HardhatUserConfig = {
defaultNetwork: "hardhat",
zksolc: {
version: "1.5.0",
},
solidity: {
compilers: [
{
version: "0.8.25",
settings: {
optimizer: {
enabled: true,
runs: 10000,
},
evmVersion: "paris",
outputSelection: {
"*": {
"*": ["storageLayout"],
},
},
},
},
],
},
networks: {
hardhat: isFork(),
zksyncsepolia: {
url: process.env.ARCHIVE_NODE_zksyncsepolia || "https://sepolia.era.zksync.dev",
ethNetwork: "sepolia",
verifyURL: "https://explorer.sepolia.era.zksync.dev/contract_verification",
accounts: DEPLOYER_PRIVATE_KEY ? [`0x${DEPLOYER_PRIVATE_KEY}`] : [],
zksync: true,
live: true,
},
},
paths: {
sources: "./contracts",
tests: "./tests",
cache: "./cache-zk",
artifacts: "./artifacts-zk",
},
mocha: {
timeout: 200000000,
},

typechain: {
outDir: "typechain",
target: "ethers-v5",
},
// Hardhat deploy
namedAccounts: {
deployer: {
default: 0, // here this will by default take the first account as deployer
},
},
dependencyCompiler: {
paths: [
"hardhat-deploy/solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol",
"hardhat-deploy/solc_0.8/openzeppelin/proxy/transparent/ProxyAdmin.sol",
"hardhat-deploy/solc_0.8/openzeppelin/proxy/transparent/ProxyAdmin.sol:ProxyAdmin",
],
},
};

export default config;
1 change: 1 addition & 0 deletions helpers/utils.ts
Original file line number Diff line number Diff line change
@@ -32,4 +32,5 @@ export const multisigs: ChainAddressesConfig = {
opbnbmainnet: "0xC46796a21a3A9FAB6546aF3434F2eBfFd0604207",
arbitrumsepolia: "0x1426A5Ae009c4443188DA8793751024E358A61C2",
arbitrumone: "0x14e0E151b33f9802b3e75b621c1457afc44DcAA0",
zksyncsepolia: "0xa2f83de95E9F28eD443132C331B6a9C9B7a9F866",
};
17 changes: 12 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -29,16 +29,17 @@
"access": "public"
},
"scripts": {
"compile": "hardhat compile",
"compile": "hardhat compile && hardhat compile --config hardhat.config.zksync.ts",
"test": "hardhat test",
"build": "rm -rf dist && hardhat compile && tsc --declaration",
"build": "rm -rf dist && hardhat compile && hardhat compile --config hardhat.config.zksync.ts && tsc --declaration",
"lint": "yarn lint:ts && yarn lint:sol && yarn prettier:check",
"lint:ts": "eslint --ignore-path ./.eslintignore --ext .js,.ts .",
"lint:sol": "solhint \"contracts/**/*.sol\"",
"lint:sol:fix": "prettier --write \"contracts/**/*.sol\"",
"prettier": "prettier --write \"**/*.{js,json,md,ts,yaml,yml,sol}\"",
"prettier:check": "prettier --check \"**/*.{js,json,md,ts,yaml,yml,sol}\"",
"docgen": "hardhat docgen"
"docgen": "hardhat docgen",
"clean": "hardhat clean && hardhat clean --config hardhat.config.zksync.ts"
},
"dependencies": {
"@nomiclabs/hardhat-ethers": "^2.2.3",
@@ -56,6 +57,10 @@
"@commitlint/cli": "^17.0.3",
"@commitlint/config-conventional": "^17.0.3",
"@defi-wonderland/smock": "^2.2.0",
"@matterlabs/hardhat-zksync": "^0.2.0",
"@matterlabs/hardhat-zksync-deploy": "^0.11.0",
"@matterlabs/hardhat-zksync-solc": "^1.2.1",
"@matterlabs/hardhat-zksync-verify": "0.7.0",
"@nomicfoundation/hardhat-chai-matchers": "^1.0.3",
"@nomicfoundation/hardhat-network-helpers": "^1.0.4",
"@nomicfoundation/hardhat-toolbox": "^2.0.0",
@@ -86,7 +91,8 @@
"ethers": "^5.7.2",
"fs-extra": "^10.1.0",
"hardhat": "^2.16.1",
"hardhat-deploy": "^0.11.26",
"hardhat-dependency-compiler": "^1.2.1",
"hardhat-deploy": "^0.12.4",
"hardhat-deploy-ethers": "^0.3.0-beta.13",
"hardhat-gas-reporter": "^1.0.8",
"husky": "^8.0.1",
@@ -99,7 +105,8 @@
"solparse": "^2.2.8",
"ts-node": "^10.7.0",
"typechain": "^5.2.0",
"typescript": "^4.6.3"
"typescript": "^4.6.3",
"zksync-ethers": "^5.9.1"
},
"_moduleAliases": {
"@nomiclabs/hardhat-ethers": "node_modules/hardhat-deploy-ethers"
1,271 changes: 1,220 additions & 51 deletions yarn.lock

Large diffs are not rendered by default.

0 comments on commit 7f76f6d

Please sign in to comment.