diff --git a/.eslint-tsconfig b/.eslint-tsconfig index f3d56b89b..7cf6ed892 100644 --- a/.eslint-tsconfig +++ b/.eslint-tsconfig @@ -1,4 +1,4 @@ { "extends": "./tsconfig.json", - "include": ["jest.config.js", ".eslintrc.js", "tests", "scenario", "deploy", "docgen-templates", "commitlint.config.js", "./hardhat.config.zksync.ts"] + "include": ["jest.config.js", ".eslintrc.js", "tests", "scenario", "deploy", "docgen-templates", "commitlint.config.js", "./hardhat.config.zksync.ts", "type-extensions.ts"] } diff --git a/deploy/001-deploy-mock-tokens.ts b/deploy/001-deploy-mock-tokens.ts index 3ed63103c..d4ba52349 100644 --- a/deploy/001-deploy-mock-tokens.ts +++ b/deploy/001-deploy-mock-tokens.ts @@ -27,6 +27,6 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { func.tags = ["MockTokens"]; -func.skip = async hre => hre.network.live +func.skip = async hre => hre.network.live; export default func; diff --git a/deploy/008-deploy-comptrollers.ts b/deploy/008-deploy-comptrollers.ts index 7572afe3f..c16f7c596 100644 --- a/deploy/008-deploy-comptrollers.ts +++ b/deploy/008-deploy-comptrollers.ts @@ -36,10 +36,10 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { skipIfAlreadyDeployed: true, }); - const unregisteredPools = await getUnregisteredPools(poolConfig, hre); + const unregisteredPools = await getUnregisteredPools(poolConfig); for (const pool of unregisteredPools) { const Comptroller = await ethers.getContractFactory("Comptroller"); - + // Deploying a proxy for Comptroller await deploy(`Comptroller_${pool.id}`, { from: deployer, diff --git a/deploy/009-deploy-vtokens.ts b/deploy/009-deploy-vtokens.ts index c83fd6458..72122ac99 100644 --- a/deploy/009-deploy-vtokens.ts +++ b/deploy/009-deploy-vtokens.ts @@ -47,7 +47,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { skipIfAlreadyDeployed: true, }); - const poolsWithUnregisteredVTokens = await getUnregisteredVTokens(poolConfig, hre); + const poolsWithUnregisteredVTokens = await getUnregisteredVTokens(poolConfig); for (const pool of poolsWithUnregisteredVTokens) { const comptrollerProxy = await ethers.getContract(`Comptroller_${pool.id}`); diff --git a/deploy/010-deploy-reward-distributors.ts b/deploy/010-deploy-reward-distributors.ts index ecf5b91db..780681634 100644 --- a/deploy/010-deploy-reward-distributors.ts +++ b/deploy/010-deploy-reward-distributors.ts @@ -18,15 +18,13 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const { tokensConfig, poolConfig, preconfiguredAddresses } = await getConfig(hre.getNetworkName()); const { isTimeBased, blocksPerYear } = getBlockOrTimestampBasedDeploymentInfo(hre.getNetworkName()); - const accessControlAddress = await toAddress( - preconfiguredAddresses.AccessControlManager || "AccessControlManager", - ); + const accessControlAddress = await toAddress(preconfiguredAddresses.AccessControlManager || "AccessControlManager"); const proxyOwnerAddress = await toAddress(preconfiguredAddresses.NormalTimelock || "account:deployer"); const defaultProxyAdmin = await hre.artifacts.readArtifact( "hardhat-deploy/solc_0.8/openzeppelin/proxy/transparent/ProxyAdmin.sol:ProxyAdmin", ); - const pools = await getUnregisteredRewardsDistributors(poolConfig, hre); + const pools = await getUnregisteredRewardsDistributors(poolConfig); await deploy("RewardsDistributorImpl", { contract: "RewardsDistributor", diff --git a/deploy/011-initial-liquidity.ts b/deploy/011-initial-liquidity.ts index 4fe2c4eff..54a509529 100644 --- a/deploy/011-initial-liquidity.ts +++ b/deploy/011-initial-liquidity.ts @@ -43,14 +43,14 @@ const faucetTokens = async (deploymentConfig: DeploymentConfig) => { const tx = await tokenContract.faucet(amount, { gasLimit: 5000000 }); await tx.wait(1); } - return vTokensToFaucet + return vTokensToFaucet; }; const sendInitialLiquidityToTreasury = async (deploymentConfig: DeploymentConfig, tokensToFaucet: VTokenConfig[]) => { if (getNetworkName() == "bscmainnet" || getNetworkName() == "ethereum") { return; } - + const { tokensConfig, preconfiguredAddresses } = deploymentConfig; const amounts = tokensToFaucet.map((token: VTokenConfig) => ({ diff --git a/deploy/013-vip-based-config.ts b/deploy/013-vip-based-config.ts index c38819862..6204d25be 100644 --- a/deploy/013-vip-based-config.ts +++ b/deploy/013-vip-based-config.ts @@ -1,6 +1,6 @@ import { BigNumberish } from "ethers"; import { defaultAbiCoder, parseEther } from "ethers/lib/utils"; -import { ethers, network, deployments } from "hardhat"; +import { deployments, ethers, network } from "hardhat"; import { DeployFunction } from "hardhat-deploy/types"; import { HardhatRuntimeEnvironment } from "hardhat/types"; @@ -97,10 +97,7 @@ const configureRewards = async ( return commands.flat(); }; -const acceptOwnership = async ( - contractName: string, - targetOwner: string, -): Promise => { +const acceptOwnership = async (contractName: string, targetOwner: string): Promise => { if (!network.live) { return []; } @@ -151,10 +148,7 @@ const addPool = (poolRegistry: PoolRegistry, comptroller: Comptroller, pool: Poo }; }; -const addPools = async ( - unregisteredPools: PoolConfig[], - poolsOwner: string, -): Promise => { +const addPools = async (unregisteredPools: PoolConfig[], poolsOwner: string): Promise => { const poolRegistry = await ethers.getContract("PoolRegistry"); const commands = await Promise.all( unregisteredPools.map(async (pool: PoolConfig) => { @@ -173,7 +167,7 @@ const transferInitialLiquidity = async ( vTokenConfig: VTokenConfig, deploymentConfig: DeploymentConfig, ): Promise => { - if (!hre.network.live) { + if (!network.live) { return []; } const { preconfiguredAddresses, tokensConfig } = deploymentConfig; @@ -255,10 +249,7 @@ const setReduceReservesBlockDelta = async ( }; }; -const addMarkets = async ( - unregisteredVTokens: PoolConfig[], - deploymentConfig: DeploymentConfig, -) => { +const addMarkets = async (unregisteredVTokens: PoolConfig[], deploymentConfig: DeploymentConfig) => { const poolRegistry = await ethers.getContract("PoolRegistry"); const poolCommands = await Promise.all( unregisteredVTokens.map(async (pool: PoolConfig) => { @@ -302,9 +293,7 @@ const hasPermission = async ( return accessControl.hasRole(role, caller); }; -const configureAccessControls = async ( - deploymentConfig: DeploymentConfig, -): Promise => { +const configureAccessControls = async (deploymentConfig: DeploymentConfig): Promise => { const { accessControlConfig, preconfiguredAddresses } = deploymentConfig; const accessControlManagerAddress = await toAddress( preconfiguredAddresses.AccessControlManager || "AccessControlManager", diff --git a/deploy/014-shortfall-protocolshare.ts b/deploy/014-shortfall-protocolshare.ts index a44f20145..7abbbdee3 100644 --- a/deploy/014-shortfall-protocolshare.ts +++ b/deploy/014-shortfall-protocolshare.ts @@ -76,5 +76,4 @@ func.skip = async hre => hre.getNetworkName() === "opbnbmainnet" || hre.getNetworkName() === "ethereum"; - export default func; diff --git a/hardhat.config.ts b/hardhat.config.ts index 8a033fbff..3239cd683 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -22,20 +22,18 @@ dotenv.config(); const DEPLOYER_PRIVATE_KEY = process.env.DEPLOYER_PRIVATE_KEY; const getRpcUrl = (networkName: string): string => { - let uri + let uri; if (networkName) { uri = process.env[`ARCHIVE_NODE_${networkName}`]; } if (!uri) { - throw new Error( - `invalid uri or network not supported by node provider : ${uri}` - ); + throw new Error(`invalid uri or network not supported by node provider : ${uri}`); } return uri; -} +}; -extendEnvironment((hre) => { - hre.getNetworkName = () => process.env.HARDHAT_FORK_NETWORK || hre.network.name +extendEnvironment(hre => { + hre.getNetworkName = () => process.env.HARDHAT_FORK_NETWORK || hre.network.name; }); extendConfig((config: HardhatConfig) => { @@ -96,7 +94,7 @@ extendConfig((config: HardhatConfig) => { `node_modules/@venusprotocol/venus-protocol/deployments/${process.env.HARDHAT_FORK_NETWORK}`, `node_modules/@venusprotocol/protocol-reserve/deployments/${process.env.HARDHAT_FORK_NETWORK}`, `node_modules/@venusprotocol/governance-contracts/deployments/${process.env.HARDHAT_FORK_NETWORK}`, - ] + ]; } } }); @@ -257,11 +255,9 @@ const config: HardhatUserConfig = { live: !!process.env.HARDHAT_FORK_NETWORK, forking: process.env.HARDHAT_FORK_NETWORK ? { - url: getRpcUrl(process.env.HARDHAT_FORK_NETWORK), - blockNumber: process.env.HARDHAT_FORK_NUMBER - ? parseInt(process.env.HARDHAT_FORK_NUMBER) - : undefined, - } + url: getRpcUrl(process.env.HARDHAT_FORK_NETWORK), + blockNumber: process.env.HARDHAT_FORK_NUMBER ? parseInt(process.env.HARDHAT_FORK_NUMBER) : undefined, + } : undefined, }, development: { diff --git a/helpers/deploymentUtils.ts b/helpers/deploymentUtils.ts index 3a80ba2bd..e578f25d6 100644 --- a/helpers/deploymentUtils.ts +++ b/helpers/deploymentUtils.ts @@ -1,4 +1,4 @@ -import { ethers, getNamedAccounts, deployments } from "hardhat"; +import { deployments, ethers, getNamedAccounts } from "hardhat"; import { Comptroller, ERC20, MockToken } from "../typechain"; import { @@ -36,9 +36,7 @@ export const getUnderlyingToken = async (assetSymbol: string, tokensConfig: Toke return ethers.getContractAt("@openzeppelin/contracts/token/ERC20/ERC20.sol:ERC20", underlyingAddress); }; -export const getUnregisteredPools = async ( - poolConfig: PoolConfig[], -): Promise => { +export const getUnregisteredPools = async (poolConfig: PoolConfig[]): Promise => { const registry = await ethers.getContract("PoolRegistry"); const registeredPools = (await registry.getAllPools()).map((p: { comptroller: string }) => p.comptroller); const isRegistered = await Promise.all( @@ -54,9 +52,7 @@ export const getUnregisteredPools = async ( return poolConfig.filter((_, idx: number) => !isRegistered[idx]); }; -export const getUnregisteredVTokens = async ( - poolConfig: PoolConfig[], -): Promise => { +export const getUnregisteredVTokens = async (poolConfig: PoolConfig[]): Promise => { const registry = await ethers.getContract("PoolRegistry"); const registeredPools = await registry.getAllPools(); const comptrollers = await Promise.all( @@ -89,9 +85,7 @@ export const getUnregisteredVTokens = async ( ); }; -export const getUnregisteredRewardsDistributors = async ( - poolConfig: PoolConfig[], -): Promise => { +export const getUnregisteredRewardsDistributors = async (poolConfig: PoolConfig[]): Promise => { const registry = await ethers.getContract("PoolRegistry"); const registeredPools = await registry.getAllPools(); const comptrollers = await Promise.all( diff --git a/type-extensions.ts b/type-extensions.ts index 42faf3f64..2fae4ac31 100644 --- a/type-extensions.ts +++ b/type-extensions.ts @@ -6,4 +6,4 @@ declare module "hardhat/types/runtime" { export interface HardhatRuntimeEnvironment { getNetworkName: () => string; } -} \ No newline at end of file +}