mirror of
				https://github.com/Instadapp/aave-protocol-v2.git
				synced 2024-07-29 21:47:30 +00:00 
			
		
		
		
	Migration scripts updated
This commit is contained in:
		
							parent
							
								
									c7a0ca5fb0
								
							
						
					
					
						commit
						8cff75f7e3
					
				| 
						 | 
				
			
			@ -34,6 +34,7 @@ contract ATokensAndRatesHelper is Ownable {
 | 
			
		|||
    address[] calldata tokens,
 | 
			
		||||
    string[] calldata symbols,
 | 
			
		||||
    uint256[6][] calldata rates,
 | 
			
		||||
    address treasuryAddress,
 | 
			
		||||
    address incentivesController
 | 
			
		||||
  ) external onlyOwner {
 | 
			
		||||
    require(tokens.length == symbols.length, 't Arrays not same length');
 | 
			
		||||
| 
						 | 
				
			
			@ -44,7 +45,7 @@ contract ATokensAndRatesHelper is Ownable {
 | 
			
		|||
          new AToken(
 | 
			
		||||
            LendingPool(pool),
 | 
			
		||||
            tokens[i],
 | 
			
		||||
            address(0),
 | 
			
		||||
            treasuryAddress,
 | 
			
		||||
            StringLib.concat('Aave interest bearing ', symbols[i]),
 | 
			
		||||
            StringLib.concat('a', symbols[i]),
 | 
			
		||||
            incentivesController
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -75,6 +75,14 @@ export const getEmergencyAdmin = async (
 | 
			
		|||
  return addressList[addressIndex];
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getTreasuryAddress = async (
 | 
			
		||||
  config: ICommonConfiguration
 | 
			
		||||
): Promise<tEthereumAddress> => {
 | 
			
		||||
  const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name;
 | 
			
		||||
  return getParamPerNetwork(config.ReserveFactorTreasuryAddress, <eEthereumNetwork>currentNetwork);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
export const getATokenDomainSeparatorPerNetwork = (
 | 
			
		||||
  network: eEthereumNetwork,
 | 
			
		||||
  config: ICommonConfiguration
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -318,11 +318,12 @@ export const deployVariableDebtToken = async (
 | 
			
		|||
  );
 | 
			
		||||
 | 
			
		||||
export const deployGenericAToken = async (
 | 
			
		||||
  [poolAddress, underlyingAssetAddress, name, symbol, incentivesController]: [
 | 
			
		||||
  [poolAddress, underlyingAssetAddress, name, symbol, treasuryAddress, incentivesController]: [
 | 
			
		||||
    tEthereumAddress,
 | 
			
		||||
    tEthereumAddress,
 | 
			
		||||
    string,
 | 
			
		||||
    string,
 | 
			
		||||
    tEthereumAddress,
 | 
			
		||||
    tEthereumAddress
 | 
			
		||||
  ],
 | 
			
		||||
  verify: boolean
 | 
			
		||||
| 
						 | 
				
			
			@ -330,11 +331,12 @@ export const deployGenericAToken = async (
 | 
			
		|||
  const args: [
 | 
			
		||||
    tEthereumAddress,
 | 
			
		||||
    tEthereumAddress,
 | 
			
		||||
    string,
 | 
			
		||||
    string,
 | 
			
		||||
    tEthereumAddress,
 | 
			
		||||
    string,
 | 
			
		||||
    string,
 | 
			
		||||
    tEthereumAddress
 | 
			
		||||
  ] = [poolAddress, underlyingAssetAddress, ZERO_ADDRESS, name, symbol, incentivesController];
 | 
			
		||||
 | 
			
		||||
  ] = [poolAddress, underlyingAssetAddress, name, symbol, treasuryAddress, incentivesController];
 | 
			
		||||
  return withSaveAndVerify(
 | 
			
		||||
    await new ATokenFactory(await getFirstSigner()).deploy(...args),
 | 
			
		||||
    eContractid.AToken,
 | 
			
		||||
| 
						 | 
				
			
			@ -344,11 +346,12 @@ export const deployGenericAToken = async (
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
export const deployDelegationAwareAToken = async (
 | 
			
		||||
  [poolAddress, underlyingAssetAddress, name, symbol, incentivesController]: [
 | 
			
		||||
  [poolAddress, underlyingAssetAddress, name, symbol, treasuryAddress, incentivesController]: [
 | 
			
		||||
    tEthereumAddress,
 | 
			
		||||
    tEthereumAddress,
 | 
			
		||||
    string,
 | 
			
		||||
    string,
 | 
			
		||||
    tEthereumAddress,
 | 
			
		||||
    tEthereumAddress
 | 
			
		||||
  ],
 | 
			
		||||
  verify: boolean
 | 
			
		||||
| 
						 | 
				
			
			@ -356,11 +359,11 @@ export const deployDelegationAwareAToken = async (
 | 
			
		|||
  const args: [
 | 
			
		||||
    tEthereumAddress,
 | 
			
		||||
    tEthereumAddress,
 | 
			
		||||
    string,
 | 
			
		||||
    string,
 | 
			
		||||
    tEthereumAddress,
 | 
			
		||||
    string,
 | 
			
		||||
    string,
 | 
			
		||||
    tEthereumAddress
 | 
			
		||||
  ] = [poolAddress, underlyingAssetAddress, ZERO_ADDRESS, name, symbol, incentivesController];
 | 
			
		||||
  ] = [poolAddress, underlyingAssetAddress, name, symbol, treasuryAddress,  incentivesController];
 | 
			
		||||
  return withSaveAndVerify(
 | 
			
		||||
    await new DelegationAwareATokenFactory(await getFirstSigner()).deploy(...args),
 | 
			
		||||
    eContractid.DelegationAwareAToken,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -32,9 +32,11 @@ export const initReservesByHelper = async (
 | 
			
		|||
  reservesParams: iMultiPoolsAssets<IReserveParams>,
 | 
			
		||||
  tokenAddresses: { [symbol: string]: tEthereumAddress },
 | 
			
		||||
  admin: tEthereumAddress,
 | 
			
		||||
  treasuryAddress: tEthereumAddress,
 | 
			
		||||
  incentivesController: tEthereumAddress,
 | 
			
		||||
  verify: boolean
 | 
			
		||||
) => {
 | 
			
		||||
 | 
			
		||||
  const stableAndVariableDeployer = await getStableAndVariableTokensHelper();
 | 
			
		||||
  const atokenAndRatesDeployer = await getATokensAndRatesHelper();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -121,18 +123,25 @@ export const initReservesByHelper = async (
 | 
			
		|||
 | 
			
		||||
    // Deploy stable and variable deployers and save implementations
 | 
			
		||||
    const tx1 = await waitForTx(
 | 
			
		||||
      await stableAndVariableDeployer.initDeployment(tokens, symbols, incentivesController)
 | 
			
		||||
      await stableAndVariableDeployer.initDeployment(
 | 
			
		||||
        tokens,
 | 
			
		||||
        symbols,
 | 
			
		||||
        incentivesController
 | 
			
		||||
      )
 | 
			
		||||
    );
 | 
			
		||||
    tx1.events?.forEach((event, index) => {
 | 
			
		||||
      rawInsertContractAddressInDb(`stableDebt${symbols[index]}`, event?.args?.stableToken);
 | 
			
		||||
      rawInsertContractAddressInDb(`variableDebt${symbols[index]}`, event?.args?.variableToken);
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    // Deploy atokens and rate strategies and save implementations
 | 
			
		||||
    const tx2 = await waitForTx(
 | 
			
		||||
      await atokenAndRatesDeployer.initDeployment(
 | 
			
		||||
        tokens,
 | 
			
		||||
        symbols,
 | 
			
		||||
        strategyRates,
 | 
			
		||||
        treasuryAddress,
 | 
			
		||||
        incentivesController
 | 
			
		||||
      )
 | 
			
		||||
    );
 | 
			
		||||
| 
						 | 
				
			
			@ -178,6 +187,7 @@ export const initReservesByHelper = async (
 | 
			
		|||
        tokenAddresses[symbol],
 | 
			
		||||
        `Aave interest bearing ${symbol}`,
 | 
			
		||||
        `a${symbol}`,
 | 
			
		||||
        treasuryAddress,
 | 
			
		||||
        ZERO_ADDRESS,
 | 
			
		||||
      ],
 | 
			
		||||
      verify
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -306,12 +306,12 @@ export const CommonsConfig: ICommonConfiguration = {
 | 
			
		|||
    [eEthereumNetwork.tenderlyMain]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
 | 
			
		||||
  },
 | 
			
		||||
  ReserveFactorTreasuryAddress: {
 | 
			
		||||
    [eEthereumNetwork.coverage]: '',
 | 
			
		||||
    [eEthereumNetwork.hardhat]: '', 
 | 
			
		||||
    [eEthereumNetwork.buidlerevm]: '',
 | 
			
		||||
    [eEthereumNetwork.kovan]: '',
 | 
			
		||||
    [eEthereumNetwork.ropsten]: '',
 | 
			
		||||
    [eEthereumNetwork.main]: '',
 | 
			
		||||
    [eEthereumNetwork.tenderlyMain]: '',
 | 
			
		||||
    [eEthereumNetwork.coverage]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
 | 
			
		||||
    [eEthereumNetwork.hardhat]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', 
 | 
			
		||||
    [eEthereumNetwork.buidlerevm]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
 | 
			
		||||
    [eEthereumNetwork.kovan]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
 | 
			
		||||
    [eEthereumNetwork.ropsten]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
 | 
			
		||||
    [eEthereumNetwork.main]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
 | 
			
		||||
    [eEthereumNetwork.tenderlyMain]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
 | 
			
		||||
  },
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,6 +9,7 @@ import {
 | 
			
		|||
import {
 | 
			
		||||
  ConfigNames,
 | 
			
		||||
  getReservesConfigByPool,
 | 
			
		||||
  getTreasuryAddress,
 | 
			
		||||
  getWethAddress,
 | 
			
		||||
  loadPoolConfig,
 | 
			
		||||
} from '../../helpers/configuration';
 | 
			
		||||
| 
						 | 
				
			
			@ -50,10 +51,13 @@ task('dev:initialize-lending-pool', 'Initialize lending pool configuration.')
 | 
			
		|||
 | 
			
		||||
    const admin = await addressesProvider.getPoolAdmin();
 | 
			
		||||
 | 
			
		||||
    const treasuryAddress = await getTreasuryAddress(poolConfig);
 | 
			
		||||
 | 
			
		||||
    await initReservesByHelper(
 | 
			
		||||
      reservesParams,
 | 
			
		||||
      protoPoolReservesAddresses,
 | 
			
		||||
      admin,
 | 
			
		||||
      treasuryAddress,
 | 
			
		||||
      ZERO_ADDRESS,
 | 
			
		||||
      verify
 | 
			
		||||
    );
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,7 +6,7 @@ import {
 | 
			
		|||
  deployAaveProtocolDataProvider,
 | 
			
		||||
  deployWETHGateway,
 | 
			
		||||
} from '../../helpers/contracts-deployments';
 | 
			
		||||
import { loadPoolConfig, ConfigNames, getWethAddress } from '../../helpers/configuration';
 | 
			
		||||
import { loadPoolConfig, ConfigNames, getWethAddress, getTreasuryAddress } from '../../helpers/configuration';
 | 
			
		||||
import { eEthereumNetwork, ICommonConfiguration } from '../../helpers/types';
 | 
			
		||||
import { waitForTx } from '../../helpers/misc-utils';
 | 
			
		||||
import {
 | 
			
		||||
| 
						 | 
				
			
			@ -42,7 +42,9 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
 | 
			
		|||
        throw 'Reserve assets is undefined. Check ReserveAssets configuration at config directory';
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      await initReservesByHelper(ReservesConfig, reserveAssets, admin, ZERO_ADDRESS, verify);
 | 
			
		||||
      const treasuryAddress = await getTreasuryAddress(poolConfig);
 | 
			
		||||
 | 
			
		||||
      await initReservesByHelper(ReservesConfig, reserveAssets, admin, treasuryAddress, ZERO_ADDRESS, verify);
 | 
			
		||||
      await enableReservesToBorrowByHelper(ReservesConfig, reserveAssets, testHelpers, admin);
 | 
			
		||||
      await enableReservesAsCollateralByHelper(ReservesConfig, reserveAssets, testHelpers, admin);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,7 +26,7 @@ import {
 | 
			
		|||
import { Signer } from 'ethers';
 | 
			
		||||
import { TokenContractId, eContractid, tEthereumAddress, AavePools } from '../helpers/types';
 | 
			
		||||
import { MintableERC20 } from '../types/MintableERC20';
 | 
			
		||||
import { getReservesConfigByPool } from '../helpers/configuration';
 | 
			
		||||
import { ConfigNames, getReservesConfigByPool, getTreasuryAddress, loadPoolConfig } from '../helpers/configuration';
 | 
			
		||||
import { initializeMakeSuite } from './helpers/make-suite';
 | 
			
		||||
 | 
			
		||||
import {
 | 
			
		||||
| 
						 | 
				
			
			@ -209,7 +209,12 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
 | 
			
		|||
  const admin = await deployer.getAddress();
 | 
			
		||||
 | 
			
		||||
  console.log('Initialize configuration');
 | 
			
		||||
  await initReservesByHelper(reservesParams, allReservesAddresses, admin, ZERO_ADDRESS);
 | 
			
		||||
 | 
			
		||||
  const config = loadPoolConfig(ConfigNames.Aave);
 | 
			
		||||
 | 
			
		||||
  const treasuryAddress = await getTreasuryAddress(config);
 | 
			
		||||
 | 
			
		||||
  await initReservesByHelper(reservesParams, allReservesAddresses, admin, treasuryAddress, ZERO_ADDRESS, false);
 | 
			
		||||
  await enableReservesToBorrowByHelper(reservesParams, allReservesAddresses, testHelpers, admin);
 | 
			
		||||
  await enableReservesAsCollateralByHelper(
 | 
			
		||||
    reservesParams,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user