Skip to content

Commit

Permalink
Base Mainnet deployment (#956)
Browse files Browse the repository at this point in the history
Co-authored-by: Patrick McKelvy <[email protected]>
  • Loading branch information
julianmrodri and pmckelvy1 authored Oct 2, 2023
1 parent 9f31dcc commit 9014df3
Show file tree
Hide file tree
Showing 25 changed files with 4,766 additions and 932 deletions.
3,149 changes: 3,149 additions & 0 deletions .openzeppelin/base_8453.json

Large diffs are not rendered by default.

23 changes: 19 additions & 4 deletions common/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export interface ITokens {
aWBTC?: string
aCRV?: string
aEthUSDC?: string
aUSDbCv3?: string
aBasUSDbC?: string
aWETHv3?: string
acbETHv3?: string
cDAI?: string
Expand Down Expand Up @@ -109,6 +109,9 @@ interface INetworkConfig {
MORPHO_AAVE_CONTROLLER?: string
MORPHO_REWARDS_DISTRIBUTOR?: string
MORPHO_AAVE_LENS?: string
COMET_REWARDS?: string
AAVE_V3_INCENTIVES_CONTROLLER?: string
AAVE_V3_POOL?: string
}

export const networkConfig: { [key: string]: INetworkConfig } = {
Expand Down Expand Up @@ -212,6 +215,9 @@ export const networkConfig: { [key: string]: INetworkConfig } = {
MORPHO_AAVE_LENS: '0x507fA343d0A90786d86C7cd885f5C49263A91FF4',
MORPHO_AAVE_CONTROLLER: '0x777777c9898D384F785Ee44Acfe945efDFf5f3E0',
MORPHO_REWARDS_DISTRIBUTOR: '0x3b14e5c73e0a56d607a8688098326fd4b4292135',
COMET_REWARDS: '0x1B0e765F6224C21223AeA2af16c1C46E38885a40',
AAVE_V3_POOL: '0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2',
AAVE_V3_INCENTIVES_CONTROLLER: '0x8164Cc65827dcFe994AB23944CBC90e0aa80bFcb',
},
'1': {
name: 'mainnet',
Expand Down Expand Up @@ -304,6 +310,9 @@ export const networkConfig: { [key: string]: INetworkConfig } = {
MORPHO_AAVE_LENS: '0x507fA343d0A90786d86C7cd885f5C49263A91FF4',
MORPHO_AAVE_CONTROLLER: '0x777777c9898D384F785Ee44Acfe945efDFf5f3E0',
MORPHO_REWARDS_DISTRIBUTOR: '0x3b14e5c73e0a56d607a8688098326fd4b4292135',
COMET_REWARDS: '0x1B0e765F6224C21223AeA2af16c1C46E38885a40',
AAVE_V3_POOL: '0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2',
AAVE_V3_INCENTIVES_CONTROLLER: '0x8164Cc65827dcFe994AB23944CBC90e0aa80bFcb',
},
'3': {
name: 'tenderly',
Expand Down Expand Up @@ -396,6 +405,9 @@ export const networkConfig: { [key: string]: INetworkConfig } = {
MORPHO_AAVE_LENS: '0x507fA343d0A90786d86C7cd885f5C49263A91FF4',
MORPHO_AAVE_CONTROLLER: '0x777777c9898D384F785Ee44Acfe945efDFf5f3E0',
MORPHO_REWARDS_DISTRIBUTOR: '0x3b14e5c73e0a56d607a8688098326fd4b4292135',
COMET_REWARDS: '0x1B0e765F6224C21223AeA2af16c1C46E38885a40',
AAVE_V3_POOL: '0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2',
AAVE_V3_INCENTIVES_CONTROLLER: '0x8164Cc65827dcFe994AB23944CBC90e0aa80bFcb',
},
'5': {
name: 'goerli',
Expand Down Expand Up @@ -495,13 +507,13 @@ export const networkConfig: { [key: string]: INetworkConfig } = {
WETH: '0x4200000000000000000000000000000000000006',
cbETH: '0x2ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec22',
cUSDbCv3: '0x9c4ec768c28520B50860ea7a15bd7213a9fF58bf',
aUSDbCv3: '0x0a1d576f3eFeF75b330424287a95A366e8281D54',
aBasUSDbC: '0x0a1d576f3eFeF75b330424287a95A366e8281D54',
aWETHv3: '0xD4a0e0b9149BCee3C920d2E00b5dE09138fd8bb7',
acbETHv3: '0xcf3D55c10DB69f28fD1A75Bd73f3D8A2d9c595ad'
acbETHv3: '0xcf3D55c10DB69f28fD1A75Bd73f3D8A2d9c595ad',
},
chainlinkFeeds: {
DAI: '0x591e79239a7d679378ec8c847e5038150364c78f', // 0.3%, 24hr
ETH: '0x71041dddad3595f9ced3dccfbe3d1f4b0a16bb70', // 0.5%, 24hr
ETH: '0x71041dddad3595f9ced3dccfbe3d1f4b0a16bb70', // 0.15%, 20min
WBTC: '0xccadc697c55bbb68dc5bcdf8d3cbe83cdd4e071e', // 0.5%, 24hr
USDC: '0x7e860098f58bbfc8648a4311b374b1d669a2bc6b', // 0.3%, 24hr
USDT: '0xf19d560eb8d2adf07bd6d13ed03e1d11215721f9', // 0.3%, 24hr
Expand All @@ -512,6 +524,9 @@ export const networkConfig: { [key: string]: INetworkConfig } = {
cbETHETHexr: '0x868a501e68F3D1E89CfC0D22F6b22E8dabce5F04', // 0.5%, 24hr
},
GNOSIS_EASY_AUCTION: '0xb1875Feaeea32Bbb02DE83D81772e07E37A40f02', // mock
COMET_REWARDS: '0x123964802e6ABabBE1Bc9547D72Ef1B69B00A6b1',
AAVE_V3_POOL: '0xA238Dd80C259a72e81d7e4664a9801593F98d1c5',
AAVE_V3_INCENTIVES_CONTROLLER: '0xf9cc4F0D883F1a1eb2c253bdb46c254Ca51E1F44',
},
}

Expand Down
8 changes: 8 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ const config: HardhatUserConfig = {
etherscan: {
apiKey: useEnv('ETHERSCAN_API_KEY'),
customChains: [
{
network: 'base',
chainId: 8453,
urls: {
apiURL: 'https://api.basescan.org/api',
browserURL: 'https://basescan.org',
},
},
{
network: 'base-goerli',
chainId: 84531,
Expand Down
22 changes: 22 additions & 0 deletions scripts/addresses/base-3.0.0/8453-tmp-assets-collateral.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"assets": {
"COMP": "0x277FD5f51fE53a9B3707a0383bF930B149C74ABf"
},
"collateral": {
"DAI": "0x5EBE8927e5495e0A7731888C81AF463cD63602fb",
"WETH": "0x42D0fA25d6d5bff01aC050c0F5aB0B2C9D01b4a3",
"USDbC": "0x6490D66B17A1E9a460Ab54131165C8F921aCcDeB",
"cbETH": "0x5fE248625aC2AB0e17A115fef288f17AF1952402",
"cUSDbCv3": "0xa372EC846131FBf9AE8b589efa3D041D9a94dF41",
"aBasUSDbC": "0x1DdB7dfdC5D26FE1f2aD02d9972f12481346Ae9b"
},
"erc20s": {
"COMP": "0x9e1028F5F1D5eDE59748FFceE5532509976840E0",
"DAI": "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",
"WETH": "0x4200000000000000000000000000000000000006",
"USDbC": "0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA",
"cbETH": "0x2ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec22",
"cUSDbCv3": "0xbC0033679AEf41Fb9FeB553Fdf55a8Bb2fC5B29e",
"aBasUSDbC": "0x308447562442Cc43978f8274fA722C9C14BafF8b"
}
}
35 changes: 35 additions & 0 deletions scripts/addresses/base-3.0.0/8453-tmp-deployments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"prerequisites": {
"RSR": "0xaB36452DbAC151bE02b16Ca17d8919826072f64a",
"RSR_FEED": "0xAa98aE504658766Dfe11F31c5D95a0bdcABDe0b1",
"GNOSIS_EASY_AUCTION": "0xb1875Feaeea32Bbb02DE83D81772e07E37A40f02"
},
"tradingLib": "0x4E01677488384B851EeAa09C8b8F6Dd0b16d7E9B",
"cvxMiningLib": "",
"facadeRead": "0xe1aa15DA8b993c6312BAeD91E0b470AE405F91BF",
"facadeAct": "0x3d6D679c863858E89e35c925F937F5814ca687F3",
"facadeWriteLib": "0x29e9740275D26fdeDBb0ABA8129C74c15c393027",
"basketLib": "0x199E12d58B36deE2D2B3dD2b91aD7bb25c787a71",
"facadeWrite": "0x0903048fD4E948c60451B41A48B35E0bafc0967F",
"deployer": "0xf1B06c2305445E34CF0147466352249724c2EAC1",
"rsrAsset": "0x23b57479327f9BccE6A1F6Be65F3dAa3C9Db797B",
"implementations": {
"main": "0x1D6d0B74E7A701aE5C2E11967b242E9861275143",
"trading": {
"gnosisTrade": "0xD4e1D5b1311C992b2735710D46A10284Bcd7D39F",
"dutchTrade": "0xDfCc89cf76aC93D113A21Da8fbfA63365b1E3DC7"
},
"components": {
"assetRegistry": "0x9c387fc258061bd3E02c851F36aE227DB03a396C",
"backingManager": "0x63e12c3b2DBCaeF1835Bb99Ac1Fdb0Ebe1bE69bE",
"basketHandler": "0x25E92785C1AC01B397224E0534f3D626868A1Cbf",
"broker": "0x12c3BB1B0da85fDaE0137aE8fDe901F7D0e106ba",
"distributor": "0xd31de64957b79435bfc702044590ac417e02c19B",
"furnace": "0x45D7dFE976cdF80962d863A66918346a457b87Bd",
"rsrTrader": "0xAeA6BD7b231C0eC7f35C2bdf47A76053D09dbD09",
"rTokenTrader": "0xAeA6BD7b231C0eC7f35C2bdf47A76053D09dbD09",
"rToken": "0xA42850A760151bb3ACF17E7f8643EB4d864bF7a6",
"stRSR": "0x53321f03A7cce52413515DFD0527e0163ec69A46"
}
}
}
6 changes: 4 additions & 2 deletions scripts/addresses/mainnet-3.0.0/1-tmp-assets-collateral.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
"maDAI": "0x9d38BFF9Af50738DF92a54Ceab2a2C2322BB1FAB",
"maWBTC": "0x49A44d50d3B1E098DAC9402c4aF8D0C0E499F250",
"maWETH": "0x878b995bDD2D9900BEE896Bd78ADd877672e1637",
"maStETH": "0x33E840e5711549358f6d4D11F9Ab2896B36E9822"
"maStETH": "0x33E840e5711549358f6d4D11F9Ab2896B36E9822",
"aEthUSDC": "0x12c3BB1B0da85fDaE0137aE8fDe901F7D0e106ba"
},
"erc20s": {
"stkAAVE": "0x4da27a545c0c5B758a6BA100e3a049001de870f5",
Expand Down Expand Up @@ -93,6 +94,7 @@
"maDAI": "0xE2b16e14dB6216e33082D5A8Be1Ef01DF7511bBb",
"maWBTC": "0xe0E1d3c6f09DA01399e84699722B11308607BBfC",
"maWETH": "0x291ed25eB61fcc074156eE79c5Da87e5DA94198F",
"maStETH": "0x97F9d5ed17A0C99B279887caD5254d15fb1B619B"
"maStETH": "0x97F9d5ed17A0C99B279887caD5254d15fb1B619B",
"aEthUSDC": "0x63e12c3b2DBCaeF1835Bb99Ac1Fdb0Ebe1bE69bE"
}
}
79 changes: 50 additions & 29 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-process-exit */
import hre from 'hardhat'
import { getChainId } from '../common/blockchain-utils'
import { networkConfig } from '../common/configuration'
import { baseL2Chains, networkConfig } from '../common/configuration'
import { sh } from './deployment/utils'

async function main() {
Expand All @@ -25,7 +25,8 @@ async function main() {
// Part 1/3 of the *overall* deployment process: Deploy all contracts
// See `confirm.ts` for part 2

const scripts = [
// Phase 1- Implementations
let scripts = [
'phase1-common/0_setup_deployments.ts',
'phase1-common/1_deploy_libraries.ts',
'phase1-common/2_deploy_implementations.ts',
Expand All @@ -34,35 +35,55 @@ async function main() {
'phase1-common/5_deploy_deployer.ts',
'phase1-common/6_deploy_facadeWrite.ts',
'phase1-common/7_deploy_facadeAct.ts',
// =============================================
'phase2-assets/0_setup_deployments.ts',
'phase2-assets/1_deploy_assets.ts',
'phase2-assets/assets/deploy_crv.ts',
'phase2-assets/assets/deploy_cvx.ts',
'phase2-assets/2_deploy_collateral.ts',
'phase2-assets/collaterals/deploy_lido_wsteth_collateral.ts',
'phase2-assets/collaterals/deploy_rocket_pool_reth_collateral.ts',
'phase2-assets/collaterals/deploy_flux_finance_collateral.ts',
'phase2-assets/collaterals/deploy_ctokenv3_usdc_collateral.ts',
'phase2-assets/collaterals/deploy_convex_stable_plugin.ts',
'phase2-assets/collaterals/deploy_convex_rToken_metapool_plugin.ts',
'phase2-assets/collaterals/deploy_convex_stable_metapool_plugin.ts',
'phase2-assets/collaterals/deploy_curve_stable_plugin.ts',
'phase2-assets/collaterals/deploy_curve_rToken_metapool_plugin.ts',
'phase2-assets/collaterals/deploy_curve_stable_metapool_plugin.ts',
'phase2-assets/collaterals/deploy_dsr_sdai.ts',
'phase2-assets/collaterals/deploy_cbeth_collateral.ts',
'phase2-assets/collaterals/deploy_morpho_aavev2_plugin.ts',
'phase2-assets/collaterals/deploy_aave_v3_usdc.ts',
// ===============================================
// These phase3 scripts will not deploy functional RTokens or Governance. They deploy bricked
// versions that are used for verification only. Further deployment is left up to the Register.
// 'phase3-rtoken/0_setup_deployments.ts',
// 'phase3-rtoken/1_deploy_rtoken.ts',
// 'phase3-rtoken/2_deploy_governance.ts',
// We can uncomment this section whenever we update governance, which will be rarely
]

// =============================================

// Phase 2 - Assets/Collateral
if (!baseL2Chains.includes(hre.network.name)) {
scripts.push(
'phase2-assets/0_setup_deployments.ts',
'phase2-assets/1_deploy_assets.ts',
'phase2-assets/assets/deploy_crv.ts',
'phase2-assets/assets/deploy_cvx.ts',
'phase2-assets/2_deploy_collateral.ts',
'phase2-assets/collaterals/deploy_lido_wsteth_collateral.ts',
'phase2-assets/collaterals/deploy_rocket_pool_reth_collateral.ts',
'phase2-assets/collaterals/deploy_flux_finance_collateral.ts',
'phase2-assets/collaterals/deploy_ctokenv3_usdc_collateral.ts',
'phase2-assets/collaterals/deploy_convex_stable_plugin.ts',
'phase2-assets/collaterals/deploy_convex_rToken_metapool_plugin.ts',
'phase2-assets/collaterals/deploy_convex_stable_metapool_plugin.ts',
'phase2-assets/collaterals/deploy_curve_stable_plugin.ts',
'phase2-assets/collaterals/deploy_curve_rToken_metapool_plugin.ts',
'phase2-assets/collaterals/deploy_curve_stable_metapool_plugin.ts',
'phase2-assets/collaterals/deploy_dsr_sdai.ts',
'phase2-assets/collaterals/deploy_cbeth_collateral.ts',
'phase2-assets/collaterals/deploy_morpho_aavev2_plugin.ts',
'phase2-assets/collaterals/deploy_aave_v3_usdc.ts'
)
} else if (chainId == '8453' || chainId == '84531') {
// Base L2 chains
scripts.push(
'phase2-assets/0_setup_deployments.ts',
'phase2-assets/1_deploy_assets.ts',
'phase2-assets/2_deploy_collateral.ts',
'phase2-assets/collaterals/deploy_cbeth_collateral.ts',
'phase2-assets/collaterals/deploy_ctokenv3_usdbc_collateral.ts',
'phase2-assets/collaterals/deploy_aave_v3_usdbc.ts'
)
}

// ===============================================

// Phase 3 - RTokens
// These phase3 scripts will not deploy functional RTokens or Governance. They deploy bricked
// versions that are used for verification only. Further deployment is left up to the Register.
// 'phase3-rtoken/0_setup_deployments.ts',
// 'phase3-rtoken/1_deploy_rtoken.ts',
// 'phase3-rtoken/2_deploy_governance.ts',
// We can uncomment and prepare this section whenever we update governance, which will be rarely

for (const script of scripts) {
console.log('\n===========================================\n', script, '')
await sh(`hardhat run scripts/deployment/${script}`)
Expand Down
16 changes: 9 additions & 7 deletions scripts/deployment/phase1-common/1_deploy_libraries.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs'
import hre, { ethers } from 'hardhat'
import { getChainId } from '../../../common/blockchain-utils'
import { networkConfig } from '../../../common/configuration'
import { baseL2Chains, networkConfig } from '../../../common/configuration'
import { getDeploymentFile, getDeploymentFilename, IDeployments } from '../common'
import { validatePrerequisites } from '../utils'
import { BasketLibP1, CvxMining, RecollateralizationLibP1 } from '../../../typechain'
Expand Down Expand Up @@ -47,17 +47,19 @@ async function main() {
fs.writeFileSync(deploymentFilename, JSON.stringify(deployments, null, 2))

// Deploy CvxMining external library
const CvxMiningFactory = await ethers.getContractFactory('CvxMining')
cvxMiningLib = <CvxMining>await CvxMiningFactory.connect(burner).deploy()
await cvxMiningLib.deployed()
deployments.cvxMiningLib = cvxMiningLib.address
if (!baseL2Chains.includes(hre.network.name)) {
const CvxMiningFactory = await ethers.getContractFactory('CvxMining')
cvxMiningLib = <CvxMining>await CvxMiningFactory.connect(burner).deploy()
await cvxMiningLib.deployed()
deployments.cvxMiningLib = cvxMiningLib.address

fs.writeFileSync(deploymentFilename, JSON.stringify(deployments, null, 2))
fs.writeFileSync(deploymentFilename, JSON.stringify(deployments, null, 2))
}

console.log(`Deployed to ${hre.network.name} (${chainId}):
TradingLib: ${tradingLib.address}
BasketLib: ${basketLib.address}
CvxMiningLib: ${cvxMiningLib.address}
CvxMiningLib: ${cvxMiningLib ? cvxMiningLib.address : 'N/A'}
Deployment file: ${deploymentFilename}`)
}

Expand Down
28 changes: 15 additions & 13 deletions scripts/deployment/phase2-assets/1_deploy_assets.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs'
import hre, { ethers } from 'hardhat'
import { getChainId } from '../../../common/blockchain-utils'
import { networkConfig } from '../../../common/configuration'
import { baseL2Chains, networkConfig } from '../../../common/configuration'
import { fp } from '../../../common/numbers'
import {
getDeploymentFile,
Expand Down Expand Up @@ -37,19 +37,21 @@ async function main() {
const deployedAssets: string[] = []

/******** Deploy StkAAVE Asset **************************/
const { asset: stkAAVEAsset } = await hre.run('deploy-asset', {
priceTimeout: priceTimeout.toString(),
priceFeed: networkConfig[chainId].chainlinkFeeds.AAVE,
oracleError: fp('0.01').toString(), // 1%
tokenAddress: networkConfig[chainId].tokens.stkAAVE,
maxTradeVolume: fp('1e6').toString(), // $1m,
oracleTimeout: oracleTimeout(chainId, '3600').toString(), // 1 hr
})
await (<Asset>await ethers.getContractAt('Asset', stkAAVEAsset)).refresh()
if (!baseL2Chains.includes(hre.network.name)) {
const { asset: stkAAVEAsset } = await hre.run('deploy-asset', {
priceTimeout: priceTimeout.toString(),
priceFeed: networkConfig[chainId].chainlinkFeeds.AAVE,
oracleError: fp('0.01').toString(), // 1%
tokenAddress: networkConfig[chainId].tokens.stkAAVE,
maxTradeVolume: fp('1e6').toString(), // $1m,
oracleTimeout: oracleTimeout(chainId, '3600').toString(), // 1 hr
})
await (<Asset>await ethers.getContractAt('Asset', stkAAVEAsset)).refresh()

assetCollDeployments.assets.stkAAVE = stkAAVEAsset
assetCollDeployments.erc20s.stkAAVE = networkConfig[chainId].tokens.stkAAVE
deployedAssets.push(stkAAVEAsset.toString())
assetCollDeployments.assets.stkAAVE = stkAAVEAsset
assetCollDeployments.erc20s.stkAAVE = networkConfig[chainId].tokens.stkAAVE
deployedAssets.push(stkAAVEAsset.toString())
}

/******** Deploy Comp Asset **************************/
const { asset: compAsset } = await hre.run('deploy-asset', {
Expand Down
Loading

0 comments on commit 9014df3

Please sign in to comment.