diff --git a/contracts/deployments/ATokensAndRatesHelper.sol b/contracts/deployments/ATokensAndRatesHelper.sol index 400f7ca6..2cac535b 100644 --- a/contracts/deployments/ATokensAndRatesHelper.sol +++ b/contracts/deployments/ATokensAndRatesHelper.sol @@ -32,6 +32,7 @@ contract ATokensAndRatesHelper is Ownable { uint256 liquidationBonus; uint256 reserveFactor; bool stableBorrowingEnabled; + bool borrowingEnabled; } constructor( @@ -73,10 +74,12 @@ contract ATokensAndRatesHelper is Ownable { inputParams[i].liquidationBonus ); - configurator.enableBorrowingOnReserve( - inputParams[i].asset, - inputParams[i].stableBorrowingEnabled - ); + if (inputParams[i].borrowingEnabled) { + configurator.enableBorrowingOnReserve( + inputParams[i].asset, + inputParams[i].stableBorrowingEnabled + ); + } configurator.setReserveFactor(inputParams[i].asset, inputParams[i].reserveFactor); } } diff --git a/helper-hardhat-config.ts b/helper-hardhat-config.ts index a445d78e..5b903000 100644 --- a/helper-hardhat-config.ts +++ b/helper-hardhat-config.ts @@ -42,7 +42,7 @@ export const NETWORKS_DEFAULT_GAS: iParamsPerNetwork = { [eEthereumNetwork.buidlerevm]: 65 * GWEI, [eEthereumNetwork.tenderlyMain]: 0.01 * GWEI, [ePolygonNetwork.mumbai]: 1 * GWEI, - [ePolygonNetwork.matic]: 2 * GWEI, + [ePolygonNetwork.matic]: 1 * GWEI, [eXDaiNetwork.xdai]: 1 * GWEI, }; diff --git a/helpers/configuration.ts b/helpers/configuration.ts index ade69a26..9b21d08d 100644 --- a/helpers/configuration.ts +++ b/helpers/configuration.ts @@ -113,6 +113,19 @@ export const getWethAddress = async (config: ICommonConfiguration) => { return weth.address; }; +export const getWrappedNativeTokenAddress = async (config: ICommonConfiguration) => { + const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name; + const wethAddress = getParamPerNetwork(config.WrappedNativeToken, currentNetwork); + if (wethAddress) { + return wethAddress; + } + if (currentNetwork.includes('main')) { + throw new Error('WETH not set at mainnet configuration.'); + } + const weth = await deployWETHMocked(); + return weth.address; +}; + export const getLendingRateOracles = (poolConfig: ICommonConfiguration) => { const { ProtocolGlobalParams: { UsdAddress }, diff --git a/helpers/contracts-deployments.ts b/helpers/contracts-deployments.ts index 68024d2a..6ae58383 100644 --- a/helpers/contracts-deployments.ts +++ b/helpers/contracts-deployments.ts @@ -56,6 +56,7 @@ import { linkBytecode, insertContractAddressInDb, deployContract, + verifyContract, } from './contracts-helpers'; import { StableAndVariableTokensHelperFactory } from '../types/StableAndVariableTokensHelperFactory'; import { MintableDelegationERC20 } from '../types/MintableDelegationERC20'; @@ -63,7 +64,6 @@ import { readArtifact as buidlerReadArtifact } from '@nomiclabs/buidler/plugins' import { HardhatRuntimeEnvironment } from 'hardhat/types'; import { LendingPoolLibraryAddresses } from '../types/LendingPoolFactory'; import { UiPoolDataProvider } from '../types'; -import { verifyContract } from './etherscan-verification'; export const deployUiPoolDataProvider = async ( [incentivesController, aaveOracle]: [tEthereumAddress, tEthereumAddress], @@ -73,7 +73,7 @@ export const deployUiPoolDataProvider = async ( const args: string[] = [incentivesController, aaveOracle]; const instance = await deployContract(id, args); if (verify) { - await verifyContract(instance.address, args); + await verifyContract(id, instance, args); } return instance; }; diff --git a/helpers/contracts-getters.ts b/helpers/contracts-getters.ts index 0f70c48b..41089e39 100644 --- a/helpers/contracts-getters.ts +++ b/helpers/contracts-getters.ts @@ -33,19 +33,19 @@ import { } from '../types'; import { IERC20DetailedFactory } from '../types/IERC20DetailedFactory'; import { MockTokenMap } from './contracts-helpers'; -import { DRE, getDb } from './misc-utils'; +import { DRE, getDb, notFalsyOrZeroAddress } from './misc-utils'; import { eContractid, PoolConfiguration, tEthereumAddress, TokenContractId } from './types'; export const getFirstSigner = async () => (await DRE.ethers.getSigners())[0]; -export const getLendingPoolAddressesProvider = async (address?: tEthereumAddress) => - await LendingPoolAddressesProviderFactory.connect( +export const getLendingPoolAddressesProvider = async (address?: tEthereumAddress) => { + return await LendingPoolAddressesProviderFactory.connect( address || (await getDb().get(`${eContractid.LendingPoolAddressesProvider}.${DRE.network.name}`).value()) .address, await getFirstSigner() ); - +}; export const getLendingPoolConfiguratorProxy = async (address?: tEthereumAddress) => { return await LendingPoolConfiguratorFactory.connect( address || @@ -172,7 +172,7 @@ export const getPairsTokenAggregator = ( }, aggregatorsAddresses: { [tokenSymbol: string]: tEthereumAddress } ): [string[], string[]] => { - const { ETH, USD, WETH, ...assetsAddressesWithoutEth } = allAssetsAddresses; + const { ETH, WETH, ...assetsAddressesWithoutEth } = allAssetsAddresses; const pairs = Object.entries(assetsAddressesWithoutEth).map(([tokenSymbol, tokenAddress]) => { //if (true/*tokenSymbol !== 'WETH' && tokenSymbol !== 'ETH' && tokenSymbol !== 'LpWETH'*/) { @@ -195,12 +195,13 @@ export const getPairsTokenAggregator = ( export const getLendingPoolAddressesProviderRegistry = async (address?: tEthereumAddress) => await LendingPoolAddressesProviderRegistryFactory.connect( - address || - ( - await getDb() - .get(`${eContractid.LendingPoolAddressesProviderRegistry}.${DRE.network.name}`) - .value() - ).address, + notFalsyOrZeroAddress(address) + ? address + : ( + await getDb() + .get(`${eContractid.LendingPoolAddressesProviderRegistry}.${DRE.network.name}`) + .value() + ).address, await getFirstSigner() ); diff --git a/helpers/contracts-helpers.ts b/helpers/contracts-helpers.ts index 015b9926..b4ab51c2 100644 --- a/helpers/contracts-helpers.ts +++ b/helpers/contracts-helpers.ts @@ -22,9 +22,10 @@ import { import { MintableERC20 } from '../types/MintableERC20'; import { Artifact } from 'hardhat/types'; import { Artifact as BuidlerArtifact } from '@nomiclabs/buidler/types'; -import { verifyContract } from './etherscan-verification'; +import { verifyEtherscanContract } from './etherscan-verification'; import { getIErc20Detailed } from './contracts-getters'; -import { usingTenderly } from './tenderly-utils'; +import { usingTenderly, verifyAtTenderly } from './tenderly-utils'; +import { usingPolygon, verifyAtPolygon } from './polygon-utils'; export type MockTokenMap = { [symbol: string]: MintableERC20 }; @@ -98,18 +99,8 @@ export const withSaveAndVerify = async ( ): Promise => { await waitForTx(instance.deployTransaction); await registerContractInJsonDb(id, instance); - if (usingTenderly()) { - console.log(); - console.log('Doing Tenderly contract verification of', id); - await (DRE as any).tenderlyRPC.verify({ - name: id, - address: instance.address, - }); - console.log(`Verified ${id} at Tenderly!`); - console.log(); - } if (verify) { - await verifyContract(instance.address, args); + await verifyContract(id, instance, args); } return instance; }; @@ -327,3 +318,19 @@ export const buildFlashLiquidationAdapterParams = ( [collateralAsset, debtAsset, user, debtToCover, useEthPath] ); }; + +export const verifyContract = async ( + id: string, + instance: Contract, + args: (string | string[])[] +) => { + if (usingPolygon()) { + await verifyAtPolygon(id, instance, args); + } else { + if (usingTenderly()) { + await verifyAtTenderly(id, instance); + } + await verifyEtherscanContract(instance.address, args); + } + return instance; +}; diff --git a/helpers/etherscan-verification.ts b/helpers/etherscan-verification.ts index ddbf80e4..3bf097d3 100644 --- a/helpers/etherscan-verification.ts +++ b/helpers/etherscan-verification.ts @@ -20,7 +20,7 @@ function delay(ms: number) { return new Promise((resolve) => setTimeout(resolve, ms)); } -export const verifyContract = async ( +export const verifyEtherscanContract = async ( address: string, constructorArguments: (string | string[])[], libraries?: string diff --git a/helpers/init-helpers.ts b/helpers/init-helpers.ts index 1ff02338..aa209583 100644 --- a/helpers/init-helpers.ts +++ b/helpers/init-helpers.ts @@ -207,7 +207,7 @@ export const initReservesByHelper = async ( interestRateStrategyAddress: strategyAddressPerAsset[reserveSymbols[i]], underlyingAsset: reserveTokens[i], treasury: treasuryAddress, - incentivesController: ZERO_ADDRESS, + incentivesController, underlyingAssetName: reserveSymbols[i], aTokenName: `${aTokenNamePrefix} ${reserveSymbols[i]}`, aTokenSymbol: `a${symbolPrefix}${reserveSymbols[i]}`, @@ -277,11 +277,6 @@ export const configureReservesByHelper = async ( const atokenAndRatesDeployer = await getATokensAndRatesHelper(); const tokens: string[] = []; const symbols: string[] = []; - const baseLTVA: string[] = []; - const liquidationThresholds: string[] = []; - const liquidationBonuses: string[] = []; - const reserveFactors: string[] = []; - const stableRatesEnabled: boolean[] = []; const inputParams: { asset: string; @@ -290,6 +285,7 @@ export const configureReservesByHelper = async ( liquidationBonus: BigNumberish; reserveFactor: BigNumberish; stableBorrowingEnabled: boolean; + borrowingEnabled: boolean; }[] = []; for (const [ @@ -300,6 +296,7 @@ export const configureReservesByHelper = async ( liquidationThreshold, reserveFactor, stableBorrowRateEnabled, + borrowingEnabled, }, ] of Object.entries(reservesParams) as [string, IReserveParams][]) { if (!tokenAddresses[assetSymbol]) { @@ -333,15 +330,11 @@ export const configureReservesByHelper = async ( liquidationBonus: liquidationBonus, reserveFactor: reserveFactor, stableBorrowingEnabled: stableBorrowRateEnabled, + borrowingEnabled: borrowingEnabled, }); tokens.push(tokenAddress); symbols.push(assetSymbol); - baseLTVA.push(baseLTVAsCollateral); - liquidationThresholds.push(liquidationThreshold); - liquidationBonuses.push(liquidationBonus); - reserveFactors.push(reserveFactor); - stableRatesEnabled.push(stableBorrowRateEnabled); } if (tokens.length) { // Set aTokenAndRatesDeployer as temporal admin @@ -372,230 +365,6 @@ const getAddressById = async ( ): Promise => (await getDb().get(`${id}.${network}`).value())?.address || undefined; -// Function deprecated? Updated but untested, script is not updated on package.json. -// This is not called during regular deployment, only in the "full:initialize-tokens" -// hardhat task. -export const initTokenReservesByHelper = async ( - reservesParams: iMultiPoolsAssets, - tokenAddresses: { [symbol: string]: tEthereumAddress }, - admin: tEthereumAddress, - addressesProviderAddress: tEthereumAddress, - ratesHelperAddress: tEthereumAddress, - dataProviderAddress: tEthereumAddress, - signer: Signer, - treasuryAddress: tEthereumAddress, - verify: boolean -) => { - let gasUsage = BigNumber.from('0'); - const atokenAndRatesDeployer = await (await getATokensAndRatesHelper(ratesHelperAddress)).connect( - signer - ); - - const addressProvider = await ( - await getLendingPoolAddressesProvider(addressesProviderAddress) - ).connect(signer); - const protocolDataProvider = await ( - await getAaveProtocolDataProvider(dataProviderAddress) - ).connect(signer); - const poolAddress = await addressProvider.getLendingPool(); - - // Set aTokenAndRatesDeployer as temporal admin - //await waitForTx(await addressProvider.setPoolAdmin(atokenAndRatesDeployer.address)); - - // CHUNK CONFIGURATION - const initChunks = 4; - - // Initialize variables for future reserves initialization - let deployedStableTokens: string[] = []; - let deployedVariableTokens: string[] = []; - let deployedATokens: string[] = []; - let deployedRates: string[] = []; - //let reserveTokens: string[] = []; - let reserveInitDecimals: string[] = []; - let reserveSymbols: string[] = []; - - let initInputParams: { - aTokenImpl: string; - stableDebtTokenImpl: string; - variableDebtTokenImpl: string; - underlyingAssetDecimals: BigNumberish; - interestRateStrategyAddress: string; - underlyingAsset: string; - treasury: string; - incentivesController: string; - underlyingAssetName: string; - aTokenName: string; - aTokenSymbol: string; - variableDebtTokenName: string; - variableDebtTokenSymbol: string; - stableDebtTokenName: string; - stableDebtTokenSymbol: string; - params: string; - }[] = []; - - const network = process.env.FORK - ? (process.env.FORK as eEthereumNetwork) - : (DRE.network.name as eNetwork); - // Grab config from DB - for (const [symbol, address] of Object.entries(tokenAddresses)) { - const { aTokenAddress } = await protocolDataProvider.getReserveTokensAddresses(address); - const reserveParamIndex = Object.keys(reservesParams).findIndex((value) => value === symbol); - const [, { reserveDecimals: decimals }] = (Object.entries(reservesParams) as [ - string, - IReserveParams - ][])[reserveParamIndex]; - - if (!isZeroAddress(aTokenAddress)) { - console.log(`- Skipping ${symbol} due already initialized`); - continue; - } - let stableTokenImpl = await getAddressById(`stableDebtTokenImpl`, network); - let variableTokenImpl = await getAddressById(`variableDebtTokenImpl`, network); - let aTokenImplementation: string | undefined = ''; - const [, { aTokenImpl, strategy }] = (Object.entries(reservesParams) as [ - string, - IReserveParams - ][])[reserveParamIndex]; - if (aTokenImpl === eContractid.AToken) { - aTokenImplementation = await getAddressById(`aTokenImpl`, network); - } else if (aTokenImpl === eContractid.DelegationAwareAToken) { - aTokenImplementation = await getAddressById(`delegationAwareATokenImpl`, network); - } - - let strategyImpl = await getAddressById(strategy.name, network); - - if (!stableTokenImpl) { - const stableDebt = await deployStableDebtToken( - [ - poolAddress, - tokenAddresses[symbol], - ZERO_ADDRESS, // Incentives controller - `Aave stable debt bearing ${symbol}`, - `stableDebt${symbol}`, - ], - verify - ); - stableTokenImpl = stableDebt.address; - } - if (!variableTokenImpl) { - const variableDebt = await deployVariableDebtToken( - [ - poolAddress, - tokenAddresses[symbol], - ZERO_ADDRESS, // Incentives Controller - `Aave variable debt bearing ${symbol}`, - `variableDebt${symbol}`, - ], - verify - ); - variableTokenImpl = variableDebt.address; - } - if (!aTokenImplementation) { - const [, { aTokenImpl }] = (Object.entries(reservesParams) as [string, IReserveParams][])[ - reserveParamIndex - ]; - const deployCustomAToken = chooseATokenDeployment(aTokenImpl); - const aToken = await deployCustomAToken( - [ - poolAddress, - tokenAddresses[symbol], - treasuryAddress, - ZERO_ADDRESS, - `Aave interest bearing ${symbol}`, - `a${symbol}`, - ], - verify - ); - aTokenImplementation = aToken.address; - } - if (!strategyImpl) { - const [, { strategy }] = (Object.entries(reservesParams) as [string, IReserveParams][])[ - reserveParamIndex - ]; - const { - optimalUtilizationRate, - baseVariableBorrowRate, - variableRateSlope1, - variableRateSlope2, - stableRateSlope1, - stableRateSlope2, - } = strategy; - const rates = await deployDefaultReserveInterestRateStrategy( - [ - tokenAddresses[symbol], - optimalUtilizationRate, - baseVariableBorrowRate, - variableRateSlope1, - variableRateSlope2, - stableRateSlope1, - stableRateSlope2, - ], - verify - ); - strategyImpl = rates.address; - } - // --- REMOVED BECAUSE WE NOW USE THE SAME IMPLEMENTATIONS --- - // const symbols = [`a${symbol}`, `variableDebt${symbol}`, `stableDebt${symbol}`]; - // const tokens = [aTokenImplementation, variableTokenImpl, stableTokenImpl]; - // for (let index = 0; index < symbols.length; index++) { - // if (!(await isErc20SymbolCorrect(tokens[index], symbols[index]))) { - // console.error(`${symbol} and implementation does not match: ${tokens[index]}`); - // throw Error('Symbol does not match implementation.'); - // } - // } - console.log(`- Added ${symbol} to the initialize batch`); - deployedStableTokens.push(stableTokenImpl); - deployedVariableTokens.push(variableTokenImpl); - deployedATokens.push(aTokenImplementation); - //reserveTokens.push(); - deployedRates.push(strategyImpl); - reserveInitDecimals.push(decimals.toString()); - reserveSymbols.push(symbol); - } - - for (let i = 0; i < deployedATokens.length; i++) { - initInputParams.push({ - aTokenImpl: deployedATokens[i], - stableDebtTokenImpl: deployedStableTokens[i], - variableDebtTokenImpl: deployedVariableTokens[i], - underlyingAssetDecimals: reserveInitDecimals[i], - interestRateStrategyAddress: deployedRates[i], - underlyingAsset: tokenAddresses[reserveSymbols[i]], - treasury: treasuryAddress, - incentivesController: ZERO_ADDRESS, - underlyingAssetName: reserveSymbols[i], - aTokenName: `Aave interest bearing ${reserveSymbols[i]}`, - aTokenSymbol: `a${reserveSymbols[i]}`, - variableDebtTokenName: `Aave variable debt bearing ${reserveSymbols[i]}`, - variableDebtTokenSymbol: `variableDebt${reserveSymbols[i]}`, - stableDebtTokenName: `Aave stable debt bearing ${reserveSymbols[i]}`, - stableDebtTokenSymbol: `stableDebt${reserveSymbols[i]}`, - params: '0x10', - }); - } - - // Deploy init reserves per chunks - const chunkedSymbols = chunk(reserveSymbols, initChunks); - const chunkedInitInputParams = chunk(initInputParams, initChunks); - - const configurator = await getLendingPoolConfiguratorProxy(); - //await waitForTx(await addressProvider.setPoolAdmin(admin)); - - console.log(`- Reserves initialization in ${chunkedInitInputParams.length} txs`); - for (let chunkIndex = 0; chunkIndex < chunkedInitInputParams.length; chunkIndex++) { - const tx3 = await waitForTx( - await configurator.batchInitReserve(chunkedInitInputParams[chunkIndex]) - ); - - console.log(` - Reserve ready for: ${chunkedSymbols[chunkIndex].join(', ')}`); - console.log(' * gasUsed', tx3.gasUsed.toString()); - } - - // Set deployer back as admin - //await waitForTx(await addressProvider.setPoolAdmin(admin)); - return gasUsage; // No longer relevant -}; - // Function deprecated const isErc20SymbolCorrect = async (token: tEthereumAddress, symbol: string) => { const erc20 = await getAToken(token); // using aToken for ERC20 interface diff --git a/helpers/polygon-utils.ts b/helpers/polygon-utils.ts new file mode 100644 index 00000000..555d2096 --- /dev/null +++ b/helpers/polygon-utils.ts @@ -0,0 +1,142 @@ +import axios from 'axios'; +import { Contract } from 'ethers/lib/ethers'; +import { HardhatRuntimeEnvironment } from 'hardhat/types'; +import { DRE } from './misc-utils'; +import { ePolygonNetwork, EthereumNetworkNames } from './types'; + +const TASK_FLATTEN_GET_FLATTENED_SOURCE = 'flatten:get-flattened-sources'; +const TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS = 'compile:solidity:get-source-paths'; + +/* Polygon Helpers */ + +export const usingPolygon = () => + DRE && Object.keys(ePolygonNetwork).includes((DRE as HardhatRuntimeEnvironment).network.name); + +/* Polygon Verifier */ + +const SOLIDITY_PRAGMA = 'pragma solidity'; +const LICENSE_IDENTIFIER = 'License-Identifier'; +const EXPERIMENTAL_ABIENCODER = 'pragma experimental ABIEncoderV2;'; + +const encodeDeployParams = (instance: Contract, args: (string | string[])[]) => { + return instance.interface.encodeDeploy(args).replace('0x', ''); +}; + +// Remove lines at "text" that includes "matcher" string, but keeping first "keep" lines +const removeLines = (text: string, matcher: string, keep = 0): string => { + let counter = keep; + return text + .split('\n') + .filter((line) => { + const match = !line.includes(matcher); + if (match === false && counter > 0) { + counter--; + return true; + } + return match; + }) + .join('\n'); +}; + +// Try to find the path of a Contract by name of the file without ".sol" +const findPath = async (id: string): Promise => { + const paths = await DRE.run(TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS); + const path = paths.find((x) => { + const t = x.split('/'); + return t[t.length - 1].split('.')[0] == id; + }); + + if (!path) { + throw Error('Missing path for contract name: ${id}'); + } + + return path; +}; + +// Hardhat Flattener, similar to truffle flattener +const hardhatFlattener = async (filePath: string) => + await DRE.run(TASK_FLATTEN_GET_FLATTENED_SOURCE, { files: [filePath] }); + +// Verify a smart contract at Polygon Matic network via a GET request to the block explorer +export const verifyAtPolygon = async ( + id: string, + instance: Contract, + args: (string | string[])[] +) => { + /* + ${net == mumbai or mainnet} + https://explorer-${net}.maticvigil.com/api + ?module=contract + &action=verify + &addressHash={addressHash} + &name={name} + &compilerVersion={compilerVersion} + &optimization={false} + &contractSourceCode={contractSourceCode} + */ + const network = (DRE as HardhatRuntimeEnvironment).network.name; + const net = network === EthereumNetworkNames.matic ? 'mainnet' : network; + const filePath = await findPath(id); + const encodedConstructorParams = encodeDeployParams(instance, args); + const flattenSourceCode = await hardhatFlattener(filePath); + + // Remove pragmas and license identifier after first match, required by block explorers like explorer-mainnet.maticgivil.com or Etherscan + const cleanedSourceCode = removeLines( + removeLines(removeLines(flattenSourceCode, LICENSE_IDENTIFIER, 1), SOLIDITY_PRAGMA, 1), + EXPERIMENTAL_ABIENCODER, + 1 + ); + try { + console.log( + `[Polygon Verify] Verifying ${id} with address ${instance.address} at Matic ${net} network` + ); + const response = await axios.post( + `https://explorer-${net}.maticvigil.com/api`, + { + addressHash: instance.address, + name: id, + compilerVersion: 'v0.6.12+commit.27d51765', + optimization: 'true', + contractSourceCode: cleanedSourceCode, + constructorArguments: encodedConstructorParams, + }, + { + params: { + module: 'contract', + action: 'verify', + }, + headers: { + 'Content-Type': 'application/json', + Referer: 'aavematic-42e1f6da', + }, + } + ); + if (response.status === 200 && response.data.message === 'OK') { + console.log(`[Polygon Verify] Verified contract at Matic ${net} network.`); + console.log( + `[Polygon Verify] Check at: https://explorer-${net}.maticvigil.com/address/${instance.address}/contracts) \n` + ); + return; + } + + throw Error(JSON.stringify(response.data, null, 2)); + } catch (error) { + if (error?.message.includes('Smart-contract already verified.')) { + console.log( + `[Polygon Verify] Already verified. Check it at: https://explorer-${net}.maticvigil.com/address/${instance.address}/contracts) \n` + ); + return; + } + console.error('[Polygon Verify] Error:', error.toString()); + console.log( + `[Polygon Verify] Skipping verification for ${id} with ${instance.address} due an unknown error.` + ); + console.log( + `Please proceed with manual verification at https://explorer-${net}.maticvigil.com/address/${instance.address}/contracts` + ); + console.log(`- Use the following as encoded constructor params`); + console.log(encodedConstructorParams); + console.log(`- Flattened and cleaned source code`); + console.log(cleanedSourceCode); + } +}; diff --git a/helpers/tenderly-utils.ts b/helpers/tenderly-utils.ts index 27445608..e561b11d 100644 --- a/helpers/tenderly-utils.ts +++ b/helpers/tenderly-utils.ts @@ -1,3 +1,4 @@ +import { Contract } from 'ethers'; import { HardhatRuntimeEnvironment } from 'hardhat/types'; import { DRE } from './misc-utils'; @@ -5,3 +6,12 @@ export const usingTenderly = () => DRE && ((DRE as HardhatRuntimeEnvironment).network.name.includes('tenderly') || process.env.TENDERLY === 'true'); + +export const verifyAtTenderly = async (id: string, instance: Contract) => { + console.log('\n- Doing Tenderly contract verification of', id); + await (DRE as any).tenderlyRPC.verify({ + name: id, + address: instance.address, + }); + console.log(` - Verified ${id} at Tenderly!`); +}; diff --git a/helpers/types.ts b/helpers/types.ts index ea8826a0..267b5abb 100644 --- a/helpers/types.ts +++ b/helpers/types.ts @@ -297,7 +297,7 @@ export type iLpPoolAssets = Pick< export type iMaticPoolAssets = Pick< iAssetsWithoutUSD, - 'DAI' | 'USDC' | 'USDT' | 'WBTC' | 'WETH' | 'WMATIC' + 'DAI' | 'USDC' | 'USDT' | 'WBTC' | 'WETH' | 'WMATIC' | 'AAVE' >; export type iXDAIPoolAssets = Pick< @@ -351,7 +351,7 @@ export enum TokenContractId { BptBALWETH = 'BptBALWETH', WMATIC = 'WMATIC', STAKE = 'STAKE', - xSUSHI = 'xSUSHI' + xSUSHI = 'xSUSHI', } export interface IReserveParams extends IReserveBorrowParams, IReserveCollateralParams { @@ -490,8 +490,10 @@ export interface ICommonConfiguration { ReservesConfig: iMultiPoolsAssets; ATokenDomainSeparator: iParamsPerNetwork; WETH: iParamsPerNetwork; + WrappedNativeToken: iParamsPerNetwork; WethGateway: iParamsPerNetwork; ReserveFactorTreasuryAddress: iParamsPerNetwork; + IncentivesController: iParamsPerNetwork; } export interface IAaveConfiguration extends ICommonConfiguration { diff --git a/markets/aave/commons.ts b/markets/aave/commons.ts index 744605ed..134e37eb 100644 --- a/markets/aave/commons.ts +++ b/markets/aave/commons.ts @@ -342,6 +342,15 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.main]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', [eEthereumNetwork.tenderlyMain]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', }, + WrappedNativeToken: { + [eEthereumNetwork.coverage]: '', // deployed in local evm + [eEthereumNetwork.hardhat]: '', // deployed in local evm + [eEthereumNetwork.buidlerevm]: '', // deployed in local evm + [eEthereumNetwork.kovan]: '0xd0a1e359811322d97991e03f863a0c30c2cf029c', + [eEthereumNetwork.ropsten]: '0xc778417e063141139fce010982780140aa0cd5ab', + [eEthereumNetwork.main]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', + [eEthereumNetwork.tenderlyMain]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', + }, ReserveFactorTreasuryAddress: { [eEthereumNetwork.coverage]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', [eEthereumNetwork.hardhat]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', @@ -351,4 +360,13 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.main]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', [eEthereumNetwork.tenderlyMain]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', }, + IncentivesController: { + [eEthereumNetwork.coverage]: ZERO_ADDRESS, + [eEthereumNetwork.hardhat]: ZERO_ADDRESS, + [eEthereumNetwork.buidlerevm]: ZERO_ADDRESS, + [eEthereumNetwork.kovan]: ZERO_ADDRESS, + [eEthereumNetwork.ropsten]: ZERO_ADDRESS, + [eEthereumNetwork.main]: ZERO_ADDRESS, + [eEthereumNetwork.tenderlyMain]: ZERO_ADDRESS, + }, }; diff --git a/markets/amm/commons.ts b/markets/amm/commons.ts index 98f11369..8be1f2c0 100644 --- a/markets/amm/commons.ts +++ b/markets/amm/commons.ts @@ -325,6 +325,15 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.main]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', [eEthereumNetwork.tenderlyMain]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', }, + WrappedNativeToken: { + [eEthereumNetwork.coverage]: '', // deployed in local evm + [eEthereumNetwork.hardhat]: '', // deployed in local evm + [eEthereumNetwork.buidlerevm]: '', // deployed in local evm + [eEthereumNetwork.kovan]: '0xd0a1e359811322d97991e03f863a0c30c2cf029c', + [eEthereumNetwork.ropsten]: '0xc778417e063141139fce010982780140aa0cd5ab', + [eEthereumNetwork.main]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', + [eEthereumNetwork.tenderlyMain]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', + }, ReserveFactorTreasuryAddress: { [eEthereumNetwork.coverage]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', [eEthereumNetwork.hardhat]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', @@ -334,4 +343,13 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.main]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', [eEthereumNetwork.tenderlyMain]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', }, + IncentivesController: { + [eEthereumNetwork.coverage]: ZERO_ADDRESS, + [eEthereumNetwork.hardhat]: ZERO_ADDRESS, + [eEthereumNetwork.buidlerevm]: ZERO_ADDRESS, + [eEthereumNetwork.kovan]: ZERO_ADDRESS, + [eEthereumNetwork.ropsten]: ZERO_ADDRESS, + [eEthereumNetwork.main]: ZERO_ADDRESS, + [eEthereumNetwork.tenderlyMain]: ZERO_ADDRESS, + }, }; diff --git a/markets/matic/commons.ts b/markets/matic/commons.ts index 42b269b0..8a0274a0 100644 --- a/markets/matic/commons.ts +++ b/markets/matic/commons.ts @@ -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, ePolygonNetwork } from '../../helpers/types'; // ---------------- @@ -49,7 +55,10 @@ export const CommonsConfig: ICommonConfiguration = { borrowRate: oneRay.multipliedBy(0.03).toFixed(), }, WMATIC: { - borrowRate: oneRay.multipliedBy(0.05).toFixed(), // TEMP + borrowRate: oneRay.multipliedBy(0.05).toFixed(), + }, + AAVE: { + borrowRate: oneRay.multipliedBy(0.03).toFixed(), }, }, // ---------------- @@ -62,46 +71,46 @@ export const CommonsConfig: ICommonConfiguration = { [ePolygonNetwork.matic]: undefined, }, PoolAdminIndex: 0, + EmergencyAdminIndex: 0, EmergencyAdmin: { [ePolygonNetwork.mumbai]: undefined, [ePolygonNetwork.matic]: undefined, }, LendingPool: { [ePolygonNetwork.mumbai]: '', - [ePolygonNetwork.matic]: '0xABdC61Cd16e5111f335f4135B7A0e65Cc7F86327', + [ePolygonNetwork.matic]: '', }, LendingPoolConfigurator: { [ePolygonNetwork.mumbai]: '', - [ePolygonNetwork.matic]: '0x17c4A170FFF882862F656597889016D3a6073534', + [ePolygonNetwork.matic]: '', }, - EmergencyAdminIndex: 1, ProviderRegistry: { - [ePolygonNetwork.mumbai]: '0x569859d41499B4dDC28bfaA43915051FF0A38a6F', // TEMP - [ePolygonNetwork.matic]: '0x28334e4791860a0c1eCF89a62B973ba04a5d643F', // TEMP + [ePolygonNetwork.mumbai]: ZERO_ADDRESS, + [ePolygonNetwork.matic]: '0x3ac4e9aa29940770aeC38fe853a4bbabb2dA9C19', }, ProviderRegistryOwner: { - [ePolygonNetwork.mumbai]: '0x18d9bA2baEfBdE0FF137C4ad031427EF205f1Fd9', // TEMP - [ePolygonNetwork.matic]: '0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F', // TEMP + [ePolygonNetwork.mumbai]: '', + [ePolygonNetwork.matic]: '0xD7D86236d6c463521920fCC50A9CB56f8C8Bf008', }, LendingRateOracle: { [ePolygonNetwork.mumbai]: '', - [ePolygonNetwork.matic]: '', - }, + [ePolygonNetwork.matic]: '0x17F73aEaD876CC4059089ff815EDA37052960dFB', + }, LendingPoolCollateralManager: { [ePolygonNetwork.mumbai]: '', - [ePolygonNetwork.matic]: '0x9Af76e0575D139570D3B4c821567Fe935E8c25C5', + [ePolygonNetwork.matic]: '', }, TokenDistributor: { [ePolygonNetwork.mumbai]: '', [ePolygonNetwork.matic]: '', }, - WethGateway: { + WethGateway: { [ePolygonNetwork.mumbai]: '', - [ePolygonNetwork.matic]: '0x15A46f5073789b7D16F6F46632aE50Bae838d938', + [ePolygonNetwork.matic]: '', }, AaveOracle: { [ePolygonNetwork.mumbai]: '', - [ePolygonNetwork.matic]: '0x1B38fa90596F2C25bCf1B193A6c6a718349AFDfC', + [ePolygonNetwork.matic]: '0x0229F777B0fAb107F9591a41d5F02E4e98dB6f2d', }, FallbackOracle: { [ePolygonNetwork.mumbai]: ZERO_ADDRESS, @@ -109,12 +118,13 @@ export const CommonsConfig: ICommonConfiguration = { }, ChainlinkAggregator: { [ePolygonNetwork.matic]: { - DAI: '0x4746DeC9e833A82EC7C2C1356372CcF2cfcD2F3D', - USDC: '0xfE4A8cc5b5B2366C1B58Bea3858e81843581b2F7', - USDT: '0x0A6513e40db6EB1b165753AD52E80663aeA50545', - WBTC: '0xc907E116054Ad103354f2D350FD2514433D57F6f', - WETH: '0xF9680D99D6C9589e2a93a78A04A279e509205945', - WMATIC: '0xAB594600376Ec9fD91F8e885dADF0CE036862dE0', + AAVE: '0xbE23a3AA13038CfC28aFd0ECe4FdE379fE7fBfc4', + DAI: '0xFC539A559e170f848323e19dfD66007520510085', + USDC: '0xefb7e6be8356cCc6827799B6A7348eE674A80EaE', + USDT: '0xf9d5AAC6E5572AEFa6bd64108ff86a222F69B64d', + WBTC: '0xA338e0492B2F944E9F8C0653D3AD1484f2657a37', + WMATIC: '0x327e23A4855b6F663a28c5161541d69Af8973302', + USD: '0xF9680D99D6C9589e2a93a78A04A279e509205945', }, [ePolygonNetwork.mumbai]: { DAI: ZERO_ADDRESS, @@ -134,11 +144,19 @@ export const CommonsConfig: ICommonConfiguration = { [ePolygonNetwork.matic]: '', }, WETH: { - [ePolygonNetwork.mumbai]: '0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889', // WMATIC address (untested) - [ePolygonNetwork.matic]: '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270', // WMATIC address + [ePolygonNetwork.mumbai]: ZERO_ADDRESS, + [ePolygonNetwork.matic]: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619', + }, + WrappedNativeToken: { + [ePolygonNetwork.mumbai]: ZERO_ADDRESS, + [ePolygonNetwork.matic]: '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270', }, ReserveFactorTreasuryAddress: { - [ePolygonNetwork.mumbai]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', // TEMP - [ePolygonNetwork.matic]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', // TEMP + [ePolygonNetwork.mumbai]: ZERO_ADDRESS, + [ePolygonNetwork.matic]: '0x7734280A4337F37Fbf4651073Db7c28C80B339e9', + }, + IncentivesController: { + [ePolygonNetwork.mumbai]: ZERO_ADDRESS, + [ePolygonNetwork.matic]: '0x357D51124f59836DeD84c8a1730D72B749d8BC23', }, }; diff --git a/markets/matic/index.ts b/markets/matic/index.ts index cc1484ae..e5bb55bf 100644 --- a/markets/matic/index.ts +++ b/markets/matic/index.ts @@ -1,4 +1,3 @@ -import { oneRay, ZERO_ADDRESS } from '../../helpers/constants'; import { IMaticConfiguration, ePolygonNetwork } from '../../helpers/types'; import { CommonsConfig } from './commons'; @@ -9,6 +8,7 @@ import { strategyWBTC, strategyWETH, strategyMATIC, + strategyAAVE, } from './reservesConfigs'; // ---------------- @@ -18,7 +18,7 @@ import { export const MaticConfig: IMaticConfiguration = { ...CommonsConfig, MarketId: 'Matic Market', - ProviderId: 3, // Unknown? + ProviderId: 3, // Unknown? ReservesConfig: { DAI: strategyDAI, USDC: strategyUSDC, @@ -26,6 +26,7 @@ export const MaticConfig: IMaticConfiguration = { WBTC: strategyWBTC, WETH: strategyWETH, WMATIC: strategyMATIC, + AAVE: strategyAAVE, }, ReserveAssets: { [ePolygonNetwork.matic]: { @@ -35,8 +36,10 @@ export const MaticConfig: IMaticConfiguration = { WBTC: '0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6', WETH: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619', WMATIC: '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270', + AAVE: '0xD6DF932A45C0f255f85145f286eA0b292B21C90B', }, - [ePolygonNetwork.mumbai]: { // Mock tokens with a simple "mint" external function, except wmatic + [ePolygonNetwork.mumbai]: { + // Mock tokens with a simple "mint" external function, except wmatic DAI: '0x13b3fda609C1eeb23b4F4b69257840760dCa6C4a', USDC: '0x52b63223994433FdE2F1350Ba69Dfd2779f06ABA', USDT: '0xB3abd1912F586fDFFa13606882c28E27913853d2', diff --git a/markets/matic/reservesConfigs.ts b/markets/matic/reservesConfigs.ts index 608d028b..e9dd26d4 100644 --- a/markets/matic/reservesConfigs.ts +++ b/markets/matic/reservesConfigs.ts @@ -1,15 +1,13 @@ // import BigNumber from 'bignumber.js'; // import { oneRay } from '../../helpers/constants'; import { eContractid, IReserveParams } from '../../helpers/types'; -import { - rateStrategyStableOne, +import { rateStrategyStableTwo, rateStrategyStableThree, rateStrategyWETH, rateStrategyAAVE, rateStrategyVolatileOne, rateStrategyVolatileTwo, - rateStrategyVolatileThree, } from './rateStrategies'; export const strategyDAI: IReserveParams = { @@ -18,10 +16,10 @@ export const strategyDAI: IReserveParams = { liquidationThreshold: '8000', liquidationBonus: '10500', borrowingEnabled: true, - stableBorrowRateEnabled: true, + stableBorrowRateEnabled: false, reserveDecimals: '18', aTokenImpl: eContractid.AToken, - reserveFactor: '1000' + reserveFactor: '1000', }; export const strategyUSDC: IReserveParams = { @@ -30,22 +28,22 @@ export const strategyUSDC: IReserveParams = { liquidationThreshold: '8500', liquidationBonus: '10500', borrowingEnabled: true, - stableBorrowRateEnabled: true, + stableBorrowRateEnabled: false, reserveDecimals: '6', aTokenImpl: eContractid.AToken, - reserveFactor: '1000' + reserveFactor: '1000', }; export const strategyUSDT: IReserveParams = { - strategy: rateStrategyStableThree, - baseLTVAsCollateral: '8000', - liquidationThreshold: '8500', - liquidationBonus: '10500', - borrowingEnabled: true, - stableBorrowRateEnabled: true, - reserveDecimals: '6', - aTokenImpl: eContractid.AToken, - reserveFactor: '1000' + strategy: rateStrategyStableThree, + baseLTVAsCollateral: '0', + liquidationThreshold: '0', + liquidationBonus: '0', + borrowingEnabled: true, + stableBorrowRateEnabled: false, + reserveDecimals: '6', + aTokenImpl: eContractid.AToken, + reserveFactor: '1000', }; export const strategyWETH: IReserveParams = { @@ -54,10 +52,10 @@ export const strategyWETH: IReserveParams = { liquidationThreshold: '8250', liquidationBonus: '10500', borrowingEnabled: true, - stableBorrowRateEnabled: true, + stableBorrowRateEnabled: false, reserveDecimals: '18', aTokenImpl: eContractid.AToken, - reserveFactor: '1000' + reserveFactor: '1000', }; export const strategyWBTC: IReserveParams = { @@ -66,20 +64,32 @@ export const strategyWBTC: IReserveParams = { liquidationThreshold: '7500', liquidationBonus: '11000', borrowingEnabled: true, - stableBorrowRateEnabled: true, + stableBorrowRateEnabled: false, reserveDecimals: '8', aTokenImpl: eContractid.AToken, - reserveFactor: '2000' + reserveFactor: '2000', }; export const strategyMATIC: IReserveParams = { - strategy: rateStrategyVolatileOne, //Temp? + strategy: rateStrategyVolatileOne, //Temp? baseLTVAsCollateral: '5000', liquidationThreshold: '6500', liquidationBonus: '11000', borrowingEnabled: true, - stableBorrowRateEnabled: true, + stableBorrowRateEnabled: false, reserveDecimals: '18', aTokenImpl: eContractid.AToken, - reserveFactor: '2000' -}; \ No newline at end of file + reserveFactor: '2000', +}; + +export const strategyAAVE: IReserveParams = { + strategy: rateStrategyAAVE, + baseLTVAsCollateral: '5000', + liquidationThreshold: '6500', + liquidationBonus: '11000', + borrowingEnabled: false, + stableBorrowRateEnabled: false, + reserveDecimals: '18', + aTokenImpl: eContractid.AToken, + reserveFactor: '0', +}; diff --git a/markets/xdai/commons.ts b/markets/xdai/commons.ts index 433d54ea..ee9f1f9f 100644 --- a/markets/xdai/commons.ts +++ b/markets/xdai/commons.ts @@ -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, eXDaiNetwork } from '../../helpers/types'; // ---------------- @@ -79,14 +85,14 @@ export const CommonsConfig: ICommonConfiguration = { }, LendingRateOracle: { [eXDaiNetwork.xdai]: '', - }, + }, LendingPoolCollateralManager: { [eXDaiNetwork.xdai]: '', }, TokenDistributor: { [eXDaiNetwork.xdai]: '', }, - WethGateway: { + WethGateway: { [eXDaiNetwork.xdai]: '', }, AaveOracle: { @@ -114,7 +120,13 @@ export const CommonsConfig: ICommonConfiguration = { WETH: { [eXDaiNetwork.xdai]: '', // DAI: xDAI is the base token, DAI is also there, We need WXDAI }, + WrappedNativeToken: { + [eXDaiNetwork.xdai]: '', // DAI: xDAI is the base token, DAI is also there, We need WXDAI + }, ReserveFactorTreasuryAddress: { - [eXDaiNetwork.xdai]: '', // TEMP + [eXDaiNetwork.xdai]: '', // TEMP + }, + IncentivesController: { + [eXDaiNetwork.xdai]: ZERO_ADDRESS, }, }; diff --git a/package-lock.json b/package-lock.json index 40428433..accf7a09 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2657,6 +2657,11 @@ "follow-redirects": "^1.10.0" } }, + "axios-curlirize": { + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/axios-curlirize/-/axios-curlirize-1.3.7.tgz", + "integrity": "sha512-csSsuMyZj1dv1fL0zRPnDAHWrmlISMvK+wx9WJI/igRVDT4VMgbf2AVenaHghFLfI1nQijXUevYEguYV6u5hjA==" + }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", diff --git a/package.json b/package.json index 3aa93fe5..79b60118 100644 --- a/package.json +++ b/package.json @@ -28,13 +28,13 @@ "aave:evm:dev:migration": "npm run compile && hardhat aave:dev", "aave:docker:full:migration": "npm run compile && npm run hardhat:docker -- aave:mainnet --skip-registry", "aave:kovan:full:migration": "npm run compile && npm run hardhat:kovan -- aave:mainnet --skip-registry", - "matic:mumbai:full:migration": "npm run compile && npm run hardhat:mumbai matic:mainnet --skip-registry", - "matic:matic:full:migration": "npm run compile && npm run hardhat:matic matic:mainnet --skip-registry", + "matic:mumbai:full:migration": "npm run compile && npm run hardhat:mumbai sidechain:mainnet -- --pool Matic --skip-registry", + "matic:matic:full:migration": "npm run compile && npm run hardhat:matic sidechain:mainnet -- --pool Matic --skip-registry", "amm:kovan:full:migration": "npm run compile && npm run hardhat:kovan -- amm:mainnet --skip-registry", "aave:docker:full:migration:add-registry": "npm run compile && npm run hardhat:docker -- aave:mainnet", "aave:kovan:full:migration:add-registry": "npm run compile && npm run hardhat:kovan -- aave:mainnet", - "matic:mumbai:full:migration:add-registry": "npm run compile && npm run hardhat:mumbai matic:mainnet", - "matic:matic:full:migration:add-registry": "npm run compile && npm run hardhat:matic matic:mainnet", + "matic:mumbai:full:migration:add-registry": "npm run compile && npm run hardhat:mumbai sidechain:mainnet -- --pool Matic", + "matic:matic:full:migration:add-registry": "npm run compile && npm run hardhat:matic sidechain:mainnet -- --pool Matic", "amm:kovan:full:migration:add-registry": "npm run compile && npm run hardhat:kovan -- amm:mainnet", "aave:docker:add-market-to-registry-from-config": "npm run compile && npm run hardhat:docker -- add-market-to-registry --pool Aave", "aave:kovan:add-market-to-registry-from-config": "npm run compile && npm run hardhat:kovan -- add-market-to-registry --pool Aave", @@ -77,14 +77,15 @@ "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", + "matic:mumbai:verify": "npm run hardhat:mumbai verify:general -- --all --pool Matic", + "matic:mainnet:verify": "npm run hardhat:matic verify:general -- --all --pool Matic", + "matic:mumbai:verify:tokens": "npm run hardhat:mumbai verify:tokens -- --pool Matic", + "matic:mainnet:verify:tokens": "npm run hardhat:matic verify:tokens -- --pool Matic", "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", "print-config:fork:mainnet": "FORK=main hardhat print-config:fork", "print-config:kovan": "hardhat --network kovan print-config --pool Aave --data-provider 0xA1901785c29cBd48bfA74e46b67C736b26054fa4", - "main:fork:initialize-tokens": "npm run compile && FORK=main hardhat full:initialize-tokens --pool Aave", - "main:initialize-tokens": "npm run compile && hardhat --network main full:initialize-tokens --pool Aave", - "kovan:initialize-tokens": "npm run compile && hardhat --network kovan full:initialize-tokens --pool Aave", "external:deploy-assets-kovan": "npm run compile && hardhat --network kovan external:deploy-new-asset --symbol ${SYMBOL} --verify", "external:deploy-assets-main": "npm run compile && hardhat --network main external:deploy-new-asset --symbol ${SYMBOL} --verify", "prepublishOnly": "npm run compile" @@ -152,6 +153,7 @@ ], "license": "AGPLv3", "dependencies": { + "axios-curlirize": "^1.3.7", "tmp-promise": "^3.0.2" }, "keywords": [ diff --git a/tasks/deployments/deploy-UiPoolDataProvider.ts b/tasks/deployments/deploy-UiPoolDataProvider.ts index 6cc07449..7696ddb9 100644 --- a/tasks/deployments/deploy-UiPoolDataProvider.ts +++ b/tasks/deployments/deploy-UiPoolDataProvider.ts @@ -1,6 +1,7 @@ import { task } from 'hardhat/config'; -import { eContractid, eEthereumNetwork, ePolygonNetwork } from '../../helpers/types'; +import { eContractid, eEthereumNetwork, eNetwork, ePolygonNetwork } from '../../helpers/types'; import { deployUiPoolDataProvider } from '../../helpers/contracts-deployments'; +import { exit } from 'process'; task(`deploy-${eContractid.UiPoolDataProvider}`, `Deploys the UiPoolDataProvider contract`) .addFlag('verify', 'Verify UiPoolDataProvider contract via Etherscan API.') @@ -9,8 +10,11 @@ task(`deploy-${eContractid.UiPoolDataProvider}`, `Deploys the UiPoolDataProvider if (!localBRE.network.config.chainId) { throw new Error('INVALID_CHAIN_ID'); } + const network = localBRE.network.name; - const addressesByNetwork = { + const addressesByNetwork: { + [key: string]: { incentivesController: string; aaveOracle: string }; + } = { [eEthereumNetwork.kovan]: { incentivesController: '0x0000000000000000000000000000000000000000', aaveOracle: '0x8fb777d67e9945e2c01936e319057f9d41d559e6', @@ -28,17 +32,25 @@ task(`deploy-${eContractid.UiPoolDataProvider}`, `Deploys the UiPoolDataProvider aaveOracle: '0xC365C653f7229894F93994CD0b30947Ab69Ff1D5', }, }; + const supportedNetworks = Object.keys(addressesByNetwork); + + if (!supportedNetworks.includes(network)) { + console.error( + `[task][error] Network "${network}" not supported, please use one of: ${supportedNetworks.join()}` + ); + exit(2); + } + + const oracle = addressesByNetwork[network].aaveOracle; + const incentivesController = addressesByNetwork[network].aaveOracle; console.log(`\n- UiPoolDataProvider deployment`); - console.log(`\tDeploying UiPoolDataProvider implementation ...`); - const UiPoolDataProvider = await deployUiPoolDataProvider( - [ - addressesByNetwork[localBRE.network.name].incentivesController, - addressesByNetwork[localBRE.network.name].aaveOracle, - ], + const uiPoolDataProvider = await deployUiPoolDataProvider( + [incentivesController, oracle], verify ); - console.log(`\tFinished UiPoolDataProvider deployment: ${UiPoolDataProvider.address}`); + console.log('UiPoolDataProvider deployed at:', uiPoolDataProvider.address); + console.log(`\tFinished UiPoolDataProvider deployment`); }); diff --git a/tasks/deployments/deploy-UniswapLiquiditySwapAdapter.ts b/tasks/deployments/deploy-UniswapLiquiditySwapAdapter.ts index a41cd975..70eb6ced 100644 --- a/tasks/deployments/deploy-UniswapLiquiditySwapAdapter.ts +++ b/tasks/deployments/deploy-UniswapLiquiditySwapAdapter.ts @@ -1,8 +1,9 @@ import { task } from 'hardhat/config'; import { UniswapLiquiditySwapAdapterFactory } from '../../types'; -import { verifyContract } from '../../helpers/etherscan-verification'; +import { verifyContract } from '../../helpers/contracts-helpers'; import { getFirstSigner } from '../../helpers/contracts-getters'; +import { eContractid } from '../../helpers/types'; const CONTRACT_NAME = 'UniswapLiquiditySwapAdapter'; @@ -29,7 +30,14 @@ task(`deploy-${CONTRACT_NAME}`, `Deploys the ${CONTRACT_NAME} contract`) ).deploy(provider, router, weth); await uniswapRepayAdapter.deployTransaction.wait(); console.log(`${CONTRACT_NAME}.address`, uniswapRepayAdapter.address); - await verifyContract(uniswapRepayAdapter.address, [provider, router, weth]); + + if (verify) { + await verifyContract(eContractid.UniswapLiquiditySwapAdapter, uniswapRepayAdapter, [ + provider, + router, + weth, + ]); + } console.log(`\tFinished ${CONTRACT_NAME} proxy and implementation deployment`); }); diff --git a/tasks/deployments/deploy-UniswapRepayAdapter.ts b/tasks/deployments/deploy-UniswapRepayAdapter.ts index 58ba23a1..e9e7b244 100644 --- a/tasks/deployments/deploy-UniswapRepayAdapter.ts +++ b/tasks/deployments/deploy-UniswapRepayAdapter.ts @@ -1,8 +1,9 @@ import { task } from 'hardhat/config'; import { UniswapRepayAdapterFactory } from '../../types'; -import { verifyContract } from '../../helpers/etherscan-verification'; +import { verifyContract } from '../../helpers/contracts-helpers'; import { getFirstSigner } from '../../helpers/contracts-getters'; +import { eContractid } from '../../helpers/types'; const CONTRACT_NAME = 'UniswapRepayAdapter'; @@ -30,7 +31,14 @@ task(`deploy-${CONTRACT_NAME}`, `Deploys the ${CONTRACT_NAME} contract`) ); await uniswapRepayAdapter.deployTransaction.wait(); console.log(`${CONTRACT_NAME}.address`, uniswapRepayAdapter.address); - await verifyContract(uniswapRepayAdapter.address, [provider, router, weth]); + + if (verify) { + await verifyContract(eContractid.UniswapRepayAdapter, uniswapRepayAdapter, [ + provider, + router, + weth, + ]); + } console.log( `\tFinished ${CONTRACT_NAME}${CONTRACT_NAME}lDataProvider proxy and implementation deployment` diff --git a/tasks/full/0_address_provider_registry.ts b/tasks/full/0_address_provider_registry.ts index 19b5e1f2..853088eb 100644 --- a/tasks/full/0_address_provider_registry.ts +++ b/tasks/full/0_address_provider_registry.ts @@ -1,11 +1,30 @@ +import { formatEther } from 'ethers/lib/utils'; import { task } from 'hardhat/config'; +import { ConfigNames, loadPoolConfig } from '../../helpers/configuration'; import { deployLendingPoolAddressesProviderRegistry } from '../../helpers/contracts-deployments'; +import { getFirstSigner } from '../../helpers/contracts-getters'; +import { getParamPerNetwork } from '../../helpers/contracts-helpers'; +import { notFalsyOrZeroAddress } from '../../helpers/misc-utils'; +import { eNetwork } from '../../helpers/types'; task('full:deploy-address-provider-registry', 'Deploy address provider registry') .addFlag('verify', 'Verify contracts at Etherscan') - .setAction(async ({ verify }, DRE) => { + .addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`) + .setAction(async ({ verify, pool }, DRE) => { await DRE.run('set-DRE'); + const poolConfig = loadPoolConfig(pool); + const network = DRE.network.name; + const signer = await getFirstSigner(); - const contract = await deployLendingPoolAddressesProviderRegistry(verify); - console.log('Registry Address:', contract.address); + const providerRegistryAddress = getParamPerNetwork(poolConfig.ProviderRegistry, network); + + console.log('Signer', await signer.getAddress()); + console.log('Balance', formatEther(await signer.getBalance())); + + if (notFalsyOrZeroAddress(providerRegistryAddress)) { + console.log('Already deployed Provider Registry Address at', providerRegistryAddress); + } else { + const contract = await deployLendingPoolAddressesProviderRegistry(verify); + console.log('Deployed Registry Address:', contract.address); + } }); diff --git a/tasks/full/1_address_provider.ts b/tasks/full/1_address_provider.ts index ab741b03..c863ae05 100644 --- a/tasks/full/1_address_provider.ts +++ b/tasks/full/1_address_provider.ts @@ -9,8 +9,6 @@ import { } from '../../helpers/configuration'; import { getParamPerNetwork } from '../../helpers/contracts-helpers'; import { eNetwork } from '../../helpers/types'; -import { isZeroAddress } from 'ethereumjs-util'; -//import BigNumber from 'bignumber.js'; task( 'full:deploy-address-provider', diff --git a/tasks/full/2_lending_pool.ts b/tasks/full/2_lending_pool.ts index 5f92b8eb..1d7a9b4a 100644 --- a/tasks/full/2_lending_pool.ts +++ b/tasks/full/2_lending_pool.ts @@ -34,6 +34,7 @@ task('full:deploy-lending-pool', 'Deploy lending pool for dev enviroment') console.log('\tDeploying new lending pool implementation & libraries...'); const lendingPoolImpl = await deployLendingPool(verify); lendingPoolImplAddress = lendingPoolImpl.address; + await lendingPoolImpl.initialize(addressesProvider.address); } console.log('\tSetting lending pool implementation with address:', lendingPoolImplAddress); // Set lending pool impl to Address provider diff --git a/tasks/full/3_oracles.ts b/tasks/full/3_oracles.ts index e3f8f27f..3346ebd4 100644 --- a/tasks/full/3_oracles.ts +++ b/tasks/full/3_oracles.ts @@ -17,7 +17,7 @@ import { getLendingRateOracle, getPairsTokenAggregator, } from '../../helpers/contracts-getters'; -import { AaveOracle } from '../../types'; +import { AaveOracle, LendingRateOracle } from '../../types'; task('full:deploy-oracles', 'Deploy oracles for dev enviroment') .addFlag('verify', 'Verify contracts at Etherscan') @@ -49,38 +49,34 @@ task('full:deploy-oracles', 'Deploy oracles for dev enviroment') const [tokens, aggregators] = getPairsTokenAggregator(tokensToWatch, chainlinkAggregators); let aaveOracle: AaveOracle; + let lendingRateOracle: LendingRateOracle; + if (notFalsyOrZeroAddress(aaveOracleAddress)) { aaveOracle = await await getAaveOracle(aaveOracleAddress); - const owner = await aaveOracle.owner(); - const signer = DRE.ethers.provider.getSigner(owner); - - aaveOracle = await (await getAaveOracle(aaveOracleAddress)).connect(signer); - await waitForTx(await aaveOracle.setAssetSources(tokens, aggregators)); } else { aaveOracle = await deployAaveOracle( [tokens, aggregators, fallbackOracleAddress, await getWethAddress(poolConfig)], verify ); + await waitForTx(await aaveOracle.setAssetSources(tokens, aggregators)); } - let lendingRateOracle = notFalsyOrZeroAddress(lendingRateOracleAddress) - ? await getLendingRateOracle(lendingRateOracleAddress) - : await deployLendingRateOracle(verify); - const { USD, ...tokensAddressesWithoutUsd } = tokensToWatch; + if (notFalsyOrZeroAddress(lendingRateOracleAddress)) { + lendingRateOracle = await getLendingRateOracle(lendingRateOracleAddress); + } else { + lendingRateOracle = await deployLendingRateOracle(verify); + const { USD, ...tokensAddressesWithoutUsd } = tokensToWatch; + await setInitialMarketRatesInRatesOracleByHelper( + lendingRateOracles, + tokensAddressesWithoutUsd, + lendingRateOracle, + admin + ); + } + + console.log('Aave Oracle: %s', lendingRateOracle.address); + console.log('Lending Rate Oracle: %s', lendingRateOracle.address); - 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 - ); - //} - 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)); await waitForTx(await addressesProvider.setLendingRateOracle(lendingRateOracle.address)); diff --git a/tasks/full/5-deploy-wethGateWay.ts b/tasks/full/5-deploy-wethGateWay.ts index 2774f107..6240693a 100644 --- a/tasks/full/5-deploy-wethGateWay.ts +++ b/tasks/full/5-deploy-wethGateWay.ts @@ -1,10 +1,10 @@ import { task } from 'hardhat/config'; -import { AaveConfig } from '../../markets/aave/index'; -import { getParamPerNetwork } from '../../helpers/contracts-helpers'; -import { loadPoolConfig, ConfigNames, getWethAddress } from '../../helpers/configuration'; +import { + loadPoolConfig, + ConfigNames, + getWrappedNativeTokenAddress, +} from '../../helpers/configuration'; import { deployWETHGateway } from '../../helpers/contracts-deployments'; -import { DRE } from '../../helpers/misc-utils'; -import { eNetwork } from '../../helpers/types'; const CONTRACT_NAME = 'WETHGateway'; @@ -13,20 +13,13 @@ task(`full-deploy-weth-gateway`, `Deploys the ${CONTRACT_NAME} contract`) .addFlag('verify', `Verify ${CONTRACT_NAME} contract via Etherscan API.`) .setAction(async ({ verify, pool }, localBRE) => { await localBRE.run('set-DRE'); - const network = localBRE.network.name; const poolConfig = loadPoolConfig(pool); - const Weth = await getWethAddress(poolConfig); - const { WethGateway } = poolConfig; + const Weth = await getWrappedNativeTokenAddress(poolConfig); if (!localBRE.network.config.chainId) { throw new Error('INVALID_CHAIN_ID'); } - let gateWay = getParamPerNetwork(WethGateway, network); - if (gateWay === '') { - const wethGateWay = await deployWETHGateway([Weth], verify); - console.log(`${CONTRACT_NAME}.address`, wethGateWay.address); - console.log(`\tFinished ${CONTRACT_NAME} deployment`); - } else { - console.log(`Weth gateway already deployed. Address: ${gateWay}`); - } + const wethGateWay = await deployWETHGateway([Weth], verify); + console.log(`${CONTRACT_NAME}.address`, wethGateWay.address); + console.log(`\tFinished ${CONTRACT_NAME} deployment`); }); diff --git a/tasks/full/6-initialize.ts b/tasks/full/6-initialize.ts index f4384e09..bfe2925e 100644 --- a/tasks/full/6-initialize.ts +++ b/tasks/full/6-initialize.ts @@ -40,10 +40,11 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.') ReservesConfig, LendingPoolCollateralManager, WethGateway, + IncentivesController, } = poolConfig as ICommonConfiguration; const reserveAssets = await getParamPerNetwork(ReserveAssets, network); - + const incentivesController = await getParamPerNetwork(IncentivesController, network); const addressesProvider = await getLendingPoolAddressesProvider(); const testHelpers = await getAaveProtocolDataProvider(); @@ -64,7 +65,7 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.') SymbolPrefix, admin, treasuryAddress, - ZERO_ADDRESS, + incentivesController, verify ); await configureReservesByHelper(ReservesConfig, reserveAssets, testHelpers, admin); @@ -87,6 +88,18 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.') await addressesProvider.setLendingPoolCollateralManager(collateralManagerAddress) ); + console.log( + '\tSetting AaveProtocolDataProvider at AddressesProvider at id: 0x01', + collateralManagerAddress + ); + const aaveProtocolDataProvider = await getAaveProtocolDataProvider(); + await waitForTx( + await addressesProvider.setAddress( + '0x0100000000000000000000000000000000000000000000000000000000000000', + aaveProtocolDataProvider.address + ) + ); + await deployWalletBalancerProvider(verify); const lendingPoolAddress = await addressesProvider.getLendingPool(); @@ -95,6 +108,7 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.') if (!notFalsyOrZeroAddress(gateWay)) { gateWay = (await getWETHGateway()).address; } + console.log('GATEWAY', gateWay); await authorizeWETHGateway(gateWay, lendingPoolAddress); } catch (err) { console.error(err); diff --git a/tasks/migrations/matic.mainnet.ts b/tasks/migrations/sidechain.mainnet.ts similarity index 73% rename from tasks/migrations/matic.mainnet.ts rename to tasks/migrations/sidechain.mainnet.ts index 2c7fe59e..60607639 100644 --- a/tasks/migrations/matic.mainnet.ts +++ b/tasks/migrations/sidechain.mainnet.ts @@ -4,11 +4,12 @@ import { ConfigNames } from '../../helpers/configuration'; import { printContracts } from '../../helpers/misc-utils'; import { usingTenderly } from '../../helpers/tenderly-utils'; -task('matic:mainnet', 'Deploy development enviroment') +task('sidechain:mainnet', 'Deploy market at sidechain') + .addParam('pool', `Market pool configuration, one of ${Object.keys(ConfigNames)}`) .addFlag('verify', 'Verify contracts at Etherscan') .addFlag('skipRegistry', 'Skip addresses provider registration at Addresses Provider Registry') - .setAction(async ({ verify, skipRegistry }, DRE) => { - const POOL_NAME = ConfigNames.Matic; + .setAction(async ({ verify, pool, skipRegistry }, DRE) => { + const POOL_NAME = pool; await DRE.run('set-DRE'); // Prevent loss of gas verifying all the needed ENVs for Etherscan verification @@ -18,6 +19,9 @@ task('matic:mainnet', 'Deploy development enviroment') console.log('Migration started\n'); + console.log('0. Deploy address provider registry'); + await DRE.run('full:deploy-address-provider-registry', { pool: POOL_NAME }); + console.log('1. Deploy address provider'); await DRE.run('full:deploy-address-provider', { pool: POOL_NAME, skipRegistry }); @@ -29,16 +33,18 @@ task('matic:mainnet', 'Deploy development enviroment') console.log('4. Deploy Data Provider'); await DRE.run('full:data-provider', { pool: POOL_NAME }); + console.log('5. Deploy WETH Gateway'); + await DRE.run('full-deploy-weth-gateway', { pool: POOL_NAME }); - console.log('5. Initialize lending pool'); + console.log('6. Initialize lending pool'); await DRE.run('full:initialize-lending-pool', { pool: POOL_NAME }); if (verify) { printContracts(); - console.log('4. Veryfing contracts'); + console.log('7. Veryfing contracts'); await DRE.run('verify:general', { all: true, pool: POOL_NAME }); - console.log('5. Veryfing aTokens and debtTokens'); + console.log('8. Veryfing aTokens and debtTokens'); await DRE.run('verify:tokens', { pool: POOL_NAME }); } diff --git a/tasks/misc/verify-sc.ts b/tasks/misc/verify-sc.ts index 12484d47..e65820a0 100644 --- a/tasks/misc/verify-sc.ts +++ b/tasks/misc/verify-sc.ts @@ -1,6 +1,5 @@ import { task } from 'hardhat/config'; -import { verifyContract, checkVerification } from '../../helpers/etherscan-verification'; - +import { verifyEtherscanContract, checkVerification } from '../../helpers/etherscan-verification'; interface VerifyParams { contractName: string; address: string; @@ -24,6 +23,6 @@ task('verify-sc', 'Inits the DRE, to have access to all the plugins') checkVerification(); - const result = await verifyContract(address, constructorArguments, libraries); + const result = await verifyEtherscanContract(address, constructorArguments, libraries); return result; }); diff --git a/tasks/verifications/1_general.ts b/tasks/verifications/1_general.ts index fef0e510..b2b3bcb7 100644 --- a/tasks/verifications/1_general.ts +++ b/tasks/verifications/1_general.ts @@ -19,13 +19,13 @@ import { getLendingPoolConfiguratorImpl, getLendingPoolConfiguratorProxy, getLendingPoolImpl, + getProxy, getWalletProvider, getWETHGateway, } from '../../helpers/contracts-getters'; -import { getParamPerNetwork } from '../../helpers/contracts-helpers'; -import { verifyContract } from '../../helpers/etherscan-verification'; +import { verifyContract, getParamPerNetwork } from '../../helpers/contracts-helpers'; import { notFalsyOrZeroAddress } from '../../helpers/misc-utils'; -import { eNetwork, ICommonConfiguration } from '../../helpers/types'; +import { eContractid, eNetwork, ICommonConfiguration } from '../../helpers/types'; task('verify:general', 'Verify contracts at Etherscan') .addFlag('all', 'Verify all contracts at Etherscan') @@ -55,6 +55,10 @@ task('verify:general', 'Verify contracts at Etherscan') const lendingPoolConfiguratorAddress = await addressesProvider.getLendingPoolConfigurator(); //getLendingPoolConfiguratorProxy(); const lendingPoolCollateralManagerAddress = await addressesProvider.getLendingPoolCollateralManager(); + const lendingPoolProxy = await getProxy(lendingPoolAddress); + const lendingPoolConfiguratorProxy = await getProxy(lendingPoolConfiguratorAddress); + const lendingPoolCollateralManagerProxy = await getProxy(lendingPoolCollateralManagerAddress); + if (all) { const lendingPoolImplAddress = getParamPerNetwork(LendingPool, network); const lendingPoolImpl = notFalsyOrZeroAddress(lendingPoolImplAddress) @@ -89,64 +93,69 @@ task('verify:general', 'Verify contracts at Etherscan') // Address Provider console.log('\n- Verifying address provider...\n'); - await verifyContract(addressesProvider.address, [MarketId]); + await verifyContract(eContractid.LendingPoolAddressesProvider, addressesProvider, [MarketId]); // Address Provider Registry console.log('\n- Verifying address provider registry...\n'); - await verifyContract(addressesProviderRegistry.address, []); + await verifyContract( + eContractid.LendingPoolAddressesProviderRegistry, + addressesProviderRegistry, + [] + ); // Lending Pool implementation console.log('\n- Verifying LendingPool Implementation...\n'); - await verifyContract(lendingPoolImpl.address, []); + await verifyContract(eContractid.LendingPool, lendingPoolImpl, []); // Lending Pool Configurator implementation console.log('\n- Verifying LendingPool Configurator Implementation...\n'); - await verifyContract(lendingPoolConfiguratorImpl.address, []); + await verifyContract(eContractid.LendingPoolConfigurator, lendingPoolConfiguratorImpl, []); // Lending Pool Collateral Manager implementation console.log('\n- Verifying LendingPool Collateral Manager Implementation...\n'); - await verifyContract(lendingPoolCollateralManagerImpl.address, []); + await verifyContract( + eContractid.LendingPoolCollateralManager, + lendingPoolCollateralManagerImpl, + [] + ); // Test helpers console.log('\n- Verifying Aave Provider Helpers...\n'); - await verifyContract(dataProvider.address, [addressesProvider.address]); + await verifyContract(eContractid.AaveProtocolDataProvider, dataProvider, [ + addressesProvider.address, + ]); // Wallet balance provider console.log('\n- Verifying Wallet Balance Provider...\n'); - await verifyContract(walletProvider.address, []); + await verifyContract(eContractid.WalletBalanceProvider, walletProvider, []); // WETHGateway console.log('\n- Verifying WETHGateway...\n'); - await verifyContract(wethGateway.address, [await getWethAddress(poolConfig)]); + await verifyContract(eContractid.WETHGateway, wethGateway, [ + await getWethAddress(poolConfig), + ]); } // Lending Pool proxy console.log('\n- Verifying Lending Pool Proxy...\n'); - await verifyContract(lendingPoolAddress, [addressesProvider.address]); + await verifyContract(eContractid.InitializableAdminUpgradeabilityProxy, lendingPoolProxy, [ + addressesProvider.address, + ]); // LendingPool Conf proxy console.log('\n- Verifying Lending Pool Configurator Proxy...\n'); - await verifyContract(lendingPoolConfiguratorAddress, [addressesProvider.address]); + await verifyContract( + eContractid.InitializableAdminUpgradeabilityProxy, + lendingPoolConfiguratorProxy, + [addressesProvider.address] + ); // Proxy collateral manager console.log('\n- Verifying Lending Pool Collateral Manager Proxy...\n'); - await verifyContract(lendingPoolCollateralManagerAddress, []); + await verifyContract( + eContractid.InitializableAdminUpgradeabilityProxy, + lendingPoolCollateralManagerProxy, + [] + ); - // DelegatedAwareAToken - console.log('\n- Verifying DelegatedAwareAToken...\n'); - const UNI = getParamPerNetwork(ReserveAssets, network).UNI; - const aUNI = await getAddressById('aUNI'); - if (aUNI) { - console.log('Verifying aUNI'); - await verifyContract(aUNI, [ - lendingPoolAddress, - UNI, - treasuryAddress, - 'Aave interest bearing UNI', - 'aUNI', - ZERO_ADDRESS, - ]); - } else { - console.error('Missing aUNI address at JSON DB. Skipping...'); - } console.log('Finished verifications.'); }); diff --git a/tasks/verifications/2_tokens.ts b/tasks/verifications/2_tokens.ts index 52d77ffd..eacc7f92 100644 --- a/tasks/verifications/2_tokens.ts +++ b/tasks/verifications/2_tokens.ts @@ -8,14 +8,16 @@ import { import { ZERO_ADDRESS } from '../../helpers/constants'; import { getAddressById, + getAToken, getFirstSigner, - getLendingPool, + getInterestRateStrategy, getLendingPoolAddressesProvider, - getLendingPoolConfiguratorProxy, + getProxy, + getStableDebtToken, + getVariableDebtToken, } from '../../helpers/contracts-getters'; -import { getParamPerNetwork } from '../../helpers/contracts-helpers'; -import { verifyContract } from '../../helpers/etherscan-verification'; -import { eNetwork, ICommonConfiguration, IReserveParams } from '../../helpers/types'; +import { getParamPerNetwork, verifyContract } from '../../helpers/contracts-helpers'; +import { eContractid, eNetwork, ICommonConfiguration, IReserveParams } from '../../helpers/types'; import { LendingPoolConfiguratorFactory, LendingPoolFactory } from '../../types'; task('verify:tokens', 'Deploy oracles for dev enviroment') @@ -66,27 +68,43 @@ task('verify:tokens', 'Deploy oracles for dev enviroment') console.log; // Proxy Stable Debt console.log(`\n- Verifying Stable Debt Token proxy...\n`); - await verifyContract(stableDebtTokenAddress, [lendingPoolConfigurator.address]); + await verifyContract( + eContractid.InitializableAdminUpgradeabilityProxy, + await getProxy(stableDebtTokenAddress), + [lendingPoolConfigurator.address] + ); // Proxy Variable Debt console.log(`\n- Verifying Debt Token proxy...\n`); - await verifyContract(variableDebtTokenAddress, [lendingPoolConfigurator.address]); + await verifyContract( + eContractid.InitializableAdminUpgradeabilityProxy, + await getProxy(variableDebtTokenAddress), + [lendingPoolConfigurator.address] + ); // Proxy aToken console.log('\n- Verifying aToken proxy...\n'); - await verifyContract(aTokenAddress, [lendingPoolConfigurator.address]); + await verifyContract( + eContractid.InitializableAdminUpgradeabilityProxy, + await getProxy(aTokenAddress), + [lendingPoolConfigurator.address] + ); // Strategy Rate console.log(`\n- Verifying Strategy rate...\n`); - await verifyContract(interestRateStrategyAddress, [ - addressesProvider.address, - optimalUtilizationRate, - baseVariableBorrowRate, - variableRateSlope1, - variableRateSlope2, - stableRateSlope1, - stableRateSlope2, - ]); + await verifyContract( + eContractid.DefaultReserveInterestRateStrategy, + await getInterestRateStrategy(interestRateStrategyAddress), + [ + addressesProvider.address, + optimalUtilizationRate, + baseVariableBorrowRate, + variableRateSlope1, + variableRateSlope2, + stableRateSlope1, + stableRateSlope2, + ] + ); const stableDebt = await getAddressById(`stableDebt${token}`); const variableDebt = await getAddressById(`variableDebt${token}`); @@ -94,7 +112,7 @@ task('verify:tokens', 'Deploy oracles for dev enviroment') if (aToken) { console.log('\n- Verifying aToken...\n'); - await verifyContract(aToken, [ + await verifyContract(eContractid.AToken, await getAToken(aToken), [ lendingPoolProxy.address, tokenAddress, treasuryAddress, @@ -107,7 +125,7 @@ task('verify:tokens', 'Deploy oracles for dev enviroment') } if (stableDebt) { console.log('\n- Verifying StableDebtToken...\n'); - await verifyContract(stableDebt, [ + await verifyContract(eContractid.StableDebtToken, await getStableDebtToken(stableDebt), [ lendingPoolProxy.address, tokenAddress, `Aave stable debt bearing ${token}`, @@ -119,13 +137,17 @@ task('verify:tokens', 'Deploy oracles for dev enviroment') } if (variableDebt) { console.log('\n- Verifying VariableDebtToken...\n'); - await verifyContract(variableDebt, [ - lendingPoolProxy.address, - tokenAddress, - `Aave variable debt bearing ${token}`, - `variableDebt${token}`, - ZERO_ADDRESS, - ]); + await verifyContract( + eContractid.VariableDebtToken, + await getVariableDebtToken(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.`); }