diff --git a/helpers/configuration.ts b/helpers/configuration.ts index a9b780fb..894dc11f 100644 --- a/helpers/configuration.ts +++ b/helpers/configuration.ts @@ -9,6 +9,7 @@ import { import { getParamPerPool } from './contracts-helpers'; import AaveConfig from '../markets/aave'; import LpConfig from '../markets/lp'; +import MaticConfig from '../markets/matic' import { CommonsConfig } from '../markets/aave/commons'; import { DRE, filterMapBy } from './misc-utils'; import { tEthereumAddress } from './types'; @@ -19,6 +20,7 @@ export enum ConfigNames { Commons = 'Commons', Aave = 'Aave', Lp = 'Lp', + Matic = 'Matic', } export const loadPoolConfig = (configName: ConfigNames): PoolConfiguration => { @@ -27,6 +29,8 @@ export const loadPoolConfig = (configName: ConfigNames): PoolConfiguration => { return AaveConfig; case ConfigNames.Lp: return LpConfig; + case ConfigNames.Matic: + return MaticConfig; case ConfigNames.Commons: return CommonsConfig; default: @@ -47,6 +51,9 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets( - { kovan, ropsten, main, buidlerevm, coverage, tenderlyMain }: iParamsPerNetwork, + { kovan, ropsten, main, buidlerevm, coverage, tenderlyMain, matic, mumbai }: iParamsPerNetwork, network: eEthereumNetwork ) => { const MAINNET_FORK = process.env.MAINNET_FORK === 'true'; @@ -154,6 +154,10 @@ export const getParamPerNetwork = ( return ropsten; case eEthereumNetwork.main: return main; + case eEthereumNetwork.matic: + return matic; + case eEthereumNetwork.mumbai: + return mumbai; case eEthereumNetwork.tenderlyMain: return tenderlyMain; } diff --git a/helpers/types.ts b/helpers/types.ts index 4c81d660..7e08399b 100644 --- a/helpers/types.ts +++ b/helpers/types.ts @@ -20,11 +20,14 @@ export enum EthereumNetworkNames { kovan = 'kovan', ropsten = 'ropsten', main = 'main', + matic = 'matic', + mumbai = 'mumbai', } export enum AavePools { proto = 'proto', lp = 'lp', + matic = 'matic', } export enum eContractid { @@ -394,6 +397,7 @@ export interface iParamsPerNetwork { export interface iParamsPerPool { [AavePools.proto]: T; [AavePools.lp]: T; + [AavePools.matic]: T; } export interface iBasicDistributionParams { diff --git a/markets/matic/commons.ts b/markets/matic/commons.ts index fb89e43a..78fb7d3d 100644 --- a/markets/matic/commons.ts +++ b/markets/matic/commons.ts @@ -134,7 +134,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.hardhat]: '', [eEthereumNetwork.buidlerevm]: '', [eEthereumNetwork.tenderlyMain]: '0x52D306e36E3B6B02c153d0266ff0f85d18BCD413', - [eEthereumNetwork.mumbai]: '', + [eEthereumNetwork.mumbai]: '0x569859d41499B4dDC28bfaA43915051FF0A38a6F', // TEMP [eEthereumNetwork.matic]: '', }, ProviderRegistryOwner: { @@ -145,7 +145,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.hardhat]: '', [eEthereumNetwork.buidlerevm]: '', [eEthereumNetwork.tenderlyMain]: '0xbd723fc4f1d737dcfc48a07fe7336766d34cad5f', - [eEthereumNetwork.mumbai]: '', + [eEthereumNetwork.mumbai]: '0x18d9bA2baEfBdE0FF137C4ad031427EF205f1Fd9', // TEMP [eEthereumNetwork.matic]: '', }, LendingRateOracle: { @@ -271,7 +271,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', [eEthereumNetwork.main]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', [eEthereumNetwork.tenderlyMain]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', - [EthereumNetwork.mumbai]: ZERO_ADDRESS, // TEMP - [EthereumNetwork.matic]: ZERO_ADDRESS, // TEMP + [EthereumNetwork.mumbai]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', // TEMP + [EthereumNetwork.matic]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', // TEMP }, }; diff --git a/markets/matic/index.ts b/markets/matic/index.ts index f48b21d9..a75e257d 100644 --- a/markets/matic/index.ts +++ b/markets/matic/index.ts @@ -15,7 +15,7 @@ import { // POOL--SPECIFIC PARAMS // ---------------- -export const AaveConfig: IMaticConfiguration = { +export const MaticConfig: IMaticConfiguration = { ...CommonsConfig, MarketId: 'Matic Market', ProviderId: 3, // Unknown? @@ -68,4 +68,4 @@ export const AaveConfig: IMaticConfiguration = { }, }; -export default AaveConfig; +export default MaticConfig; diff --git a/package.json b/package.json index b2492041..5e2e3985 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "hardhat:ropsten": "hardhat--network ropsten", "hardhat:main": "hardhat --network main", "hardhat:docker": "hardhat --network hardhatevm_docker", + "hardhat:mumbai": "hardhat --network mumbai", "compile": "SKIP_LOAD=true hardhat compile", "console:fork": "MAINNET_FORK=true hardhat console", "test": "TS_NODE_TRANSPILE_ONLY=1 hardhat test ./test-suites/test-aave/*.spec.ts", @@ -40,6 +41,7 @@ "aave:docker:full:migration": "npm run compile && npm run hardhat:docker -- aave:mainnet", "aave:kovan:full:migration": "npm run compile && npm run hardhat:kovan -- aave:mainnet --verify", "lp:kovan:full:migration": "npm run compile && npm run hardhat:kovan -- lp:mainnet --verify", + "matic:mumbai:full:migration": "npm run compile && npm run hardhat:mumbai matic:mainnet", "aave:kovan:full:initialize": "npm run hardhat:kovan -- full:initialize-lending-pool --verify --pool Aave", "aave:ropsten:full:migration": "npm run compile && npm run hardhat:ropsten -- aave:mainnet --verify", "aave:fork:main:tenderly": "npm run compile && npm run hardhat:tenderly-main -- aave:mainnet", diff --git a/tasks/migrations/matic.mainnet.ts b/tasks/migrations/matic.mainnet.ts new file mode 100644 index 00000000..0c8efe3c --- /dev/null +++ b/tasks/migrations/matic.mainnet.ts @@ -0,0 +1,50 @@ +import { task } from 'hardhat/config'; +import { checkVerification } from '../../helpers/etherscan-verification'; +import { ConfigNames } from '../../helpers/configuration'; +import { printContracts } from '../../helpers/misc-utils'; +import { usingTenderly } from '../../helpers/tenderly-utils'; + +task('matic:mainnet', 'Deploy development enviroment') + .addFlag('verify', 'Verify contracts at Etherscan') + .setAction(async ({ verify }, DRE) => { + const POOL_NAME = ConfigNames.Matic; + await DRE.run('set-DRE'); + + // Prevent loss of gas verifying all the needed ENVs for Etherscan verification + if (verify) { + checkVerification(); + } + + console.log('Migration started\n'); + + 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'); + + console.log('3. Deploy oracles'); + await DRE.run('full:deploy-oracles', { pool: POOL_NAME }); + + console.log('4. Deploy Data Provider'); + await DRE.run('full:data-provider', { pool: POOL_NAME }); + + console.log('5. Initialize lending pool'); + await DRE.run('full:initialize-lending-pool', { pool: POOL_NAME }); + + if (verify) { + printContracts(); + console.log('4. Veryfing contracts'); + await DRE.run('verify:general', { all: true, pool: POOL_NAME }); + + console.log('5. Veryfing aTokens and debtTokens'); + await DRE.run('verify:tokens', { pool: POOL_NAME }); + } + + if (usingTenderly()) { + const postDeployHead = DRE.tenderlyRPC.getHead(); + console.log('Tenderly UUID', postDeployHead); + } + console.log('\nFinished migrations'); + printContracts(); + });