2020-11-30 18:25:06 +00:00
|
|
|
import { task } from 'hardhat/config';
|
2020-12-02 08:28:55 +00:00
|
|
|
import {
|
|
|
|
loadPoolConfig,
|
|
|
|
ConfigNames,
|
|
|
|
getWethAddress,
|
|
|
|
getTreasuryAddress,
|
|
|
|
} from '../../helpers/configuration';
|
2020-11-30 18:25:06 +00:00
|
|
|
import { ZERO_ADDRESS } from '../../helpers/constants';
|
2020-11-10 20:16:31 +00:00
|
|
|
import {
|
|
|
|
getAddressById,
|
|
|
|
getLendingPool,
|
|
|
|
getLendingPoolAddressesProvider,
|
|
|
|
getLendingPoolConfiguratorProxy,
|
|
|
|
} from '../../helpers/contracts-getters';
|
2020-11-30 18:25:06 +00:00
|
|
|
import { getParamPerNetwork } from '../../helpers/contracts-helpers';
|
|
|
|
import { verifyContract } from '../../helpers/etherscan-verification';
|
|
|
|
import { eEthereumNetwork, ICommonConfiguration, IReserveParams } from '../../helpers/types';
|
2020-11-10 20:16:31 +00:00
|
|
|
|
|
|
|
task('verify:tokens', 'Deploy oracles for dev enviroment')
|
|
|
|
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
|
2020-11-30 18:25:06 +00:00
|
|
|
.setAction(async ({ verify, all, pool }, localDRE) => {
|
2020-11-10 20:16:31 +00:00
|
|
|
await localDRE.run('set-DRE');
|
|
|
|
const network = localDRE.network.name as eEthereumNetwork;
|
|
|
|
const poolConfig = loadPoolConfig(pool);
|
2020-11-30 18:25:06 +00:00
|
|
|
const { ReserveAssets, ReservesConfig } = poolConfig as ICommonConfiguration;
|
2020-12-02 08:28:55 +00:00
|
|
|
const treasuryAddress = await getTreasuryAddress(poolConfig);
|
2020-11-10 20:16:31 +00:00
|
|
|
|
|
|
|
const addressesProvider = await getLendingPoolAddressesProvider();
|
|
|
|
const lendingPoolProxy = await getLendingPool();
|
|
|
|
const lendingPoolConfigurator = await getLendingPoolConfiguratorProxy();
|
|
|
|
|
|
|
|
const configs = Object.entries(ReservesConfig) as [string, IReserveParams][];
|
|
|
|
for (const entry of Object.entries(getParamPerNetwork(ReserveAssets, network))) {
|
|
|
|
const [token, tokenAddress] = entry;
|
|
|
|
console.log(`- Verifying ${token} token related contracts`);
|
|
|
|
const {
|
|
|
|
stableDebtTokenAddress,
|
|
|
|
variableDebtTokenAddress,
|
|
|
|
aTokenAddress,
|
|
|
|
interestRateStrategyAddress,
|
|
|
|
} = await lendingPoolProxy.getReserveData(tokenAddress);
|
|
|
|
|
|
|
|
const tokenConfig = configs.find(([symbol]) => symbol === token);
|
|
|
|
if (!tokenConfig) {
|
|
|
|
throw `ReservesConfig not found for ${token} token`;
|
|
|
|
}
|
|
|
|
|
|
|
|
const {
|
2020-11-30 18:25:06 +00:00
|
|
|
optimalUtilizationRate,
|
2020-11-10 20:16:31 +00:00
|
|
|
baseVariableBorrowRate,
|
|
|
|
variableRateSlope1,
|
|
|
|
variableRateSlope2,
|
|
|
|
stableRateSlope1,
|
|
|
|
stableRateSlope2,
|
2021-02-10 23:23:05 +00:00
|
|
|
} = tokenConfig[1].strategy;
|
2020-11-10 20:16:31 +00:00
|
|
|
|
|
|
|
console.log;
|
|
|
|
// Proxy Stable Debt
|
|
|
|
console.log(`\n- Verifying Stable Debt Token proxy...\n`);
|
|
|
|
await verifyContract(stableDebtTokenAddress, [lendingPoolConfigurator.address]);
|
|
|
|
|
|
|
|
// Proxy Variable Debt
|
|
|
|
console.log(`\n- Verifying Debt Token proxy...\n`);
|
|
|
|
await verifyContract(variableDebtTokenAddress, [lendingPoolConfigurator.address]);
|
|
|
|
|
|
|
|
// Proxy aToken
|
|
|
|
console.log('\n- Verifying aToken proxy...\n');
|
|
|
|
await verifyContract(aTokenAddress, [lendingPoolConfigurator.address]);
|
|
|
|
|
|
|
|
// Strategy Rate
|
|
|
|
console.log(`\n- Verifying Strategy rate...\n`);
|
|
|
|
await verifyContract(interestRateStrategyAddress, [
|
|
|
|
addressesProvider.address,
|
2020-11-30 18:25:06 +00:00
|
|
|
optimalUtilizationRate,
|
2020-11-10 20:16:31 +00:00
|
|
|
baseVariableBorrowRate,
|
|
|
|
variableRateSlope1,
|
|
|
|
variableRateSlope2,
|
|
|
|
stableRateSlope1,
|
|
|
|
stableRateSlope2,
|
|
|
|
]);
|
|
|
|
|
|
|
|
const stableDebt = await getAddressById(`stableDebt${token}`);
|
|
|
|
const variableDebt = await getAddressById(`variableDebt${token}`);
|
|
|
|
const aToken = await getAddressById(`a${token}`);
|
|
|
|
|
2020-12-02 09:58:44 +00:00
|
|
|
if (aToken) {
|
|
|
|
console.log('\n- Verifying aToken...\n');
|
|
|
|
await verifyContract(aToken, [
|
|
|
|
lendingPoolProxy.address,
|
|
|
|
tokenAddress,
|
|
|
|
treasuryAddress,
|
|
|
|
`Aave interest bearing ${token}`,
|
|
|
|
`a${token}`,
|
|
|
|
ZERO_ADDRESS,
|
|
|
|
]);
|
|
|
|
} else {
|
|
|
|
console.error(`Skipping aToken verify for ${token}. Missing address at JSON DB.`);
|
|
|
|
}
|
|
|
|
if (stableDebt) {
|
|
|
|
console.log('\n- Verifying StableDebtToken...\n');
|
|
|
|
await verifyContract(stableDebt, [
|
|
|
|
lendingPoolProxy.address,
|
|
|
|
tokenAddress,
|
|
|
|
`Aave stable debt bearing ${token}`,
|
|
|
|
`stableDebt${token}`,
|
|
|
|
ZERO_ADDRESS,
|
|
|
|
]);
|
|
|
|
} else {
|
|
|
|
console.error(`Skipping stable debt verify for ${token}. Missing address at JSON DB.`);
|
|
|
|
}
|
|
|
|
if (variableDebt) {
|
|
|
|
console.log('\n- Verifying VariableDebtToken...\n');
|
|
|
|
await verifyContract(variableDebt, [
|
|
|
|
lendingPoolProxy.address,
|
|
|
|
tokenAddress,
|
|
|
|
`Aave variable debt bearing ${token}`,
|
|
|
|
`variableDebt${token}`,
|
|
|
|
ZERO_ADDRESS,
|
|
|
|
]);
|
|
|
|
} else {
|
|
|
|
console.error(`Skipping variable debt verify for ${token}. Missing address at JSON DB.`);
|
|
|
|
}
|
2020-11-10 20:16:31 +00:00
|
|
|
}
|
|
|
|
});
|