Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VEN-1830]: Refactor constants and deployment scripts for the sepolia deployment #294

Merged
merged 52 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
003887d
refactor: convert blocksPerYear constant to immutable and from intere…
0xlucian Aug 22, 2023
d34f157
refactor: add sepolia and ethereum to network and deployment configur…
0xlucian Aug 23, 2023
aad307e
refactor: fix linting
0xlucian Aug 23, 2023
740ae23
refactor: fix PoolLens failing test
0xlucian Aug 23, 2023
a7497da
refactor: add sepolia multisig to deployment config and transfer owne…
0xlucian Aug 28, 2023
dfba236
Update hardhat.config.ts
0xlucian Aug 31, 2023
2eb1b35
refactor: fix variable naming and add natspec for it
0xlucian Aug 31, 2023
b78e110
fix: compilation error
0xlucian Aug 31, 2023
13e5e63
Apply suggestions from code review
0xlucian Sep 1, 2023
4dd4752
chore: add sepolia token and pool deployment config
0xlucian Sep 1, 2023
16cac01
chore: deployment of Mock tokens on Sepolia and adding DEPLOYER_KEY
0xlucian Sep 1, 2023
9d99b73
chore: add config for Sepolia IL deployment
0xlucian Sep 4, 2023
647045b
chore: add deployments of core contracts.
0xlucian Sep 4, 2023
c0a95e8
chore: redeployments on sepolia
GitGuru7 Sep 18, 2023
1fb476e
chore: remove unused contract deployment
GitGuru7 Sep 18, 2023
f63346a
fix: config of usdt_core
GitGuru7 Sep 22, 2023
a9adb7e
refactor: replace multisig with vTreasury for vTokenReceiver address
0xlucian Oct 11, 2023
44a2719
refactor: change vTreasury value to be referenced from preconfiguredA…
0xlucian Oct 11, 2023
a120e2a
Update helpers/deploymentConfig.ts
0xlucian Oct 11, 2023
4244f64
fix: riskfund deploy script fix (wrong resolution of merge conflict)
0xlucian Oct 11, 2023
8469906
fix: lint and preconfiguredAddress decaration of Vtreasury wrong refe…
0xlucian Oct 11, 2023
bfaacdd
fix: format code
0xlucian Oct 11, 2023
6e2cfe5
chore: add deployment config for rewards on sepolia
0xlucian Oct 31, 2023
8aa8e84
chore: add MockXVS along with reward distributors for Sepolia
0xlucian Oct 31, 2023
5f092a6
chore: deploy CRV and crvUSD mock tokens to sepolia
0xlucian Nov 2, 2023
386581f
feat: updating deployment files
0xlucian Nov 27, 2023
822663b
refactor: add multisig for ETHEREUM
0xlucian Nov 27, 2023
e3f1625
fix: delete unused contract for this repo
0xlucian Nov 27, 2023
a4c7e0e
chore: update venus protocol package dependencies versions
0xlucian Nov 27, 2023
416baec
chore: refactor deployments to use deployment addresses from differen…
0xlucian Nov 27, 2023
b957327
feat: updating deployment files
0xlucian Nov 27, 2023
aaa46bb
chore: remove old deployments for sepolia
0xlucian Nov 27, 2023
539f94b
Merge branch 'refactor/ven-1830' of github.com:VenusProtocol/isolated…
0xlucian Nov 27, 2023
d2b7cdb
feat: updating deployment files
0xlucian Nov 27, 2023
0939e0a
fix: hardhat config file
0xlucian Nov 27, 2023
773e78c
Merge branch 'refactor/ven-1830' of github.com:VenusProtocol/isolated…
0xlucian Nov 27, 2023
2af5264
chore: add deployments in hardhat config file
0xlucian Nov 28, 2023
4ed9d5b
chore: update package version of oracle
0xlucian Nov 28, 2023
68b1e8c
refactor: use Multisig values from deployment config
0xlucian Nov 28, 2023
207c11b
chore: add newly deployed contracts
0xlucian Nov 28, 2023
1ccdfbe
refactor: VIP based config and scripts to match the latest deployment…
0xlucian Nov 28, 2023
4da3b52
refactor: adjust name of imported deployment script
0xlucian Nov 28, 2023
afaeec8
refactor:add unified config for ethereum and other networks and chang…
0xlucian Nov 28, 2023
f1e3083
feat: updating deployment files
0xlucian Nov 28, 2023
8234296
fix: yarn build
0xlucian Nov 28, 2023
06aad44
Merge branch 'refactor/ven-1830' of github.com:VenusProtocol/isolated…
0xlucian Nov 28, 2023
dbb2ce3
chore: update protocol-reserves version
0xlucian Nov 28, 2023
46e1327
fix: update venus-protocol version
0xlucian Nov 28, 2023
7bad19c
fix: bump protocol package version
coreyar Nov 28, 2023
efdf4c0
fix: deployment scripts for local deployment and update oracle packag…
0xlucian Nov 29, 2023
b8c14c0
fix: tests
0xlucian Nov 29, 2023
21d82f1
refactor: FORK_TESTNET and FORK_MAINNET variables in fork tests to ma…
0xlucian Nov 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
MNEMONIC=
ETHERSCAN_API_KEY=ABC123ABC123ABC123ABC123ABC123ABC1
FORK_MAINNET=false
QUICK_NODE_KEY=ABC123ABC123ABC123ABC123ABC123ABC1
# true or false
FORK=false
FORKED_NETWORK=bscmainnet

