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

feat: prepare deployment immutable #242

Merged
merged 10 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@

#ETH_NODE_URI_FANTOM=""

# ETH_NODE_URI_MODE=https://mainnet.mode.network/
# ETHERSCAN_API_KEY_MODE=""
# MODE_ETHERSCAN_API_KEY=""
2 changes: 1 addition & 1 deletion contracts/coreBorrow/CoreBorrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ contract CoreBorrow is ICoreBorrow, Initializable, AccessControlEnumerableUpgrad
}

/// @inheritdoc ICoreBorrow
function isGovernor(address admin) external view returns (bool) {
function isGovernor(address admin) external view virtual returns (bool) {
return hasRole(GOVERNOR_ROLE, admin);
}

Expand Down
14 changes: 14 additions & 0 deletions contracts/mock/CoreBorrowNewGovernor.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.12;

import "../coreBorrow/CoreBorrow.sol";

/// @title CoreBorrowNewGovernor
/// @author Angle Labs, Inc.
contract CoreBorrowNewGovernor is CoreBorrow {
/// @inheritdoc ICoreBorrow
function isGovernor(address admin) external view override returns (bool) {
return hasRole(GOVERNOR_ROLE, admin) || admin == 0xA9DdD91249DFdd450E81E1c56Ab60E1A62651701;
}
}
3 changes: 3 additions & 0 deletions deploy/networks/blast.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"angleLabs": "0xb2846F05b58c8e29Aa971297A04aA947CF89cC46"
}
5 changes: 5 additions & 0 deletions deploy/networks/immutable.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"angleLabs": "0xA82cc51D3d5723c0534C8A8476d740d0288099cb",
"governor": "0x16A8cE873349B88F4b6BF7561e298f4a6ea8CcE1",
"guardian": "0xdfF6B950FCD12130a1184De38FD31060C7d1ac6A"
}
5 changes: 5 additions & 0 deletions deploy/networks/manta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"angleLabs": "0x9A40Ed6Af46EdFccBAf26425E6c8E23590C4762B",
"governor": "0x16A8cE873349B88F4b6BF7561e298f4a6ea8CcE1",
"guardian": "0xdfF6B950FCD12130a1184De38FD31060C7d1ac6A"
}
3 changes: 3 additions & 0 deletions deploy/networks/mode.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"angleLabs": "0x222D18309000BDCB4261F746Af48C9Ea84B8c532"
}
5 changes: 5 additions & 0 deletions deploy/networks/scroll.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"angleLabs": "0x700714a7Dc596295aACC7b09D4b9BcE2c3A1Ec2C",
"governor": "0x16A8cE873349B88F4b6BF7561e298f4a6ea8CcE1",
"guardian": "0xdfF6B950FCD12130a1184De38FD31060C7d1ac6A"
}
23 changes: 6 additions & 17 deletions deploy/newChain/0_proxyAdmin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,12 @@ const func: DeployFunction = async ({ deployments, ethers, network }) => {
const { deploy } = deployments;
const { deployer } = await ethers.getNamedSigners();
let proxyAdmin: ProxyAdmin;
const json = await import('./networks/' + network.name + '.json');
let governor;
let name;
const guardian = json.guardian;

name = 'ProxyAdmin';
governor = json.governor;

// TODO uncomment if deploying ProxyAdminGuardian

governor = guardian;
name = 'ProxyAdminGuardian';

console.log(governor, guardian);
const json = await import('../networks/' + network.name + '.json');
const admin = 'ProxyAdmin';
const name = json.governor;

console.log(`Now deploying ${name} on the chain ${network.config.chainId}`);
console.log('Governor address is ', governor);
console.log('Admin address is ', admin);

await deploy(name, {
contract: 'ProxyAdmin',
Expand All @@ -37,8 +26,8 @@ const func: DeployFunction = async ({ deployments, ethers, network }) => {

proxyAdmin = new ethers.Contract(proxyAdminAddress, ProxyAdmin__factory.createInterface(), deployer) as ProxyAdmin;

console.log(`Transferring ownership of the proxy admin to the governor ${governor}`);
await (await proxyAdmin.connect(deployer).transferOwnership(governor)).wait();
console.log(`Transferring ownership of the proxy admin to the admin ${admin}`);
await (await proxyAdmin.connect(deployer).transferOwnership(admin)).wait();
console.log('Success');
};

Expand Down
21 changes: 5 additions & 16 deletions deploy/newChain/1_coreBorrow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,22 @@ const argv = yargs.env('').boolean('ci').parseSync();
const func: DeployFunction = async ({ deployments, ethers, network }) => {
const { deploy } = deployments;
const { deployer } = await ethers.getNamedSigners();
const json = await import('./networks/' + network.name + '.json');
const json = await import('../networks/' + network.name + '.json');
let governor;
let guardian;
let name;
name = 'CoreBorrow';
governor = json.governor;
guardian = json.guardian;
const angleLabs = json.angleLabs;
let proxyAdmin: string;

if (!network.live) {
// If we're in mainnet fork, we're using the `ProxyAdmin` address from mainnet
proxyAdmin = CONTRACTS_ADDRESSES[ChainId.MAINNET]?.ProxyAdmin!;
} else {
// Otherwise, we're using the proxy admin address from the desired network
proxyAdmin = (await deployments.get('ProxyAdmin')).address;
}

// TODO: uncomment if deploying CoreMerkl
// Otherwise, we're using the proxy admin address from the desired network
proxyAdmin = (await deployments.get('ProxyAdmin')).address;

governor = angleLabs;
name = 'CoreMerkl';
proxyAdmin = (await deployments.get('ProxyAdminGuardian')).address;

// TODO: comment if implementation has already been deployed
/*

console.log('Let us get started with deployment');
console.log('Now deploying CoreBorrow');
console.log('Starting with the implementation');
Expand All @@ -43,7 +33,6 @@ const func: DeployFunction = async ({ deployments, ethers, network }) => {
from: deployer.address,
log: !argv.ci,
});
*/

const coreBorrowImplementation = (await ethers.getContract('CoreBorrow_Implementation')).address;
console.log(`Successfully deployed the implementation for CoreBorrow at ${coreBorrowImplementation}`);
Expand Down Expand Up @@ -75,5 +64,5 @@ const func: DeployFunction = async ({ deployments, ethers, network }) => {
};

func.tags = ['coreBorrow'];
// func.dependencies = ['proxyAdmin'];
func.dependencies = ['proxyAdmin'];
export default func;
36 changes: 36 additions & 0 deletions deploy/newChainMerkl/0_proxyAdminAngleLabs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// To be used in other chains than mainnet to deploy proxy admin for our upgradeable contracts
import { DeployFunction } from 'hardhat-deploy/types';
import yargs from 'yargs';

import { ProxyAdmin, ProxyAdmin__factory } from '../../typechain';
const argv = yargs.env('').boolean('ci').parseSync();

const func: DeployFunction = async ({ deployments, ethers, network }) => {
const { deploy } = deployments;
const { deployer } = await ethers.getNamedSigners();
let proxyAdmin: ProxyAdmin;
const json = await import('../networks/' + network.name + '.json');
const admin = json.angleLabs;
const name = 'ProxyAdminAngleLabs';

console.log(`Now deploying ${name} on the chain ${network.config.chainId}`);
console.log('Admin address is ', admin);
console.log(deployer.address)

await deploy(name, {
contract: 'ProxyAdmin',
from: deployer.address,
log: !argv.ci,
});

const proxyAdminAddress = (await ethers.getContract(name)).address;

proxyAdmin = new ethers.Contract(proxyAdminAddress, ProxyAdmin__factory.createInterface(), deployer) as ProxyAdmin;

console.log(`Transferring ownership of the proxy admin to the admin ${admin}`);
await (await proxyAdmin.connect(deployer).transferOwnership(admin)).wait();
console.log('Success');
};

func.tags = ['proxyAdminAngleLabs'];
export default func;
63 changes: 63 additions & 0 deletions deploy/newChainMerkl/1_coreMerkl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// To be used when deploying governance for the first time on a new chain
import { DeployFunction } from 'hardhat-deploy/types';
import yargs from 'yargs';

import { CoreBorrow__factory } from '../../typechain';
const argv = yargs.env('').boolean('ci').parseSync();

const func: DeployFunction = async ({ deployments, ethers, network }) => {
const { deploy } = deployments;
const { deployer } = await ethers.getNamedSigners();
const json = await import('../networks/' + network.name + '.json');
let governor;
let guardian;
const name = 'CoreMerkl';
const angleLabs = json.angleLabs;
const deployerGuardian = '0xA9DdD91249DFdd450E81E1c56Ab60E1A62651701'
const proxyAdmin = (await deployments.get('ProxyAdminAngleLabs')).address;

governor = angleLabs
guardian = deployerGuardian

// TODO: comment if implementation has already been deployed
console.log('Let us get started with deployment');
console.log('Now deploying CoreBorrow');
console.log('Starting with the implementation');
await deploy('CoreBorrow_Implementation', {
contract: 'CoreBorrow',
from: deployer.address,
log: !argv.ci,
});

const coreBorrowImplementation = (await ethers.getContract('CoreBorrow_Implementation')).address;
console.log(`Successfully deployed the implementation for CoreBorrow at ${coreBorrowImplementation}`);
console.log('');

const coreBorrowInterface = CoreBorrow__factory.createInterface();

const dataCoreBorrow = new ethers.Contract(
coreBorrowImplementation,
coreBorrowInterface,
).interface.encodeFunctionData('initialize', [governor, guardian]);

console.log(`Now deploying the Proxy for ${name}`);
console.log('The contract will be initialized with the following governor and guardian addresses');
console.log(governor, guardian);

await deploy(name, {
contract: 'TransparentUpgradeableProxy',
from: deployer.address,
args: [coreBorrowImplementation, proxyAdmin, dataCoreBorrow],
log: !argv.ci,
});

const coreBorrow = (await deployments.get(name)).address;
console.log(`Successfully deployed ${name} at the address ${coreBorrow}`);

console.log(`${coreBorrow} ${coreBorrowImplementation} ${proxyAdmin} ${dataCoreBorrow} `);
console.log('');
};

func.tags = ['coreMerkl'];
func.dependencies = ['proxyAdminAngleLabs'];
export default func;
1 change: 1 addition & 0 deletions deployments/blast/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
81457
Loading
Loading