mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Move verification to a separate task and run after deployment. Speed up verification via more logic to prevent too many retries.
This commit is contained in:
parent
8389410819
commit
6eb19a2d66
|
@ -251,7 +251,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"kovan": {
|
||||
"address": "0x688C81eC2A0Be6F287fD8C9c343D299c03A34804",
|
||||
"address": "0x8C7ECfD09Ef1F4e5558cB8ccC96e75f2F224caE8",
|
||||
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
|
||||
},
|
||||
"hardhat": {
|
||||
|
@ -265,7 +265,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"kovan": {
|
||||
"address": "0xf189cC1eD07cEFB6e61082104e12673E133163f5",
|
||||
"address": "0x9227414C87834383Ca84fad024AE32523Ef10F9F",
|
||||
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
|
||||
},
|
||||
"hardhat": {
|
||||
|
@ -279,7 +279,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"kovan": {
|
||||
"address": "0x757855037B01c45832f8d662D217C766Ba4e8e74",
|
||||
"address": "0x84EE313786A3198dD8c339708101FD44a1446871",
|
||||
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
|
||||
},
|
||||
"hardhat": {
|
||||
|
@ -293,7 +293,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"kovan": {
|
||||
"address": "0xBc013D1412E0F4acacAa64CDc1c93e8A3Ecd8fF4",
|
||||
"address": "0xB05737274337dCBCCC9c62A4A2b210882d7b9811",
|
||||
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
|
||||
},
|
||||
"hardhat": {
|
||||
|
@ -307,7 +307,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"kovan": {
|
||||
"address": "0xba681EfB276237903df60ef92D564610A393Dbd6",
|
||||
"address": "0x88cF7D778AC89282dDd4641a842Feaaad112e302",
|
||||
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
|
||||
},
|
||||
"hardhat": {
|
||||
|
@ -321,7 +321,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"kovan": {
|
||||
"address": "0x59525b17808F0a7eFe62303ca46e596A5a602683"
|
||||
"address": "0xD115B2Bd4B65F74f4ED61de653d0E76D1f3a9B65"
|
||||
},
|
||||
"hardhat": {
|
||||
"address": "0x813F07B2100e59ba6555d0D6dBA2660c68514665"
|
||||
|
@ -332,7 +332,7 @@
|
|||
"address": "0xdbaA15927b1463EdD14Cf51D082BD7703Fd1C238"
|
||||
},
|
||||
"kovan": {
|
||||
"address": "0x0a9bc0ce44e6473a1B0e30b54b7227de6E75Fd83"
|
||||
"address": "0xD73c368707D7AD80B4f0C33A5AeD0EA1f5D5F40C"
|
||||
},
|
||||
"hardhat": {
|
||||
"address": "0xdbaA15927b1463EdD14Cf51D082BD7703Fd1C238"
|
||||
|
@ -344,7 +344,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"kovan": {
|
||||
"address": "0x882AD7981FE3d63200A23F5d009A1d0488b5ea7e",
|
||||
"address": "0x9C983988764D9AE64565844C2A0349ECE513BACC",
|
||||
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
|
||||
},
|
||||
"hardhat": {
|
||||
|
@ -358,7 +358,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"kovan": {
|
||||
"address": "0x20Bfad73e3A8aA9161b5c553f7825002a175DB23",
|
||||
"address": "0x29f853B79829EB9Aa8DB8D42f2398A0b89B5404B",
|
||||
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
|
||||
},
|
||||
"hardhat": {
|
||||
|
@ -411,7 +411,7 @@
|
|||
"address": "0x93472C0e03215F9c33DA240Eb16703C8244eAa8c"
|
||||
},
|
||||
"kovan": {
|
||||
"address": "0xe875775D75F384944E77086Ea54bAD008ea8004A",
|
||||
"address": "0x1e20D68372F8Da94BB10aE7331eeCBf6293c3093",
|
||||
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
|
||||
},
|
||||
"hardhat": {
|
||||
|
@ -424,7 +424,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"kovan": {
|
||||
"address": "0xc072D8A233C8C52239dcD6ab39954240a0699055",
|
||||
"address": "0xca67A1eAE05B38Ce57AfE463f4508Ffe0133301D",
|
||||
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
|
||||
},
|
||||
"hardhat": {
|
||||
|
@ -446,7 +446,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"kovan": {
|
||||
"address": "0xf896A27CDd4E3bC101aCEa86cc1cE6b7C91AEFA1",
|
||||
"address": "0xA7Ba135e916BFdAE50D2cD446F02c675121E4372",
|
||||
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
|
||||
},
|
||||
"hardhat": {
|
||||
|
@ -489,6 +489,10 @@
|
|||
"address": "0x0Cf45557d25a4e4c0F1aC65EF6c48ae67c61a0E6",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"kovan": {
|
||||
"address": "0x459ddF0837bf703E4F165F380835baF2D24Ffc11",
|
||||
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
|
||||
},
|
||||
"hardhat": {
|
||||
"address": "0x7fAeC7791277Ff512c41CA903c177B2Ed952dDAc",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
|
@ -583,5 +587,20 @@
|
|||
"address": "0x53369fd4680FfE3DfF39Fc6DDa9CfbfD43daeA2E",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
"LendingPoolImpl": {
|
||||
"kovan": {
|
||||
"address": "0x74E26a9131209c5F6aa8461128b416379ec6C9B7"
|
||||
}
|
||||
},
|
||||
"LendingPoolConfiguratorImpl": {
|
||||
"kovan": {
|
||||
"address": "0xD98d801Cd300BA85Bc3ac2d911b687EA464f2cD1"
|
||||
}
|
||||
},
|
||||
"LendingPoolCollateralManagerImpl": {
|
||||
"kovan": {
|
||||
"address": "0xca67A1eAE05B38Ce57AfE463f4508Ffe0133301D"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,8 @@ import 'hardhat-typechain';
|
|||
|
||||
const SKIP_LOAD = process.env.SKIP_LOAD === 'true';
|
||||
const DEFAULT_BLOCK_GAS_LIMIT = 12450000;
|
||||
const DEFAULT_GAS_PRICE = 10;
|
||||
const DEFAULT_GAS_MUL = 2;
|
||||
const DEFAULT_GAS_PRICE = 1000000000;
|
||||
const HARDFORK = 'istanbul';
|
||||
const INFURA_KEY = process.env.INFURA_KEY || '';
|
||||
const ETHERSCAN_KEY = process.env.ETHERSCAN_KEY || '';
|
||||
|
@ -40,7 +41,8 @@ const getCommonNetworkConfig = (networkName: eEthereumNetwork, networkId: number
|
|||
url: `https://${networkName}.infura.io/v3/${INFURA_KEY}`,
|
||||
hardfork: HARDFORK,
|
||||
blockGasLimit: DEFAULT_BLOCK_GAS_LIMIT,
|
||||
gasMultiplier: DEFAULT_GAS_PRICE,
|
||||
gasMultiplier: DEFAULT_GAS_MUL,
|
||||
gasPrice: DEFAULT_GAS_PRICE,
|
||||
chainId: networkId,
|
||||
accounts: {
|
||||
mnemonic: MNEMONIC,
|
||||
|
|
|
@ -53,7 +53,9 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
|
|||
pool
|
||||
);
|
||||
|
||||
export const getGenesisPoolAdmin = async (config: ICommonConfiguration) => {
|
||||
export const getGenesisPoolAdmin = async (
|
||||
config: ICommonConfiguration
|
||||
): Promise<tEthereumAddress> => {
|
||||
const currentNetwork = DRE.network.name;
|
||||
const targetAddress = getParamPerNetwork(config.PoolAdmin, <eEthereumNetwork>currentNetwork);
|
||||
if (targetAddress) {
|
||||
|
@ -66,7 +68,9 @@ export const getGenesisPoolAdmin = async (config: ICommonConfiguration) => {
|
|||
return addressList[addressIndex];
|
||||
};
|
||||
|
||||
export const getEmergencyAdmin = async (config: ICommonConfiguration) => {
|
||||
export const getEmergencyAdmin = async (
|
||||
config: ICommonConfiguration
|
||||
): Promise<tEthereumAddress> => {
|
||||
const currentNetwork = DRE.network.name;
|
||||
const targetAddress = getParamPerNetwork(config.EmergencyAdmin, <eEthereumNetwork>currentNetwork);
|
||||
if (targetAddress) {
|
||||
|
|
|
@ -48,7 +48,12 @@ import {
|
|||
Weth9MockedFactory,
|
||||
WethGatewayFactory,
|
||||
} from '../types';
|
||||
import {withSaveAndVerify, registerContractInJsonDb, linkBytecode} from './contracts-helpers';
|
||||
import {
|
||||
withSaveAndVerify,
|
||||
registerContractInJsonDb,
|
||||
linkBytecode,
|
||||
insertContractAddressInDb,
|
||||
} from './contracts-helpers';
|
||||
import {StableAndVariableTokensHelperFactory} from '../types/StableAndVariableTokensHelperFactory';
|
||||
import {MintableDelegationErc20} from '../types/MintableDelegationErc20';
|
||||
import {readArtifact as buidlerReadArtifact} from '@nomiclabs/buidler/plugins';
|
||||
|
@ -76,13 +81,21 @@ export const deployLendingPoolAddressesProviderRegistry = async (verify?: boolea
|
|||
verify
|
||||
);
|
||||
|
||||
export const deployLendingPoolConfigurator = async (verify?: boolean) =>
|
||||
withSaveAndVerify(
|
||||
await new LendingPoolConfiguratorFactory(await getFirstSigner()).deploy(),
|
||||
export const deployLendingPoolConfigurator = async (verify?: boolean) => {
|
||||
const lendingPoolConfiguratorImpl = await new LendingPoolConfiguratorFactory(
|
||||
await getFirstSigner()
|
||||
).deploy();
|
||||
await insertContractAddressInDb(
|
||||
eContractid.LendingPoolConfiguratorImpl,
|
||||
lendingPoolConfiguratorImpl.address
|
||||
);
|
||||
return withSaveAndVerify(
|
||||
lendingPoolConfiguratorImpl,
|
||||
eContractid.LendingPoolConfigurator,
|
||||
[],
|
||||
verify
|
||||
);
|
||||
};
|
||||
|
||||
export const deployReserveLogicLibrary = async (verify?: boolean) =>
|
||||
withSaveAndVerify(
|
||||
|
@ -156,12 +169,9 @@ export const deployAaveLibraries = async (
|
|||
|
||||
export const deployLendingPool = async (verify?: boolean) => {
|
||||
const libraries = await deployAaveLibraries(verify);
|
||||
return withSaveAndVerify(
|
||||
await new LendingPoolFactory(libraries, await getFirstSigner()).deploy(),
|
||||
eContractid.LendingPool,
|
||||
[],
|
||||
verify
|
||||
);
|
||||
const lendingPoolImpl = await new LendingPoolFactory(libraries, await getFirstSigner()).deploy();
|
||||
await insertContractAddressInDb(eContractid.LendingPoolImpl, lendingPoolImpl.address);
|
||||
return withSaveAndVerify(lendingPoolImpl, eContractid.LendingPool, [], verify);
|
||||
};
|
||||
|
||||
export const deployPriceOracle = async (verify?: boolean) =>
|
||||
|
@ -200,8 +210,15 @@ export const deployChainlinkProxyPriceProvider = async (
|
|||
);
|
||||
|
||||
export const deployLendingPoolCollateralManager = async (verify?: boolean) => {
|
||||
const collateralManagerImpl = await new LendingPoolCollateralManagerFactory(
|
||||
await getFirstSigner()
|
||||
).deploy();
|
||||
await insertContractAddressInDb(
|
||||
eContractid.LendingPoolCollateralManagerImpl,
|
||||
collateralManagerImpl.address
|
||||
);
|
||||
return withSaveAndVerify(
|
||||
await new LendingPoolCollateralManagerFactory(await getFirstSigner()).deploy(),
|
||||
collateralManagerImpl,
|
||||
eContractid.LendingPoolCollateralManager,
|
||||
[],
|
||||
verify
|
||||
|
|
|
@ -4,8 +4,10 @@ import {
|
|||
ATokensAndRatesHelperFactory,
|
||||
DefaultReserveInterestRateStrategyFactory,
|
||||
GenericLogicFactory,
|
||||
InitializableAdminUpgradeabilityProxyFactory,
|
||||
LendingPoolAddressesProviderFactory,
|
||||
LendingPoolAddressesProviderRegistryFactory,
|
||||
LendingPoolCollateralManagerFactory,
|
||||
LendingPoolConfiguratorFactory,
|
||||
LendingPoolFactory,
|
||||
LendingRateOracleFactory,
|
||||
|
@ -20,11 +22,13 @@ import {
|
|||
StableAndVariableTokensHelperFactory,
|
||||
StableDebtTokenFactory,
|
||||
VariableDebtTokenFactory,
|
||||
WalletBalanceProviderFactory,
|
||||
Weth9Factory,
|
||||
Weth9MockedFactory,
|
||||
WethGatewayFactory,
|
||||
} from '../types';
|
||||
import {Ierc20DetailedFactory} from '../types/Ierc20DetailedFactory';
|
||||
import {UpgradeabilityProxy} from '../types/UpgradeabilityProxy';
|
||||
import {MockTokenMap} from './contracts-helpers';
|
||||
import {DRE, getDb} from './misc-utils';
|
||||
import {eContractid, PoolConfiguration, tEthereumAddress, TokenContractId} from './types';
|
||||
|
@ -271,3 +275,48 @@ export const getSelfdestructTransferMock = async (address?: tEthereumAddress) =>
|
|||
.address,
|
||||
await getFirstSigner()
|
||||
);
|
||||
|
||||
export const getProxy = async (address: tEthereumAddress) =>
|
||||
await InitializableAdminUpgradeabilityProxyFactory.connect(address, await getFirstSigner());
|
||||
|
||||
export const getLendingPoolImpl = async (address?: tEthereumAddress) =>
|
||||
await LendingPoolFactory.connect(
|
||||
address ||
|
||||
(await getDb().get(`${eContractid.LendingPoolImpl}.${DRE.network.name}`).value()).address,
|
||||
await getFirstSigner()
|
||||
);
|
||||
|
||||
export const getLendingPoolConfiguratorImpl = async (address?: tEthereumAddress) =>
|
||||
await LendingPoolConfiguratorFactory.connect(
|
||||
address ||
|
||||
(await getDb().get(`${eContractid.LendingPoolConfiguratorImpl}.${DRE.network.name}`).value())
|
||||
.address,
|
||||
await getFirstSigner()
|
||||
);
|
||||
|
||||
export const getLendingPoolCollateralManagerImpl = async (address?: tEthereumAddress) =>
|
||||
await LendingPoolCollateralManagerFactory.connect(
|
||||
address ||
|
||||
(
|
||||
await getDb()
|
||||
.get(`${eContractid.LendingPoolCollateralManagerImpl}.${DRE.network.name}`)
|
||||
.value()
|
||||
).address,
|
||||
await getFirstSigner()
|
||||
);
|
||||
|
||||
export const getWalletProvider = async (address?: tEthereumAddress) =>
|
||||
await WalletBalanceProviderFactory.connect(
|
||||
address ||
|
||||
(await getDb().get(`${eContractid.WalletBalanceProvider}.${DRE.network.name}`).value())
|
||||
.address,
|
||||
await getFirstSigner()
|
||||
);
|
||||
|
||||
export const getLendingPoolCollateralManager = async (address?: tEthereumAddress) =>
|
||||
await LendingPoolCollateralManagerFactory.connect(
|
||||
address ||
|
||||
(await getDb().get(`${eContractid.LendingPoolCollateralManager}.${DRE.network.name}`).value())
|
||||
.address,
|
||||
await getFirstSigner()
|
||||
);
|
||||
|
|
|
@ -83,7 +83,7 @@ export const withSaveAndVerify = async <ContractType extends Contract>(
|
|||
await waitForTx(instance.deployTransaction);
|
||||
await registerContractInJsonDb(id, instance);
|
||||
if (verify) {
|
||||
await verifyContract(id, instance.address, args);
|
||||
await verifyContract(instance.address, args);
|
||||
}
|
||||
return instance;
|
||||
};
|
||||
|
|
|
@ -1,36 +1,26 @@
|
|||
import {exit} from 'process';
|
||||
import fs from 'fs';
|
||||
import globby from 'globby';
|
||||
import {file} from 'tmp-promise';
|
||||
import {DRE} from './misc-utils';
|
||||
|
||||
const listSolidityFiles = (dir: string) => globby(`${dir}/**/*.sol`);
|
||||
|
||||
const fatalErrors = [
|
||||
`The address provided as argument contains a contract, but its bytecode`,
|
||||
`Daily limit of 100 source code submissions reached`,
|
||||
`has no bytecode. Is the contract deployed to this network`,
|
||||
`The constructor for`,
|
||||
];
|
||||
|
||||
const okErrors = [`Contract source code already verified`];
|
||||
|
||||
const unableVerifyError = 'Fail - Unable to verify';
|
||||
|
||||
export const SUPPORTED_ETHERSCAN_NETWORKS = ['main', 'ropsten', 'kovan'];
|
||||
|
||||
export const getEtherscanPath = async (contractName: string) => {
|
||||
const paths = await listSolidityFiles(DRE.config.paths.sources);
|
||||
const path = paths.find((p) => p.includes(contractName));
|
||||
if (!path) {
|
||||
throw new Error(
|
||||
`Contract path not found for ${contractName}. Check if smart contract file is equal to contractName input.`
|
||||
);
|
||||
}
|
||||
|
||||
return `${path}:${contractName}`;
|
||||
};
|
||||
|
||||
function delay(ms: number) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
export const verifyContract = async (
|
||||
contractName: string,
|
||||
address: string,
|
||||
constructorArguments: (string | string[])[],
|
||||
libraries?: string
|
||||
|
@ -45,7 +35,6 @@ export const verifyContract = async (
|
|||
`Current network ${currentNetwork} not supported. Please change to one of the next networks: ${SUPPORTED_ETHERSCAN_NETWORKS.toString()}`
|
||||
);
|
||||
}
|
||||
const etherscanPath = await getEtherscanPath(contractName);
|
||||
|
||||
try {
|
||||
console.log(
|
||||
|
@ -61,7 +50,6 @@ export const verifyContract = async (
|
|||
fs.writeSync(fd, `module.exports = ${JSON.stringify([...constructorArguments])};`);
|
||||
|
||||
const params = {
|
||||
contractName: etherscanPath,
|
||||
address: address,
|
||||
libraries,
|
||||
constructorArgs: path,
|
||||
|
@ -98,16 +86,26 @@ export const runTaskWithRetry = async (
|
|||
}
|
||||
} catch (error) {
|
||||
counter--;
|
||||
console.info(`[ETHERSCAN][[INFO] Retrying attemps: ${counter}.`);
|
||||
console.error('[ETHERSCAN][[ERROR]', error.message);
|
||||
|
||||
if (fatalErrors.some((fatalError) => error.message.includes(fatalError))) {
|
||||
console.error(
|
||||
'[ETHERSCAN][[ERROR] Fatal error detected, skip retries and resume deployment.'
|
||||
);
|
||||
if (okErrors.some((okReason) => error.message.includes(okReason))) {
|
||||
console.info('[ETHERSCAN][INFO] Skipping due OK response: ', error.message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (fatalErrors.some((fatalError) => error.message.includes(fatalError))) {
|
||||
console.error(
|
||||
'[ETHERSCAN][ERROR] Fatal error detected, skip retries and resume deployment.',
|
||||
error.message
|
||||
);
|
||||
return;
|
||||
}
|
||||
console.error('[ETHERSCAN][ERROR]', error.message);
|
||||
console.log();
|
||||
console.info(`[ETHERSCAN][[INFO] Retrying attemps: ${counter}.`);
|
||||
if (error.message.includes(unableVerifyError)) {
|
||||
console.log('[ETHERSCAN][WARNING] Trying to verify via uploading all sources.');
|
||||
delete params.relatedSources;
|
||||
}
|
||||
await runTaskWithRetry(task, params, counter, msDelay, cleanup);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -64,6 +64,9 @@ export enum eContractid {
|
|||
WETH = 'WETH',
|
||||
WETHMocked = 'WETHMocked',
|
||||
SelfdestructTransferMock = 'SelfdestructTransferMock',
|
||||
LendingPoolImpl = 'LendingPoolImpl',
|
||||
LendingPoolConfiguratorImpl = 'LendingPoolConfiguratorImpl',
|
||||
LendingPoolCollateralManagerImpl = 'LendingPoolCollateralManagerImpl',
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -53,7 +53,10 @@
|
|||
"print-contracts:kovan": "npm run hardhat:kovan -- print-contracts",
|
||||
"print-contracts:main": "npm run hardhat:main -- print-contracts",
|
||||
"print-contracts:ropsten": "npm run hardhat:main -- print-contracts",
|
||||
"dev:deployUIProvider": "npm run buidler:kovan deploy-UiPoolDataProvider"
|
||||
"dev:deployUIProvider": "npm run hardhat:kovan deploy-UiPoolDataProvider",
|
||||
"kovan:verify": "npm run hardhat:kovan full:verify -- --all --verify --pool Aave",
|
||||
"ropsten:verify": "npm run hardhat:ropsten full:verify -- --all --verify --pool Aave",
|
||||
"mainnet:verify": "npm run hardhat:main full:verify -- --all --verify --pool Aave"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nomiclabs/buidler": "^1.4.7",
|
||||
|
|
135
tasks/full/6_verify.ts
Normal file
135
tasks/full/6_verify.ts
Normal file
|
@ -0,0 +1,135 @@
|
|||
import {task} from 'hardhat/config';
|
||||
import {loadPoolConfig, ConfigNames, getWethAddress} from '../../helpers/configuration';
|
||||
import {
|
||||
getAaveProtocolTestHelpers,
|
||||
getLendingPool,
|
||||
getLendingPoolAddressesProvider,
|
||||
getLendingPoolAddressesProviderRegistry,
|
||||
getLendingPoolCollateralManager,
|
||||
getLendingPoolCollateralManagerImpl,
|
||||
getLendingPoolConfiguratorImpl,
|
||||
getLendingPoolConfiguratorProxy,
|
||||
getLendingPoolImpl,
|
||||
getWalletProvider,
|
||||
getWETHGateway,
|
||||
} from '../../helpers/contracts-getters';
|
||||
import {getParamPerNetwork} from '../../helpers/contracts-helpers';
|
||||
import {verifyContract} from '../../helpers/etherscan-verification';
|
||||
import {eEthereumNetwork, ICommonConfiguration} from '../../helpers/types';
|
||||
|
||||
task('full:verify', 'Deploy oracles for dev enviroment')
|
||||
.addFlag('verify', 'Verify proxy contracts at Etherscan')
|
||||
.addFlag('all', 'Verify all contracts at Etherscan')
|
||||
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
|
||||
.setAction(async ({verify, all, pool}, localDRE) => {
|
||||
await localDRE.run('set-DRE');
|
||||
const network = localDRE.network.name as eEthereumNetwork;
|
||||
const poolConfig = loadPoolConfig(pool);
|
||||
const {ReserveAssets, ReservesConfig} = poolConfig as ICommonConfiguration;
|
||||
|
||||
const addressesProvider = await getLendingPoolAddressesProvider();
|
||||
const addressesProviderRegistry = await getLendingPoolAddressesProviderRegistry();
|
||||
const lendingPoolProxy = await getLendingPool();
|
||||
const lendingPoolConfigurator = await getLendingPoolConfiguratorProxy();
|
||||
const lendingPoolCollateralManager = await getLendingPoolCollateralManager();
|
||||
|
||||
if (!verify) {
|
||||
return;
|
||||
}
|
||||
if (all) {
|
||||
const lendingPoolImpl = await getLendingPoolImpl();
|
||||
const lendingPoolConfiguratorImpl = await getLendingPoolConfiguratorImpl();
|
||||
const lendingPoolCollateralManagerImpl = await getLendingPoolCollateralManagerImpl();
|
||||
const testHelpers = await getAaveProtocolTestHelpers();
|
||||
const walletProvider = await getWalletProvider();
|
||||
const wethGateway = await getWETHGateway();
|
||||
|
||||
// Address Provider
|
||||
console.log('\n- Verifying address provider...\n');
|
||||
await verifyContract(addressesProvider.address, []);
|
||||
|
||||
// Address Provider Registry
|
||||
console.log('\n- Verifying address provider registry...\n');
|
||||
await verifyContract(addressesProviderRegistry.address, []);
|
||||
|
||||
// Lending Pool implementation
|
||||
console.log('\n- Verifying LendingPool Implementation...\n');
|
||||
await verifyContract(lendingPoolImpl.address, []);
|
||||
|
||||
// Lending Pool Configurator implementation
|
||||
console.log('\n- Verifying LendingPool Configurator Implementation...\n');
|
||||
await verifyContract(lendingPoolConfiguratorImpl.address, []);
|
||||
|
||||
// Lending Pool Collateral Manager implementation
|
||||
console.log('\n- Verifying LendingPool Collateral Manager Implementation...\n');
|
||||
await verifyContract(lendingPoolCollateralManagerImpl.address, []);
|
||||
|
||||
// Test helpers
|
||||
console.log('\n- Verifying Aave Helpers...\n');
|
||||
await verifyContract(testHelpers.address, [addressesProvider.address]);
|
||||
|
||||
// Wallet balance provider
|
||||
console.log('\n- Verifying Wallet Balance Provider...\n');
|
||||
await verifyContract(walletProvider.address, [addressesProvider.address]);
|
||||
|
||||
// WETHGateway
|
||||
console.log('\n- Verifying WETHGateway...\n');
|
||||
await verifyContract(wethGateway.address, [
|
||||
await getWethAddress(poolConfig),
|
||||
lendingPoolProxy.address,
|
||||
]);
|
||||
}
|
||||
// Lending Pool proxy
|
||||
console.log('\n- Verifying Lending Pool Proxy...\n');
|
||||
await verifyContract(lendingPoolProxy.address, [addressesProvider.address]);
|
||||
|
||||
// LendingPool Conf proxy
|
||||
console.log('\n- Verifying Lending Pool Configurator Proxy...\n');
|
||||
await verifyContract(lendingPoolConfigurator.address, [addressesProvider.address]);
|
||||
|
||||
// Proxy collateral manager
|
||||
console.log('\n- Verifying Lending Pool Collateral Manager Proxy...\n');
|
||||
await verifyContract(lendingPoolCollateralManager.address, []);
|
||||
|
||||
// Stable token
|
||||
const DAI = getParamPerNetwork(ReserveAssets, network).DAI;
|
||||
const USDC = getParamPerNetwork(ReserveAssets, network).USDC;
|
||||
|
||||
const {
|
||||
stableDebtTokenAddress,
|
||||
variableDebtTokenAddress,
|
||||
aTokenAddress,
|
||||
interestRateStrategyAddress,
|
||||
} = await lendingPoolProxy.getReserveData(DAI);
|
||||
const {stableDebtTokenAddress: usdStable} = await lendingPoolProxy.getReserveData(USDC);
|
||||
const {
|
||||
baseVariableBorrowRate,
|
||||
variableRateSlope1,
|
||||
variableRateSlope2,
|
||||
stableRateSlope1,
|
||||
stableRateSlope2,
|
||||
} = ReservesConfig.DAI;
|
||||
|
||||
// Proxy Stable Debt
|
||||
console.log('\n- Verifying DAI Stable Debt Token proxy...\n');
|
||||
await verifyContract(stableDebtTokenAddress, [lendingPoolConfigurator.address]);
|
||||
|
||||
// Proxy Variable Debt
|
||||
console.log('\n- Verifying DAI Variable Debt Token proxy...\n');
|
||||
await verifyContract(variableDebtTokenAddress, [lendingPoolConfigurator.address]);
|
||||
|
||||
// Proxy aToken
|
||||
console.log('\n- Verifying aDAI Token proxy...\n');
|
||||
await verifyContract(aTokenAddress, [lendingPoolConfigurator.address]);
|
||||
|
||||
// Strategy Rate
|
||||
console.log('\n- Verifying Strategy rate...\n');
|
||||
await verifyContract(interestRateStrategyAddress, [
|
||||
addressesProvider.address,
|
||||
baseVariableBorrowRate,
|
||||
variableRateSlope1,
|
||||
variableRateSlope2,
|
||||
stableRateSlope1,
|
||||
stableRateSlope2,
|
||||
]);
|
||||
});
|
|
@ -20,13 +20,16 @@ task('aave:full', 'Deploy development enviroment')
|
|||
console.log('Migration started\n');
|
||||
|
||||
console.log('1. Deploy address provider');
|
||||
await localBRE.run('full:deploy-address-provider', {verify, pool: POOL_NAME});
|
||||
await localBRE.run('full:deploy-address-provider', {pool: POOL_NAME});
|
||||
|
||||
console.log('2. Deploy lending pool');
|
||||
await localBRE.run('full:deploy-lending-pool', {verify});
|
||||
await localBRE.run('full:deploy-lending-pool');
|
||||
|
||||
console.log('3. Initialize lending pool');
|
||||
await localBRE.run('full:initialize-lending-pool', {verify, pool: POOL_NAME});
|
||||
await localBRE.run('full:initialize-lending-pool', {pool: POOL_NAME});
|
||||
|
||||
console.log('4. Veryfing contracts');
|
||||
await localBRE.run('full:verify', {verify, all: true, pool: POOL_NAME});
|
||||
|
||||
console.log('\nFinished migrations');
|
||||
printContracts();
|
||||
|
|
|
@ -9,7 +9,6 @@ interface VerifyParams {
|
|||
}
|
||||
|
||||
task('verify-sc', 'Inits the DRE, to have access to all the plugins')
|
||||
.addParam('contractName', 'Name of the Solidity smart contract')
|
||||
.addParam('address', 'Ethereum address of the smart contract')
|
||||
.addOptionalParam(
|
||||
'libraries',
|
||||
|
@ -20,16 +19,11 @@ task('verify-sc', 'Inits the DRE, to have access to all the plugins')
|
|||
'arguments for contract constructor',
|
||||
[]
|
||||
)
|
||||
.setAction(
|
||||
async (
|
||||
{contractName, address, constructorArguments = [], libraries}: VerifyParams,
|
||||
localBRE
|
||||
) => {
|
||||
await localBRE.run('set-DRE');
|
||||
.setAction(async ({address, constructorArguments = [], libraries}: VerifyParams, localBRE) => {
|
||||
await localBRE.run('set-DRE');
|
||||
|
||||
checkVerification();
|
||||
checkVerification();
|
||||
|
||||
const result = await verifyContract(contractName, address, constructorArguments, libraries);
|
||||
return result;
|
||||
}
|
||||
);
|
||||
const result = await verifyContract(address, constructorArguments, libraries);
|
||||
return result;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user