Cleaned up more conf, getParanetwork working now. Added weth Gateway Matic

This commit is contained in:
Hadrien Charlanes 2021-02-23 15:42:47 +01:00
parent 029a349d90
commit e3846332db
19 changed files with 187 additions and 152 deletions

View File

@ -3,7 +3,7 @@ import fs from 'fs';
import { HardhatUserConfig } from 'hardhat/types'; import { HardhatUserConfig } from 'hardhat/types';
// @ts-ignore // @ts-ignore
import { accounts } from './test-wallets.js'; import { accounts } from './test-wallets.js';
import { eEthereumNetwork, ePolygonNetwork, eXDaiNetwork } from './helpers/types'; import { eEthereumNetwork, eNetwork, ePolygonNetwork, eXDaiNetwork } from './helpers/types';
import { BUIDLEREVM_CHAINID, COVERAGE_CHAINID } from './helpers/buidler-constants'; import { BUIDLEREVM_CHAINID, COVERAGE_CHAINID } from './helpers/buidler-constants';
import { NETWORKS_RPC_URL, NETWORKS_DEFAULT_GAS } from './helper-hardhat-config'; import { NETWORKS_RPC_URL, NETWORKS_DEFAULT_GAS } from './helper-hardhat-config';
@ -41,7 +41,7 @@ if (!SKIP_LOAD) {
require(`${path.join(__dirname, 'tasks/misc')}/set-bre.ts`); require(`${path.join(__dirname, 'tasks/misc')}/set-bre.ts`);
const getCommonNetworkConfig = (networkName: eEthereumNetwork | ePolygonNetwork | eXDaiNetwork, networkId: number) => ({ const getCommonNetworkConfig = (networkName: eNetwork, networkId: number) => ({
url: NETWORKS_RPC_URL[networkName], url: NETWORKS_RPC_URL[networkName],
hardfork: HARDFORK, hardfork: HARDFORK,
blockGasLimit: DEFAULT_BLOCK_GAS_LIMIT, blockGasLimit: DEFAULT_BLOCK_GAS_LIMIT,

View File

@ -4,12 +4,12 @@ import {
IReserveParams, IReserveParams,
PoolConfiguration, PoolConfiguration,
ICommonConfiguration, ICommonConfiguration,
eEthereumNetwork, eNetwork,
} from './types'; } from './types';
import { getParamPerPool } from './contracts-helpers'; import { getParamPerPool } from './contracts-helpers';
import AaveConfig from '../markets/aave'; import AaveConfig from '../markets/aave';
import LpConfig from '../markets/lp'; import LpConfig from '../markets/lp';
import MaticConfig from '../markets/matic' import MaticConfig from '../markets/matic';
import { CommonsConfig } from '../markets/aave/commons'; import { CommonsConfig } from '../markets/aave/commons';
import { DRE, filterMapBy } from './misc-utils'; import { DRE, filterMapBy } from './misc-utils';
import { tEthereumAddress } from './types'; import { tEthereumAddress } from './types';
@ -62,7 +62,7 @@ export const getGenesisPoolAdmin = async (
config: ICommonConfiguration config: ICommonConfiguration
): Promise<tEthereumAddress> => { ): Promise<tEthereumAddress> => {
const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name; const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name;
const targetAddress = getParamPerNetwork(config.PoolAdmin, <eEthereumNetwork>currentNetwork); const targetAddress = getParamPerNetwork(config.PoolAdmin, <eNetwork>currentNetwork);
if (targetAddress) { if (targetAddress) {
return targetAddress; return targetAddress;
} }
@ -77,7 +77,7 @@ export const getEmergencyAdmin = async (
config: ICommonConfiguration config: ICommonConfiguration
): Promise<tEthereumAddress> => { ): Promise<tEthereumAddress> => {
const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name; const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name;
const targetAddress = getParamPerNetwork(config.EmergencyAdmin, <eEthereumNetwork>currentNetwork); const targetAddress = getParamPerNetwork(config.EmergencyAdmin, <eNetwork>currentNetwork);
if (targetAddress) { if (targetAddress) {
return targetAddress; return targetAddress;
} }
@ -92,17 +92,17 @@ export const getTreasuryAddress = async (
config: ICommonConfiguration config: ICommonConfiguration
): Promise<tEthereumAddress> => { ): Promise<tEthereumAddress> => {
const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name; const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name;
return getParamPerNetwork(config.ReserveFactorTreasuryAddress, <eEthereumNetwork>currentNetwork); return getParamPerNetwork(config.ReserveFactorTreasuryAddress, <eNetwork>currentNetwork);
}; };
export const getATokenDomainSeparatorPerNetwork = ( export const getATokenDomainSeparatorPerNetwork = (
network: eEthereumNetwork, network: eNetwork,
config: ICommonConfiguration config: ICommonConfiguration
): tEthereumAddress => getParamPerNetwork<tEthereumAddress>(config.ATokenDomainSeparator, network); ): tEthereumAddress => getParamPerNetwork<tEthereumAddress>(config.ATokenDomainSeparator, network);
export const getWethAddress = async (config: ICommonConfiguration) => { export const getWethAddress = async (config: ICommonConfiguration) => {
const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name; const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name;
const wethAddress = getParamPerNetwork(config.WETH, <eEthereumNetwork>currentNetwork); const wethAddress = getParamPerNetwork(config.WETH, <eNetwork>currentNetwork);
if (wethAddress) { if (wethAddress) {
return wethAddress; return wethAddress;
} }

View File

@ -11,6 +11,13 @@ import {
AavePools, AavePools,
iParamsPerNetwork, iParamsPerNetwork,
iParamsPerPool, iParamsPerPool,
ePolygonNetwork,
eXDaiNetwork,
eNetwork,
iParamsPerNetworkAll,
iEthereumParamsPerNetwork,
iPolygonParamsPerNetwork,
iXDaiParamsPerNetwork,
} from './types'; } from './types';
import { MintableERC20 } from '../types/MintableERC20'; import { MintableERC20 } from '../types/MintableERC20';
import { Artifact } from 'hardhat/types'; import { Artifact } from 'hardhat/types';
@ -132,10 +139,17 @@ export const linkBytecode = (artifact: BuidlerArtifact | Artifact, libraries: an
return bytecode; return bytecode;
}; };
export const getParamPerNetwork = <T>( export const getParamPerNetwork = <T>(param: iParamsPerNetwork<T>, network: eNetwork) => {
{ kovan, ropsten, main, buidlerevm, coverage, tenderlyMain, matic, mumbai }: iParamsPerNetwork<T>, const {
network: eEthereumNetwork main,
) => { ropsten,
kovan,
coverage,
buidlerevm,
tenderlyMain,
} = param as iEthereumParamsPerNetwork<T>;
const { matic, mumbai } = param as iPolygonParamsPerNetwork<T>;
const { xdai } = param as iXDaiParamsPerNetwork<T>;
const MAINNET_FORK = process.env.MAINNET_FORK === 'true'; const MAINNET_FORK = process.env.MAINNET_FORK === 'true';
if (MAINNET_FORK) { if (MAINNET_FORK) {
return main; return main;
@ -153,13 +167,15 @@ export const getParamPerNetwork = <T>(
case eEthereumNetwork.ropsten: case eEthereumNetwork.ropsten:
return ropsten; return ropsten;
case eEthereumNetwork.main: case eEthereumNetwork.main:
return main;
case eEthereumNetwork.matic:
return matic;
case eEthereumNetwork.mumbai:
return mumbai; return mumbai;
case eEthereumNetwork.tenderlyMain: case eEthereumNetwork.tenderlyMain:
return tenderlyMain; return tenderlyMain;
case ePolygonNetwork.matic:
return matic;
case ePolygonNetwork.mumbai:
return mumbai;
case eXDaiNetwork.xdai:
return xdai;
} }
}; };

View File

@ -1,6 +1,7 @@
import { import {
eContractid, eContractid,
eEthereumNetwork, eEthereumNetwork,
eNetwork,
iMultiPoolsAssets, iMultiPoolsAssets,
IReserveParams, IReserveParams,
tEthereumAddress, tEthereumAddress,
@ -69,21 +70,21 @@ export const initReservesByHelper = async (
let reserveSymbols: string[] = []; let reserveSymbols: string[] = [];
let initInputParams: { let initInputParams: {
aTokenImpl: string, aTokenImpl: string;
stableDebtTokenImpl: string, stableDebtTokenImpl: string;
variableDebtTokenImpl: string, variableDebtTokenImpl: string;
underlyingAssetDecimals: BigNumberish, underlyingAssetDecimals: BigNumberish;
interestRateStrategyAddress: string, interestRateStrategyAddress: string;
underlyingAsset: string, underlyingAsset: string;
treasury: string, treasury: string;
incentivesController: string, incentivesController: string;
underlyingAssetName: string, underlyingAssetName: string;
aTokenName: string, aTokenName: string;
aTokenSymbol: string, aTokenSymbol: string;
variableDebtTokenName: string, variableDebtTokenName: string;
variableDebtTokenSymbol: string, variableDebtTokenSymbol: string;
stableDebtTokenName: string, stableDebtTokenName: string;
stableDebtTokenSymbol: string, stableDebtTokenSymbol: string;
}[] = []; }[] = [];
let strategyRates: [ let strategyRates: [
@ -99,10 +100,10 @@ export const initReservesByHelper = async (
let strategyAddresses: Record<string, tEthereumAddress> = {}; let strategyAddresses: Record<string, tEthereumAddress> = {};
let strategyAddressPerAsset: Record<string, string> = {}; let strategyAddressPerAsset: Record<string, string> = {};
let aTokenType: Record<string, string> = {}; let aTokenType: Record<string, string> = {};
let delegationAwareATokenImplementationAddress = ""; let delegationAwareATokenImplementationAddress = '';
let aTokenImplementationAddress = ""; let aTokenImplementationAddress = '';
let stableDebtTokenImplementationAddress = ""; let stableDebtTokenImplementationAddress = '';
let variableDebtTokenImplementationAddress = ""; let variableDebtTokenImplementationAddress = '';
// NOT WORKING ON MATIC // NOT WORKING ON MATIC
// const tx1 = await waitForTx( // const tx1 = await waitForTx(
@ -130,20 +131,19 @@ export const initReservesByHelper = async (
if (delegatedAwareReserves.length > 0) { if (delegatedAwareReserves.length > 0) {
const delegationAwareATokenImplementation = await deployDelegationAwareATokenImpl(verify); const delegationAwareATokenImplementation = await deployDelegationAwareATokenImpl(verify);
delegationAwareATokenImplementationAddress = delegationAwareATokenImplementation.address; delegationAwareATokenImplementationAddress = delegationAwareATokenImplementation.address;
rawInsertContractAddressInDb(`delegationAwareATokenImpl`, delegationAwareATokenImplementationAddress); rawInsertContractAddressInDb(
`delegationAwareATokenImpl`,
delegationAwareATokenImplementationAddress
);
} }
const reserves = Object.entries(reservesParams).filter( const reserves = Object.entries(reservesParams).filter(
([_, { aTokenImpl }]) => aTokenImpl === eContractid.DelegationAwareAToken || ([_, { aTokenImpl }]) =>
aTokenImpl === eContractid.AToken aTokenImpl === eContractid.DelegationAwareAToken || aTokenImpl === eContractid.AToken
) as [string, IReserveParams][]; ) as [string, IReserveParams][];
for (let [symbol, params] of reserves) { for (let [symbol, params] of reserves) {
const { const { strategy, aTokenImpl, reserveDecimals } = params;
strategy,
aTokenImpl,
reserveDecimals,
} = params;
const { const {
optimalUtilizationRate, optimalUtilizationRate,
baseVariableBorrowRate, baseVariableBorrowRate,
@ -163,21 +163,20 @@ export const initReservesByHelper = async (
stableRateSlope1, stableRateSlope1,
stableRateSlope2, stableRateSlope2,
]; ];
strategyAddresses[strategy.name] = (await deployDefaultReserveInterestRateStrategy( strategyAddresses[strategy.name] = (
rateStrategies[strategy.name], await deployDefaultReserveInterestRateStrategy(rateStrategies[strategy.name], verify)
verify ).address;
)).address;
// This causes the last strategy to be printed twice, once under "DefaultReserveInterestRateStrategy" // This causes the last strategy to be printed twice, once under "DefaultReserveInterestRateStrategy"
// and once under the actual `strategyASSET` key. // and once under the actual `strategyASSET` key.
rawInsertContractAddressInDb(strategy.name, strategyAddresses[strategy.name]); rawInsertContractAddressInDb(strategy.name, strategyAddresses[strategy.name]);
} }
strategyAddressPerAsset[symbol] = strategyAddresses[strategy.name]; strategyAddressPerAsset[symbol] = strategyAddresses[strategy.name];
console.log("Strategy address for asset %s: %s", symbol, strategyAddressPerAsset[symbol]) console.log('Strategy address for asset %s: %s', symbol, strategyAddressPerAsset[symbol]);
if (aTokenImpl === eContractid.AToken) { if (aTokenImpl === eContractid.AToken) {
aTokenType[symbol] = "generic"; aTokenType[symbol] = 'generic';
} else if (aTokenImpl === eContractid.DelegationAwareAToken) { } else if (aTokenImpl === eContractid.DelegationAwareAToken) {
aTokenType[symbol] = "delegation aware"; aTokenType[symbol] = 'delegation aware';
} }
reserveInitDecimals.push(reserveDecimals); reserveInitDecimals.push(reserveDecimals);
@ -208,7 +207,7 @@ export const initReservesByHelper = async (
variableDebtTokenName: `${variableDebtTokenNamePrefix} ${symbolPrefix}${reserveSymbols[i]}`, variableDebtTokenName: `${variableDebtTokenNamePrefix} ${symbolPrefix}${reserveSymbols[i]}`,
variableDebtTokenSymbol: `variableDebt${symbolPrefix}${reserveSymbols[i]}`, variableDebtTokenSymbol: `variableDebt${symbolPrefix}${reserveSymbols[i]}`,
stableDebtTokenName: `${stableDebtTokenNamePrefix} ${reserveSymbols[i]}`, stableDebtTokenName: `${stableDebtTokenNamePrefix} ${reserveSymbols[i]}`,
stableDebtTokenSymbol: `stableDebt${symbolPrefix}${reserveSymbols[i]}` stableDebtTokenSymbol: `stableDebt${symbolPrefix}${reserveSymbols[i]}`,
}); });
} }
@ -319,7 +318,7 @@ export const configureReservesByHelper = async (
liquidationThreshold: liquidationThreshold, liquidationThreshold: liquidationThreshold,
liquidationBonus: liquidationBonus, liquidationBonus: liquidationBonus,
reserveFactor: reserveFactor, reserveFactor: reserveFactor,
stableBorrowingEnabled: stableBorrowRateEnabled stableBorrowingEnabled: stableBorrowRateEnabled,
}); });
tokens.push(tokenAddress); tokens.push(tokenAddress);
@ -342,10 +341,9 @@ export const configureReservesByHelper = async (
console.log(`- Configure reserves in ${chunkedInputParams.length} txs`); console.log(`- Configure reserves in ${chunkedInputParams.length} txs`);
for (let chunkIndex = 0; chunkIndex < chunkedInputParams.length; chunkIndex++) { for (let chunkIndex = 0; chunkIndex < chunkedInputParams.length; chunkIndex++) {
await waitForTx( await waitForTx(
await atokenAndRatesDeployer.configureReserves( await atokenAndRatesDeployer.configureReserves(chunkedInputParams[chunkIndex], {
chunkedInputParams[chunkIndex], gasLimit: 12000000,
{ gasLimit: 12000000 } })
)
); );
console.log(` - Init for: ${chunkedSymbols[chunkIndex].join(', ')}`); console.log(` - Init for: ${chunkedSymbols[chunkIndex].join(', ')}`);
} }
@ -356,7 +354,7 @@ export const configureReservesByHelper = async (
const getAddressById = async ( const getAddressById = async (
id: string, id: string,
network: eEthereumNetwork network: eNetwork
): Promise<tEthereumAddress | undefined> => ): Promise<tEthereumAddress | undefined> =>
(await getDb().get(`${id}.${network}`).value())?.address || undefined; (await getDb().get(`${id}.${network}`).value())?.address || undefined;
@ -403,27 +401,25 @@ export const initTokenReservesByHelper = async (
let reserveSymbols: string[] = []; let reserveSymbols: string[] = [];
let initInputParams: { let initInputParams: {
aTokenImpl: string, aTokenImpl: string;
stableDebtTokenImpl: string, stableDebtTokenImpl: string;
variableDebtTokenImpl: string, variableDebtTokenImpl: string;
underlyingAssetDecimals: BigNumberish, underlyingAssetDecimals: BigNumberish;
interestRateStrategyAddress: string, interestRateStrategyAddress: string;
underlyingAsset: string, underlyingAsset: string;
treasury: string, treasury: string;
incentivesController: string, incentivesController: string;
underlyingAssetName: string, underlyingAssetName: string;
aTokenName: string, aTokenName: string;
aTokenSymbol: string, aTokenSymbol: string;
variableDebtTokenName: string, variableDebtTokenName: string;
variableDebtTokenSymbol: string, variableDebtTokenSymbol: string;
stableDebtTokenName: string, stableDebtTokenName: string;
stableDebtTokenSymbol: string, stableDebtTokenSymbol: string;
}[] = []; }[] = [];
const network = const network =
process.env.MAINNET_FORK === 'true' process.env.MAINNET_FORK === 'true' ? eEthereumNetwork.main : (DRE.network.name as eNetwork);
? eEthereumNetwork.main
: (DRE.network.name as eEthereumNetwork);
// Grab config from DB // Grab config from DB
for (const [symbol, address] of Object.entries(tokenAddresses)) { for (const [symbol, address] of Object.entries(tokenAddresses)) {
const { aTokenAddress } = await protocolDataProvider.getReserveTokensAddresses(address); const { aTokenAddress } = await protocolDataProvider.getReserveTokensAddresses(address);
@ -439,10 +435,11 @@ export const initTokenReservesByHelper = async (
} }
let stableTokenImpl = await getAddressById(`stableDebtTokenImpl`, network); let stableTokenImpl = await getAddressById(`stableDebtTokenImpl`, network);
let variableTokenImpl = await getAddressById(`variableDebtTokenImpl`, network); let variableTokenImpl = await getAddressById(`variableDebtTokenImpl`, network);
let aTokenImplementation: string | undefined = ""; let aTokenImplementation: string | undefined = '';
const [, { aTokenImpl, strategy }] = (Object.entries(reservesParams) as [string, IReserveParams][])[ const [, { aTokenImpl, strategy }] = (Object.entries(reservesParams) as [
reserveParamIndex string,
]; IReserveParams
][])[reserveParamIndex];
if (aTokenImpl === eContractid.AToken) { if (aTokenImpl === eContractid.AToken) {
aTokenImplementation = await getAddressById(`aTokenImpl`, network); aTokenImplementation = await getAddressById(`aTokenImpl`, network);
} else if (aTokenImpl === eContractid.DelegationAwareAToken) { } else if (aTokenImpl === eContractid.DelegationAwareAToken) {
@ -458,7 +455,7 @@ export const initTokenReservesByHelper = async (
tokenAddresses[symbol], tokenAddresses[symbol],
ZERO_ADDRESS, // Incentives controller ZERO_ADDRESS, // Incentives controller
`Aave stable debt bearing ${symbol}`, `Aave stable debt bearing ${symbol}`,
`stableDebt${symbol}` `stableDebt${symbol}`,
], ],
verify verify
); );
@ -471,7 +468,7 @@ export const initTokenReservesByHelper = async (
tokenAddresses[symbol], tokenAddresses[symbol],
ZERO_ADDRESS, // Incentives Controller ZERO_ADDRESS, // Incentives Controller
`Aave variable debt bearing ${symbol}`, `Aave variable debt bearing ${symbol}`,
`variableDebt${symbol}` `variableDebt${symbol}`,
], ],
verify verify
); );
@ -489,19 +486,16 @@ export const initTokenReservesByHelper = async (
treasuryAddress, treasuryAddress,
ZERO_ADDRESS, ZERO_ADDRESS,
`Aave interest bearing ${symbol}`, `Aave interest bearing ${symbol}`,
`a${symbol}` `a${symbol}`,
], ],
verify verify
); );
aTokenImplementation = aToken.address; aTokenImplementation = aToken.address;
} }
if (!strategyImpl) { if (!strategyImpl) {
const [ const [, { strategy }] = (Object.entries(reservesParams) as [string, IReserveParams][])[
, reserveParamIndex
{ ];
strategy
},
] = (Object.entries(reservesParams) as [string, IReserveParams][])[reserveParamIndex];
const { const {
optimalUtilizationRate, optimalUtilizationRate,
baseVariableBorrowRate, baseVariableBorrowRate,
@ -559,7 +553,7 @@ export const initTokenReservesByHelper = async (
variableDebtTokenName: `Aave variable debt bearing ${reserveSymbols[i]}`, variableDebtTokenName: `Aave variable debt bearing ${reserveSymbols[i]}`,
variableDebtTokenSymbol: `variableDebt${reserveSymbols[i]}`, variableDebtTokenSymbol: `variableDebt${reserveSymbols[i]}`,
stableDebtTokenName: `Aave stable debt bearing ${reserveSymbols[i]}`, stableDebtTokenName: `Aave stable debt bearing ${reserveSymbols[i]}`,
stableDebtTokenSymbol: `stableDebt${reserveSymbols[i]}` stableDebtTokenSymbol: `stableDebt${reserveSymbols[i]}`,
}); });
} }

