diff --git a/hardhat.config.ts b/hardhat.config.ts index 278577bb..dc47392f 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -3,7 +3,13 @@ import fs from 'fs'; import { HardhatUserConfig } from 'hardhat/types'; // @ts-ignore import { accounts } from './test-wallets.js'; -import { eEthereumNetwork, eNetwork, ePolygonNetwork, eXDaiNetwork } from './helpers/types'; +import { + eAvalancheNetwork, + eEthereumNetwork, + eNetwork, + ePolygonNetwork, + eXDaiNetwork, +} from './helpers/types'; import { BUIDLEREVM_CHAINID, COVERAGE_CHAINID } from './helpers/buidler-constants'; import { NETWORKS_RPC_URL, @@ -100,6 +106,8 @@ const buidlerConfig: HardhatUserConfig = { matic: getCommonNetworkConfig(ePolygonNetwork.matic, 137), mumbai: getCommonNetworkConfig(ePolygonNetwork.mumbai, 80001), xdai: getCommonNetworkConfig(eXDaiNetwork.xdai, 100), + avalanche: getCommonNetworkConfig(eAvalancheNetwork.avalanche, 43114), + fuji: getCommonNetworkConfig(eAvalancheNetwork.fuji, 43113), hardhat: { hardfork: 'berlin', blockGasLimit: DEFAULT_BLOCK_GAS_LIMIT, diff --git a/helper-hardhat-config.ts b/helper-hardhat-config.ts index 3df38000..6747c444 100644 --- a/helper-hardhat-config.ts +++ b/helper-hardhat-config.ts @@ -1,6 +1,7 @@ // @ts-ignore import { HardhatNetworkForkingUserConfig, HardhatUserConfig } from 'hardhat/types'; import { + eAvalancheNetwork, eEthereumNetwork, ePolygonNetwork, eXDaiNetwork, @@ -49,6 +50,8 @@ export const NETWORKS_RPC_URL: iParamsPerNetwork = { [ePolygonNetwork.mumbai]: 'https://rpc-mumbai.maticvigil.com', [ePolygonNetwork.matic]: 'https://rpc-mainnet.matic.network', [eXDaiNetwork.xdai]: 'https://rpc.xdaichain.com/', + [eAvalancheNetwork.avalanche]: 'https://cchain.explorer.avax.network/', + [eAvalancheNetwork.fuji]: 'https://api.avax-test.network/ext/bc/C/rpc' }; export const NETWORKS_DEFAULT_GAS: iParamsPerNetwork = { @@ -62,6 +65,8 @@ export const NETWORKS_DEFAULT_GAS: iParamsPerNetwork = { [ePolygonNetwork.mumbai]: 1 * GWEI, [ePolygonNetwork.matic]: 1 * GWEI, [eXDaiNetwork.xdai]: 1 * GWEI, + [eAvalancheNetwork.avalanche]: 255 * GWEI, + [eAvalancheNetwork.fuji]: 255 * GWEI }; export const BLOCK_TO_FORK: iParamsPerNetwork = { @@ -75,4 +80,6 @@ export const BLOCK_TO_FORK: iParamsPerNetwork = { [ePolygonNetwork.mumbai]: undefined, [ePolygonNetwork.matic]: undefined, [eXDaiNetwork.xdai]: undefined, + [eAvalancheNetwork.avalanche]: undefined, + [eAvalancheNetwork.fuji]: undefined }; diff --git a/helpers/configuration.ts b/helpers/configuration.ts index 82e74e41..5ba2c386 100644 --- a/helpers/configuration.ts +++ b/helpers/configuration.ts @@ -9,6 +9,7 @@ import { import { getEthersSignersAddresses, getParamPerPool } from './contracts-helpers'; import AaveConfig from '../markets/aave'; import MaticConfig from '../markets/matic'; +import AvalancheConfig from '../markets/avalanche'; import AmmConfig from '../markets/amm'; import { CommonsConfig } from '../markets/aave/commons'; import { DRE, filterMapBy } from './misc-utils'; @@ -21,6 +22,7 @@ export enum ConfigNames { Aave = 'Aave', Matic = 'Matic', Amm = 'Amm', + Avalanche = 'Avalanche' } export const loadPoolConfig = (configName: ConfigNames): PoolConfiguration => { @@ -31,6 +33,8 @@ export const loadPoolConfig = (configName: ConfigNames): PoolConfiguration => { return MaticConfig; case ConfigNames.Amm: return AmmConfig; + case ConfigNames.Avalanche: + return AvalancheConfig; case ConfigNames.Commons: return CommonsConfig; default: @@ -54,6 +58,9 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets(param: iParamsPerNetwork, network: eNetwork) => { - const { - main, - ropsten, - kovan, - coverage, - buidlerevm, - tenderlyMain, - } = param as iEthereumParamsPerNetwork; + const { main, ropsten, kovan, coverage, buidlerevm, tenderlyMain } = + param as iEthereumParamsPerNetwork; const { matic, mumbai } = param as iPolygonParamsPerNetwork; const { xdai } = param as iXDaiParamsPerNetwork; + const { avalanche, fuji } = param as iAvalancheParamsPerNetwork; if (process.env.FORK) { return param[process.env.FORK as eNetwork] as T; } @@ -177,10 +174,14 @@ export const getParamPerNetwork = (param: iParamsPerNetwork, network: eNet return mumbai; case eXDaiNetwork.xdai: return xdai; + case eAvalancheNetwork.avalanche: + return avalanche; + case eAvalancheNetwork.fuji: + return fuji; } }; -export const getParamPerPool = ({ proto, amm, matic }: iParamsPerPool, pool: AavePools) => { +export const getParamPerPool = ({ proto, amm, matic, avalanche }: iParamsPerPool, pool: AavePools) => { switch (pool) { case AavePools.proto: return proto; @@ -188,6 +189,8 @@ export const getParamPerPool = ({ proto, amm, matic }: iParamsPerPool, poo return amm; case AavePools.matic: return matic; + case AavePools.avalanche: + return avalanche; default: return proto; } diff --git a/helpers/init-helpers.ts b/helpers/init-helpers.ts index aa209583..a3035692 100644 --- a/helpers/init-helpers.ts +++ b/helpers/init-helpers.ts @@ -349,7 +349,7 @@ export const configureReservesByHelper = async ( for (let chunkIndex = 0; chunkIndex < chunkedInputParams.length; chunkIndex++) { await waitForTx( await atokenAndRatesDeployer.configureReserves(chunkedInputParams[chunkIndex], { - gasLimit: 12000000, + gasLimit: 8000000, // TODO: Change this }) ); console.log(` - Init for: ${chunkedSymbols[chunkIndex].join(', ')}`); diff --git a/helpers/types.ts b/helpers/types.ts index 267b5abb..e2052c7f 100644 --- a/helpers/types.ts +++ b/helpers/types.ts @@ -4,7 +4,7 @@ export interface SymbolMap { [symbol: string]: T; } -export type eNetwork = eEthereumNetwork | ePolygonNetwork | eXDaiNetwork; +export type eNetwork = eEthereumNetwork | ePolygonNetwork | eXDaiNetwork | eAvalancheNetwork; export enum eEthereumNetwork { buidlerevm = 'buidlerevm', @@ -25,6 +25,11 @@ export enum eXDaiNetwork { xdai = 'xdai', } +export enum eAvalancheNetwork { + avalanche = 'avalanche', + fuji = 'fuji', +} + export enum EthereumNetworkNames { kovan = 'kovan', ropsten = 'ropsten', @@ -32,12 +37,16 @@ export enum EthereumNetworkNames { matic = 'matic', mumbai = 'mumbai', xdai = 'xdai', + avalanche = 'avalanche', + fuji = 'fuji' + } export enum AavePools { proto = 'proto', matic = 'matic', amm = 'amm', + avalanche = 'avalanche' } export enum eContractid { @@ -239,6 +248,7 @@ export interface iAssetBase { WMATIC: T; STAKE: T; xSUSHI: T; + AVAX: T; } export type iAssetsWithoutETH = Omit, 'ETH'>; @@ -305,6 +315,11 @@ export type iXDAIPoolAssets = Pick< 'DAI' | 'USDC' | 'USDT' | 'WBTC' | 'WETH' | 'STAKE' >; +export type iAvalanchePoolAssets = Pick< + iAssetsWithoutUSD, + 'WETH' | 'DAI' | 'USDC' | 'USDT' | 'AAVE' | 'WBTC' | 'AVAX' +>; + export type iMultiPoolsAssets = iAssetCommon | iAavePoolAssets; export type iAavePoolTokens = Omit, 'ETH'>; @@ -352,6 +367,7 @@ export enum TokenContractId { WMATIC = 'WMATIC', STAKE = 'STAKE', xSUSHI = 'xSUSHI', + AVAX = 'AVAX' } export interface IReserveParams extends IReserveBorrowParams, IReserveCollateralParams { @@ -394,7 +410,8 @@ export interface IMarketRates { export type iParamsPerNetwork = | iEthereumParamsPerNetwork | iPolygonParamsPerNetwork - | iXDaiParamsPerNetwork; + | iXDaiParamsPerNetwork + | iAvalancheParamsPerNetwork; export interface iParamsPerNetworkAll extends iEthereumParamsPerNetwork, @@ -420,10 +437,16 @@ export interface iXDaiParamsPerNetwork { [eXDaiNetwork.xdai]: T; } +export interface iAvalancheParamsPerNetwork { + [eAvalancheNetwork.avalanche]: T; + [eAvalancheNetwork.fuji]: T; +} + export interface iParamsPerPool { [AavePools.proto]: T; [AavePools.matic]: T; [AavePools.amm]: T; + [AavePools.avalanche]: T; } export interface iBasicDistributionParams { @@ -512,6 +535,10 @@ export interface IXDAIConfiguration extends ICommonConfiguration { ReservesConfig: iXDAIPoolAssets; } +export interface IAvalancheConfiguration extends ICommonConfiguration { + ReservesConfig: iAvalanchePoolAssets; +} + export interface ITokenAddress { [token: string]: tEthereumAddress; } diff --git a/test-suites/test-aave/__setup.spec.ts b/test-suites/test-aave/__setup.spec.ts index c004d10f..ca9f7698 100644 --- a/test-suites/test-aave/__setup.spec.ts +++ b/test-suites/test-aave/__setup.spec.ts @@ -191,6 +191,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => { USD: USD_ADDRESS, STAKE: mockTokens.STAKE.address, xSUSHI: mockTokens.xSUSHI.address, + AVAX: mockTokens.AVAX.address }, fallbackOracle );