# Replace with your deployer's private key
DEPLOYER_PRIVATE_KEY=

## Archive nodes - Replace <YOUR_KEY_HERE> with your actual keys and uncomment the line you need
## ARCHIVE_NODE_bsctestnet=https://bsc-testnet.nodereal.io/v1/<YOUR_KEY_HERE>
## ARCHIVE_NODE_bscmainnet=https://bsc-mainnet.nodereal.io/v1/<YOUR_KEY_HERE>
## ARCHIVE_NODE_sepolia=https://ethereum-sepolia.blockpi.network/v1/rpc/public
## ARCHIVE_NODE_ethereum=https://eth-mainnet.nodereal.io/v1/<YOUR_KEY_HERE>

# Uncomment the lines below if you want to deploy on mainnet using Frame Wallet
#ARCHIVE_NODE_ethereum=http://127.0.0.1:1248
#ARCHIVE_NODE_bscmainnet=http://127.0.0.1:1248

# Replace with your Etherscan API key
ETHERSCAN_API_KEY=

# Set to true or false to control gas reporting
REPORT_GAS=
17 changes: 12 additions & 5 deletions contracts/BaseJumpRateModelV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity 0.8.13;
import { IAccessControlManagerV8 } from "@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.sol";

import { InterestRateModel } from "./InterestRateModel.sol";
import { BLOCKS_PER_YEAR, EXP_SCALE, MANTISSA_ONE } from "./lib/constants.sol";
import { EXP_SCALE, MANTISSA_ONE } from "./lib/constants.sol";

