Skip to content

Commit

Permalink
chore: 👕
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyar committed Sep 26, 2024
1 parent d922d09 commit 2a01c75
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .eslint-tsconfig
Original file line number Diff line number Diff line change
@@ -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"]
}
2 changes: 1 addition & 1 deletion deploy/001-deploy-mock-tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
4 changes: 2 additions & 2 deletions deploy/008-deploy-comptrollers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion deploy/009-deploy-vtokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);

Expand Down
6 changes: 2 additions & 4 deletions deploy/010-deploy-reward-distributors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions deploy/011-initial-liquidity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => ({
Expand Down
23 changes: 6 additions & 17 deletions deploy/013-vip-based-config.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -97,10 +97,7 @@ const configureRewards = async (
return commands.flat();
};

const acceptOwnership = async (
contractName: string,
targetOwner: string,
): Promise<GovernanceCommand[]> => {
const acceptOwnership = async (contractName: string, targetOwner: string): Promise<GovernanceCommand[]> => {
if (!network.live) {
return [];
}
Expand Down Expand Up @@ -151,10 +148,7 @@ const addPool = (poolRegistry: PoolRegistry, comptroller: Comptroller, pool: Poo
};
};

const addPools = async (
unregisteredPools: PoolConfig[],
poolsOwner: string,
): Promise<GovernanceCommand[]> => {
const addPools = async (unregisteredPools: PoolConfig[], poolsOwner: string): Promise<GovernanceCommand[]> => {
const poolRegistry = await ethers.getContract<PoolRegistry>("PoolRegistry");
const commands = await Promise.all(
unregisteredPools.map(async (pool: PoolConfig) => {
Expand All @@ -173,7 +167,7 @@ const transferInitialLiquidity = async (
vTokenConfig: VTokenConfig,
deploymentConfig: DeploymentConfig,
): Promise<GovernanceCommand[]> => {
if (!hre.network.live) {
if (!network.live) {
return [];
}
const { preconfiguredAddresses, tokensConfig } = deploymentConfig;
Expand Down Expand Up @@ -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>("PoolRegistry");
const poolCommands = await Promise.all(
unregisteredVTokens.map(async (pool: PoolConfig) => {
Expand Down Expand Up @@ -302,9 +293,7 @@ const hasPermission = async (
return accessControl.hasRole(role, caller);
};

const configureAccessControls = async (
deploymentConfig: DeploymentConfig,
): Promise<GovernanceCommand[]> => {
const configureAccessControls = async (deploymentConfig: DeploymentConfig): Promise<GovernanceCommand[]> => {
const { accessControlConfig, preconfiguredAddresses } = deploymentConfig;
const accessControlManagerAddress = await toAddress(
preconfiguredAddresses.AccessControlManager || "AccessControlManager",
Expand Down
1 change: 0 additions & 1 deletion deploy/014-shortfall-protocolshare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,4 @@ func.skip = async hre =>
hre.getNetworkName() === "opbnbmainnet" ||
hre.getNetworkName() === "ethereum";


export default func;
22 changes: 9 additions & 13 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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}`,
]
];
}
}
});
Expand Down Expand Up @@ -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: {
Expand Down
14 changes: 4 additions & 10 deletions helpers/deploymentUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ethers, getNamedAccounts, deployments } from "hardhat";
import { deployments, ethers, getNamedAccounts } from "hardhat";

import { Comptroller, ERC20, MockToken } from "../typechain";
import {
Expand Down Expand Up @@ -36,9 +36,7 @@ export const getUnderlyingToken = async (assetSymbol: string, tokensConfig: Toke
return ethers.getContractAt<ERC20>("@openzeppelin/contracts/token/ERC20/ERC20.sol:ERC20", underlyingAddress);
};

export const getUnregisteredPools = async (
poolConfig: PoolConfig[],
): Promise<PoolConfig[]> => {
export const getUnregisteredPools = async (poolConfig: PoolConfig[]): Promise<PoolConfig[]> => {
const registry = await ethers.getContract("PoolRegistry");
const registeredPools = (await registry.getAllPools()).map((p: { comptroller: string }) => p.comptroller);
const isRegistered = await Promise.all(
Expand All @@ -54,9 +52,7 @@ export const getUnregisteredPools = async (
return poolConfig.filter((_, idx: number) => !isRegistered[idx]);
};

export const getUnregisteredVTokens = async (
poolConfig: PoolConfig[],
): Promise<PoolConfig[]> => {
export const getUnregisteredVTokens = async (poolConfig: PoolConfig[]): Promise<PoolConfig[]> => {
const registry = await ethers.getContract("PoolRegistry");
const registeredPools = await registry.getAllPools();
const comptrollers = await Promise.all(
Expand Down Expand Up @@ -89,9 +85,7 @@ export const getUnregisteredVTokens = async (
);
};

export const getUnregisteredRewardsDistributors = async (
poolConfig: PoolConfig[],
): Promise<PoolConfig[]> => {
export const getUnregisteredRewardsDistributors = async (poolConfig: PoolConfig[]): Promise<PoolConfig[]> => {
const registry = await ethers.getContract("PoolRegistry");
const registeredPools = await registry.getAllPools();
const comptrollers = await Promise.all(
Expand Down
2 changes: 1 addition & 1 deletion type-extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ declare module "hardhat/types/runtime" {
export interface HardhatRuntimeEnvironment {
getNetworkName: () => string;
}
}
}

0 comments on commit 2a01c75

Please sign in to comment.