View File

@ -4,6 +4,8 @@ export interface SymbolMap<T> {
[symbol: string]: T; [symbol: string]: T;
} }
export type eNetwork = eEthereumNetwork | ePolygonNetwork | eXDaiNetwork;
export enum eEthereumNetwork { export enum eEthereumNetwork {
buidlerevm = 'buidlerevm', buidlerevm = 'buidlerevm',
kovan = 'kovan', kovan = 'kovan',
@ -16,7 +18,7 @@ export enum eEthereumNetwork {
export enum ePolygonNetwork { export enum ePolygonNetwork {
matic = 'matic', matic = 'matic',
mumbai = 'mumbail', mumbai = 'mumbai',
} }
export enum eXDaiNetwork { export enum eXDaiNetwork {
@ -398,6 +400,11 @@ export type iParamsPerNetwork<T> =
| iPolygonParamsPerNetwork<T> | iPolygonParamsPerNetwork<T>
| iXDaiParamsPerNetwork<T>; | iXDaiParamsPerNetwork<T>;
export interface iParamsPerNetworkAll<T>
extends iEthereumParamsPerNetwork<T>,
iPolygonParamsPerNetwork<T>,
iXDaiParamsPerNetwork<T> {}
export interface iEthereumParamsPerNetwork<T> { export interface iEthereumParamsPerNetwork<T> {
[eEthereumNetwork.coverage]: T; [eEthereumNetwork.coverage]: T;
[eEthereumNetwork.buidlerevm]: T; [eEthereumNetwork.buidlerevm]: T;

View File

@ -97,7 +97,7 @@ export const CommonsConfig: ICommonConfiguration = {
}, },
WethGateway: { WethGateway: {
[ePolygonNetwork.mumbai]: '', [ePolygonNetwork.mumbai]: '',
[ePolygonNetwork.matic]: '', [ePolygonNetwork.matic]: '0x4fAfE6704a78e21Fc43C01bEb153607604F6768a',
}, },
AaveOracle: { AaveOracle: {
[ePolygonNetwork.mumbai]: '', [ePolygonNetwork.mumbai]: '',

View File

@ -8,7 +8,7 @@ import {
authorizeWETHGateway, authorizeWETHGateway,
} from '../../helpers/contracts-deployments'; } from '../../helpers/contracts-deployments';
import { getParamPerNetwork } from '../../helpers/contracts-helpers'; import { getParamPerNetwork } from '../../helpers/contracts-helpers';
import { eEthereumNetwork } from '../../helpers/types'; import { eNetwork } from '../../helpers/types';
import { import {
ConfigNames, ConfigNames,
getReservesConfigByPool, getReservesConfigByPool,
@ -33,7 +33,7 @@ task('dev:initialize-lending-pool', 'Initialize lending pool configuration.')
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`) .addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
.setAction(async ({ verify, pool }, localBRE) => { .setAction(async ({ verify, pool }, localBRE) => {
await localBRE.run('set-DRE'); await localBRE.run('set-DRE');
const network = <eEthereumNetwork>localBRE.network.name; const network = <eNetwork>localBRE.network.name;
const poolConfig = loadPoolConfig(pool); const poolConfig = loadPoolConfig(pool);
const { const {
ATokenNamePrefix, ATokenNamePrefix,

View File

@ -11,7 +11,7 @@ import {
getGenesisPoolAdmin, getGenesisPoolAdmin,
getEmergencyAdmin, getEmergencyAdmin,
} from '../../helpers/configuration'; } from '../../helpers/configuration';
import { eEthereumNetwork } from '../../helpers/types'; import { eNetwork } from '../../helpers/types';
import { import {
getFirstSigner, getFirstSigner,
getLendingPoolAddressesProviderRegistry, getLendingPoolAddressesProviderRegistry,
@ -31,7 +31,7 @@ task(
.setAction(async ({ verify, pool }, DRE) => { .setAction(async ({ verify, pool }, DRE) => {
await DRE.run('set-DRE'); await DRE.run('set-DRE');
let signer: Signer; let signer: Signer;
const network = <eEthereumNetwork>DRE.network.name; const network = <eNetwork>DRE.network.name;
const poolConfig = loadPoolConfig(pool); const poolConfig = loadPoolConfig(pool);
const { ProviderId, MarketId } = poolConfig; const { ProviderId, MarketId } = poolConfig;

View File

@ -6,7 +6,7 @@ import {
deployLendingPoolConfigurator, deployLendingPoolConfigurator,
deployStableAndVariableTokensHelper, deployStableAndVariableTokensHelper,
} from '../../helpers/contracts-deployments'; } from '../../helpers/contracts-deployments';
import { eContractid, eEthereumNetwork } from '../../helpers/types'; import { eContractid, eNetwork } from '../../helpers/types';
import { notFalsyOrZeroAddress, waitForTx } from '../../helpers/misc-utils'; import { notFalsyOrZeroAddress, waitForTx } from '../../helpers/misc-utils';
import { import {
getLendingPoolAddressesProvider, getLendingPoolAddressesProvider,
@ -22,20 +22,20 @@ task('full:deploy-lending-pool', 'Deploy lending pool for dev enviroment')
.setAction(async ({ verify, pool }, DRE: HardhatRuntimeEnvironment) => { .setAction(async ({ verify, pool }, DRE: HardhatRuntimeEnvironment) => {
try { try {
await DRE.run('set-DRE'); await DRE.run('set-DRE');
const network = <eEthereumNetwork>DRE.network.name; const network = <eNetwork>DRE.network.name;
const poolConfig = loadPoolConfig(pool) const poolConfig = loadPoolConfig(pool);
const addressesProvider = await getLendingPoolAddressesProvider(); const addressesProvider = await getLendingPoolAddressesProvider();
const { LendingPool, LendingPoolConfigurator } = poolConfig; const { LendingPool, LendingPoolConfigurator } = poolConfig;
// Reuse/deploy lending pool implementation // Reuse/deploy lending pool implementation
let lendingPoolImplAddress = getParamPerNetwork(LendingPool, network) let lendingPoolImplAddress = getParamPerNetwork(LendingPool, network);
if (!notFalsyOrZeroAddress(lendingPoolImplAddress)) { if (!notFalsyOrZeroAddress(lendingPoolImplAddress)) {
console.log("\tDeploying new lending pool implementation & libraries..."); console.log('\tDeploying new lending pool implementation & libraries...');
const lendingPoolImpl = await deployLendingPool(verify); const lendingPoolImpl = await deployLendingPool(verify);
lendingPoolImplAddress = lendingPoolImpl.address; lendingPoolImplAddress = lendingPoolImpl.address;
} }
console.log("\tSetting lending pool implementation with address:" , lendingPoolImplAddress); console.log('\tSetting lending pool implementation with address:', lendingPoolImplAddress);
// Set lending pool impl to Address provider // Set lending pool impl to Address provider
await waitForTx(await addressesProvider.setLendingPoolImpl(lendingPoolImplAddress)); await waitForTx(await addressesProvider.setLendingPoolImpl(lendingPoolImplAddress));
@ -47,11 +47,14 @@ task('full:deploy-lending-pool', 'Deploy lending pool for dev enviroment')
// Reuse/deploy lending pool configurator // Reuse/deploy lending pool configurator
let lendingPoolConfiguratorImplAddress = getParamPerNetwork(LendingPoolConfigurator, network); //await deployLendingPoolConfigurator(verify); let lendingPoolConfiguratorImplAddress = getParamPerNetwork(LendingPoolConfigurator, network); //await deployLendingPoolConfigurator(verify);
if (!notFalsyOrZeroAddress(lendingPoolConfiguratorImplAddress)) { if (!notFalsyOrZeroAddress(lendingPoolConfiguratorImplAddress)) {
console.log("\tDeploying new configurator implementation..."); console.log('\tDeploying new configurator implementation...');
const lendingPoolConfiguratorImpl = await deployLendingPoolConfigurator(verify); const lendingPoolConfiguratorImpl = await deployLendingPoolConfigurator(verify);
lendingPoolConfiguratorImplAddress = lendingPoolConfiguratorImpl.address; lendingPoolConfiguratorImplAddress = lendingPoolConfiguratorImpl.address;
} }
console.log("\tSetting lending pool configurator implementation with address:" , lendingPoolConfiguratorImplAddress); console.log(
'\tSetting lending pool configurator implementation with address:',
lendingPoolConfiguratorImplAddress
);
// Set lending pool conf impl to Address Provider // Set lending pool conf impl to Address Provider
await waitForTx( await waitForTx(
await addressesProvider.setLendingPoolConfiguratorImpl(lendingPoolConfiguratorImplAddress) await addressesProvider.setLendingPoolConfiguratorImpl(lendingPoolConfiguratorImplAddress)

View File

@ -2,7 +2,7 @@ import { task } from 'hardhat/config';
import { getParamPerNetwork } from '../../helpers/contracts-helpers'; import { getParamPerNetwork } from '../../helpers/contracts-helpers';
import { deployAaveOracle, deployLendingRateOracle } from '../../helpers/contracts-deployments'; import { deployAaveOracle, deployLendingRateOracle } from '../../helpers/contracts-deployments';
import { setInitialMarketRatesInRatesOracleByHelper } from '../../helpers/oracles-helpers'; import { setInitialMarketRatesInRatesOracleByHelper } from '../../helpers/oracles-helpers';
import { ICommonConfiguration, eEthereumNetwork, SymbolMap } from '../../helpers/types'; import { ICommonConfiguration, eNetwork, SymbolMap } from '../../helpers/types';
import { waitForTx, notFalsyOrZeroAddress } from '../../helpers/misc-utils'; import { waitForTx, notFalsyOrZeroAddress } from '../../helpers/misc-utils';
import { import {
ConfigNames, ConfigNames,
@ -25,7 +25,7 @@ task('full:deploy-oracles', 'Deploy oracles for dev enviroment')
.setAction(async ({ verify, pool }, DRE) => { .setAction(async ({ verify, pool }, DRE) => {
try { try {
await DRE.run('set-DRE'); await DRE.run('set-DRE');
const network = <eEthereumNetwork>DRE.network.name; const network = <eNetwork>DRE.network.name;
const poolConfig = loadPoolConfig(pool); const poolConfig = loadPoolConfig(pool);
const { const {
ProtocolGlobalParams: { UsdAddress }, ProtocolGlobalParams: { UsdAddress },
@ -73,7 +73,7 @@ task('full:deploy-oracles', 'Deploy oracles for dev enviroment')
admin admin
); );
//} //}
console.log("ORACLES: %s and %s", aaveOracle.address, lendingRateOracle.address); console.log('ORACLES: %s and %s', aaveOracle.address, lendingRateOracle.address);
// Register the proxy price provider on the addressesProvider // Register the proxy price provider on the addressesProvider
await waitForTx(await addressesProvider.setPriceOracle(aaveOracle.address)); await waitForTx(await addressesProvider.setPriceOracle(aaveOracle.address));
await waitForTx(await addressesProvider.setLendingRateOracle(lendingRateOracle.address)); await waitForTx(await addressesProvider.setLendingRateOracle(lendingRateOracle.address));

View File

@ -4,7 +4,7 @@ import { getParamPerNetwork } from '../../helpers/contracts-helpers';
import { loadPoolConfig, ConfigNames, getWethAddress } from '../../helpers/configuration'; import { loadPoolConfig, ConfigNames, getWethAddress } from '../../helpers/configuration';
import { deployWETHGateway } from '../../helpers/contracts-deployments'; import { deployWETHGateway } from '../../helpers/contracts-deployments';
import { DRE } from '../../helpers/misc-utils'; import { DRE } from '../../helpers/misc-utils';
import { eEthereumNetwork } from '../../helpers/types'; import { eNetwork } from '../../helpers/types';
const CONTRACT_NAME = 'WETHGateway'; const CONTRACT_NAME = 'WETHGateway';
@ -13,7 +13,7 @@ task(`full-deploy-weth-gateway`, `Deploys the ${CONTRACT_NAME} contract`)
.addFlag('verify', `Verify ${CONTRACT_NAME} contract via Etherscan API.`) .addFlag('verify', `Verify ${CONTRACT_NAME} contract via Etherscan API.`)
.setAction(async ({ verify, pool }, localBRE) => { .setAction(async ({ verify, pool }, localBRE) => {
await localBRE.run('set-DRE'); await localBRE.run('set-DRE');
const network = <eEthereumNetwork>localBRE.network.name; const network = <eNetwork>localBRE.network.name;
const poolConfig = loadPoolConfig(pool); const poolConfig = loadPoolConfig(pool);
const Weth = await getWethAddress(poolConfig); const Weth = await getWethAddress(poolConfig);
const { WethGateway } = poolConfig; const { WethGateway } = poolConfig;

View File

@ -13,7 +13,7 @@ import {
getTreasuryAddress, getTreasuryAddress,
} from '../../helpers/configuration'; } from '../../helpers/configuration';
import { getWETHGateway } from '../../helpers/contracts-getters'; import { getWETHGateway } from '../../helpers/contracts-getters';
import { eEthereumNetwork, ICommonConfiguration } from '../../helpers/types'; import { eNetwork, ICommonConfiguration } from '../../helpers/types';
import { notFalsyOrZeroAddress, waitForTx } from '../../helpers/misc-utils'; import { notFalsyOrZeroAddress, waitForTx } from '../../helpers/misc-utils';
import { initReservesByHelper, configureReservesByHelper } from '../../helpers/init-helpers'; import { initReservesByHelper, configureReservesByHelper } from '../../helpers/init-helpers';
import { exit } from 'process'; import { exit } from 'process';
@ -29,7 +29,7 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
.setAction(async ({ verify, pool }, localBRE) => { .setAction(async ({ verify, pool }, localBRE) => {
try { try {
await localBRE.run('set-DRE'); await localBRE.run('set-DRE');
const network = <eEthereumNetwork>localBRE.network.name; const network = <eNetwork>localBRE.network.name;
const poolConfig = loadPoolConfig(pool); const poolConfig = loadPoolConfig(pool);
const { const {
ATokenNamePrefix, ATokenNamePrefix,
@ -79,7 +79,10 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
} }
// Seems unnecessary to register the collateral manager in the JSON db // Seems unnecessary to register the collateral manager in the JSON db
console.log("\tSetting lending pool collateral manager implementation with address", collateralManagerAddress); console.log(
'\tSetting lending pool collateral manager implementation with address',
collateralManagerAddress
);
await waitForTx( await waitForTx(
await addressesProvider.setLendingPoolCollateralManager(collateralManagerAddress) await addressesProvider.setLendingPoolCollateralManager(collateralManagerAddress)
); );

View File

@ -1,5 +1,5 @@
import { task } from 'hardhat/config'; import { task } from 'hardhat/config';
import { EthereumNetwork } from '../../helpers/types'; import { eEthereumNetwork } from '../../helpers/types';
import { getTreasuryAddress } from '../../helpers/configuration'; import { getTreasuryAddress } from '../../helpers/configuration';
import * as marketConfigs from '../../markets/aave'; import * as marketConfigs from '../../markets/aave';
import * as reserveConfigs from '../../markets/aave/reservesConfigs'; import * as reserveConfigs from '../../markets/aave/reservesConfigs';
@ -18,7 +18,7 @@ const LENDING_POOL_ADDRESS_PROVIDER = {
kovan: '0x652B2937Efd0B5beA1c8d54293FC1289672AFC6b', kovan: '0x652B2937Efd0B5beA1c8d54293FC1289672AFC6b',
}; };
const isSymbolValid = (symbol: string, network: EthereumNetwork) => const isSymbolValid = (symbol: string, network: eEthereumNetwork) =>
Object.keys(reserveConfigs).includes('strategy' + symbol) && Object.keys(reserveConfigs).includes('strategy' + symbol) &&
marketConfigs.AaveConfig.ReserveAssets[network][symbol] && marketConfigs.AaveConfig.ReserveAssets[network][symbol] &&
marketConfigs.AaveConfig.ReservesConfig[symbol] === reserveConfigs['strategy' + symbol]; marketConfigs.AaveConfig.ReservesConfig[symbol] === reserveConfigs['strategy' + symbol];
@ -28,7 +28,7 @@ task('external:deploy-new-asset', 'Deploy A token, Debt Tokens, Risk Parameters'
.addFlag('verify', 'Verify contracts at Etherscan') .addFlag('verify', 'Verify contracts at Etherscan')
.setAction(async ({ verify, symbol }, localBRE) => { .setAction(async ({ verify, symbol }, localBRE) => {
const network = localBRE.network.name; const network = localBRE.network.name;
if (!isSymbolValid(symbol, network as EthereumNetwork)) { if (!isSymbolValid(symbol, network as eEthereumNetwork)) {
throw new Error( throw new Error(
` `
WRONG RESERVE ASSET SETUP: WRONG RESERVE ASSET SETUP:

View File

@ -1,7 +1,7 @@
import { task } from 'hardhat/config'; import { task } from 'hardhat/config';
import { getParamPerNetwork } from '../../helpers/contracts-helpers'; import { getParamPerNetwork } from '../../helpers/contracts-helpers';
import { loadPoolConfig, ConfigNames, getTreasuryAddress } from '../../helpers/configuration'; import { loadPoolConfig, ConfigNames, getTreasuryAddress } from '../../helpers/configuration';
import { eEthereumNetwork, ICommonConfiguration } from '../../helpers/types'; import { eEthereumNetwork, eNetwork, ICommonConfiguration } from '../../helpers/types';
import { waitForTx } from '../../helpers/misc-utils'; import { waitForTx } from '../../helpers/misc-utils';
import { initTokenReservesByHelper } from '../../helpers/init-helpers'; import { initTokenReservesByHelper } from '../../helpers/init-helpers';
import { exit } from 'process'; import { exit } from 'process';
@ -23,9 +23,7 @@ task('full:initialize-tokens', 'Initialize lending pool configuration.')
await DRE.run('set-DRE'); await DRE.run('set-DRE');
let signer: Signer; let signer: Signer;
const network = const network =
process.env.MAINNET_FORK === 'true' process.env.MAINNET_FORK === 'true' ? eEthereumNetwork.main : <eNetwork>DRE.network.name;
? eEthereumNetwork.main
: <eEthereumNetwork>DRE.network.name;
const poolConfig = loadPoolConfig(pool); const poolConfig = loadPoolConfig(pool);
const { ReserveAssets, ReservesConfig } = poolConfig as ICommonConfiguration; const { ReserveAssets, ReservesConfig } = poolConfig as ICommonConfiguration;

View File

@ -7,7 +7,7 @@ import {
} from '../../helpers/contracts-getters'; } from '../../helpers/contracts-getters';
import { getParamPerNetwork } from '../../helpers/contracts-helpers'; import { getParamPerNetwork } from '../../helpers/contracts-helpers';
import { DRE } from '../../helpers/misc-utils'; import { DRE } from '../../helpers/misc-utils';
import { eEthereumNetwork } from '../../helpers/types'; import { eEthereumNetwork, eNetwork, ePolygonNetwork, eXDaiNetwork } from '../../helpers/types';
task('print-config', 'Inits the DRE, to have access to all the plugins') task('print-config', 'Inits the DRE, to have access to all the plugins')
.addParam('dataProvider', 'Address of AaveProtocolDataProvider') .addParam('dataProvider', 'Address of AaveProtocolDataProvider')
@ -17,7 +17,7 @@ task('print-config', 'Inits the DRE, to have access to all the plugins')
const network = const network =
process.env.MAINNET_FORK === 'true' process.env.MAINNET_FORK === 'true'
? eEthereumNetwork.main ? eEthereumNetwork.main
: (localBRE.network.name as eEthereumNetwork); : (localBRE.network.name as eNetwork);
const poolConfig = loadPoolConfig(pool); const poolConfig = loadPoolConfig(pool);
const providerRegistryAddress = getParamPerNetwork(poolConfig.ProviderRegistry, network); const providerRegistryAddress = getParamPerNetwork(poolConfig.ProviderRegistry, network);

View File

@ -25,14 +25,14 @@ import {
import { getParamPerNetwork } from '../../helpers/contracts-helpers'; import { getParamPerNetwork } from '../../helpers/contracts-helpers';
import { verifyContract } from '../../helpers/etherscan-verification'; import { verifyContract } from '../../helpers/etherscan-verification';
import { notFalsyOrZeroAddress } from '../../helpers/misc-utils'; import { notFalsyOrZeroAddress } from '../../helpers/misc-utils';
import { eEthereumNetwork, ICommonConfiguration } from '../../helpers/types'; import { eNetwork, ICommonConfiguration } from '../../helpers/types';
task('verify:general', 'Verify contracts at Etherscan') task('verify:general', 'Verify contracts at Etherscan')
.addFlag('all', 'Verify all contracts at Etherscan') .addFlag('all', 'Verify all contracts at Etherscan')
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`) .addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
.setAction(async ({ all, pool }, localDRE) => { .setAction(async ({ all, pool }, localDRE) => {
await localDRE.run('set-DRE'); await localDRE.run('set-DRE');
const network = localDRE.network.name as eEthereumNetwork; const network = localDRE.network.name as eNetwork;
const poolConfig = loadPoolConfig(pool); const poolConfig = loadPoolConfig(pool);
const { const {
ReserveAssets, ReserveAssets,
@ -61,13 +61,21 @@ task('verify:general', 'Verify contracts at Etherscan')
? await getLendingPoolImpl(lendingPoolImplAddress) ? await getLendingPoolImpl(lendingPoolImplAddress)
: await getLendingPoolImpl(); : await getLendingPoolImpl();
const lendingPoolConfiguratorImplAddress = getParamPerNetwork(LendingPoolConfigurator, network); const lendingPoolConfiguratorImplAddress = getParamPerNetwork(
LendingPoolConfigurator,
network
);
const lendingPoolConfiguratorImpl = notFalsyOrZeroAddress(lendingPoolConfiguratorImplAddress) const lendingPoolConfiguratorImpl = notFalsyOrZeroAddress(lendingPoolConfiguratorImplAddress)
? await getLendingPoolConfiguratorImpl(lendingPoolConfiguratorImplAddress) ? await getLendingPoolConfiguratorImpl(lendingPoolConfiguratorImplAddress)
: await getLendingPoolConfiguratorImpl(); : await getLendingPoolConfiguratorImpl();
const lendingPoolCollateralManagerImplAddress = getParamPerNetwork(LendingPoolCollateralManager, network); const lendingPoolCollateralManagerImplAddress = getParamPerNetwork(
const lendingPoolCollateralManagerImpl = notFalsyOrZeroAddress(lendingPoolCollateralManagerImplAddress) LendingPoolCollateralManager,
network
);
const lendingPoolCollateralManagerImpl = notFalsyOrZeroAddress(
lendingPoolCollateralManagerImplAddress
)
? await getLendingPoolCollateralManagerImpl(lendingPoolCollateralManagerImplAddress) ? await getLendingPoolCollateralManagerImpl(lendingPoolCollateralManagerImplAddress)
: await getLendingPoolCollateralManagerImpl(); : await getLendingPoolCollateralManagerImpl();

View File

@ -15,14 +15,14 @@ import {
} from '../../helpers/contracts-getters'; } from '../../helpers/contracts-getters';
import { getParamPerNetwork } from '../../helpers/contracts-helpers'; import { getParamPerNetwork } from '../../helpers/contracts-helpers';
import { verifyContract } from '../../helpers/etherscan-verification'; import { verifyContract } from '../../helpers/etherscan-verification';
import { eEthereumNetwork, ICommonConfiguration, IReserveParams } from '../../helpers/types'; import { eNetwork, ICommonConfiguration, IReserveParams } from '../../helpers/types';
import { LendingPoolConfiguratorFactory, LendingPoolFactory } from '../../types'; import { LendingPoolConfiguratorFactory, LendingPoolFactory } from '../../types';
task('verify:tokens', 'Deploy oracles for dev enviroment') task('verify:tokens', 'Deploy oracles for dev enviroment')
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`) .addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
.setAction(async ({ verify, all, pool }, localDRE) => { .setAction(async ({ verify, all, pool }, localDRE) => {
await localDRE.run('set-DRE'); await localDRE.run('set-DRE');
const network = localDRE.network.name as eEthereumNetwork; const network = localDRE.network.name as eNetwork;
const poolConfig = loadPoolConfig(pool); const poolConfig = loadPoolConfig(pool);
const { ReserveAssets, ReservesConfig } = poolConfig as ICommonConfiguration; const { ReserveAssets, ReservesConfig } = poolConfig as ICommonConfiguration;
const treasuryAddress = await getTreasuryAddress(poolConfig); const treasuryAddress = await getTreasuryAddress(poolConfig);

View File

@ -28,7 +28,6 @@ import {
deployFlashLiquidationAdapter, deployFlashLiquidationAdapter,
authorizeWETHGateway, authorizeWETHGateway,
} from '../../helpers/contracts-deployments'; } from '../../helpers/contracts-deployments';
import { eEthereumNetwork } from '../../helpers/types';
import { Signer } from 'ethers'; import { Signer } from 'ethers';
import { TokenContractId, eContractid, tEthereumAddress, AavePools } from '../../helpers/types'; import { TokenContractId, eContractid, tEthereumAddress, AavePools } from '../../helpers/types';
import { MintableERC20 } from '../../types/MintableERC20'; import { MintableERC20 } from '../../types/MintableERC20';

View File

@ -3,7 +3,7 @@ import { BUIDLEREVM_CHAINID } from '../../helpers/buidler-constants';
import { buildPermitParams, getSignatureFromTypedData } from '../../helpers/contracts-helpers'; import { buildPermitParams, getSignatureFromTypedData } from '../../helpers/contracts-helpers';
import { expect } from 'chai'; import { expect } from 'chai';
import { ethers } from 'ethers'; import { ethers } from 'ethers';
import { eEthereumNetwork, ProtocolErrors } from '../../helpers/types'; import { ProtocolErrors } from '../../helpers/types';
import { makeSuite, TestEnv } from './helpers/make-suite'; import { makeSuite, TestEnv } from './helpers/make-suite';
import { DRE } from '../../helpers/misc-utils'; import { DRE } from '../../helpers/misc-utils';
import { import {
@ -35,7 +35,14 @@ makeSuite('AToken: underlying delegation', (testEnv: TestEnv) => {
delegationERC20 = await deployMintableDelegationERC20(['DEL', 'DEL', '18']); delegationERC20 = await deployMintableDelegationERC20(['DEL', 'DEL', '18']);
delegationAToken = await deployDelegationAwareAToken( delegationAToken = await deployDelegationAwareAToken(
[pool.address, delegationERC20.address, await getTreasuryAddress(AaveConfig), ZERO_ADDRESS, 'aDEL', 'aDEL'], [
pool.address,
delegationERC20.address,
await getTreasuryAddress(AaveConfig),
ZERO_ADDRESS,
'aDEL',
'aDEL',
],
false false
); );