mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Merge branch 'feat/token-verification-loop-and-fix-lending-rate-oracle-task' into 'master'
Fixes task related with LendingOracle. Add token verification task. See merge request aave-tech/protocol-v2!157
This commit is contained in:
commit
f73db4dbd9
|
@ -135,7 +135,7 @@ export const stablecoinStrategySUSD: IReserveParams = {
|
|||
liquidationBonus: '0',
|
||||
borrowingEnabled: false,
|
||||
stableBorrowRateEnabled: false,
|
||||
reserveDecimals: '18',
|
||||
reserveDecimals: '6',
|
||||
};
|
||||
|
||||
export const strategySNX: IReserveParams = {
|
||||
|
|
|
@ -24,7 +24,7 @@ const MNEMONIC = process.env.MNEMONIC || '';
|
|||
|
||||
// Prevent to load scripts before compilation and typechain
|
||||
if (!SKIP_LOAD) {
|
||||
['misc', 'migrations', 'dev', 'full'].forEach((folder) => {
|
||||
['misc', 'migrations', 'dev', 'full', 'verifications'].forEach((folder) => {
|
||||
const tasksPath = path.join(__dirname, 'tasks', folder);
|
||||
fs.readdirSync(tasksPath)
|
||||
.filter((pth) => pth.includes('.ts'))
|
||||
|
|
|
@ -54,9 +54,12 @@
|
|||
"print-contracts:main": "npm run hardhat:main -- print-contracts",
|
||||
"print-contracts:ropsten": "npm run hardhat:main -- print-contracts",
|
||||
"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"
|
||||
"kovan:verify": "npm run hardhat:kovan verify:general -- --all --pool Aave",
|
||||
"ropsten:verify": "npm run hardhat:ropsten verify:general -- --all --pool Aave",
|
||||
"mainnet:verify": "npm run hardhat:main verify:general -- --all --pool Aave",
|
||||
"kovan:verify:tokens": "npm run hardhat:kovan verify:tokens -- --pool Aave",
|
||||
"ropsten:verify:tokens": "npm run hardhat:ropsten verify:tokens -- --pool Aave",
|
||||
"mainnet:verify:tokens": "npm run hardhat:main verify:tokens -- --pool Aave"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nomiclabs/buidler": "^1.4.7",
|
||||
|
|
|
@ -58,7 +58,6 @@ task(
|
|||
const lendingRateOracle = getParamPerNetwork(poolConfig.LendingRateOracle, network);
|
||||
|
||||
if (lendingRateOracle && lendingRateOracle !== '') {
|
||||
await waitForTx(await addressesProvider.setLendingRateOracle(proxyProvider));
|
||||
await waitForTx(await addressesProvider.setLendingRateOracle(lendingRateOracle));
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -28,9 +28,14 @@ task('aave:full', 'Deploy development enviroment')
|
|||
console.log('3. Initialize lending pool');
|
||||
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});
|
||||
if (verify) {
|
||||
printContracts();
|
||||
console.log('4. Veryfing contracts');
|
||||
await localBRE.run('verify:general', {all: true, pool: POOL_NAME});
|
||||
|
||||
console.log('5. Veryfing aTokens and debtTokens');
|
||||
await localBRE.run('verify:tokens', {pool: POOL_NAME});
|
||||
}
|
||||
console.log('\nFinished migrations');
|
||||
printContracts();
|
||||
});
|
||||
|
|
|
@ -20,11 +20,10 @@ 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')
|
||||
task('verify:general', 'Deploy oracles for dev enviroment')
|
||||
.addFlag('all', 'Verify all contracts at Etherscan')
|
||||
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
|
||||
.setAction(async ({verify, all, pool}, localDRE) => {
|
||||
.setAction(async ({all, pool}, localDRE) => {
|
||||
await localDRE.run('set-DRE');
|
||||
const network = localDRE.network.name as eEthereumNetwork;
|
||||
const poolConfig = loadPoolConfig(pool);
|
||||
|
@ -36,9 +35,6 @@ task('full:verify', 'Deploy oracles for dev enviroment')
|
|||
const lendingPoolConfigurator = await getLendingPoolConfiguratorProxy();
|
||||
const lendingPoolCollateralManager = await getLendingPoolCollateralManager();
|
||||
|
||||
if (!verify) {
|
||||
return;
|
||||
}
|
||||
if (all) {
|
||||
const lendingPoolImpl = await getLendingPoolImpl();
|
||||
const lendingPoolConfiguratorImpl = await getLendingPoolConfiguratorImpl();
|
109
tasks/verifications/2_tokens.ts
Normal file
109
tasks/verifications/2_tokens.ts
Normal file
|
@ -0,0 +1,109 @@
|
|||
import {task} from 'hardhat/config';
|
||||
import {loadPoolConfig, ConfigNames, getWethAddress} from '../../helpers/configuration';
|
||||
import {ZERO_ADDRESS} from '../../helpers/constants';
|
||||
import {
|
||||
getAddressById,
|
||||
getLendingPool,
|
||||
getLendingPoolAddressesProvider,
|
||||
getLendingPoolConfiguratorProxy,
|
||||
} from '../../helpers/contracts-getters';
|
||||
import {getParamPerNetwork} from '../../helpers/contracts-helpers';
|
||||
import {verifyContract} from '../../helpers/etherscan-verification';
|
||||
import {eEthereumNetwork, ICommonConfiguration, IReserveParams} from '../../helpers/types';
|
||||
|
||||
task('verify:tokens', 'Deploy oracles for dev enviroment')
|
||||
.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 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 {
|
||||
baseVariableBorrowRate,
|
||||
variableRateSlope1,
|
||||
variableRateSlope2,
|
||||
stableRateSlope1,
|
||||
stableRateSlope2,
|
||||
} = tokenConfig[1];
|
||||
|
||||
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,
|
||||
baseVariableBorrowRate,
|
||||
variableRateSlope1,
|
||||
variableRateSlope2,
|
||||
stableRateSlope1,
|
||||
stableRateSlope2,
|
||||
]);
|
||||
|
||||
const stableDebt = await getAddressById(`stableDebt${token}`);
|
||||
const variableDebt = await getAddressById(`variableDebt${token}`);
|
||||
const aToken = await getAddressById(`a${token}`);
|
||||
|
||||
// aToken
|
||||
console.log('\n- Verifying aToken...\n');
|
||||
await verifyContract(aToken, [
|
||||
lendingPoolProxy.address,
|
||||
tokenAddress,
|
||||
ZERO_ADDRESS,
|
||||
`Aave interest bearing ${token}`,
|
||||
`a${token}`,
|
||||
ZERO_ADDRESS,
|
||||
]);
|
||||
|
||||
// stableDebtToken
|
||||
console.log('\n- Verifying StableDebtToken...\n');
|
||||
await verifyContract(stableDebt, [
|
||||
lendingPoolProxy.address,
|
||||
tokenAddress,
|
||||
`Aave stable debt bearing ${token}`,
|
||||
`stableDebt${token}`,
|
||||
ZERO_ADDRESS,
|
||||
]);
|
||||
|
||||
// variableDebtToken
|
||||
console.log('\n- Verifying VariableDebtToken...\n');
|
||||
await verifyContract(variableDebt, [
|
||||
lendingPoolProxy.address,
|
||||
tokenAddress,
|
||||
`Aave variable debt bearing ${token}`,
|
||||
`variableDebt${token}`,
|
||||
ZERO_ADDRESS,
|
||||
]);
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue
Block a user