/**
* @title Logic for Compound's JumpRateModel Contract V2.
Expand All @@ -13,6 +13,10 @@ import { BLOCKS_PER_YEAR, EXP_SCALE, MANTISSA_ONE } from "./lib/constants.sol";
* The parameters of this interest rate model can be adjusted by the owner. Version 2 modifies Version 1 by enabling updateable parameters.
*/
abstract contract BaseJumpRateModelV2 is InterestRateModel {
/**
* @notice The approximate number of blocks per year that is assumed by the interest rate model
*/
uint256 public immutable blocksPerYear;
/**
* @notice The address of the AccessControlManager contract
*/
Expand Down Expand Up @@ -52,22 +56,25 @@ abstract contract BaseJumpRateModelV2 is InterestRateModel {

/**
* @notice Construct an interest rate model
* @param blocksPerYear_ The approximate number of blocks per year that is assumed by the interest rate model.
* @param baseRatePerYear The approximate target base APR, as a mantissa (scaled by EXP_SCALE)
* @param multiplierPerYear The rate of increase in interest rate wrt utilization (scaled by EXP_SCALE)
* @param jumpMultiplierPerYear The multiplierPerBlock after hitting a specified utilization point
* @param kink_ The utilization point at which the jump multiplier is applied
* @param accessControlManager_ The address of the AccessControlManager contract
*/
constructor(
uint256 blocksPerYear_,
uint256 baseRatePerYear,
uint256 multiplierPerYear,
uint256 jumpMultiplierPerYear,
uint256 kink_,
IAccessControlManagerV8 accessControlManager_
) {
require(address(accessControlManager_) != address(0), "invalid ACM address");

require(blocksPerYear_ != 0, "Invalid blocks per year");
accessControlManager = accessControlManager_;
blocksPerYear = blocksPerYear_;

_updateJumpRateModel(baseRatePerYear, multiplierPerYear, jumpMultiplierPerYear, kink_);
}
Expand Down Expand Up @@ -162,9 +169,9 @@ abstract contract BaseJumpRateModelV2 is InterestRateModel {
uint256 jumpMultiplierPerYear,
uint256 kink_
) internal {
baseRatePerBlock = baseRatePerYear / BLOCKS_PER_YEAR;
multiplierPerBlock = multiplierPerYear / BLOCKS_PER_YEAR;
jumpMultiplierPerBlock = jumpMultiplierPerYear / BLOCKS_PER_YEAR;
baseRatePerBlock = baseRatePerYear / blocksPerYear;
multiplierPerBlock = multiplierPerYear / blocksPerYear;
jumpMultiplierPerBlock = jumpMultiplierPerYear / blocksPerYear;
kink = kink_;

emit NewInterestParams(baseRatePerBlock, multiplierPerBlock, jumpMultiplierPerBlock, kink);
Expand Down
10 changes: 9 additions & 1 deletion contracts/JumpRateModelV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,21 @@ import { BaseJumpRateModelV2 } from "./BaseJumpRateModelV2.sol";
*/
contract JumpRateModelV2 is BaseJumpRateModelV2 {
constructor(
uint256 blocksPerYear_,
uint256 baseRatePerYear,
uint256 multiplierPerYear,
uint256 jumpMultiplierPerYear,
uint256 kink_,
IAccessControlManagerV8 accessControlManager_
)
BaseJumpRateModelV2(baseRatePerYear, multiplierPerYear, jumpMultiplierPerYear, kink_, accessControlManager_)
BaseJumpRateModelV2(
blocksPerYear_,
baseRatePerYear,
multiplierPerYear,
jumpMultiplierPerYear,
kink_,
accessControlManager_
)
/* solhint-disable-next-line no-empty-blocks */
{

Expand Down
14 changes: 10 additions & 4 deletions contracts/WhitePaperInterestRateModel.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
pragma solidity 0.8.13;

import { InterestRateModel } from "./InterestRateModel.sol";
import { BLOCKS_PER_YEAR, EXP_SCALE, MANTISSA_ONE } from "./lib/constants.sol";
import { EXP_SCALE, MANTISSA_ONE } from "./lib/constants.sol";

/**
* @title Compound's WhitePaperInterestRateModel Contract
* @author Compound
* @notice The parameterized model described in section 2.4 of the original Compound Protocol whitepaper
*/
contract WhitePaperInterestRateModel is InterestRateModel {
/**
* @notice The approximate number of blocks per year that is assumed by the interest rate model
*/
uint256 public immutable blocksPerYear;
/**
* @notice The multiplier of utilization rate that gives the slope of the interest rate
*/
Expand All @@ -27,9 +31,11 @@ contract WhitePaperInterestRateModel is InterestRateModel {
* @param baseRatePerYear The approximate target base APR, as a mantissa (scaled by EXP_SCALE)
* @param multiplierPerYear The rate of increase in interest rate wrt utilization (scaled by EXP_SCALE)
*/
constructor(uint256 baseRatePerYear, uint256 multiplierPerYear) {
baseRatePerBlock = baseRatePerYear / BLOCKS_PER_YEAR;
multiplierPerBlock = multiplierPerYear / BLOCKS_PER_YEAR;
constructor(uint256 blocksPerYear_, uint256 baseRatePerYear, uint256 multiplierPerYear) {
require(blocksPerYear_ != 0, "Invalid blocks per year");
baseRatePerBlock = baseRatePerYear / blocksPerYear_;
multiplierPerBlock = multiplierPerYear / blocksPerYear_;
blocksPerYear = blocksPerYear_;

emit NewInterestParams(baseRatePerBlock, multiplierPerBlock);
}
Expand Down
3 changes: 0 additions & 3 deletions contracts/lib/constants.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;

/// @dev The approximate number of blocks per year that is assumed by the interest rate model
uint256 constant BLOCKS_PER_YEAR = 10_512_000;

/// @dev Base unit for computations, usually used in scaling (multiplications, divisions)
uint256 constant EXP_SCALE = 1e18;

Expand Down
2 changes: 1 addition & 1 deletion deploy/003-price-oracle-configure-feeds.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import configureOracleFeeds from "@venusprotocol/oracle/dist/deploy/2-configure-feeds";
import configureOracleFeeds from "@venusprotocol/oracle/dist/deploy/3-configure-feeds";
import { HardhatRuntimeEnvironment } from "hardhat/types";

configureOracleFeeds.tags = ["Oracle"];
Expand Down
23 changes: 13 additions & 10 deletions deploy/009-deploy-vtokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import { DeployResult } from "hardhat-deploy/dist/types";
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";

import { getConfig, getTokenConfig } from "../helpers/deploymentConfig";
import { blocksPerYear, getConfig, getTokenConfig } from "../helpers/deploymentConfig";
import { InterestRateModels } from "../helpers/deploymentConfig";
import { getUnregisteredVTokens, toAddress } from "../helpers/deploymentUtils";

const ADDRESS_ONE = "0x0000000000000000000000000000000000000001";
import { AddressOne } from "../helpers/utils";
0xlucian marked this conversation as resolved.
Show resolved Hide resolved

const mantissaToBps = (num: BigNumberish) => {
return BigNumber.from(num).div(parseUnits("1", 14)).toString();
Expand All @@ -20,7 +19,6 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();
const { tokensConfig, poolConfig, preconfiguredAddresses } = await getConfig(hre.network.name);
0xlucian marked this conversation as resolved.
Show resolved Hide resolved
const protocolShareReserve = await deployments.getOrNull("ProtocolShareReserve");

const accessControlManagerAddress = await toAddress(
preconfiguredAddresses.AccessControlManager || "AccessControlManager",
Expand Down Expand Up @@ -74,14 +72,22 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
}

let rateModelAddress: string;
const BLOCKS_PER_YEAR: number = blocksPerYear[hre.network.name];
if (rateModel === InterestRateModels.JumpRate.toString()) {
const [b, m, j, k] = [baseRatePerYear, multiplierPerYear, jumpMultiplierPerYear, kink_].map(mantissaToBps);
const rateModelName = `JumpRateModelV2_base${b}bps_slope${m}bps_jump${j}bps_kink${k}bps`;
console.log(`Deploying interest rate model ${rateModelName}`);
const result: DeployResult = await deploy(rateModelName, {
from: deployer,
contract: "JumpRateModelV2",
args: [baseRatePerYear, multiplierPerYear, jumpMultiplierPerYear, kink_, accessControlManagerAddress],
args: [
BLOCKS_PER_YEAR,
baseRatePerYear,
multiplierPerYear,
jumpMultiplierPerYear,
kink_,
accessControlManagerAddress,
],
log: true,
autoMine: true,
});
Expand All @@ -93,7 +99,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const result: DeployResult = await deploy(rateModelName, {
from: deployer,
contract: "WhitePaperInterestRateModel",
args: [baseRatePerYear, multiplierPerYear],
args: [BLOCKS_PER_YEAR, baseRatePerYear, multiplierPerYear],
log: true,
autoMine: true,
});
Expand All @@ -115,10 +121,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
vTokenDecimals,
preconfiguredAddresses.NormalTimelock || deployer, // admin
accessControlManagerAddress,
[
preconfiguredAddresses.Shortfall || ADDRESS_ONE,
protocolShareReserve ? protocolShareReserve.address : treasuryAddress,
],
[AddressOne, treasuryAddress],
reserveFactor,
];
await deploy(`VToken_${symbol}`, {
Expand Down
17 changes: 11 additions & 6 deletions deploy/011-initial-liquidity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
getConfig,
getTokenConfig,
} from "../helpers/deploymentConfig";
import { getUnderlyingMock, getUnderlyingToken, getUnregisteredVTokens } from "../helpers/deploymentUtils";
import { getUnderlyingMock, getUnderlyingToken, getUnregisteredVTokens, toAddress } from "../helpers/deploymentUtils";
0xlucian marked this conversation as resolved.
Show resolved Hide resolved

const sumAmounts = async (tokens: { symbol: string; amount: BigNumber }[]) => {
const amounts: { [symbol: string]: BigNumber } = {};
Expand Down Expand Up @@ -44,8 +44,8 @@ const faucetTokens = async (deploymentConfig: DeploymentConfig, hre: HardhatRunt
}
};

const approveTimelock = async (deploymentConfig: DeploymentConfig, hre: HardhatRuntimeEnvironment) => {
if (hre.network.name !== "bsctestnet") {
const sendInitialLiquidityToTreasury = async (deploymentConfig: DeploymentConfig, hre: HardhatRuntimeEnvironment) => {
if (hre.network.name == "bscmainnet" || hre.network.name == "ethereum") {
return;
}
const { poolConfig, tokensConfig, preconfiguredAddresses } = deploymentConfig;
Expand All @@ -59,16 +59,21 @@ const approveTimelock = async (deploymentConfig: DeploymentConfig, hre: HardhatR
const totalAmounts = await sumAmounts(amounts);
for (const [symbol, amount] of Object.entries(totalAmounts)) {
const tokenContract = await getUnderlyingToken(symbol, tokensConfig);
console.log(`Approving ${amount} ${symbol} to Timelock`);
const tx = await tokenContract.approve(preconfiguredAddresses.NormalTimelock, amount, { gasLimit: 5000000 });
console.log(`Sending ${amount} ${symbol} to VTreasury`);
console.log(`Token Contract: ${tokenContract.address}`);
console.log(`Token Contract: ${amount.toString()}`);
const treasuryAddress = await toAddress(preconfiguredAddresses.VTreasury || "VTreasury", hre);
console.log(`Token Contract: ${treasuryAddress}`);

const tx = await tokenContract.transfer(treasuryAddress, amount, { gasLimit: 5000000 });
await tx.wait(1);
}
};

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const deploymentConfig = await getConfig(hre.network.name);
await faucetTokens(deploymentConfig, hre);
await approveTimelock(deploymentConfig, hre);
await sendInitialLiquidityToTreasury(deploymentConfig, hre);
};

func.tags = ["InitialLiquidity", "il"];
Expand Down
41 changes: 14 additions & 27 deletions deploy/013-vip-based-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
contract: string;
signature: string;
argTypes: string[];
parameters: any[];

Check warning on line 29 in deploy/013-vip-based-config.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
value: BigNumberish;
}

Expand Down Expand Up @@ -177,36 +177,23 @@
deploymentConfig: DeploymentConfig,
hre: HardhatRuntimeEnvironment,
): Promise<GovernanceCommand[]> => {
const { deployer } = await hre.getNamedAccounts();
if (!hre.network.live) {
return [];
}
const { preconfiguredAddresses, tokensConfig } = deploymentConfig;
const { asset, initialSupply } = vTokenConfig;
const token = getTokenConfig(asset, tokensConfig);
const tokenContract = await getUnderlyingToken(token.symbol, tokensConfig);

if (hre.network.name === "bsctestnet") {
console.log(`Adding a command to transfer ${initialSupply} ${token.symbol} to Timelock`);
return [
{
contract: tokenContract.address,
signature: "transferFrom(address,address,uint256)",
argTypes: ["address", "address", "uint256"],
parameters: [deployer, preconfiguredAddresses.NormalTimelock, initialSupply],
value: 0,
},
];
} else if (hre.network.name === "bscmainnet") {
console.log(`Adding a command to withdraw ${initialSupply} ${token.symbol} to Timelock`);
return [
{
contract: preconfiguredAddresses.VTreasury,
signature: "withdrawTreasuryBEP20(address,uint256,address)",
argTypes: ["address", "uint256", "address"],
parameters: [tokenContract.address, initialSupply, preconfiguredAddresses.NormalTimelock],
value: 0,
},
];
}
return [];
console.log(`Adding a command to withdraw ${initialSupply} ${token.symbol} to Timelock from Treasury`);
return [
{
contract: preconfiguredAddresses.VTreasury,
signature: "withdrawTreasuryToken(address,uint256,address)",
argTypes: ["address", "uint256", "address"],
parameters: [tokenContract.address, initialSupply, preconfiguredAddresses.NormalTimelock],
value: 0,
},
];
};

const approvePoolRegistry = async (
Expand Down Expand Up @@ -318,7 +305,7 @@
caller: string,
hre: HardhatRuntimeEnvironment,
): Promise<boolean> => {
const role = makeRole(hre.network.name === "bscmainnet", targetContract, method);
const role = makeRole(hre.network.live, targetContract, method);
return accessControl.hasRole(role, caller);
};

Expand Down Expand Up @@ -360,7 +347,7 @@
const logCommand = (prefix: string, command: GovernanceCommand) => {
const valueStr = command.value == 0 ? "" : "{ value: " + parseEther(command.value.toString()) + " }";
console.log(`${prefix} ${command.contract}.${command.signature}${valueStr} (`);
command.parameters.forEach((param: any) => console.log(` ${param},`));

Check warning on line 350 in deploy/013-vip-based-config.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
console.log(")");
};

Expand Down
47 changes: 47 additions & 0 deletions deploy/015-transfer-funds-ownership.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { ethers } from "hardhat";
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";

import { ETHEREUM_MULTISIG, SEPOLIA_MULTISIG } from "../helpers/deploymentConfig";

interface Config {
[key: string]: string;
}

const TESTNET_MNEMONIC_SIGNER = "0xFA747c4a62c4D168276329F822d004026A1c05E9"; // signer[1] from testnet mnemonic

const targetOwners: Config = {
hardhat: "0x70997970C51812dc3A010C7d01b50e0d17dc79C8", // signer[1] from hardhat mnemonic
0xlucian marked this conversation as resolved.
Show resolved Hide resolved
bsctestnet: TESTNET_MNEMONIC_SIGNER,
bscmainnet: "0x939bD8d64c0A9583A7Dcea9933f7b21697ab6396", // NORMAL VIP Timelock
0xlucian marked this conversation as resolved.
Show resolved Hide resolved
sepolia: SEPOLIA_MULTISIG,
ethereum: ETHEREUM_MULTISIG,
};

const contracts = ["RiskFund", "Shortfall", "ProtocolShareReserve"];

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
await transfer2StepOwnerships(contracts, hre.network.name);
};

const transfer2StepOwnerships = async (contractNames: string[], networkName: string) => {
for (const contractName of contractNames) {
const contract = await ethers.getContract(contractName);
const owner = await contract.owner();

let tx;
if (owner !== targetOwners[networkName]) {
tx = await contract.transferOwnership(targetOwners[networkName]);
await tx.wait(1);
const pendingOwner = await contract.pendingOwner();
console.log(
`${contractName} owner ${owner} sucessfully changed to ${pendingOwner}. Please accept the ownership.`,
);
} else {
console.error(`${contractName} owner ${owner} is equal to target ownership address ${targetOwners[networkName]}`);
}
}
};

func.tags = ["TransferFundsOwnership"];
export default func;
Loading
Loading