Add config parameters and minor script review

This commit is contained in:
David Racero 2021-03-09 17:55:43 +01:00
parent 7e39178e8f
commit ffcdb04824
7 changed files with 54 additions and 40 deletions

View File

@ -2,6 +2,7 @@ import { Contract, Signer, utils, ethers, BigNumberish } from 'ethers';
import { signTypedData_v4 } from 'eth-sig-util';
import { fromRpcSig, ECDSASignature } from 'ethereumjs-util';
import BigNumber from 'bignumber.js';
import { BigNumber as BigNumberEthers } from 'ethers';
import { getDb, DRE, waitForTx } from './misc-utils';
import {
tEthereumAddress,
@ -14,7 +15,6 @@ import {
ePolygonNetwork,
eXDaiNetwork,
eNetwork,
iParamsPerNetworkAll,
iEthereumParamsPerNetwork,
iPolygonParamsPerNetwork,
iXDaiParamsPerNetwork,
@ -26,11 +26,23 @@ import { verifyContract } from './etherscan-verification';
import { getIErc20Detailed } from './contracts-getters';
import { usingTenderly } from './tenderly-utils';
export let gasCounter = BigNumberEthers.from('0');
export let gasCostsCounter = BigNumberEthers.from('0');
export const setGasCounter = (gas: BigNumberish, price: BigNumberish) => {
gasCounter = gasCounter.add(gas);
gasCostsCounter = gasCostsCounter.add(BigNumberEthers.from(gas).mul(price));
};
export type MockTokenMap = { [symbol: string]: MintableERC20 };
export const registerContractInJsonDb = async (contractId: string, contractInstance: Contract) => {
const currentNetwork = DRE.network.name;
const MAINNET_FORK = process.env.MAINNET_FORK === 'true';
const tx = await contractInstance.deployTransaction.wait();
setGasCounter(tx.gasUsed, contractInstance.deployTransaction.gasPrice);
if (MAINNET_FORK || (currentNetwork !== 'hardhat' && !currentNetwork.includes('coverage'))) {
console.log(`*** ${contractId} ***\n`);
console.log(`Network: ${currentNetwork}`);

View File

@ -31,7 +31,6 @@ import {
} from './contracts-deployments';
import { ZERO_ADDRESS } from './constants';
import { isZeroAddress } from 'ethereumjs-util';
import { DefaultReserveInterestRateStrategy, DelegationAwareAToken } from '../types';
export const chooseATokenDeployment = (id: eContractid) => {
switch (id) {
@ -209,7 +208,7 @@ export const initReservesByHelper = async (
variableDebtTokenSymbol: `variableDebt${symbolPrefix}${reserveSymbols[i]}`,
stableDebtTokenName: `${stableDebtTokenNamePrefix} ${reserveSymbols[i]}`,
stableDebtTokenSymbol: `stableDebt${symbolPrefix}${reserveSymbols[i]}`,
params: '0x10'
params: '0x10',
});
}
@ -296,8 +295,6 @@ export const configureReservesByHelper = async (
stableBorrowRateEnabled,
},
] of Object.entries(reservesParams) as [string, IReserveParams][]) {
if (baseLTVAsCollateral === '-1') continue;
const assetAddressIndex = Object.keys(tokenAddresses).findIndex(
(value) => value === assetSymbol
);
@ -343,9 +340,7 @@ export const configureReservesByHelper = async (
console.log(`- Configure reserves in ${chunkedInputParams.length} txs`);
for (let chunkIndex = 0; chunkIndex < chunkedInputParams.length; chunkIndex++) {
await waitForTx(
await atokenAndRatesDeployer.configureReserves(chunkedInputParams[chunkIndex], {
gasLimit: 12000000,
})
await atokenAndRatesDeployer.configureReserves(chunkedInputParams[chunkIndex])
);
console.log(` - Init for: ${chunkedSymbols[chunkIndex].join(', ')}`);
}
@ -557,7 +552,7 @@ export const initTokenReservesByHelper = async (
variableDebtTokenSymbol: `variableDebt${reserveSymbols[i]}`,
stableDebtTokenName: `Aave stable debt bearing ${reserveSymbols[i]}`,
stableDebtTokenSymbol: `stableDebt${reserveSymbols[i]}`,
params: '0x10'
params: '0x10',
});
}
@ -580,7 +575,7 @@ export const initTokenReservesByHelper = async (
// Set deployer back as admin
//await waitForTx(await addressProvider.setPoolAdmin(admin));
return gasUsage; // No longer relevant
return gasUsage; // No longer relevant
};
// Function deprecated

View File

@ -1,5 +1,11 @@
import BigNumber from 'bignumber.js';
import { oneEther, oneRay, RAY, ZERO_ADDRESS, MOCK_CHAINLINK_AGGREGATORS_PRICES } from '../../helpers/constants';
import {
oneEther,
oneRay,
RAY,
ZERO_ADDRESS,
MOCK_CHAINLINK_AGGREGATORS_PRICES,
} from '../../helpers/constants';
import { ICommonConfiguration, eEthereumNetwork } from '../../helpers/types';
// ----------------
@ -139,11 +145,11 @@ export const CommonsConfig: ICommonConfiguration = {
[eEthereumNetwork.coverage]: '',
[eEthereumNetwork.hardhat]: '',
[eEthereumNetwork.buidlerevm]: '',
[eEthereumNetwork.kovan]: '',//'0xdCde9Bb6a49e37fA433990832AB541AE2d4FEB4a',
[eEthereumNetwork.kovan]: '0xdCde9Bb6a49e37fA433990832AB541AE2d4FEB4a',
[eEthereumNetwork.ropsten]: '0x05dcca805a6562c1bdd0423768754acb6993241b',
[eEthereumNetwork.main]: '',//'0x8A32f49FFbA88aba6EFF96F45D8BD1D4b3f35c7D',
[eEthereumNetwork.main]: '0x8A32f49FFbA88aba6EFF96F45D8BD1D4b3f35c7D',
[eEthereumNetwork.tenderlyMain]: '0x8A32f49FFbA88aba6EFF96F45D8BD1D4b3f35c7D',
},
},
LendingPoolCollateralManager: {
[eEthereumNetwork.coverage]: '',
[eEthereumNetwork.hardhat]: '',
@ -193,9 +199,9 @@ export const CommonsConfig: ICommonConfiguration = {
[eEthereumNetwork.coverage]: '',
[eEthereumNetwork.hardhat]: '',
[eEthereumNetwork.buidlerevm]: '',
[eEthereumNetwork.kovan]: '',//'0xB8bE51E6563BB312Cbb2aa26e352516c25c26ac1',
[eEthereumNetwork.kovan]: '0xB8bE51E6563BB312Cbb2aa26e352516c25c26ac1',
[eEthereumNetwork.ropsten]: ZERO_ADDRESS,
[eEthereumNetwork.main]: '',//'0xA50ba011c48153De246E5192C8f9258A2ba79Ca9',
[eEthereumNetwork.main]: '0xA50ba011c48153De246E5192C8f9258A2ba79Ca9',
[eEthereumNetwork.tenderlyMain]: '0xA50ba011c48153De246E5192C8f9258A2ba79Ca9',
},
FallbackOracle: {

View File

@ -125,7 +125,7 @@ export const CommonsConfig: ICommonConfiguration = {
[eEthereumNetwork.buidlerevm]: undefined,
[eEthereumNetwork.kovan]: undefined,
[eEthereumNetwork.ropsten]: undefined,
[eEthereumNetwork.main]: undefined,
[eEthereumNetwork.main]: '0xb9062896ec3a615a4e4444df183f0531a77218ae',
[eEthereumNetwork.tenderlyMain]: undefined,
},
EmergencyAdminIndex: 1,
@ -139,7 +139,6 @@ export const CommonsConfig: ICommonConfiguration = {
[eEthereumNetwork.tenderlyMain]: '0x52D306e36E3B6B02c153d0266ff0f85d18BCD413',
},
ProviderRegistryOwner: {
// DEPLOYED WITH CORRECT ADDRESS
[eEthereumNetwork.kovan]: '0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F',
[eEthereumNetwork.ropsten]: '',
[eEthereumNetwork.main]: '0xbd723fc4f1d737dcfc48a07fe7336766d34cad5f',
@ -154,7 +153,7 @@ export const CommonsConfig: ICommonConfiguration = {
[eEthereumNetwork.buidlerevm]: '', // Updated to match Kovan deployment
[eEthereumNetwork.kovan]: '0xd00Bd28FAdDa9d5658D1D4e0c151973146C7A533', //'0xE48F95873855bfd97BF89572DDf5cBC44D9c545b'
[eEthereumNetwork.ropsten]: '0x05dcca805a6562c1bdd0423768754acb6993241b',
[eEthereumNetwork.main]: '', //'0x8A32f49FFbA88aba6EFF96F45D8BD1D4b3f35c7D', // Need to re-deploy because of onlyOwner
[eEthereumNetwork.main]: '0x8A32f49FFbA88aba6EFF96F45D8BD1D4b3f35c7D',
[eEthereumNetwork.tenderlyMain]: '0x8A32f49FFbA88aba6EFF96F45D8BD1D4b3f35c7D',
},
LendingPoolCollateralManager: {
@ -172,7 +171,7 @@ export const CommonsConfig: ICommonConfiguration = {
[eEthereumNetwork.buidlerevm]: '',
[eEthereumNetwork.kovan]: '0x36eB31800aa67a9c50df1d56EE01981A6E14Cce5',
[eEthereumNetwork.ropsten]: '',
[eEthereumNetwork.main]: '',
[eEthereumNetwork.main]: '0x5A8adC696009a2e0d142c46fDddd8C44bE1604b4',
[eEthereumNetwork.tenderlyMain]: '',
},
LendingPool: {
@ -181,7 +180,7 @@ export const CommonsConfig: ICommonConfiguration = {
[eEthereumNetwork.buidlerevm]: '',
[eEthereumNetwork.kovan]: '0x78142De7a1930412E9e50dEB3b80dB284c2dFa3A',
[eEthereumNetwork.ropsten]: '',
[eEthereumNetwork.main]: '',
[eEthereumNetwork.main]: '0xaACA8859EFD9643B98C042691DA60b217C9CdD64',
[eEthereumNetwork.tenderlyMain]: '',
},
WethGateway: {
@ -190,7 +189,7 @@ export const CommonsConfig: ICommonConfiguration = {
[eEthereumNetwork.buidlerevm]: '',
[eEthereumNetwork.kovan]: '0x1c4A1cC35A477aa1cF35DF671d93ACc04d8131E0',
[eEthereumNetwork.ropsten]: '',
[eEthereumNetwork.main]: '',
[eEthereumNetwork.main]: '0xcc9a0B7c43DC2a5F023Bb9b738E45B0Ef6B06E04',
[eEthereumNetwork.tenderlyMain]: '',
},
TokenDistributor: {
@ -206,9 +205,9 @@ export const CommonsConfig: ICommonConfiguration = {
[eEthereumNetwork.coverage]: '',
[eEthereumNetwork.hardhat]: '',
[eEthereumNetwork.buidlerevm]: '',
[eEthereumNetwork.kovan]: '0x8fb777d67e9945e2c01936e319057f9d41d559e6', // Need to re-deploy because of onlyOwner
[eEthereumNetwork.kovan]: '0x8fb777d67e9945e2c01936e319057f9d41d559e6',
[eEthereumNetwork.ropsten]: ZERO_ADDRESS,
[eEthereumNetwork.main]: '', //'0xA50ba011c48153De246E5192C8f9258A2ba79Ca9', // Need to re-deploy because of onlyOwner
[eEthereumNetwork.main]: '0xA50ba011c48153De246E5192C8f9258A2ba79Ca9',
[eEthereumNetwork.tenderlyMain]: '0xA50ba011c48153De246E5192C8f9258A2ba79Ca9',
},
FallbackOracle: {

View File

@ -71,15 +71,14 @@ task('full:deploy-oracles', 'Deploy oracles for dev enviroment')
lendingRateOracle = lendingRateOracle.connect(
DRE.ethers.provider.getSigner(await lendingRateOracle.owner())
);
// This must be done any time a new market is created I believe
//if (!lendingRateOracleAddress) {
await setInitialMarketRatesInRatesOracleByHelper(
lendingRateOracles,
tokensAddressesWithoutUsd,
lendingRateOracle,
admin
);
//}
if (!lendingRateOracleAddress) {
await setInitialMarketRatesInRatesOracleByHelper(
lendingRateOracles,
tokensAddressesWithoutUsd,
lendingRateOracle,
admin
);
}
console.log('ORACLES: %s and %s', aaveOracle.address, lendingRateOracle.address);
// Register the proxy price provider on the addressesProvider
await waitForTx(await addressesProvider.setPriceOracle(aaveOracle.address));

View File

@ -77,7 +77,6 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
const collateralManager = await deployLendingPoolCollateralManager(verify);
collateralManagerAddress = collateralManager.address;
}
// Seems unnecessary to register the collateral manager in the JSON db
console.log(
'\tSetting lending pool collateral manager implementation with address',
@ -89,13 +88,13 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
await deployWalletBalancerProvider(verify);
const lendingPoolAddress = await addressesProvider.getLendingPool();
let gateWay = getParamPerNetwork(WethGateway, network);
if (!notFalsyOrZeroAddress(gateWay)) {
gateWay = (await getWETHGateway()).address;
}
await authorizeWETHGateway(gateWay, lendingPoolAddress);
// Next action should be done separately to prevent script to break, if the owner of Gateway is different than current deployer address
// const lendingPoolAddress = await addressesProvider.getLendingPool();
// await authorizeWETHGateway(gateWay, lendingPoolAddress);
} catch (err) {
console.error(err);
exit(1);

View File

@ -3,6 +3,8 @@ import { checkVerification } from '../../helpers/etherscan-verification';
import { ConfigNames } from '../../helpers/configuration';
import { printContracts } from '../../helpers/misc-utils';
import { usingTenderly } from '../../helpers/tenderly-utils';
import { gasCostsCounter, gasCounter } from '../../helpers/contracts-helpers';
import { formatEther } from 'ethers/lib/utils';
task('amm:mainnet', 'Deploy development enviroment')
.addFlag('verify', 'Verify contracts at Etherscan')
@ -19,7 +21,6 @@ task('amm:mainnet', 'Deploy development enviroment')
console.log('1. Deploy address provider');
await DRE.run('full:deploy-address-provider', { pool: POOL_NAME });
console.log('2. Deploy lending pool');
await DRE.run('full:deploy-lending-pool', { pool: POOL_NAME });
@ -31,7 +32,6 @@ task('amm:mainnet', 'Deploy development enviroment')
console.log('5. Deploy WETH Gateway');
await DRE.run('full-deploy-weth-gateway', { pool: POOL_NAME });
console.log('6. Initialize lending pool');
await DRE.run('full:initialize-lending-pool', { pool: POOL_NAME });
@ -51,6 +51,10 @@ task('amm:mainnet', 'Deploy development enviroment')
console.log('- Head', postDeployHead);
console.log('- Fork', postDeployFork);
}
console.log('\nFinished migrations');
printContracts();
console.log('\nFinished migrations');
console.log('Total GAS wei: ', gasCounter.toString());
console.log('Total ETH costs: ', formatEther(gasCostsCounter));
});