2020-12-01 09:29:30 +00:00
|
|
|
import { zeroAddress } from 'ethereumjs-util';
|
|
|
|
import { task } from 'hardhat/config';
|
2020-12-02 08:28:55 +00:00
|
|
|
import {
|
|
|
|
loadPoolConfig,
|
|
|
|
ConfigNames,
|
|
|
|
getWethAddress,
|
|
|
|
getTreasuryAddress,
|
|
|
|
} from '../../helpers/configuration';
|
2020-12-01 09:29:30 +00:00
|
|
|
import { ZERO_ADDRESS } from '../../helpers/constants';
|
2020-11-10 12:11:33 +00:00
|
|
|
import {
|
2020-11-10 14:19:47 +00:00
|
|
|
getAaveProtocolDataProvider,
|
2020-11-10 13:18:48 +00:00
|
|
|
getAddressById,
|
2020-11-10 12:11:33 +00:00
|
|
|
getLendingPool,
|
|
|
|
getLendingPoolAddressesProvider,
|
|
|
|
getLendingPoolAddressesProviderRegistry,
|
|
|
|
getLendingPoolCollateralManager,
|
|
|
|
getLendingPoolCollateralManagerImpl,
|
|
|
|
getLendingPoolConfiguratorImpl,
|
|
|
|
getLendingPoolConfiguratorProxy,
|
|
|
|
getLendingPoolImpl,
|
|
|
|
getWalletProvider,
|
|
|
|
getWETHGateway,
|
|
|
|
} from '../../helpers/contracts-getters';
|
2020-12-01 09:29:30 +00:00
|
|
|
import { getParamPerNetwork } from '../../helpers/contracts-helpers';
|
|
|
|
import { verifyContract } from '../../helpers/etherscan-verification';
|
|
|
|
import { notFalsyOrZeroAddress } from '../../helpers/misc-utils';
|
|
|
|
import { eEthereumNetwork, ICommonConfiguration } from '../../helpers/types';
|
2020-11-10 12:11:33 +00:00
|
|
|
|
2020-11-10 20:16:31 +00:00
|
|
|
task('verify:general', 'Deploy oracles for dev enviroment')
|
2020-11-10 12:11:33 +00:00
|
|
|
.addFlag('all', 'Verify all contracts at Etherscan')
|
|
|
|
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
|
2020-12-01 09:29:30 +00:00
|
|
|
.setAction(async ({ all, pool }, localDRE) => {
|
2020-11-10 12:11:33 +00:00
|
|
|
await localDRE.run('set-DRE');
|
|
|
|
const network = localDRE.network.name as eEthereumNetwork;
|
|
|
|
const poolConfig = loadPoolConfig(pool);
|
2020-12-01 09:29:30 +00:00
|
|
|
const {
|
|
|
|
ReserveAssets,
|
|
|
|
ReservesConfig,
|
|
|
|
ProviderRegistry,
|
|
|
|
MarketId,
|
|
|
|
} = poolConfig as ICommonConfiguration;
|
2020-12-02 08:28:55 +00:00
|
|
|
const treasuryAddress = await getTreasuryAddress(poolConfig);
|
2020-11-10 12:11:33 +00:00
|
|
|
|
2020-12-01 09:29:30 +00:00
|
|
|
const registryAddress = getParamPerNetwork(ProviderRegistry, network);
|
2020-11-10 12:11:33 +00:00
|
|
|
const addressesProvider = await getLendingPoolAddressesProvider();
|
2020-12-01 09:29:30 +00:00
|
|
|
const addressesProviderRegistry = notFalsyOrZeroAddress(registryAddress)
|
|
|
|
? await getLendingPoolAddressesProviderRegistry(registryAddress)
|
|
|
|
: await getLendingPoolAddressesProviderRegistry();
|
2020-11-10 12:11:33 +00:00
|
|
|
const lendingPoolProxy = await getLendingPool();
|
|
|
|
const lendingPoolConfigurator = await getLendingPoolConfiguratorProxy();
|
|
|
|
const lendingPoolCollateralManager = await getLendingPoolCollateralManager();
|
|
|
|
|
|
|
|
if (all) {
|
|
|
|
const lendingPoolImpl = await getLendingPoolImpl();
|
|
|
|
const lendingPoolConfiguratorImpl = await getLendingPoolConfiguratorImpl();
|
|
|
|
const lendingPoolCollateralManagerImpl = await getLendingPoolCollateralManagerImpl();
|
2020-11-10 14:19:47 +00:00
|
|
|
const dataProvider = await getAaveProtocolDataProvider();
|
2020-11-10 12:11:33 +00:00
|
|
|
const walletProvider = await getWalletProvider();
|
|
|
|
const wethGateway = await getWETHGateway();
|
|
|
|
|
|
|
|
// Address Provider
|
|
|
|
console.log('\n- Verifying address provider...\n');
|
2020-12-01 09:29:30 +00:00
|
|
|
await verifyContract(addressesProvider.address, [MarketId]);
|
2020-11-10 12:11:33 +00:00
|
|
|
|
|
|
|
// 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
|
2020-11-10 14:19:47 +00:00
|
|
|
console.log('\n- Verifying Aave Provider Helpers...\n');
|
|
|
|
await verifyContract(dataProvider.address, [addressesProvider.address]);
|
2020-11-10 12:11:33 +00:00
|
|
|
|
|
|
|
// Wallet balance provider
|
|
|
|
console.log('\n- Verifying Wallet Balance Provider...\n');
|
2020-12-01 09:29:30 +00:00
|
|
|
await verifyContract(walletProvider.address, []);
|
2020-11-10 12:11:33 +00:00
|
|
|
|
|
|
|
// 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, []);
|
|
|
|
|
2020-11-10 13:18:48 +00:00
|
|
|
// Tokens verification
|
2020-11-10 12:11:33 +00:00
|
|
|
const DAI = getParamPerNetwork(ReserveAssets, network).DAI;
|
2020-11-10 13:18:48 +00:00
|
|
|
const stableDebtDai = await getAddressById('stableDebtDAI');
|
|
|
|
const variableDebtDai = await getAddressById('variableDebtDAI');
|
|
|
|
const aDAI = await getAddressById('aDAI');
|
2020-11-10 12:11:33 +00:00
|
|
|
const {
|
|
|
|
stableDebtTokenAddress,
|
|
|
|
variableDebtTokenAddress,
|
|
|
|
aTokenAddress,
|
|
|
|
interestRateStrategyAddress,
|
|
|
|
} = await lendingPoolProxy.getReserveData(DAI);
|
|
|
|
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,
|
|
|
|
]);
|
2020-11-10 13:18:48 +00:00
|
|
|
|
|
|
|
// aToken
|
|
|
|
console.log('\n- Verifying aToken...\n');
|
|
|
|
await verifyContract(aDAI, [
|
|
|
|
lendingPoolProxy.address,
|
|
|
|
DAI,
|
2020-12-02 08:28:55 +00:00
|
|
|
treasuryAddress,
|
2020-11-10 13:18:48 +00:00
|
|
|
'Aave interest bearing DAI',
|
|
|
|
'aDAI',
|
|
|
|
ZERO_ADDRESS,
|
|
|
|
]);
|
|
|
|
// stableDebtToken
|
|
|
|
console.log('\n- Verifying StableDebtToken...\n');
|
|
|
|
await verifyContract(stableDebtDai, [
|
|
|
|
lendingPoolProxy.address,
|
|
|
|
DAI,
|
|
|
|
'Aave stable debt bearing DAI',
|
|
|
|
'stableDebtDAI',
|
|
|
|
ZERO_ADDRESS,
|
|
|
|
]);
|
|
|
|
// variableDebtToken
|
|
|
|
console.log('\n- Verifying VariableDebtToken...\n');
|
|
|
|
await verifyContract(variableDebtDai, [
|
|
|
|
lendingPoolProxy.address,
|
|
|
|
DAI,
|
|
|
|
'Aave variable debt bearing DAI',
|
|
|
|
'variableDebtDAI',
|
|
|
|
ZERO_ADDRESS,
|
|
|
|
]);
|
|
|
|
// DelegatedAwareAToken
|
|
|
|
console.log('\n- Verifying DelegatedAwareAToken...\n');
|
|
|
|
const UNI = getParamPerNetwork(ReserveAssets, network).UNI;
|
|
|
|
const aUNI = await getAddressById('aUNI');
|
|
|
|
await verifyContract(aUNI, [
|
|
|
|
lendingPoolProxy.address,
|
|
|
|
UNI,
|
2020-12-02 08:28:55 +00:00
|
|
|
treasuryAddress,
|
2020-11-10 13:18:48 +00:00
|
|
|
'Aave interest bearing UNI',
|
|
|
|
'aUNI',
|
|
|
|
ZERO_ADDRESS,
|
|
|
|
]);
|
2020-11-10 12:11:33 +00:00
|
|
|
});
|