Prevent to hang if missing address at db json

This commit is contained in:
David Racero 2020-12-02 10:58:44 +01:00
parent 04c49117b8
commit 39f71f9610
3 changed files with 54 additions and 110 deletions

View File

@ -320,8 +320,8 @@ export const getLendingPoolCollateralManager = async (address?: tEthereumAddress
await getFirstSigner() await getFirstSigner()
); );
export const getAddressById = async (id: string) => export const getAddressById = async (id: string): Promise<tEthereumAddress | undefined> =>
(await getDb().get(`${id}.${DRE.network.name}`).value()).address; (await getDb().get(`${id}.${DRE.network.name}`).value())?.address || undefined;
export const getAaveOracle = async (address?: tEthereumAddress) => export const getAaveOracle = async (address?: tEthereumAddress) =>
await AaveOracleFactory.connect( await AaveOracleFactory.connect(

View File

@ -1,3 +1,4 @@
import { error } from 'console';
import { zeroAddress } from 'ethereumjs-util'; import { zeroAddress } from 'ethereumjs-util';
import { task } from 'hardhat/config'; import { task } from 'hardhat/config';
import { import {
@ -105,86 +106,22 @@ task('verify:general', 'Deploy oracles for dev enviroment')
console.log('\n- Verifying Lending Pool Collateral Manager Proxy...\n'); console.log('\n- Verifying Lending Pool Collateral Manager Proxy...\n');
await verifyContract(lendingPoolCollateralManager.address, []); await verifyContract(lendingPoolCollateralManager.address, []);
// Tokens verification
const DAI = getParamPerNetwork(ReserveAssets, network).DAI;
const stableDebtDai = await getAddressById('stableDebtDAI');
const variableDebtDai = await getAddressById('variableDebtDAI');
const aDAI = await getAddressById('aDAI');
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,
]);
// aToken
console.log('\n- Verifying aToken...\n');
await verifyContract(aDAI, [
lendingPoolProxy.address,
DAI,
treasuryAddress,
'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 // DelegatedAwareAToken
console.log('\n- Verifying DelegatedAwareAToken...\n'); console.log('\n- Verifying DelegatedAwareAToken...\n');
const UNI = getParamPerNetwork(ReserveAssets, network).UNI; const UNI = getParamPerNetwork(ReserveAssets, network).UNI;
const aUNI = await getAddressById('aUNI'); const aUNI = await getAddressById('aUNI');
await verifyContract(aUNI, [ if (aUNI) {
lendingPoolProxy.address, console.log('Verifying aUNI');
UNI, await verifyContract(aUNI, [
treasuryAddress, lendingPoolProxy.address,
'Aave interest bearing UNI', UNI,
'aUNI', treasuryAddress,
ZERO_ADDRESS, 'Aave interest bearing UNI',
]); 'aUNI',
ZERO_ADDRESS,
]);
} else {
console.error('Missing aUNI address at JSON DB. Skipping...');
}
console.log('Finished verifications.');
}); });

View File

@ -83,35 +83,42 @@ task('verify:tokens', 'Deploy oracles for dev enviroment')
const variableDebt = await getAddressById(`variableDebt${token}`); const variableDebt = await getAddressById(`variableDebt${token}`);
const aToken = await getAddressById(`a${token}`); const aToken = await getAddressById(`a${token}`);
// aToken if (aToken) {
console.log('\n- Verifying aToken...\n'); console.log('\n- Verifying aToken...\n');
await verifyContract(aToken, [ await verifyContract(aToken, [
lendingPoolProxy.address, lendingPoolProxy.address,
tokenAddress, tokenAddress,
treasuryAddress, treasuryAddress,
`Aave interest bearing ${token}`, `Aave interest bearing ${token}`,
`a${token}`, `a${token}`,
ZERO_ADDRESS, ZERO_ADDRESS,
]); ]);
} else {
// stableDebtToken console.error(`Skipping aToken verify for ${token}. Missing address at JSON DB.`);
console.log('\n- Verifying StableDebtToken...\n'); }
await verifyContract(stableDebt, [ if (stableDebt) {
lendingPoolProxy.address, console.log('\n- Verifying StableDebtToken...\n');
tokenAddress, await verifyContract(stableDebt, [
`Aave stable debt bearing ${token}`, lendingPoolProxy.address,
`stableDebt${token}`, tokenAddress,
ZERO_ADDRESS, `Aave stable debt bearing ${token}`,
]); `stableDebt${token}`,
ZERO_ADDRESS,
// variableDebtToken ]);
console.log('\n- Verifying VariableDebtToken...\n'); } else {
await verifyContract(variableDebt, [ console.error(`Skipping stable debt verify for ${token}. Missing address at JSON DB.`);
lendingPoolProxy.address, }
tokenAddress, if (variableDebt) {
`Aave variable debt bearing ${token}`, console.log('\n- Verifying VariableDebtToken...\n');
`variableDebt${token}`, await verifyContract(variableDebt, [
ZERO_ADDRESS, 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.`);
}
} }
}); });