mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
feat: Add support for custom quote currencies
This commit is contained in:
parent
99c97b4f13
commit
7708bc6d2f
|
|
@ -18,29 +18,34 @@ import {SafeERC20} from '../dependencies/openzeppelin/contracts/SafeERC20.sol';
|
||||||
contract AaveOracle is IPriceOracleGetter, Ownable {
|
contract AaveOracle is IPriceOracleGetter, Ownable {
|
||||||
using SafeERC20 for IERC20;
|
using SafeERC20 for IERC20;
|
||||||
|
|
||||||
event WethSet(address indexed weth);
|
event BaseCurrencySet(address indexed baseCurrency, uint256 baseCurrencyUnit);
|
||||||
event AssetSourceUpdated(address indexed asset, address indexed source);
|
event AssetSourceUpdated(address indexed asset, address indexed source);
|
||||||
event FallbackOracleUpdated(address indexed fallbackOracle);
|
event FallbackOracleUpdated(address indexed fallbackOracle);
|
||||||
|
|
||||||
mapping(address => IChainlinkAggregator) private assetsSources;
|
mapping(address => IChainlinkAggregator) private assetsSources;
|
||||||
IPriceOracleGetter private _fallbackOracle;
|
IPriceOracleGetter private _fallbackOracle;
|
||||||
address public immutable WETH;
|
address public immutable BASE_CURRENCY;
|
||||||
|
uint256 public immutable BASE_CURRENCY_UNIT;
|
||||||
|
|
||||||
/// @notice Constructor
|
/// @notice Constructor
|
||||||
/// @param assets The addresses of the assets
|
/// @param assets The addresses of the assets
|
||||||
/// @param sources The address of the source of each asset
|
/// @param sources The address of the source of each asset
|
||||||
/// @param fallbackOracle The address of the fallback oracle to use if the data of an
|
/// @param fallbackOracle The address of the fallback oracle to use if the data of an
|
||||||
/// aggregator is not consistent
|
/// aggregator is not consistent
|
||||||
|
/// @param baseCurrency the base currency used for the price quotes. If USD is used, base currency is 0x0
|
||||||
|
/// @param baseCurrencyUnit the unit of the base currency
|
||||||
constructor(
|
constructor(
|
||||||
address[] memory assets,
|
address[] memory assets,
|
||||||
address[] memory sources,
|
address[] memory sources,
|
||||||
address fallbackOracle,
|
address fallbackOracle,
|
||||||
address weth
|
address baseCurrency,
|
||||||
|
uint256 baseCurrencyUnit
|
||||||
) public {
|
) public {
|
||||||
_setFallbackOracle(fallbackOracle);
|
_setFallbackOracle(fallbackOracle);
|
||||||
_setAssetsSources(assets, sources);
|
_setAssetsSources(assets, sources);
|
||||||
WETH = weth;
|
BASE_CURRENCY = baseCurrency;
|
||||||
emit WethSet(weth);
|
BASE_CURRENCY_UNIT = baseCurrencyUnit;
|
||||||
|
emit BaseCurrencySet(baseCurrency, baseCurrencyUnit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @notice External function called by the Aave governance to set or replace sources of assets
|
/// @notice External function called by the Aave governance to set or replace sources of assets
|
||||||
|
|
@ -83,8 +88,8 @@ contract AaveOracle is IPriceOracleGetter, Ownable {
|
||||||
function getAssetPrice(address asset) public view override returns (uint256) {
|
function getAssetPrice(address asset) public view override returns (uint256) {
|
||||||
IChainlinkAggregator source = assetsSources[asset];
|
IChainlinkAggregator source = assetsSources[asset];
|
||||||
|
|
||||||
if (asset == WETH) {
|
if (asset == BASE_CURRENCY) {
|
||||||
return 1 ether;
|
return BASE_CURRENCY_UNIT;
|
||||||
} else if (address(source) == address(0)) {
|
} else if (address(source) == address(0)) {
|
||||||
return _fallbackOracle.getAssetPrice(asset);
|
return _fallbackOracle.getAssetPrice(asset);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ const buidlerConfig: HardhatUserConfig = {
|
||||||
kovan: getCommonNetworkConfig(eEthereumNetwork.kovan, 42),
|
kovan: getCommonNetworkConfig(eEthereumNetwork.kovan, 42),
|
||||||
ropsten: getCommonNetworkConfig(eEthereumNetwork.ropsten, 3),
|
ropsten: getCommonNetworkConfig(eEthereumNetwork.ropsten, 3),
|
||||||
main: getCommonNetworkConfig(eEthereumNetwork.main, 1),
|
main: getCommonNetworkConfig(eEthereumNetwork.main, 1),
|
||||||
tenderlyMain: getCommonNetworkConfig(eEthereumNetwork.tenderlyMain, 3030),
|
tenderly: getCommonNetworkConfig(eEthereumNetwork.tenderly, 3030),
|
||||||
matic: getCommonNetworkConfig(ePolygonNetwork.matic, 137),
|
matic: getCommonNetworkConfig(ePolygonNetwork.matic, 137),
|
||||||
mumbai: getCommonNetworkConfig(ePolygonNetwork.mumbai, 80001),
|
mumbai: getCommonNetworkConfig(ePolygonNetwork.mumbai, 80001),
|
||||||
xdai: getCommonNetworkConfig(eXDaiNetwork.xdai, 100),
|
xdai: getCommonNetworkConfig(eXDaiNetwork.xdai, 100),
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ export const NETWORKS_RPC_URL: iParamsPerNetwork<string> = {
|
||||||
[eEthereumNetwork.coverage]: 'http://localhost:8555',
|
[eEthereumNetwork.coverage]: 'http://localhost:8555',
|
||||||
[eEthereumNetwork.hardhat]: 'http://localhost:8545',
|
[eEthereumNetwork.hardhat]: 'http://localhost:8545',
|
||||||
[eEthereumNetwork.buidlerevm]: 'http://localhost:8545',
|
[eEthereumNetwork.buidlerevm]: 'http://localhost:8545',
|
||||||
[eEthereumNetwork.tenderlyMain]: `https://rpc.tenderly.co/fork/${TENDERLY_FORK_ID}`,
|
[eEthereumNetwork.tenderly]: `https://rpc.tenderly.co/fork/`,
|
||||||
[ePolygonNetwork.mumbai]: 'https://rpc-mumbai.maticvigil.com',
|
[ePolygonNetwork.mumbai]: 'https://rpc-mumbai.maticvigil.com',
|
||||||
[ePolygonNetwork.matic]: 'https://rpc-mainnet.matic.network',
|
[ePolygonNetwork.matic]: 'https://rpc-mainnet.matic.network',
|
||||||
[eXDaiNetwork.xdai]: 'https://rpc.xdaichain.com/',
|
[eXDaiNetwork.xdai]: 'https://rpc.xdaichain.com/',
|
||||||
|
|
@ -58,7 +58,7 @@ export const NETWORKS_DEFAULT_GAS: iParamsPerNetwork<number> = {
|
||||||
[eEthereumNetwork.coverage]: 65 * GWEI,
|
[eEthereumNetwork.coverage]: 65 * GWEI,
|
||||||
[eEthereumNetwork.hardhat]: 65 * GWEI,
|
[eEthereumNetwork.hardhat]: 65 * GWEI,
|
||||||
[eEthereumNetwork.buidlerevm]: 65 * GWEI,
|
[eEthereumNetwork.buidlerevm]: 65 * GWEI,
|
||||||
[eEthereumNetwork.tenderlyMain]: 0.01 * GWEI,
|
[eEthereumNetwork.tenderly]: 1 * GWEI,
|
||||||
[ePolygonNetwork.mumbai]: 1 * GWEI,
|
[ePolygonNetwork.mumbai]: 1 * GWEI,
|
||||||
[ePolygonNetwork.matic]: 1 * GWEI,
|
[ePolygonNetwork.matic]: 1 * GWEI,
|
||||||
[eXDaiNetwork.xdai]: 1 * GWEI,
|
[eXDaiNetwork.xdai]: 1 * GWEI,
|
||||||
|
|
@ -71,7 +71,7 @@ export const BLOCK_TO_FORK: iParamsPerNetwork<number | undefined> = {
|
||||||
[eEthereumNetwork.coverage]: undefined,
|
[eEthereumNetwork.coverage]: undefined,
|
||||||
[eEthereumNetwork.hardhat]: undefined,
|
[eEthereumNetwork.hardhat]: undefined,
|
||||||
[eEthereumNetwork.buidlerevm]: undefined,
|
[eEthereumNetwork.buidlerevm]: undefined,
|
||||||
[eEthereumNetwork.tenderlyMain]: 12406069,
|
[eEthereumNetwork.tenderly]: undefined,
|
||||||
[ePolygonNetwork.mumbai]: undefined,
|
[ePolygonNetwork.mumbai]: undefined,
|
||||||
[ePolygonNetwork.matic]: undefined,
|
[ePolygonNetwork.matic]: undefined,
|
||||||
[eXDaiNetwork.xdai]: undefined,
|
[eXDaiNetwork.xdai]: undefined,
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,14 @@ import {
|
||||||
iMultiPoolsAssets,
|
iMultiPoolsAssets,
|
||||||
IReserveParams,
|
IReserveParams,
|
||||||
PoolConfiguration,
|
PoolConfiguration,
|
||||||
ICommonConfiguration,
|
|
||||||
eNetwork,
|
eNetwork,
|
||||||
|
IBaseConfiguration,
|
||||||
} from './types';
|
} from './types';
|
||||||
import { getEthersSignersAddresses, getParamPerPool } from './contracts-helpers';
|
import { getEthersSignersAddresses, getParamPerPool } from './contracts-helpers';
|
||||||
import AaveConfig from '../markets/aave';
|
import AaveConfig from '../markets/aave';
|
||||||
import MaticConfig from '../markets/matic';
|
import MaticConfig from '../markets/matic';
|
||||||
import AmmConfig from '../markets/amm';
|
import AmmConfig from '../markets/amm';
|
||||||
|
|
||||||
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';
|
||||||
|
|
@ -34,7 +35,11 @@ export const loadPoolConfig = (configName: ConfigNames): PoolConfiguration => {
|
||||||
case ConfigNames.Commons:
|
case ConfigNames.Commons:
|
||||||
return CommonsConfig;
|
return CommonsConfig;
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unsupported pool configuration: ${Object.values(ConfigNames)}`);
|
throw new Error(
|
||||||
|
`Unsupported pool configuration: ${configName} is not one of the supported configs ${Object.values(
|
||||||
|
ConfigNames
|
||||||
|
)}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -59,7 +64,7 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
|
||||||
);
|
);
|
||||||
|
|
||||||
export const getGenesisPoolAdmin = async (
|
export const getGenesisPoolAdmin = async (
|
||||||
config: ICommonConfiguration
|
config: IBaseConfiguration
|
||||||
): Promise<tEthereumAddress> => {
|
): Promise<tEthereumAddress> => {
|
||||||
const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name;
|
const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name;
|
||||||
const targetAddress = getParamPerNetwork(config.PoolAdmin, <eNetwork>currentNetwork);
|
const targetAddress = getParamPerNetwork(config.PoolAdmin, <eNetwork>currentNetwork);
|
||||||
|
|
@ -71,9 +76,7 @@ export const getGenesisPoolAdmin = async (
|
||||||
return addressList[addressIndex];
|
return addressList[addressIndex];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getEmergencyAdmin = async (
|
export const getEmergencyAdmin = async (config: IBaseConfiguration): Promise<tEthereumAddress> => {
|
||||||
config: ICommonConfiguration
|
|
||||||
): Promise<tEthereumAddress> => {
|
|
||||||
const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name;
|
const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name;
|
||||||
const targetAddress = getParamPerNetwork(config.EmergencyAdmin, <eNetwork>currentNetwork);
|
const targetAddress = getParamPerNetwork(config.EmergencyAdmin, <eNetwork>currentNetwork);
|
||||||
if (targetAddress) {
|
if (targetAddress) {
|
||||||
|
|
@ -84,19 +87,17 @@ export const getEmergencyAdmin = async (
|
||||||
return addressList[addressIndex];
|
return addressList[addressIndex];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getTreasuryAddress = async (
|
export const getTreasuryAddress = async (config: IBaseConfiguration): Promise<tEthereumAddress> => {
|
||||||
config: ICommonConfiguration
|
|
||||||
): Promise<tEthereumAddress> => {
|
|
||||||
const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name;
|
const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name;
|
||||||
return getParamPerNetwork(config.ReserveFactorTreasuryAddress, <eNetwork>currentNetwork);
|
return getParamPerNetwork(config.ReserveFactorTreasuryAddress, <eNetwork>currentNetwork);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getATokenDomainSeparatorPerNetwork = (
|
export const getATokenDomainSeparatorPerNetwork = (
|
||||||
network: eNetwork,
|
network: eNetwork,
|
||||||
config: ICommonConfiguration
|
config: IBaseConfiguration
|
||||||
): tEthereumAddress => getParamPerNetwork<tEthereumAddress>(config.ATokenDomainSeparator, network);
|
): tEthereumAddress => getParamPerNetwork<tEthereumAddress>(config.ATokenDomainSeparator, network);
|
||||||
|
|
||||||
export const getWethAddress = async (config: ICommonConfiguration) => {
|
export const getWethAddress = async (config: IBaseConfiguration) => {
|
||||||
const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name;
|
const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name;
|
||||||
const wethAddress = getParamPerNetwork(config.WETH, <eNetwork>currentNetwork);
|
const wethAddress = getParamPerNetwork(config.WETH, <eNetwork>currentNetwork);
|
||||||
if (wethAddress) {
|
if (wethAddress) {
|
||||||
|
|
@ -109,7 +110,7 @@ export const getWethAddress = async (config: ICommonConfiguration) => {
|
||||||
return weth.address;
|
return weth.address;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getWrappedNativeTokenAddress = async (config: ICommonConfiguration) => {
|
export const getWrappedNativeTokenAddress = async (config: IBaseConfiguration) => {
|
||||||
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.WrappedNativeToken, <eNetwork>currentNetwork);
|
const wethAddress = getParamPerNetwork(config.WrappedNativeToken, <eNetwork>currentNetwork);
|
||||||
if (wethAddress) {
|
if (wethAddress) {
|
||||||
|
|
@ -122,7 +123,7 @@ export const getWrappedNativeTokenAddress = async (config: ICommonConfiguration)
|
||||||
return weth.address;
|
return weth.address;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getLendingRateOracles = (poolConfig: ICommonConfiguration) => {
|
export const getLendingRateOracles = (poolConfig: IBaseConfiguration) => {
|
||||||
const {
|
const {
|
||||||
ProtocolGlobalParams: { UsdAddress },
|
ProtocolGlobalParams: { UsdAddress },
|
||||||
LendingRateOracleRatesCommon,
|
LendingRateOracleRatesCommon,
|
||||||
|
|
@ -134,3 +135,15 @@ export const getLendingRateOracles = (poolConfig: ICommonConfiguration) => {
|
||||||
Object.keys(ReserveAssets[network]).includes(key)
|
Object.keys(ReserveAssets[network]).includes(key)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getQuoteCurrency = async (config: IBaseConfiguration) => {
|
||||||
|
switch (config.OracleQuoteCurrency) {
|
||||||
|
case 'ETH':
|
||||||
|
case 'WETH':
|
||||||
|
return getWethAddress(config);
|
||||||
|
case 'USD':
|
||||||
|
return config.ProtocolGlobalParams.UsdAddress;
|
||||||
|
default:
|
||||||
|
throw `Quote ${config.OracleQuoteCurrency} currency not set. Add a new case to getQuoteCurrency switch`;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import BigNumber from 'bignumber.js';
|
import BigNumber from 'bignumber.js';
|
||||||
|
import { eEthereumNetwork } from './types';
|
||||||
|
|
||||||
// ----------------
|
// ----------------
|
||||||
// MATH
|
// MATH
|
||||||
|
|
@ -12,6 +13,7 @@ export const RAY = new BigNumber(10).exponentiatedBy(27).toFixed();
|
||||||
export const HALF_RAY = new BigNumber(RAY).multipliedBy(0.5).toFixed();
|
export const HALF_RAY = new BigNumber(RAY).multipliedBy(0.5).toFixed();
|
||||||
export const WAD_RAY_RATIO = Math.pow(10, 9).toString();
|
export const WAD_RAY_RATIO = Math.pow(10, 9).toString();
|
||||||
export const oneEther = new BigNumber(Math.pow(10, 18));
|
export const oneEther = new BigNumber(Math.pow(10, 18));
|
||||||
|
export const oneUsd = new BigNumber(Math.pow(10, 8));
|
||||||
export const oneRay = new BigNumber(Math.pow(10, 27));
|
export const oneRay = new BigNumber(Math.pow(10, 27));
|
||||||
export const MAX_UINT_AMOUNT =
|
export const MAX_UINT_AMOUNT =
|
||||||
'115792089237316195423570985008687907853269984665640564039457584007913129639935';
|
'115792089237316195423570985008687907853269984665640564039457584007913129639935';
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { Contract } from 'ethers';
|
import { Contract } from 'ethers';
|
||||||
import { DRE } from './misc-utils';
|
import { DRE, notFalsyOrZeroAddress } from './misc-utils';
|
||||||
import {
|
import {
|
||||||
tEthereumAddress,
|
tEthereumAddress,
|
||||||
eContractid,
|
eContractid,
|
||||||
|
|
@ -13,9 +13,8 @@ import {
|
||||||
} from './types';
|
} from './types';
|
||||||
import { MintableERC20 } from '../types/MintableERC20';
|
import { MintableERC20 } from '../types/MintableERC20';
|
||||||
import { MockContract } from 'ethereum-waffle';
|
import { MockContract } from 'ethereum-waffle';
|
||||||
import { getReservesConfigByPool } from './configuration';
|
import { ConfigNames, getReservesConfigByPool, loadPoolConfig } from './configuration';
|
||||||
import { getFirstSigner } from './contracts-getters';
|
import { getFirstSigner } from './contracts-getters';
|
||||||
import { ZERO_ADDRESS } from './constants';
|
|
||||||
import {
|
import {
|
||||||
AaveProtocolDataProviderFactory,
|
AaveProtocolDataProviderFactory,
|
||||||
ATokenFactory,
|
ATokenFactory,
|
||||||
|
|
@ -57,6 +56,7 @@ import {
|
||||||
insertContractAddressInDb,
|
insertContractAddressInDb,
|
||||||
deployContract,
|
deployContract,
|
||||||
verifyContract,
|
verifyContract,
|
||||||
|
getOptionalParamAddressPerNetwork,
|
||||||
} from './contracts-helpers';
|
} from './contracts-helpers';
|
||||||
import { StableAndVariableTokensHelperFactory } from '../types/StableAndVariableTokensHelperFactory';
|
import { StableAndVariableTokensHelperFactory } from '../types/StableAndVariableTokensHelperFactory';
|
||||||
import { MintableDelegationERC20 } from '../types/MintableDelegationERC20';
|
import { MintableDelegationERC20 } from '../types/MintableDelegationERC20';
|
||||||
|
|
@ -64,6 +64,7 @@ import { readArtifact as buidlerReadArtifact } from '@nomiclabs/buidler/plugins'
|
||||||
import { HardhatRuntimeEnvironment } from 'hardhat/types';
|
import { HardhatRuntimeEnvironment } from 'hardhat/types';
|
||||||
import { LendingPoolLibraryAddresses } from '../types/LendingPoolFactory';
|
import { LendingPoolLibraryAddresses } from '../types/LendingPoolFactory';
|
||||||
import { UiPoolDataProvider } from '../types';
|
import { UiPoolDataProvider } from '../types';
|
||||||
|
import { eNetwork } from './types';
|
||||||
|
|
||||||
export const deployUiPoolDataProvider = async (
|
export const deployUiPoolDataProvider = async (
|
||||||
[incentivesController, aaveOracle]: [tEthereumAddress, tEthereumAddress],
|
[incentivesController, aaveOracle]: [tEthereumAddress, tEthereumAddress],
|
||||||
|
|
@ -224,7 +225,7 @@ export const deployMockAggregator = async (price: tStringTokenSmallUnits, verify
|
||||||
);
|
);
|
||||||
|
|
||||||
export const deployAaveOracle = async (
|
export const deployAaveOracle = async (
|
||||||
args: [tEthereumAddress[], tEthereumAddress[], tEthereumAddress, tEthereumAddress],
|
args: [tEthereumAddress[], tEthereumAddress[], tEthereumAddress, tEthereumAddress, string],
|
||||||
verify?: boolean
|
verify?: boolean
|
||||||
) =>
|
) =>
|
||||||
withSaveAndVerify(
|
withSaveAndVerify(
|
||||||
|
|
@ -352,20 +353,20 @@ export const deployVariableDebtToken = async (
|
||||||
return instance;
|
return instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const deployGenericStableDebtToken = async () =>
|
export const deployGenericStableDebtToken = async (verify?: boolean) =>
|
||||||
withSaveAndVerify(
|
withSaveAndVerify(
|
||||||
await new StableDebtTokenFactory(await getFirstSigner()).deploy(),
|
await new StableDebtTokenFactory(await getFirstSigner()).deploy(),
|
||||||
eContractid.StableDebtToken,
|
eContractid.StableDebtToken,
|
||||||
[],
|
[],
|
||||||
false
|
verify
|
||||||
);
|
);
|
||||||
|
|
||||||
export const deployGenericVariableDebtToken = async () =>
|
export const deployGenericVariableDebtToken = async (verify?: boolean) =>
|
||||||
withSaveAndVerify(
|
withSaveAndVerify(
|
||||||
await new VariableDebtTokenFactory(await getFirstSigner()).deploy(),
|
await new VariableDebtTokenFactory(await getFirstSigner()).deploy(),
|
||||||
eContractid.VariableDebtToken,
|
eContractid.VariableDebtToken,
|
||||||
[],
|
[],
|
||||||
false
|
verify
|
||||||
);
|
);
|
||||||
|
|
||||||
export const deployGenericAToken = async (
|
export const deployGenericAToken = async (
|
||||||
|
|
@ -638,3 +639,75 @@ export const deployFlashLiquidationAdapter = async (
|
||||||
args,
|
args,
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const chooseATokenDeployment = (id: eContractid) => {
|
||||||
|
switch (id) {
|
||||||
|
case eContractid.AToken:
|
||||||
|
return deployGenericATokenImpl;
|
||||||
|
case eContractid.DelegationAwareAToken:
|
||||||
|
return deployDelegationAwareATokenImpl;
|
||||||
|
default:
|
||||||
|
throw Error(`Missing aToken implementation deployment script for: ${id}`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const deployATokenImplementations = async (
|
||||||
|
pool: ConfigNames,
|
||||||
|
reservesConfig: { [key: string]: IReserveParams },
|
||||||
|
verify = false
|
||||||
|
) => {
|
||||||
|
const poolConfig = loadPoolConfig(pool);
|
||||||
|
const network = <eNetwork>DRE.network.name;
|
||||||
|
|
||||||
|
// Obtain the different AToken implementations of all reserves inside the Market config
|
||||||
|
const aTokenImplementations = [
|
||||||
|
...Object.entries(reservesConfig).reduce<Set<eContractid>>((acc, [, entry]) => {
|
||||||
|
acc.add(entry.aTokenImpl);
|
||||||
|
return acc;
|
||||||
|
}, new Set<eContractid>()),
|
||||||
|
];
|
||||||
|
|
||||||
|
console.log(aTokenImplementations);
|
||||||
|
|
||||||
|
for (let x = 0; x < aTokenImplementations.length; x++) {
|
||||||
|
const aTokenAddress = getOptionalParamAddressPerNetwork(
|
||||||
|
poolConfig[aTokenImplementations[x].toString()],
|
||||||
|
network
|
||||||
|
);
|
||||||
|
if (!notFalsyOrZeroAddress(aTokenAddress)) {
|
||||||
|
const deployImplementationMethod = chooseATokenDeployment(aTokenImplementations[x]);
|
||||||
|
console.log(`Deploying implementation`, aTokenImplementations[x]);
|
||||||
|
await deployImplementationMethod(verify);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Debt tokens, for now all Market configs follows same implementations
|
||||||
|
const genericStableDebtTokenAddress = getOptionalParamAddressPerNetwork(
|
||||||
|
poolConfig.StableDebtTokenImplementation,
|
||||||
|
network
|
||||||
|
);
|
||||||
|
const geneticVariableDebtTokenAddress = getOptionalParamAddressPerNetwork(
|
||||||
|
poolConfig.VariableDebtTokenImplementation,
|
||||||
|
network
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!notFalsyOrZeroAddress(genericStableDebtTokenAddress)) {
|
||||||
|
await deployGenericStableDebtToken(verify);
|
||||||
|
}
|
||||||
|
if (!notFalsyOrZeroAddress(geneticVariableDebtTokenAddress)) {
|
||||||
|
await deployGenericVariableDebtToken(verify);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const deployRateStrategy = async (
|
||||||
|
strategyName: string,
|
||||||
|
args: [tEthereumAddress, string, string, string, string, string, string],
|
||||||
|
verify: boolean
|
||||||
|
): Promise<tEthereumAddress> => {
|
||||||
|
switch (strategyName) {
|
||||||
|
default:
|
||||||
|
return await (
|
||||||
|
await deployDefaultReserveInterestRateStrategy(args, verify)
|
||||||
|
).address;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ import {
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import { IERC20DetailedFactory } from '../types/IERC20DetailedFactory';
|
import { IERC20DetailedFactory } from '../types/IERC20DetailedFactory';
|
||||||
import { getEthersSigners, MockTokenMap } from './contracts-helpers';
|
import { getEthersSigners, MockTokenMap } from './contracts-helpers';
|
||||||
import { DRE, getDb, notFalsyOrZeroAddress } from './misc-utils';
|
import { DRE, getDb, notFalsyOrZeroAddress, omit } from './misc-utils';
|
||||||
import { eContractid, PoolConfiguration, tEthereumAddress, TokenContractId } from './types';
|
import { eContractid, PoolConfiguration, tEthereumAddress, TokenContractId } from './types';
|
||||||
|
|
||||||
export const getFirstSigner = async () => (await getEthersSigners())[0];
|
export const getFirstSigner = async () => (await getEthersSigners())[0];
|
||||||
|
|
@ -41,16 +41,18 @@ export const getFirstSigner = async () => (await getEthersSigners())[0];
|
||||||
export const getLendingPoolAddressesProvider = async (address?: tEthereumAddress) => {
|
export const getLendingPoolAddressesProvider = async (address?: tEthereumAddress) => {
|
||||||
return await LendingPoolAddressesProviderFactory.connect(
|
return await LendingPoolAddressesProviderFactory.connect(
|
||||||
address ||
|
address ||
|
||||||
(await getDb().get(`${eContractid.LendingPoolAddressesProvider}.${DRE.network.name}`).value())
|
(
|
||||||
.address,
|
await getDb().get(`${eContractid.LendingPoolAddressesProvider}.${DRE.network.name}`).value()
|
||||||
|
).address,
|
||||||
await getFirstSigner()
|
await getFirstSigner()
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
export const getLendingPoolConfiguratorProxy = async (address?: tEthereumAddress) => {
|
export const getLendingPoolConfiguratorProxy = async (address?: tEthereumAddress) => {
|
||||||
return await LendingPoolConfiguratorFactory.connect(
|
return await LendingPoolConfiguratorFactory.connect(
|
||||||
address ||
|
address ||
|
||||||
(await getDb().get(`${eContractid.LendingPoolConfigurator}.${DRE.network.name}`).value())
|
(
|
||||||
.address,
|
await getDb().get(`${eContractid.LendingPoolConfigurator}.${DRE.network.name}`).value()
|
||||||
|
).address,
|
||||||
await getFirstSigner()
|
await getFirstSigner()
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
@ -58,14 +60,18 @@ export const getLendingPoolConfiguratorProxy = async (address?: tEthereumAddress
|
||||||
export const getLendingPool = async (address?: tEthereumAddress) =>
|
export const getLendingPool = async (address?: tEthereumAddress) =>
|
||||||
await LendingPoolFactory.connect(
|
await LendingPoolFactory.connect(
|
||||||
address ||
|
address ||
|
||||||
(await getDb().get(`${eContractid.LendingPool}.${DRE.network.name}`).value()).address,
|
(
|
||||||
|
await getDb().get(`${eContractid.LendingPool}.${DRE.network.name}`).value()
|
||||||
|
).address,
|
||||||
await getFirstSigner()
|
await getFirstSigner()
|
||||||
);
|
);
|
||||||
|
|
||||||
export const getPriceOracle = async (address?: tEthereumAddress) =>
|
export const getPriceOracle = async (address?: tEthereumAddress) =>
|
||||||
await PriceOracleFactory.connect(
|
await PriceOracleFactory.connect(
|
||||||
address ||
|
address ||
|
||||||
(await getDb().get(`${eContractid.PriceOracle}.${DRE.network.name}`).value()).address,
|
(
|
||||||
|
await getDb().get(`${eContractid.PriceOracle}.${DRE.network.name}`).value()
|
||||||
|
).address,
|
||||||
await getFirstSigner()
|
await getFirstSigner()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -78,36 +84,45 @@ export const getAToken = async (address?: tEthereumAddress) =>
|
||||||
export const getStableDebtToken = async (address?: tEthereumAddress) =>
|
export const getStableDebtToken = async (address?: tEthereumAddress) =>
|
||||||
await StableDebtTokenFactory.connect(
|
await StableDebtTokenFactory.connect(
|
||||||
address ||
|
address ||
|
||||||
(await getDb().get(`${eContractid.StableDebtToken}.${DRE.network.name}`).value()).address,
|
(
|
||||||
|
await getDb().get(`${eContractid.StableDebtToken}.${DRE.network.name}`).value()
|
||||||
|
).address,
|
||||||
await getFirstSigner()
|
await getFirstSigner()
|
||||||
);
|
);
|
||||||
|
|
||||||
export const getVariableDebtToken = async (address?: tEthereumAddress) =>
|
export const getVariableDebtToken = async (address?: tEthereumAddress) =>
|
||||||
await VariableDebtTokenFactory.connect(
|
await VariableDebtTokenFactory.connect(
|
||||||
address ||
|
address ||
|
||||||
(await getDb().get(`${eContractid.VariableDebtToken}.${DRE.network.name}`).value()).address,
|
(
|
||||||
|
await getDb().get(`${eContractid.VariableDebtToken}.${DRE.network.name}`).value()
|
||||||
|
).address,
|
||||||
await getFirstSigner()
|
await getFirstSigner()
|
||||||
);
|
);
|
||||||
|
|
||||||
export const getMintableERC20 = async (address: tEthereumAddress) =>
|
export const getMintableERC20 = async (address: tEthereumAddress) =>
|
||||||
await MintableERC20Factory.connect(
|
await MintableERC20Factory.connect(
|
||||||
address ||
|
address ||
|
||||||
(await getDb().get(`${eContractid.MintableERC20}.${DRE.network.name}`).value()).address,
|
(
|
||||||
|
await getDb().get(`${eContractid.MintableERC20}.${DRE.network.name}`).value()
|
||||||
|
).address,
|
||||||
await getFirstSigner()
|
await getFirstSigner()
|
||||||
);
|
);
|
||||||
|
|
||||||
export const getIErc20Detailed = async (address: tEthereumAddress) =>
|
export const getIErc20Detailed = async (address: tEthereumAddress) =>
|
||||||
await IERC20DetailedFactory.connect(
|
await IERC20DetailedFactory.connect(
|
||||||
address ||
|
address ||
|
||||||
(await getDb().get(`${eContractid.IERC20Detailed}.${DRE.network.name}`).value()).address,
|
(
|
||||||
|
await getDb().get(`${eContractid.IERC20Detailed}.${DRE.network.name}`).value()
|
||||||
|
).address,
|
||||||
await getFirstSigner()
|
await getFirstSigner()
|
||||||
);
|
);
|
||||||
|
|
||||||
export const getAaveProtocolDataProvider = async (address?: tEthereumAddress) =>
|
export const getAaveProtocolDataProvider = async (address?: tEthereumAddress) =>
|
||||||
await AaveProtocolDataProviderFactory.connect(
|
await AaveProtocolDataProviderFactory.connect(
|
||||||
address ||
|
address ||
|
||||||
(await getDb().get(`${eContractid.AaveProtocolDataProvider}.${DRE.network.name}`).value())
|
(
|
||||||
.address,
|
await getDb().get(`${eContractid.AaveProtocolDataProvider}.${DRE.network.name}`).value()
|
||||||
|
).address,
|
||||||
await getFirstSigner()
|
await getFirstSigner()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -125,15 +140,18 @@ export const getInterestRateStrategy = async (address?: tEthereumAddress) =>
|
||||||
export const getMockFlashLoanReceiver = async (address?: tEthereumAddress) =>
|
export const getMockFlashLoanReceiver = async (address?: tEthereumAddress) =>
|
||||||
await MockFlashLoanReceiverFactory.connect(
|
await MockFlashLoanReceiverFactory.connect(
|
||||||
address ||
|
address ||
|
||||||
(await getDb().get(`${eContractid.MockFlashLoanReceiver}.${DRE.network.name}`).value())
|
(
|
||||||
.address,
|
await getDb().get(`${eContractid.MockFlashLoanReceiver}.${DRE.network.name}`).value()
|
||||||
|
).address,
|
||||||
await getFirstSigner()
|
await getFirstSigner()
|
||||||
);
|
);
|
||||||
|
|
||||||
export const getLendingRateOracle = async (address?: tEthereumAddress) =>
|
export const getLendingRateOracle = async (address?: tEthereumAddress) =>
|
||||||
await LendingRateOracleFactory.connect(
|
await LendingRateOracleFactory.connect(
|
||||||
address ||
|
address ||
|
||||||
(await getDb().get(`${eContractid.LendingRateOracle}.${DRE.network.name}`).value()).address,
|
(
|
||||||
|
await getDb().get(`${eContractid.LendingRateOracle}.${DRE.network.name}`).value()
|
||||||
|
).address,
|
||||||
await getFirstSigner()
|
await getFirstSigner()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -166,23 +184,37 @@ export const getAllMockedTokens = async () => {
|
||||||
return tokens;
|
return tokens;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getQuoteCurrencies = (oracleQuoteCurrency: string): string[] => {
|
||||||
|
switch (oracleQuoteCurrency) {
|
||||||
|
case 'USD':
|
||||||
|
return ['USD'];
|
||||||
|
case 'ETH':
|
||||||
|
case 'WETH':
|
||||||
|
default:
|
||||||
|
return ['ETH', 'WETH'];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const getPairsTokenAggregator = (
|
export const getPairsTokenAggregator = (
|
||||||
allAssetsAddresses: {
|
allAssetsAddresses: {
|
||||||
[tokenSymbol: string]: tEthereumAddress;
|
[tokenSymbol: string]: tEthereumAddress;
|
||||||
},
|
},
|
||||||
aggregatorsAddresses: { [tokenSymbol: string]: tEthereumAddress }
|
aggregatorsAddresses: { [tokenSymbol: string]: tEthereumAddress },
|
||||||
|
oracleQuoteCurrency: string
|
||||||
): [string[], string[]] => {
|
): [string[], string[]] => {
|
||||||
const { ETH, WETH, ...assetsAddressesWithoutEth } = allAssetsAddresses;
|
const assetsWithoutQuoteCurrency = omit(
|
||||||
|
allAssetsAddresses,
|
||||||
|
getQuoteCurrencies(oracleQuoteCurrency)
|
||||||
|
);
|
||||||
|
|
||||||
const pairs = Object.entries(assetsAddressesWithoutEth).map(([tokenSymbol, tokenAddress]) => {
|
const pairs = Object.entries(assetsWithoutQuoteCurrency).map(([tokenSymbol, tokenAddress]) => {
|
||||||
//if (true/*tokenSymbol !== 'WETH' && tokenSymbol !== 'ETH' && tokenSymbol !== 'LpWETH'*/) {
|
//if (true/*tokenSymbol !== 'WETH' && tokenSymbol !== 'ETH' && tokenSymbol !== 'LpWETH'*/) {
|
||||||
const aggregatorAddressIndex = Object.keys(aggregatorsAddresses).findIndex(
|
const aggregatorAddressIndex = Object.keys(aggregatorsAddresses).findIndex(
|
||||||
(value) => value === tokenSymbol
|
(value) => value === tokenSymbol
|
||||||
);
|
);
|
||||||
const [, aggregatorAddress] = (Object.entries(aggregatorsAddresses) as [
|
const [, aggregatorAddress] = (
|
||||||
string,
|
Object.entries(aggregatorsAddresses) as [string, tEthereumAddress][]
|
||||||
tEthereumAddress
|
)[aggregatorAddressIndex];
|
||||||
][])[aggregatorAddressIndex];
|
|
||||||
return [tokenAddress, aggregatorAddress];
|
return [tokenAddress, aggregatorAddress];
|
||||||
//}
|
//}
|
||||||
}) as [string, string][];
|
}) as [string, string][];
|
||||||
|
|
@ -208,14 +240,18 @@ export const getLendingPoolAddressesProviderRegistry = async (address?: tEthereu
|
||||||
export const getReserveLogic = async (address?: tEthereumAddress) =>
|
export const getReserveLogic = async (address?: tEthereumAddress) =>
|
||||||
await ReserveLogicFactory.connect(
|
await ReserveLogicFactory.connect(
|
||||||
address ||
|
address ||
|
||||||
(await getDb().get(`${eContractid.ReserveLogic}.${DRE.network.name}`).value()).address,
|
(
|
||||||
|
await getDb().get(`${eContractid.ReserveLogic}.${DRE.network.name}`).value()
|
||||||
|
).address,
|
||||||
await getFirstSigner()
|
await getFirstSigner()
|
||||||
);
|
);
|
||||||
|
|
||||||
export const getGenericLogic = async (address?: tEthereumAddress) =>
|
export const getGenericLogic = async (address?: tEthereumAddress) =>
|
||||||
await GenericLogicFactory.connect(
|
await GenericLogicFactory.connect(
|
||||||
address ||
|
address ||
|
||||||
(await getDb().get(`${eContractid.GenericLogic}.${DRE.network.name}`).value()).address,
|
(
|
||||||
|
await getDb().get(`${eContractid.GenericLogic}.${DRE.network.name}`).value()
|
||||||
|
).address,
|
||||||
await getFirstSigner()
|
await getFirstSigner()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -233,15 +269,18 @@ export const getStableAndVariableTokensHelper = async (address?: tEthereumAddres
|
||||||
export const getATokensAndRatesHelper = async (address?: tEthereumAddress) =>
|
export const getATokensAndRatesHelper = async (address?: tEthereumAddress) =>
|
||||||
await ATokensAndRatesHelperFactory.connect(
|
await ATokensAndRatesHelperFactory.connect(
|
||||||
address ||
|
address ||
|
||||||
(await getDb().get(`${eContractid.ATokensAndRatesHelper}.${DRE.network.name}`).value())
|
(
|
||||||
.address,
|
await getDb().get(`${eContractid.ATokensAndRatesHelper}.${DRE.network.name}`).value()
|
||||||
|
).address,
|
||||||
await getFirstSigner()
|
await getFirstSigner()
|
||||||
);
|
);
|
||||||
|
|
||||||
export const getWETHGateway = async (address?: tEthereumAddress) =>
|
export const getWETHGateway = async (address?: tEthereumAddress) =>
|
||||||
await WETHGatewayFactory.connect(
|
await WETHGatewayFactory.connect(
|
||||||
address ||
|
address ||
|
||||||
(await getDb().get(`${eContractid.WETHGateway}.${DRE.network.name}`).value()).address,
|
(
|
||||||
|
await getDb().get(`${eContractid.WETHGateway}.${DRE.network.name}`).value()
|
||||||
|
).address,
|
||||||
await getFirstSigner()
|
await getFirstSigner()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -260,23 +299,27 @@ export const getMockAToken = async (address?: tEthereumAddress) =>
|
||||||
export const getMockVariableDebtToken = async (address?: tEthereumAddress) =>
|
export const getMockVariableDebtToken = async (address?: tEthereumAddress) =>
|
||||||
await MockVariableDebtTokenFactory.connect(
|
await MockVariableDebtTokenFactory.connect(
|
||||||
address ||
|
address ||
|
||||||
(await getDb().get(`${eContractid.MockVariableDebtToken}.${DRE.network.name}`).value())
|
(
|
||||||
.address,
|
await getDb().get(`${eContractid.MockVariableDebtToken}.${DRE.network.name}`).value()
|
||||||
|
).address,
|
||||||
await getFirstSigner()
|
await getFirstSigner()
|
||||||
);
|
);
|
||||||
|
|
||||||
export const getMockStableDebtToken = async (address?: tEthereumAddress) =>
|
export const getMockStableDebtToken = async (address?: tEthereumAddress) =>
|
||||||
await MockStableDebtTokenFactory.connect(
|
await MockStableDebtTokenFactory.connect(
|
||||||
address ||
|
address ||
|
||||||
(await getDb().get(`${eContractid.MockStableDebtToken}.${DRE.network.name}`).value()).address,
|
(
|
||||||
|
await getDb().get(`${eContractid.MockStableDebtToken}.${DRE.network.name}`).value()
|
||||||
|
).address,
|
||||||
await getFirstSigner()
|
await getFirstSigner()
|
||||||
);
|
);
|
||||||
|
|
||||||
export const getSelfdestructTransferMock = async (address?: tEthereumAddress) =>
|
export const getSelfdestructTransferMock = async (address?: tEthereumAddress) =>
|
||||||
await SelfdestructTransferFactory.connect(
|
await SelfdestructTransferFactory.connect(
|
||||||
address ||
|
address ||
|
||||||
(await getDb().get(`${eContractid.SelfdestructTransferMock}.${DRE.network.name}`).value())
|
(
|
||||||
.address,
|
await getDb().get(`${eContractid.SelfdestructTransferMock}.${DRE.network.name}`).value()
|
||||||
|
).address,
|
||||||
await getFirstSigner()
|
await getFirstSigner()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -286,15 +329,18 @@ export const getProxy = async (address: tEthereumAddress) =>
|
||||||
export const getLendingPoolImpl = async (address?: tEthereumAddress) =>
|
export const getLendingPoolImpl = async (address?: tEthereumAddress) =>
|
||||||
await LendingPoolFactory.connect(
|
await LendingPoolFactory.connect(
|
||||||
address ||
|
address ||
|
||||||
(await getDb().get(`${eContractid.LendingPoolImpl}.${DRE.network.name}`).value()).address,
|
(
|
||||||
|
await getDb().get(`${eContractid.LendingPoolImpl}.${DRE.network.name}`).value()
|
||||||
|
).address,
|
||||||
await getFirstSigner()
|
await getFirstSigner()
|
||||||
);
|
);
|
||||||
|
|
||||||
export const getLendingPoolConfiguratorImpl = async (address?: tEthereumAddress) =>
|
export const getLendingPoolConfiguratorImpl = async (address?: tEthereumAddress) =>
|
||||||
await LendingPoolConfiguratorFactory.connect(
|
await LendingPoolConfiguratorFactory.connect(
|
||||||
address ||
|
address ||
|
||||||
(await getDb().get(`${eContractid.LendingPoolConfiguratorImpl}.${DRE.network.name}`).value())
|
(
|
||||||
.address,
|
await getDb().get(`${eContractid.LendingPoolConfiguratorImpl}.${DRE.network.name}`).value()
|
||||||
|
).address,
|
||||||
await getFirstSigner()
|
await getFirstSigner()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -312,16 +358,18 @@ export const getLendingPoolCollateralManagerImpl = async (address?: tEthereumAdd
|
||||||
export const getWalletProvider = async (address?: tEthereumAddress) =>
|
export const getWalletProvider = async (address?: tEthereumAddress) =>
|
||||||
await WalletBalanceProviderFactory.connect(
|
await WalletBalanceProviderFactory.connect(
|
||||||
address ||
|
address ||
|
||||||
(await getDb().get(`${eContractid.WalletBalanceProvider}.${DRE.network.name}`).value())
|
(
|
||||||
.address,
|
await getDb().get(`${eContractid.WalletBalanceProvider}.${DRE.network.name}`).value()
|
||||||
|
).address,
|
||||||
await getFirstSigner()
|
await getFirstSigner()
|
||||||
);
|
);
|
||||||
|
|
||||||
export const getLendingPoolCollateralManager = async (address?: tEthereumAddress) =>
|
export const getLendingPoolCollateralManager = async (address?: tEthereumAddress) =>
|
||||||
await LendingPoolCollateralManagerFactory.connect(
|
await LendingPoolCollateralManagerFactory.connect(
|
||||||
address ||
|
address ||
|
||||||
(await getDb().get(`${eContractid.LendingPoolCollateralManager}.${DRE.network.name}`).value())
|
(
|
||||||
.address,
|
await getDb().get(`${eContractid.LendingPoolCollateralManager}.${DRE.network.name}`).value()
|
||||||
|
).address,
|
||||||
await getFirstSigner()
|
await getFirstSigner()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -337,31 +385,36 @@ export const getAaveOracle = async (address?: tEthereumAddress) =>
|
||||||
export const getMockUniswapRouter = async (address?: tEthereumAddress) =>
|
export const getMockUniswapRouter = async (address?: tEthereumAddress) =>
|
||||||
await MockUniswapV2Router02Factory.connect(
|
await MockUniswapV2Router02Factory.connect(
|
||||||
address ||
|
address ||
|
||||||
(await getDb().get(`${eContractid.MockUniswapV2Router02}.${DRE.network.name}`).value())
|
(
|
||||||
.address,
|
await getDb().get(`${eContractid.MockUniswapV2Router02}.${DRE.network.name}`).value()
|
||||||
|
).address,
|
||||||
await getFirstSigner()
|
await getFirstSigner()
|
||||||
);
|
);
|
||||||
|
|
||||||
export const getUniswapLiquiditySwapAdapter = async (address?: tEthereumAddress) =>
|
export const getUniswapLiquiditySwapAdapter = async (address?: tEthereumAddress) =>
|
||||||
await UniswapLiquiditySwapAdapterFactory.connect(
|
await UniswapLiquiditySwapAdapterFactory.connect(
|
||||||
address ||
|
address ||
|
||||||
(await getDb().get(`${eContractid.UniswapLiquiditySwapAdapter}.${DRE.network.name}`).value())
|
(
|
||||||
.address,
|
await getDb().get(`${eContractid.UniswapLiquiditySwapAdapter}.${DRE.network.name}`).value()
|
||||||
|
).address,
|
||||||
await getFirstSigner()
|
await getFirstSigner()
|
||||||
);
|
);
|
||||||
|
|
||||||
export const getUniswapRepayAdapter = async (address?: tEthereumAddress) =>
|
export const getUniswapRepayAdapter = async (address?: tEthereumAddress) =>
|
||||||
await UniswapRepayAdapterFactory.connect(
|
await UniswapRepayAdapterFactory.connect(
|
||||||
address ||
|
address ||
|
||||||
(await getDb().get(`${eContractid.UniswapRepayAdapter}.${DRE.network.name}`).value()).address,
|
(
|
||||||
|
await getDb().get(`${eContractid.UniswapRepayAdapter}.${DRE.network.name}`).value()
|
||||||
|
).address,
|
||||||
await getFirstSigner()
|
await getFirstSigner()
|
||||||
);
|
);
|
||||||
|
|
||||||
export const getFlashLiquidationAdapter = async (address?: tEthereumAddress) =>
|
export const getFlashLiquidationAdapter = async (address?: tEthereumAddress) =>
|
||||||
await FlashLiquidationAdapterFactory.connect(
|
await FlashLiquidationAdapterFactory.connect(
|
||||||
address ||
|
address ||
|
||||||
(await getDb().get(`${eContractid.FlashLiquidationAdapter}.${DRE.network.name}`).value())
|
(
|
||||||
.address,
|
await getDb().get(`${eContractid.FlashLiquidationAdapter}.${DRE.network.name}`).value()
|
||||||
|
).address,
|
||||||
await getFirstSigner()
|
await getFirstSigner()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { Contract, Signer, utils, ethers, BigNumberish } from 'ethers';
|
||||||
import { signTypedData_v4 } from 'eth-sig-util';
|
import { signTypedData_v4 } from 'eth-sig-util';
|
||||||
import { fromRpcSig, ECDSASignature } from 'ethereumjs-util';
|
import { fromRpcSig, ECDSASignature } from 'ethereumjs-util';
|
||||||
import BigNumber from 'bignumber.js';
|
import BigNumber from 'bignumber.js';
|
||||||
import { getDb, DRE, waitForTx } from './misc-utils';
|
import { getDb, DRE, waitForTx, notFalsyOrZeroAddress } from './misc-utils';
|
||||||
import {
|
import {
|
||||||
tEthereumAddress,
|
tEthereumAddress,
|
||||||
eContractid,
|
eContractid,
|
||||||
|
|
@ -14,7 +14,6 @@ import {
|
||||||
ePolygonNetwork,
|
ePolygonNetwork,
|
||||||
eXDaiNetwork,
|
eXDaiNetwork,
|
||||||
eNetwork,
|
eNetwork,
|
||||||
iParamsPerNetworkAll,
|
|
||||||
iEthereumParamsPerNetwork,
|
iEthereumParamsPerNetwork,
|
||||||
iPolygonParamsPerNetwork,
|
iPolygonParamsPerNetwork,
|
||||||
iXDaiParamsPerNetwork,
|
iXDaiParamsPerNetwork,
|
||||||
|
|
@ -26,6 +25,8 @@ import { verifyEtherscanContract } from './etherscan-verification';
|
||||||
import { getFirstSigner, getIErc20Detailed } from './contracts-getters';
|
import { getFirstSigner, getIErc20Detailed } from './contracts-getters';
|
||||||
import { usingTenderly, verifyAtTenderly } from './tenderly-utils';
|
import { usingTenderly, verifyAtTenderly } from './tenderly-utils';
|
||||||
import { usingPolygon, verifyAtPolygon } from './polygon-utils';
|
import { usingPolygon, verifyAtPolygon } from './polygon-utils';
|
||||||
|
import { ConfigNames, loadPoolConfig } from './configuration';
|
||||||
|
import { ZERO_ADDRESS } from './constants';
|
||||||
import { getDefenderRelaySigner, usingDefender } from './defender-utils';
|
import { getDefenderRelaySigner, usingDefender } from './defender-utils';
|
||||||
|
|
||||||
export type MockTokenMap = { [symbol: string]: MintableERC20 };
|
export type MockTokenMap = { [symbol: string]: MintableERC20 };
|
||||||
|
|
@ -142,14 +143,8 @@ export const linkBytecode = (artifact: BuidlerArtifact | Artifact, libraries: an
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getParamPerNetwork = <T>(param: iParamsPerNetwork<T>, network: eNetwork) => {
|
export const getParamPerNetwork = <T>(param: iParamsPerNetwork<T>, network: eNetwork) => {
|
||||||
const {
|
const { main, ropsten, kovan, coverage, buidlerevm, tenderly } =
|
||||||
main,
|
param as iEthereumParamsPerNetwork<T>;
|
||||||
ropsten,
|
|
||||||
kovan,
|
|
||||||
coverage,
|
|
||||||
buidlerevm,
|
|
||||||
tenderlyMain,
|
|
||||||
} = param as iEthereumParamsPerNetwork<T>;
|
|
||||||
const { matic, mumbai } = param as iPolygonParamsPerNetwork<T>;
|
const { matic, mumbai } = param as iPolygonParamsPerNetwork<T>;
|
||||||
const { xdai } = param as iXDaiParamsPerNetwork<T>;
|
const { xdai } = param as iXDaiParamsPerNetwork<T>;
|
||||||
if (process.env.FORK) {
|
if (process.env.FORK) {
|
||||||
|
|
@ -169,8 +164,8 @@ export const getParamPerNetwork = <T>(param: iParamsPerNetwork<T>, network: eNet
|
||||||
return ropsten;
|
return ropsten;
|
||||||
case eEthereumNetwork.main:
|
case eEthereumNetwork.main:
|
||||||
return main;
|
return main;
|
||||||
case eEthereumNetwork.tenderlyMain:
|
case eEthereumNetwork.tenderly:
|
||||||
return tenderlyMain;
|
return tenderly;
|
||||||
case ePolygonNetwork.matic:
|
case ePolygonNetwork.matic:
|
||||||
return matic;
|
return matic;
|
||||||
case ePolygonNetwork.mumbai:
|
case ePolygonNetwork.mumbai:
|
||||||
|
|
@ -180,6 +175,16 @@ export const getParamPerNetwork = <T>(param: iParamsPerNetwork<T>, network: eNet
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getOptionalParamAddressPerNetwork = (
|
||||||
|
param: iParamsPerNetwork<tEthereumAddress> | undefined | null,
|
||||||
|
network: eNetwork
|
||||||
|
) => {
|
||||||
|
if (!param) {
|
||||||
|
return ZERO_ADDRESS;
|
||||||
|
}
|
||||||
|
return getParamPerNetwork(param, network);
|
||||||
|
};
|
||||||
|
|
||||||
export const getParamPerPool = <T>({ proto, amm, matic }: iParamsPerPool<T>, pool: AavePools) => {
|
export const getParamPerPool = <T>({ proto, amm, matic }: iParamsPerPool<T>, pool: AavePools) => {
|
||||||
switch (pool) {
|
switch (pool) {
|
||||||
case AavePools.proto:
|
case AavePools.proto:
|
||||||
|
|
@ -342,3 +347,23 @@ export const verifyContract = async (
|
||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getContractAddressWithJsonFallback = async (
|
||||||
|
id: string,
|
||||||
|
pool: ConfigNames
|
||||||
|
): Promise<tEthereumAddress> => {
|
||||||
|
const poolConfig = loadPoolConfig(pool);
|
||||||
|
const network = <eNetwork>DRE.network.name;
|
||||||
|
const db = getDb();
|
||||||
|
|
||||||
|
const contractAtMarketConfig = getOptionalParamAddressPerNetwork(poolConfig[id], network);
|
||||||
|
if (notFalsyOrZeroAddress(contractAtMarketConfig)) {
|
||||||
|
return contractAtMarketConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
const contractAtDb = await getDb().get(`${id}.${DRE.network.name}`).value();
|
||||||
|
if (contractAtDb?.address) {
|
||||||
|
return contractAtDb.address as tEthereumAddress;
|
||||||
|
}
|
||||||
|
throw Error(`Missing contract address ${id} at Market config and JSON local db`);
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,48 +1,31 @@
|
||||||
import {
|
import {
|
||||||
eContractid,
|
eContractid,
|
||||||
eEthereumNetwork,
|
|
||||||
eNetwork,
|
eNetwork,
|
||||||
iMultiPoolsAssets,
|
iMultiPoolsAssets,
|
||||||
IReserveParams,
|
IReserveParams,
|
||||||
tEthereumAddress,
|
tEthereumAddress,
|
||||||
} from './types';
|
} from './types';
|
||||||
import { AaveProtocolDataProvider } from '../types/AaveProtocolDataProvider';
|
import { AaveProtocolDataProvider } from '../types/AaveProtocolDataProvider';
|
||||||
import { chunk, DRE, getDb, waitForTx } from './misc-utils';
|
import { chunk, getDb, waitForTx } from './misc-utils';
|
||||||
import {
|
import {
|
||||||
getAaveProtocolDataProvider,
|
|
||||||
getAToken,
|
getAToken,
|
||||||
getATokensAndRatesHelper,
|
getATokensAndRatesHelper,
|
||||||
getFirstSigner,
|
|
||||||
getLendingPoolAddressesProvider,
|
getLendingPoolAddressesProvider,
|
||||||
getLendingPoolConfiguratorProxy,
|
getLendingPoolConfiguratorProxy,
|
||||||
getStableAndVariableTokensHelper,
|
|
||||||
} from './contracts-getters';
|
} from './contracts-getters';
|
||||||
import { rawInsertContractAddressInDb } from './contracts-helpers';
|
|
||||||
import { BigNumber, BigNumberish, Signer } from 'ethers';
|
|
||||||
import {
|
import {
|
||||||
deployDefaultReserveInterestRateStrategy,
|
getContractAddressWithJsonFallback,
|
||||||
deployDelegationAwareAToken,
|
rawInsertContractAddressInDb,
|
||||||
deployDelegationAwareATokenImpl,
|
} from './contracts-helpers';
|
||||||
deployGenericAToken,
|
import { BigNumberish } from 'ethers';
|
||||||
deployGenericATokenImpl,
|
import { ConfigNames } from './configuration';
|
||||||
deployGenericStableDebtToken,
|
import { deployRateStrategy } from './contracts-deployments';
|
||||||
deployGenericVariableDebtToken,
|
|
||||||
deployStableDebtToken,
|
|
||||||
deployVariableDebtToken,
|
|
||||||
} from './contracts-deployments';
|
|
||||||
import { ZERO_ADDRESS } from './constants';
|
|
||||||
import { isZeroAddress } from 'ethereumjs-util';
|
|
||||||
import { DefaultReserveInterestRateStrategy, DelegationAwareAToken } from '../types';
|
|
||||||
import { config } from 'process';
|
|
||||||
|
|
||||||
export const chooseATokenDeployment = (id: eContractid) => {
|
export const getATokenExtraParams = async (aTokenName: string, tokenAddress: tEthereumAddress) => {
|
||||||
switch (id) {
|
console.log(aTokenName);
|
||||||
case eContractid.AToken:
|
switch (aTokenName) {
|
||||||
return deployGenericAToken;
|
|
||||||
case eContractid.DelegationAwareAToken:
|
|
||||||
return deployDelegationAwareAToken;
|
|
||||||
default:
|
default:
|
||||||
throw Error(`Missing aToken deployment script for: ${id}`);
|
return '0x10';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -56,19 +39,15 @@ export const initReservesByHelper = async (
|
||||||
admin: tEthereumAddress,
|
admin: tEthereumAddress,
|
||||||
treasuryAddress: tEthereumAddress,
|
treasuryAddress: tEthereumAddress,
|
||||||
incentivesController: tEthereumAddress,
|
incentivesController: tEthereumAddress,
|
||||||
|
poolName: ConfigNames,
|
||||||
verify: boolean
|
verify: boolean
|
||||||
): Promise<BigNumber> => {
|
) => {
|
||||||
let gasUsage = BigNumber.from('0');
|
|
||||||
const stableAndVariableDeployer = await getStableAndVariableTokensHelper();
|
|
||||||
|
|
||||||
const addressProvider = await getLendingPoolAddressesProvider();
|
const addressProvider = await getLendingPoolAddressesProvider();
|
||||||
|
|
||||||
// CHUNK CONFIGURATION
|
// CHUNK CONFIGURATION
|
||||||
const initChunks = 4;
|
const initChunks = 1;
|
||||||
|
|
||||||
// Initialize variables for future reserves initialization
|
// Initialize variables for future reserves initialization
|
||||||
let reserveTokens: string[] = [];
|
|
||||||
let reserveInitDecimals: string[] = [];
|
|
||||||
let reserveSymbols: string[] = [];
|
let reserveSymbols: string[] = [];
|
||||||
|
|
||||||
let initInputParams: {
|
let initInputParams: {
|
||||||
|
|
@ -101,49 +80,8 @@ export const initReservesByHelper = async (
|
||||||
];
|
];
|
||||||
let rateStrategies: Record<string, typeof strategyRates> = {};
|
let rateStrategies: Record<string, typeof strategyRates> = {};
|
||||||
let strategyAddresses: Record<string, tEthereumAddress> = {};
|
let strategyAddresses: Record<string, tEthereumAddress> = {};
|
||||||
let strategyAddressPerAsset: Record<string, string> = {};
|
|
||||||
let aTokenType: Record<string, string> = {};
|
|
||||||
let delegationAwareATokenImplementationAddress = '';
|
|
||||||
let aTokenImplementationAddress = '';
|
|
||||||
let stableDebtTokenImplementationAddress = '';
|
|
||||||
let variableDebtTokenImplementationAddress = '';
|
|
||||||
|
|
||||||
// NOT WORKING ON MATIC, DEPLOYING INDIVIDUAL IMPLs INSTEAD
|
const reserves = Object.entries(reservesParams);
|
||||||
// const tx1 = await waitForTx(
|
|
||||||
// await stableAndVariableDeployer.initDeployment([ZERO_ADDRESS], ["1"])
|
|
||||||
// );
|
|
||||||
// console.log(tx1.events);
|
|
||||||
// tx1.events?.forEach((event, index) => {
|
|
||||||
// stableDebtTokenImplementationAddress = event?.args?.stableToken;
|
|
||||||
// variableDebtTokenImplementationAddress = event?.args?.variableToken;
|
|
||||||
// rawInsertContractAddressInDb(`stableDebtTokenImpl`, stableDebtTokenImplementationAddress);
|
|
||||||
// rawInsertContractAddressInDb(`variableDebtTokenImpl`, variableDebtTokenImplementationAddress);
|
|
||||||
// });
|
|
||||||
//gasUsage = gasUsage.add(tx1.gasUsed);
|
|
||||||
stableDebtTokenImplementationAddress = await (await deployGenericStableDebtToken()).address;
|
|
||||||
variableDebtTokenImplementationAddress = await (await deployGenericVariableDebtToken()).address;
|
|
||||||
|
|
||||||
const aTokenImplementation = await deployGenericATokenImpl(verify);
|
|
||||||
aTokenImplementationAddress = aTokenImplementation.address;
|
|
||||||
rawInsertContractAddressInDb(`aTokenImpl`, aTokenImplementationAddress);
|
|
||||||
|
|
||||||
const delegatedAwareReserves = Object.entries(reservesParams).filter(
|
|
||||||
([_, { aTokenImpl }]) => aTokenImpl === eContractid.DelegationAwareAToken
|
|
||||||
) as [string, IReserveParams][];
|
|
||||||
|
|
||||||
if (delegatedAwareReserves.length > 0) {
|
|
||||||
const delegationAwareATokenImplementation = await deployDelegationAwareATokenImpl(verify);
|
|
||||||
delegationAwareATokenImplementationAddress = delegationAwareATokenImplementation.address;
|
|
||||||
rawInsertContractAddressInDb(
|
|
||||||
`delegationAwareATokenImpl`,
|
|
||||||
delegationAwareATokenImplementationAddress
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const reserves = Object.entries(reservesParams).filter(
|
|
||||||
([_, { aTokenImpl }]) =>
|
|
||||||
aTokenImpl === eContractid.DelegationAwareAToken || aTokenImpl === eContractid.AToken
|
|
||||||
) as [string, IReserveParams][];
|
|
||||||
|
|
||||||
for (let [symbol, params] of reserves) {
|
for (let [symbol, params] of reserves) {
|
||||||
if (!tokenAddresses[symbol]) {
|
if (!tokenAddresses[symbol]) {
|
||||||
|
|
@ -170,52 +108,41 @@ export const initReservesByHelper = async (
|
||||||
stableRateSlope1,
|
stableRateSlope1,
|
||||||
stableRateSlope2,
|
stableRateSlope2,
|
||||||
];
|
];
|
||||||
strategyAddresses[strategy.name] = (
|
strategyAddresses[strategy.name] = await deployRateStrategy(
|
||||||
await deployDefaultReserveInterestRateStrategy(rateStrategies[strategy.name], verify)
|
strategy.name,
|
||||||
).address;
|
rateStrategies[strategy.name],
|
||||||
|
verify
|
||||||
|
);
|
||||||
|
|
||||||
// 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];
|
// Prepare input parameters
|
||||||
console.log('Strategy address for asset %s: %s', symbol, strategyAddressPerAsset[symbol]);
|
|
||||||
|
|
||||||
if (aTokenImpl === eContractid.AToken) {
|
|
||||||
aTokenType[symbol] = 'generic';
|
|
||||||
} else if (aTokenImpl === eContractid.DelegationAwareAToken) {
|
|
||||||
aTokenType[symbol] = 'delegation aware';
|
|
||||||
}
|
|
||||||
|
|
||||||
reserveInitDecimals.push(reserveDecimals);
|
|
||||||
reserveTokens.push(tokenAddresses[symbol]);
|
|
||||||
reserveSymbols.push(symbol);
|
reserveSymbols.push(symbol);
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 0; i < reserveSymbols.length; i++) {
|
|
||||||
let aTokenToUse: string;
|
|
||||||
if (aTokenType[reserveSymbols[i]] === 'generic') {
|
|
||||||
aTokenToUse = aTokenImplementationAddress;
|
|
||||||
} else {
|
|
||||||
aTokenToUse = delegationAwareATokenImplementationAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
initInputParams.push({
|
initInputParams.push({
|
||||||
aTokenImpl: aTokenToUse,
|
aTokenImpl: await getContractAddressWithJsonFallback(aTokenImpl, poolName),
|
||||||
stableDebtTokenImpl: stableDebtTokenImplementationAddress,
|
stableDebtTokenImpl: await getContractAddressWithJsonFallback(
|
||||||
variableDebtTokenImpl: variableDebtTokenImplementationAddress,
|
eContractid.StableDebtToken,
|
||||||
underlyingAssetDecimals: reserveInitDecimals[i],
|
poolName
|
||||||
interestRateStrategyAddress: strategyAddressPerAsset[reserveSymbols[i]],
|
),
|
||||||
underlyingAsset: reserveTokens[i],
|
variableDebtTokenImpl: await getContractAddressWithJsonFallback(
|
||||||
|
eContractid.VariableDebtToken,
|
||||||
|
poolName
|
||||||
|
),
|
||||||
|
underlyingAssetDecimals: reserveDecimals,
|
||||||
|
interestRateStrategyAddress: strategyAddresses[strategy.name],
|
||||||
|
underlyingAsset: tokenAddresses[symbol],
|
||||||
treasury: treasuryAddress,
|
treasury: treasuryAddress,
|
||||||
incentivesController,
|
incentivesController: incentivesController,
|
||||||
underlyingAssetName: reserveSymbols[i],
|
underlyingAssetName: symbol,
|
||||||
aTokenName: `${aTokenNamePrefix} ${reserveSymbols[i]}`,
|
aTokenName: `${aTokenNamePrefix} ${symbol}`,
|
||||||
aTokenSymbol: `a${symbolPrefix}${reserveSymbols[i]}`,
|
aTokenSymbol: `a${symbolPrefix}${symbol}`,
|
||||||
variableDebtTokenName: `${variableDebtTokenNamePrefix} ${symbolPrefix}${reserveSymbols[i]}`,
|
variableDebtTokenName: `${variableDebtTokenNamePrefix} ${symbolPrefix}${symbol}`,
|
||||||
variableDebtTokenSymbol: `variableDebt${symbolPrefix}${reserveSymbols[i]}`,
|
variableDebtTokenSymbol: `variableDebt${symbolPrefix}${symbol}`,
|
||||||
stableDebtTokenName: `${stableDebtTokenNamePrefix} ${reserveSymbols[i]}`,
|
stableDebtTokenName: `${stableDebtTokenNamePrefix} ${symbol}`,
|
||||||
stableDebtTokenSymbol: `stableDebt${symbolPrefix}${reserveSymbols[i]}`,
|
stableDebtTokenSymbol: `stableDebt${symbolPrefix}${symbol}`,
|
||||||
params: '0x10',
|
params: await getATokenExtraParams(aTokenImpl, tokenAddresses[symbol]),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -224,7 +151,6 @@ export const initReservesByHelper = async (
|
||||||
const chunkedInitInputParams = chunk(initInputParams, initChunks);
|
const chunkedInitInputParams = chunk(initInputParams, initChunks);
|
||||||
|
|
||||||
const configurator = await getLendingPoolConfiguratorProxy();
|
const configurator = await getLendingPoolConfiguratorProxy();
|
||||||
//await waitForTx(await addressProvider.setPoolAdmin(admin));
|
|
||||||
|
|
||||||
console.log(`- Reserves initialization in ${chunkedInitInputParams.length} txs`);
|
console.log(`- Reserves initialization in ${chunkedInitInputParams.length} txs`);
|
||||||
for (let chunkIndex = 0; chunkIndex < chunkedInitInputParams.length; chunkIndex++) {
|
for (let chunkIndex = 0; chunkIndex < chunkedInitInputParams.length; chunkIndex++) {
|
||||||
|
|
@ -234,10 +160,7 @@ export const initReservesByHelper = async (
|
||||||
|
|
||||||
console.log(` - Reserve ready for: ${chunkedSymbols[chunkIndex].join(', ')}`);
|
console.log(` - Reserve ready for: ${chunkedSymbols[chunkIndex].join(', ')}`);
|
||||||
console.log(' * gasUsed', tx3.gasUsed.toString());
|
console.log(' * gasUsed', tx3.gasUsed.toString());
|
||||||
//gasUsage = gasUsage.add(tx3.gasUsed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return gasUsage; // Deprecated
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getPairsTokenAggregator = (
|
export const getPairsTokenAggregator = (
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ import { BuidlerRuntimeEnvironment } from '@nomiclabs/buidler/types';
|
||||||
import { tEthereumAddress } from './types';
|
import { tEthereumAddress } from './types';
|
||||||
import { isAddress } from 'ethers/lib/utils';
|
import { isAddress } from 'ethers/lib/utils';
|
||||||
import { isZeroAddress } from 'ethereumjs-util';
|
import { isZeroAddress } from 'ethereumjs-util';
|
||||||
|
import { SignerWithAddress } from '../test-suites/test-aave/helpers/make-suite';
|
||||||
|
import { usingTenderly } from './tenderly-utils';
|
||||||
|
|
||||||
export const toWad = (value: string | number) => new BigNumber(value).times(WAD).toFixed();
|
export const toWad = (value: string | number) => new BigNumber(value).times(WAD).toFixed();
|
||||||
|
|
||||||
|
|
@ -116,6 +118,27 @@ export const notFalsyOrZeroAddress = (address: tEthereumAddress | null | undefin
|
||||||
return isAddress(address) && !isZeroAddress(address);
|
return isAddress(address) && !isZeroAddress(address);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const impersonateAddress = async (address: tEthereumAddress): Promise<SignerWithAddress> => {
|
||||||
|
if (!usingTenderly()) {
|
||||||
|
await (DRE as HardhatRuntimeEnvironment).network.provider.request({
|
||||||
|
method: 'hardhat_impersonateAccount',
|
||||||
|
params: [address],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const signer = await DRE.ethers.provider.getSigner(address);
|
||||||
|
|
||||||
|
return {
|
||||||
|
signer,
|
||||||
|
address,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const omit = <T, U extends keyof T>(obj: T, keys: U[]): Omit<T, U> =>
|
||||||
|
(Object.keys(obj) as U[]).reduce(
|
||||||
|
(acc, curr) => (keys.includes(curr) ? acc : { ...acc, [curr]: obj[curr] }),
|
||||||
|
{} as Omit<T, U>
|
||||||
|
);
|
||||||
|
|
||||||
export const impersonateAccountsHardhat = async (accounts: string[]) => {
|
export const impersonateAccountsHardhat = async (accounts: string[]) => {
|
||||||
if (process.env.TENDERLY === 'true') {
|
if (process.env.TENDERLY === 'true') {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ export enum eEthereumNetwork {
|
||||||
main = 'main',
|
main = 'main',
|
||||||
coverage = 'coverage',
|
coverage = 'coverage',
|
||||||
hardhat = 'hardhat',
|
hardhat = 'hardhat',
|
||||||
tenderlyMain = 'tenderlyMain',
|
tenderly = 'tenderly',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ePolygonNetwork {
|
export enum ePolygonNetwork {
|
||||||
|
|
@ -424,7 +424,7 @@ export interface iEthereumParamsPerNetwork<T> {
|
||||||
[eEthereumNetwork.ropsten]: T;
|
[eEthereumNetwork.ropsten]: T;
|
||||||
[eEthereumNetwork.main]: T;
|
[eEthereumNetwork.main]: T;
|
||||||
[eEthereumNetwork.hardhat]: T;
|
[eEthereumNetwork.hardhat]: T;
|
||||||
[eEthereumNetwork.tenderlyMain]: T;
|
[eEthereumNetwork.tenderly]: T;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface iPolygonParamsPerNetwork<T> {
|
export interface iPolygonParamsPerNetwork<T> {
|
||||||
|
|
@ -478,7 +478,7 @@ export interface ILendingRate {
|
||||||
borrowRate: string;
|
borrowRate: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ICommonConfiguration {
|
export interface IBaseConfiguration {
|
||||||
MarketId: string;
|
MarketId: string;
|
||||||
ATokenNamePrefix: string;
|
ATokenNamePrefix: string;
|
||||||
StableDebtTokenNamePrefix: string;
|
StableDebtTokenNamePrefix: string;
|
||||||
|
|
@ -486,7 +486,6 @@ export interface ICommonConfiguration {
|
||||||
SymbolPrefix: string;
|
SymbolPrefix: string;
|
||||||
ProviderId: number;
|
ProviderId: number;
|
||||||
ProtocolGlobalParams: IProtocolGlobalConfig;
|
ProtocolGlobalParams: IProtocolGlobalConfig;
|
||||||
Mocks: IMocksConfig;
|
|
||||||
ProviderRegistry: iParamsPerNetwork<tEthereumAddress | undefined>;
|
ProviderRegistry: iParamsPerNetwork<tEthereumAddress | undefined>;
|
||||||
ProviderRegistryOwner: iParamsPerNetwork<tEthereumAddress | undefined>;
|
ProviderRegistryOwner: iParamsPerNetwork<tEthereumAddress | undefined>;
|
||||||
LendingPoolCollateralManager: iParamsPerNetwork<tEthereumAddress>;
|
LendingPoolCollateralManager: iParamsPerNetwork<tEthereumAddress>;
|
||||||
|
|
@ -502,14 +501,22 @@ export interface ICommonConfiguration {
|
||||||
PoolAdminIndex: number;
|
PoolAdminIndex: number;
|
||||||
EmergencyAdmin: iParamsPerNetwork<tEthereumAddress | undefined>;
|
EmergencyAdmin: iParamsPerNetwork<tEthereumAddress | undefined>;
|
||||||
EmergencyAdminIndex: number;
|
EmergencyAdminIndex: number;
|
||||||
ReserveAssets: iParamsPerNetwork<SymbolMap<tEthereumAddress>>;
|
|
||||||
ReservesConfig: iMultiPoolsAssets<IReserveParams>;
|
|
||||||
ATokenDomainSeparator: iParamsPerNetwork<string>;
|
ATokenDomainSeparator: iParamsPerNetwork<string>;
|
||||||
WETH: iParamsPerNetwork<tEthereumAddress>;
|
WETH: iParamsPerNetwork<tEthereumAddress>;
|
||||||
WrappedNativeToken: iParamsPerNetwork<tEthereumAddress>;
|
WrappedNativeToken: iParamsPerNetwork<tEthereumAddress>;
|
||||||
WethGateway: iParamsPerNetwork<tEthereumAddress>;
|
WethGateway: iParamsPerNetwork<tEthereumAddress>;
|
||||||
ReserveFactorTreasuryAddress: iParamsPerNetwork<tEthereumAddress>;
|
ReserveFactorTreasuryAddress: iParamsPerNetwork<tEthereumAddress>;
|
||||||
IncentivesController: iParamsPerNetwork<tEthereumAddress>;
|
IncentivesController: iParamsPerNetwork<tEthereumAddress>;
|
||||||
|
StableDebtTokenImplementation?: iParamsPerNetwork<tEthereumAddress>;
|
||||||
|
VariableDebtTokenImplementation?: iParamsPerNetwork<tEthereumAddress>;
|
||||||
|
ReserveAssets: iParamsPerNetwork<SymbolMap<tEthereumAddress>>;
|
||||||
|
OracleQuoteCurrency: string;
|
||||||
|
OracleQuoteUnit: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ICommonConfiguration extends IBaseConfiguration {
|
||||||
|
ReservesConfig: iMultiPoolsAssets<IReserveParams>;
|
||||||
|
Mocks: IMocksConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IAaveConfiguration extends ICommonConfiguration {
|
export interface IAaveConfiguration extends ICommonConfiguration {
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
import BigNumber from 'bignumber.js';
|
|
||||||
import {
|
import {
|
||||||
oneEther,
|
|
||||||
oneRay,
|
oneRay,
|
||||||
RAY,
|
|
||||||
ZERO_ADDRESS,
|
ZERO_ADDRESS,
|
||||||
MOCK_CHAINLINK_AGGREGATORS_PRICES,
|
MOCK_CHAINLINK_AGGREGATORS_PRICES,
|
||||||
|
oneEther,
|
||||||
} from '../../helpers/constants';
|
} from '../../helpers/constants';
|
||||||
import { ICommonConfiguration, eEthereumNetwork } from '../../helpers/types';
|
import { ICommonConfiguration, eEthereumNetwork } from '../../helpers/types';
|
||||||
|
|
||||||
|
|
@ -19,6 +17,8 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
VariableDebtTokenNamePrefix: 'Aave variable debt bearing',
|
VariableDebtTokenNamePrefix: 'Aave variable debt bearing',
|
||||||
SymbolPrefix: '',
|
SymbolPrefix: '',
|
||||||
ProviderId: 0, // Overriden in index.ts
|
ProviderId: 0, // Overriden in index.ts
|
||||||
|
OracleQuoteCurrency: 'ETH',
|
||||||
|
OracleQuoteUnit: oneEther.toString(),
|
||||||
ProtocolGlobalParams: {
|
ProtocolGlobalParams: {
|
||||||
TokenDistributorPercentageBase: '10000',
|
TokenDistributorPercentageBase: '10000',
|
||||||
MockUsdPriceInWei: '5848466240000000',
|
MockUsdPriceInWei: '5848466240000000',
|
||||||
|
|
@ -113,7 +113,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.kovan]: undefined,
|
[eEthereumNetwork.kovan]: undefined,
|
||||||
[eEthereumNetwork.ropsten]: undefined,
|
[eEthereumNetwork.ropsten]: undefined,
|
||||||
[eEthereumNetwork.main]: undefined,
|
[eEthereumNetwork.main]: undefined,
|
||||||
[eEthereumNetwork.tenderlyMain]: undefined,
|
[eEthereumNetwork.tenderly]: undefined,
|
||||||
},
|
},
|
||||||
PoolAdminIndex: 0,
|
PoolAdminIndex: 0,
|
||||||
EmergencyAdmin: {
|
EmergencyAdmin: {
|
||||||
|
|
@ -123,7 +123,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.kovan]: undefined,
|
[eEthereumNetwork.kovan]: undefined,
|
||||||
[eEthereumNetwork.ropsten]: undefined,
|
[eEthereumNetwork.ropsten]: undefined,
|
||||||
[eEthereumNetwork.main]: undefined,
|
[eEthereumNetwork.main]: undefined,
|
||||||
[eEthereumNetwork.tenderlyMain]: undefined,
|
[eEthereumNetwork.tenderly]: undefined,
|
||||||
},
|
},
|
||||||
EmergencyAdminIndex: 1,
|
EmergencyAdminIndex: 1,
|
||||||
ProviderRegistry: {
|
ProviderRegistry: {
|
||||||
|
|
@ -133,7 +133,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.coverage]: '',
|
[eEthereumNetwork.coverage]: '',
|
||||||
[eEthereumNetwork.hardhat]: '',
|
[eEthereumNetwork.hardhat]: '',
|
||||||
[eEthereumNetwork.buidlerevm]: '',
|
[eEthereumNetwork.buidlerevm]: '',
|
||||||
[eEthereumNetwork.tenderlyMain]: '0x52D306e36E3B6B02c153d0266ff0f85d18BCD413',
|
[eEthereumNetwork.tenderly]: '0x52D306e36E3B6B02c153d0266ff0f85d18BCD413',
|
||||||
},
|
},
|
||||||
ProviderRegistryOwner: {
|
ProviderRegistryOwner: {
|
||||||
[eEthereumNetwork.kovan]: '0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F',
|
[eEthereumNetwork.kovan]: '0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F',
|
||||||
|
|
@ -142,7 +142,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.coverage]: '',
|
[eEthereumNetwork.coverage]: '',
|
||||||
[eEthereumNetwork.hardhat]: '',
|
[eEthereumNetwork.hardhat]: '',
|
||||||
[eEthereumNetwork.buidlerevm]: '',
|
[eEthereumNetwork.buidlerevm]: '',
|
||||||
[eEthereumNetwork.tenderlyMain]: '0xB9062896ec3A615a4e4444DF183F0531a77218AE',
|
[eEthereumNetwork.tenderly]: '0xB9062896ec3A615a4e4444DF183F0531a77218AE',
|
||||||
},
|
},
|
||||||
LendingRateOracle: {
|
LendingRateOracle: {
|
||||||
[eEthereumNetwork.coverage]: '',
|
[eEthereumNetwork.coverage]: '',
|
||||||
|
|
@ -151,7 +151,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.kovan]: '', //'0xdCde9Bb6a49e37fA433990832AB541AE2d4FEB4a',
|
[eEthereumNetwork.kovan]: '', //'0xdCde9Bb6a49e37fA433990832AB541AE2d4FEB4a',
|
||||||
[eEthereumNetwork.ropsten]: '0x05dcca805a6562c1bdd0423768754acb6993241b',
|
[eEthereumNetwork.ropsten]: '0x05dcca805a6562c1bdd0423768754acb6993241b',
|
||||||
[eEthereumNetwork.main]: '', //'0x8A32f49FFbA88aba6EFF96F45D8BD1D4b3f35c7D',
|
[eEthereumNetwork.main]: '', //'0x8A32f49FFbA88aba6EFF96F45D8BD1D4b3f35c7D',
|
||||||
[eEthereumNetwork.tenderlyMain]: '0x8A32f49FFbA88aba6EFF96F45D8BD1D4b3f35c7D',
|
[eEthereumNetwork.tenderly]: '0x8A32f49FFbA88aba6EFF96F45D8BD1D4b3f35c7D',
|
||||||
},
|
},
|
||||||
LendingPoolCollateralManager: {
|
LendingPoolCollateralManager: {
|
||||||
[eEthereumNetwork.coverage]: '',
|
[eEthereumNetwork.coverage]: '',
|
||||||
|
|
@ -160,7 +160,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.kovan]: '0x9269b6453d0d75370c4c85e5a42977a53efdb72a',
|
[eEthereumNetwork.kovan]: '0x9269b6453d0d75370c4c85e5a42977a53efdb72a',
|
||||||
[eEthereumNetwork.ropsten]: '',
|
[eEthereumNetwork.ropsten]: '',
|
||||||
[eEthereumNetwork.main]: '0xbd4765210d4167CE2A5b87280D9E8Ee316D5EC7C',
|
[eEthereumNetwork.main]: '0xbd4765210d4167CE2A5b87280D9E8Ee316D5EC7C',
|
||||||
[eEthereumNetwork.tenderlyMain]: '0xbd4765210d4167CE2A5b87280D9E8Ee316D5EC7C',
|
[eEthereumNetwork.tenderly]: '0xbd4765210d4167CE2A5b87280D9E8Ee316D5EC7C',
|
||||||
},
|
},
|
||||||
LendingPoolConfigurator: {
|
LendingPoolConfigurator: {
|
||||||
[eEthereumNetwork.coverage]: '',
|
[eEthereumNetwork.coverage]: '',
|
||||||
|
|
@ -169,7 +169,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.kovan]: '',
|
[eEthereumNetwork.kovan]: '',
|
||||||
[eEthereumNetwork.ropsten]: '',
|
[eEthereumNetwork.ropsten]: '',
|
||||||
[eEthereumNetwork.main]: '',
|
[eEthereumNetwork.main]: '',
|
||||||
[eEthereumNetwork.tenderlyMain]: '',
|
[eEthereumNetwork.tenderly]: '',
|
||||||
},
|
},
|
||||||
LendingPool: {
|
LendingPool: {
|
||||||
[eEthereumNetwork.coverage]: '',
|
[eEthereumNetwork.coverage]: '',
|
||||||
|
|
@ -178,7 +178,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.kovan]: '',
|
[eEthereumNetwork.kovan]: '',
|
||||||
[eEthereumNetwork.ropsten]: '',
|
[eEthereumNetwork.ropsten]: '',
|
||||||
[eEthereumNetwork.main]: '',
|
[eEthereumNetwork.main]: '',
|
||||||
[eEthereumNetwork.tenderlyMain]: '',
|
[eEthereumNetwork.tenderly]: '',
|
||||||
},
|
},
|
||||||
WethGateway: {
|
WethGateway: {
|
||||||
[eEthereumNetwork.coverage]: '',
|
[eEthereumNetwork.coverage]: '',
|
||||||
|
|
@ -187,7 +187,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.kovan]: '',
|
[eEthereumNetwork.kovan]: '',
|
||||||
[eEthereumNetwork.ropsten]: '',
|
[eEthereumNetwork.ropsten]: '',
|
||||||
[eEthereumNetwork.main]: '',
|
[eEthereumNetwork.main]: '',
|
||||||
[eEthereumNetwork.tenderlyMain]: '',
|
[eEthereumNetwork.tenderly]: '',
|
||||||
},
|
},
|
||||||
TokenDistributor: {
|
TokenDistributor: {
|
||||||
[eEthereumNetwork.coverage]: '',
|
[eEthereumNetwork.coverage]: '',
|
||||||
|
|
@ -196,7 +196,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.kovan]: '0x971efe90088f21dc6a36f610ffed77fc19710708',
|
[eEthereumNetwork.kovan]: '0x971efe90088f21dc6a36f610ffed77fc19710708',
|
||||||
[eEthereumNetwork.ropsten]: '0xeba2ea67942b8250d870b12750b594696d02fc9c',
|
[eEthereumNetwork.ropsten]: '0xeba2ea67942b8250d870b12750b594696d02fc9c',
|
||||||
[eEthereumNetwork.main]: '0xe3d9988f676457123c5fd01297605efdd0cba1ae',
|
[eEthereumNetwork.main]: '0xe3d9988f676457123c5fd01297605efdd0cba1ae',
|
||||||
[eEthereumNetwork.tenderlyMain]: '0xe3d9988f676457123c5fd01297605efdd0cba1ae',
|
[eEthereumNetwork.tenderly]: '0xe3d9988f676457123c5fd01297605efdd0cba1ae',
|
||||||
},
|
},
|
||||||
AaveOracle: {
|
AaveOracle: {
|
||||||
[eEthereumNetwork.coverage]: '',
|
[eEthereumNetwork.coverage]: '',
|
||||||
|
|
@ -205,7 +205,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.kovan]: '', //'0xB8bE51E6563BB312Cbb2aa26e352516c25c26ac1',
|
[eEthereumNetwork.kovan]: '', //'0xB8bE51E6563BB312Cbb2aa26e352516c25c26ac1',
|
||||||
[eEthereumNetwork.ropsten]: ZERO_ADDRESS,
|
[eEthereumNetwork.ropsten]: ZERO_ADDRESS,
|
||||||
[eEthereumNetwork.main]: '', //'0xA50ba011c48153De246E5192C8f9258A2ba79Ca9',
|
[eEthereumNetwork.main]: '', //'0xA50ba011c48153De246E5192C8f9258A2ba79Ca9',
|
||||||
[eEthereumNetwork.tenderlyMain]: '0xA50ba011c48153De246E5192C8f9258A2ba79Ca9',
|
[eEthereumNetwork.tenderly]: '0xA50ba011c48153De246E5192C8f9258A2ba79Ca9',
|
||||||
},
|
},
|
||||||
FallbackOracle: {
|
FallbackOracle: {
|
||||||
[eEthereumNetwork.coverage]: '',
|
[eEthereumNetwork.coverage]: '',
|
||||||
|
|
@ -214,7 +214,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.kovan]: '0x50913E8E1c650E790F8a1E741FF9B1B1bB251dfe',
|
[eEthereumNetwork.kovan]: '0x50913E8E1c650E790F8a1E741FF9B1B1bB251dfe',
|
||||||
[eEthereumNetwork.ropsten]: '0xAD1a978cdbb8175b2eaeC47B01404f8AEC5f4F0d',
|
[eEthereumNetwork.ropsten]: '0xAD1a978cdbb8175b2eaeC47B01404f8AEC5f4F0d',
|
||||||
[eEthereumNetwork.main]: ZERO_ADDRESS,
|
[eEthereumNetwork.main]: ZERO_ADDRESS,
|
||||||
[eEthereumNetwork.tenderlyMain]: ZERO_ADDRESS,
|
[eEthereumNetwork.tenderly]: ZERO_ADDRESS,
|
||||||
},
|
},
|
||||||
ChainlinkAggregator: {
|
ChainlinkAggregator: {
|
||||||
[eEthereumNetwork.coverage]: {},
|
[eEthereumNetwork.coverage]: {},
|
||||||
|
|
@ -287,7 +287,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
USD: '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419',
|
USD: '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419',
|
||||||
xSUSHI: '0x9b26214bEC078E68a394AaEbfbffF406Ce14893F',
|
xSUSHI: '0x9b26214bEC078E68a394AaEbfbffF406Ce14893F',
|
||||||
},
|
},
|
||||||
[eEthereumNetwork.tenderlyMain]: {
|
[eEthereumNetwork.tenderly]: {
|
||||||
AAVE: '0x6Df09E975c830ECae5bd4eD9d90f3A95a4f88012',
|
AAVE: '0x6Df09E975c830ECae5bd4eD9d90f3A95a4f88012',
|
||||||
BAT: '0x0d16d4528239e9ee52fa531af613AcdB23D88c94',
|
BAT: '0x0d16d4528239e9ee52fa531af613AcdB23D88c94',
|
||||||
BUSD: '0x614715d2Af89E6EC99A233818275142cE88d1Cfd',
|
BUSD: '0x614715d2Af89E6EC99A233818275142cE88d1Cfd',
|
||||||
|
|
@ -318,7 +318,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.main]: {},
|
[eEthereumNetwork.main]: {},
|
||||||
[eEthereumNetwork.kovan]: {},
|
[eEthereumNetwork.kovan]: {},
|
||||||
[eEthereumNetwork.ropsten]: {},
|
[eEthereumNetwork.ropsten]: {},
|
||||||
[eEthereumNetwork.tenderlyMain]: {},
|
[eEthereumNetwork.tenderly]: {},
|
||||||
},
|
},
|
||||||
ReservesConfig: {},
|
ReservesConfig: {},
|
||||||
ATokenDomainSeparator: {
|
ATokenDomainSeparator: {
|
||||||
|
|
@ -331,7 +331,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.kovan]: '',
|
[eEthereumNetwork.kovan]: '',
|
||||||
[eEthereumNetwork.ropsten]: '',
|
[eEthereumNetwork.ropsten]: '',
|
||||||
[eEthereumNetwork.main]: '',
|
[eEthereumNetwork.main]: '',
|
||||||
[eEthereumNetwork.tenderlyMain]: '',
|
[eEthereumNetwork.tenderly]: '',
|
||||||
},
|
},
|
||||||
WETH: {
|
WETH: {
|
||||||
[eEthereumNetwork.coverage]: '', // deployed in local evm
|
[eEthereumNetwork.coverage]: '', // deployed in local evm
|
||||||
|
|
@ -340,7 +340,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.kovan]: '0xd0a1e359811322d97991e03f863a0c30c2cf029c',
|
[eEthereumNetwork.kovan]: '0xd0a1e359811322d97991e03f863a0c30c2cf029c',
|
||||||
[eEthereumNetwork.ropsten]: '0xc778417e063141139fce010982780140aa0cd5ab',
|
[eEthereumNetwork.ropsten]: '0xc778417e063141139fce010982780140aa0cd5ab',
|
||||||
[eEthereumNetwork.main]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
[eEthereumNetwork.main]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
||||||
[eEthereumNetwork.tenderlyMain]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
[eEthereumNetwork.tenderly]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
||||||
},
|
},
|
||||||
WrappedNativeToken: {
|
WrappedNativeToken: {
|
||||||
[eEthereumNetwork.coverage]: '', // deployed in local evm
|
[eEthereumNetwork.coverage]: '', // deployed in local evm
|
||||||
|
|
@ -349,7 +349,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.kovan]: '0xd0a1e359811322d97991e03f863a0c30c2cf029c',
|
[eEthereumNetwork.kovan]: '0xd0a1e359811322d97991e03f863a0c30c2cf029c',
|
||||||
[eEthereumNetwork.ropsten]: '0xc778417e063141139fce010982780140aa0cd5ab',
|
[eEthereumNetwork.ropsten]: '0xc778417e063141139fce010982780140aa0cd5ab',
|
||||||
[eEthereumNetwork.main]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
[eEthereumNetwork.main]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
||||||
[eEthereumNetwork.tenderlyMain]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
[eEthereumNetwork.tenderly]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
||||||
},
|
},
|
||||||
ReserveFactorTreasuryAddress: {
|
ReserveFactorTreasuryAddress: {
|
||||||
[eEthereumNetwork.coverage]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
|
[eEthereumNetwork.coverage]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
|
||||||
|
|
@ -358,7 +358,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.kovan]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
|
[eEthereumNetwork.kovan]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
|
||||||
[eEthereumNetwork.ropsten]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
|
[eEthereumNetwork.ropsten]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
|
||||||
[eEthereumNetwork.main]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
|
[eEthereumNetwork.main]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
|
||||||
[eEthereumNetwork.tenderlyMain]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
|
[eEthereumNetwork.tenderly]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
|
||||||
},
|
},
|
||||||
IncentivesController: {
|
IncentivesController: {
|
||||||
[eEthereumNetwork.coverage]: ZERO_ADDRESS,
|
[eEthereumNetwork.coverage]: ZERO_ADDRESS,
|
||||||
|
|
@ -367,6 +367,6 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.kovan]: ZERO_ADDRESS,
|
[eEthereumNetwork.kovan]: ZERO_ADDRESS,
|
||||||
[eEthereumNetwork.ropsten]: ZERO_ADDRESS,
|
[eEthereumNetwork.ropsten]: ZERO_ADDRESS,
|
||||||
[eEthereumNetwork.main]: ZERO_ADDRESS,
|
[eEthereumNetwork.main]: ZERO_ADDRESS,
|
||||||
[eEthereumNetwork.tenderlyMain]: ZERO_ADDRESS,
|
[eEthereumNetwork.tenderly]: ZERO_ADDRESS,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ export const AaveConfig: IAaveConfiguration = {
|
||||||
ZRX: '0xE41d2489571d322189246DaFA5ebDe1F4699F498',
|
ZRX: '0xE41d2489571d322189246DaFA5ebDe1F4699F498',
|
||||||
xSUSHI: '0x8798249c2E607446EfB7Ad49eC89dD1865Ff4272',
|
xSUSHI: '0x8798249c2E607446EfB7Ad49eC89dD1865Ff4272',
|
||||||
},
|
},
|
||||||
[eEthereumNetwork.tenderlyMain]: {
|
[eEthereumNetwork.tenderly]: {
|
||||||
AAVE: '0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9',
|
AAVE: '0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9',
|
||||||
BAT: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
BAT: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
||||||
BUSD: '0x4Fabb145d64652a948d72533023f6E7A623C7C53',
|
BUSD: '0x4Fabb145d64652a948d72533023f6E7A623C7C53',
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import {
|
||||||
RAY,
|
RAY,
|
||||||
ZERO_ADDRESS,
|
ZERO_ADDRESS,
|
||||||
MOCK_CHAINLINK_AGGREGATORS_PRICES,
|
MOCK_CHAINLINK_AGGREGATORS_PRICES,
|
||||||
|
oneUsd,
|
||||||
} from '../../helpers/constants';
|
} from '../../helpers/constants';
|
||||||
import { ICommonConfiguration, eEthereumNetwork } from '../../helpers/types';
|
import { ICommonConfiguration, eEthereumNetwork } from '../../helpers/types';
|
||||||
|
|
||||||
|
|
@ -19,6 +20,8 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
VariableDebtTokenNamePrefix: 'Aave AMM Market variable debt',
|
VariableDebtTokenNamePrefix: 'Aave AMM Market variable debt',
|
||||||
SymbolPrefix: 'Amm',
|
SymbolPrefix: 'Amm',
|
||||||
ProviderId: 0, // Overriden in index.ts
|
ProviderId: 0, // Overriden in index.ts
|
||||||
|
OracleQuoteCurrency: 'ETH',
|
||||||
|
OracleQuoteUnit: oneEther.toString(),
|
||||||
ProtocolGlobalParams: {
|
ProtocolGlobalParams: {
|
||||||
TokenDistributorPercentageBase: '10000',
|
TokenDistributorPercentageBase: '10000',
|
||||||
MockUsdPriceInWei: '5848466240000000',
|
MockUsdPriceInWei: '5848466240000000',
|
||||||
|
|
@ -116,7 +119,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.kovan]: undefined,
|
[eEthereumNetwork.kovan]: undefined,
|
||||||
[eEthereumNetwork.ropsten]: undefined,
|
[eEthereumNetwork.ropsten]: undefined,
|
||||||
[eEthereumNetwork.main]: undefined,
|
[eEthereumNetwork.main]: undefined,
|
||||||
[eEthereumNetwork.tenderlyMain]: undefined,
|
[eEthereumNetwork.tenderly]: undefined,
|
||||||
},
|
},
|
||||||
PoolAdminIndex: 0,
|
PoolAdminIndex: 0,
|
||||||
EmergencyAdmin: {
|
EmergencyAdmin: {
|
||||||
|
|
@ -126,7 +129,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.kovan]: undefined,
|
[eEthereumNetwork.kovan]: undefined,
|
||||||
[eEthereumNetwork.ropsten]: undefined,
|
[eEthereumNetwork.ropsten]: undefined,
|
||||||
[eEthereumNetwork.main]: undefined,
|
[eEthereumNetwork.main]: undefined,
|
||||||
[eEthereumNetwork.tenderlyMain]: undefined,
|
[eEthereumNetwork.tenderly]: undefined,
|
||||||
},
|
},
|
||||||
EmergencyAdminIndex: 1,
|
EmergencyAdminIndex: 1,
|
||||||
ProviderRegistry: {
|
ProviderRegistry: {
|
||||||
|
|
@ -136,7 +139,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.coverage]: '',
|
[eEthereumNetwork.coverage]: '',
|
||||||
[eEthereumNetwork.hardhat]: '',
|
[eEthereumNetwork.hardhat]: '',
|
||||||
[eEthereumNetwork.buidlerevm]: '',
|
[eEthereumNetwork.buidlerevm]: '',
|
||||||
[eEthereumNetwork.tenderlyMain]: '0x52D306e36E3B6B02c153d0266ff0f85d18BCD413',
|
[eEthereumNetwork.tenderly]: '0x52D306e36E3B6B02c153d0266ff0f85d18BCD413',
|
||||||
},
|
},
|
||||||
ProviderRegistryOwner: {
|
ProviderRegistryOwner: {
|
||||||
[eEthereumNetwork.kovan]: '0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F',
|
[eEthereumNetwork.kovan]: '0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F',
|
||||||
|
|
@ -145,7 +148,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.coverage]: '',
|
[eEthereumNetwork.coverage]: '',
|
||||||
[eEthereumNetwork.hardhat]: '',
|
[eEthereumNetwork.hardhat]: '',
|
||||||
[eEthereumNetwork.buidlerevm]: '',
|
[eEthereumNetwork.buidlerevm]: '',
|
||||||
[eEthereumNetwork.tenderlyMain]: '0xB9062896ec3A615a4e4444DF183F0531a77218AE',
|
[eEthereumNetwork.tenderly]: '0xB9062896ec3A615a4e4444DF183F0531a77218AE',
|
||||||
},
|
},
|
||||||
LendingRateOracle: {
|
LendingRateOracle: {
|
||||||
[eEthereumNetwork.coverage]: '',
|
[eEthereumNetwork.coverage]: '',
|
||||||
|
|
@ -154,7 +157,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.kovan]: '0xd00Bd28FAdDa9d5658D1D4e0c151973146C7A533', //'0xE48F95873855bfd97BF89572DDf5cBC44D9c545b'
|
[eEthereumNetwork.kovan]: '0xd00Bd28FAdDa9d5658D1D4e0c151973146C7A533', //'0xE48F95873855bfd97BF89572DDf5cBC44D9c545b'
|
||||||
[eEthereumNetwork.ropsten]: '0x05dcca805a6562c1bdd0423768754acb6993241b',
|
[eEthereumNetwork.ropsten]: '0x05dcca805a6562c1bdd0423768754acb6993241b',
|
||||||
[eEthereumNetwork.main]: '', //'0x8A32f49FFbA88aba6EFF96F45D8BD1D4b3f35c7D', // Need to re-deploy because of onlyOwner
|
[eEthereumNetwork.main]: '', //'0x8A32f49FFbA88aba6EFF96F45D8BD1D4b3f35c7D', // Need to re-deploy because of onlyOwner
|
||||||
[eEthereumNetwork.tenderlyMain]: '0x8A32f49FFbA88aba6EFF96F45D8BD1D4b3f35c7D',
|
[eEthereumNetwork.tenderly]: '0x8A32f49FFbA88aba6EFF96F45D8BD1D4b3f35c7D',
|
||||||
},
|
},
|
||||||
LendingPoolCollateralManager: {
|
LendingPoolCollateralManager: {
|
||||||
[eEthereumNetwork.coverage]: '',
|
[eEthereumNetwork.coverage]: '',
|
||||||
|
|
@ -163,7 +166,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.kovan]: '0x9269b6453d0d75370c4c85e5a42977a53efdb72a',
|
[eEthereumNetwork.kovan]: '0x9269b6453d0d75370c4c85e5a42977a53efdb72a',
|
||||||
[eEthereumNetwork.ropsten]: '',
|
[eEthereumNetwork.ropsten]: '',
|
||||||
[eEthereumNetwork.main]: '0xbd4765210d4167CE2A5b87280D9E8Ee316D5EC7C',
|
[eEthereumNetwork.main]: '0xbd4765210d4167CE2A5b87280D9E8Ee316D5EC7C',
|
||||||
[eEthereumNetwork.tenderlyMain]: '0xbd4765210d4167CE2A5b87280D9E8Ee316D5EC7C',
|
[eEthereumNetwork.tenderly]: '0xbd4765210d4167CE2A5b87280D9E8Ee316D5EC7C',
|
||||||
},
|
},
|
||||||
LendingPoolConfigurator: {
|
LendingPoolConfigurator: {
|
||||||
[eEthereumNetwork.coverage]: '',
|
[eEthereumNetwork.coverage]: '',
|
||||||
|
|
@ -172,7 +175,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.kovan]: '0x36eB31800aa67a9c50df1d56EE01981A6E14Cce5',
|
[eEthereumNetwork.kovan]: '0x36eB31800aa67a9c50df1d56EE01981A6E14Cce5',
|
||||||
[eEthereumNetwork.ropsten]: '',
|
[eEthereumNetwork.ropsten]: '',
|
||||||
[eEthereumNetwork.main]: '',
|
[eEthereumNetwork.main]: '',
|
||||||
[eEthereumNetwork.tenderlyMain]: '',
|
[eEthereumNetwork.tenderly]: '',
|
||||||
},
|
},
|
||||||
LendingPool: {
|
LendingPool: {
|
||||||
[eEthereumNetwork.coverage]: '',
|
[eEthereumNetwork.coverage]: '',
|
||||||
|
|
@ -181,7 +184,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.kovan]: '0x78142De7a1930412E9e50dEB3b80dB284c2dFa3A',
|
[eEthereumNetwork.kovan]: '0x78142De7a1930412E9e50dEB3b80dB284c2dFa3A',
|
||||||
[eEthereumNetwork.ropsten]: '',
|
[eEthereumNetwork.ropsten]: '',
|
||||||
[eEthereumNetwork.main]: '',
|
[eEthereumNetwork.main]: '',
|
||||||
[eEthereumNetwork.tenderlyMain]: '',
|
[eEthereumNetwork.tenderly]: '',
|
||||||
},
|
},
|
||||||
WethGateway: {
|
WethGateway: {
|
||||||
[eEthereumNetwork.coverage]: '',
|
[eEthereumNetwork.coverage]: '',
|
||||||
|
|
@ -190,7 +193,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.kovan]: '0x1c4A1cC35A477aa1cF35DF671d93ACc04d8131E0',
|
[eEthereumNetwork.kovan]: '0x1c4A1cC35A477aa1cF35DF671d93ACc04d8131E0',
|
||||||
[eEthereumNetwork.ropsten]: '',
|
[eEthereumNetwork.ropsten]: '',
|
||||||
[eEthereumNetwork.main]: '',
|
[eEthereumNetwork.main]: '',
|
||||||
[eEthereumNetwork.tenderlyMain]: '',
|
[eEthereumNetwork.tenderly]: '',
|
||||||
},
|
},
|
||||||
TokenDistributor: {
|
TokenDistributor: {
|
||||||
[eEthereumNetwork.coverage]: '',
|
[eEthereumNetwork.coverage]: '',
|
||||||
|
|
@ -199,7 +202,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.kovan]: '0x971efe90088f21dc6a36f610ffed77fc19710708',
|
[eEthereumNetwork.kovan]: '0x971efe90088f21dc6a36f610ffed77fc19710708',
|
||||||
[eEthereumNetwork.ropsten]: '0xeba2ea67942b8250d870b12750b594696d02fc9c',
|
[eEthereumNetwork.ropsten]: '0xeba2ea67942b8250d870b12750b594696d02fc9c',
|
||||||
[eEthereumNetwork.main]: '0xe3d9988f676457123c5fd01297605efdd0cba1ae',
|
[eEthereumNetwork.main]: '0xe3d9988f676457123c5fd01297605efdd0cba1ae',
|
||||||
[eEthereumNetwork.tenderlyMain]: '0xe3d9988f676457123c5fd01297605efdd0cba1ae',
|
[eEthereumNetwork.tenderly]: '0xe3d9988f676457123c5fd01297605efdd0cba1ae',
|
||||||
},
|
},
|
||||||
AaveOracle: {
|
AaveOracle: {
|
||||||
[eEthereumNetwork.coverage]: '',
|
[eEthereumNetwork.coverage]: '',
|
||||||
|
|
@ -208,7 +211,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.kovan]: '0x8fb777d67e9945e2c01936e319057f9d41d559e6', // Need to re-deploy because of onlyOwner
|
[eEthereumNetwork.kovan]: '0x8fb777d67e9945e2c01936e319057f9d41d559e6', // Need to re-deploy because of onlyOwner
|
||||||
[eEthereumNetwork.ropsten]: ZERO_ADDRESS,
|
[eEthereumNetwork.ropsten]: ZERO_ADDRESS,
|
||||||
[eEthereumNetwork.main]: '', //'0xA50ba011c48153De246E5192C8f9258A2ba79Ca9', // Need to re-deploy because of onlyOwner
|
[eEthereumNetwork.main]: '', //'0xA50ba011c48153De246E5192C8f9258A2ba79Ca9', // Need to re-deploy because of onlyOwner
|
||||||
[eEthereumNetwork.tenderlyMain]: '0xA50ba011c48153De246E5192C8f9258A2ba79Ca9',
|
[eEthereumNetwork.tenderly]: '0xA50ba011c48153De246E5192C8f9258A2ba79Ca9',
|
||||||
},
|
},
|
||||||
FallbackOracle: {
|
FallbackOracle: {
|
||||||
[eEthereumNetwork.coverage]: '',
|
[eEthereumNetwork.coverage]: '',
|
||||||
|
|
@ -217,7 +220,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.kovan]: '0x50913E8E1c650E790F8a1E741FF9B1B1bB251dfe',
|
[eEthereumNetwork.kovan]: '0x50913E8E1c650E790F8a1E741FF9B1B1bB251dfe',
|
||||||
[eEthereumNetwork.ropsten]: '0xAD1a978cdbb8175b2eaeC47B01404f8AEC5f4F0d',
|
[eEthereumNetwork.ropsten]: '0xAD1a978cdbb8175b2eaeC47B01404f8AEC5f4F0d',
|
||||||
[eEthereumNetwork.main]: ZERO_ADDRESS,
|
[eEthereumNetwork.main]: ZERO_ADDRESS,
|
||||||
[eEthereumNetwork.tenderlyMain]: ZERO_ADDRESS,
|
[eEthereumNetwork.tenderly]: ZERO_ADDRESS,
|
||||||
},
|
},
|
||||||
ChainlinkAggregator: {
|
ChainlinkAggregator: {
|
||||||
[eEthereumNetwork.coverage]: {},
|
[eEthereumNetwork.coverage]: {},
|
||||||
|
|
@ -270,7 +273,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
BptBALWETH: '0x2e4e78936b100be6Ef85BCEf7FB25bC770B02B85',
|
BptBALWETH: '0x2e4e78936b100be6Ef85BCEf7FB25bC770B02B85',
|
||||||
USD: '0x9326BFA02ADD2366b30bacB125260Af641031331',
|
USD: '0x9326BFA02ADD2366b30bacB125260Af641031331',
|
||||||
},
|
},
|
||||||
[eEthereumNetwork.tenderlyMain]: {
|
[eEthereumNetwork.tenderly]: {
|
||||||
USDT: '0xEe9F2375b4bdF6387aa8265dD4FB8F16512A1d46',
|
USDT: '0xEe9F2375b4bdF6387aa8265dD4FB8F16512A1d46',
|
||||||
WBTC: '0xdeb288F737066589598e9214E782fa5A8eD689e8',
|
WBTC: '0xdeb288F737066589598e9214E782fa5A8eD689e8',
|
||||||
USDC: '0x986b5E1e1755e3C2440e960477f25201B0a8bbD4',
|
USDC: '0x986b5E1e1755e3C2440e960477f25201B0a8bbD4',
|
||||||
|
|
@ -301,7 +304,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.main]: {},
|
[eEthereumNetwork.main]: {},
|
||||||
[eEthereumNetwork.kovan]: {},
|
[eEthereumNetwork.kovan]: {},
|
||||||
[eEthereumNetwork.ropsten]: {},
|
[eEthereumNetwork.ropsten]: {},
|
||||||
[eEthereumNetwork.tenderlyMain]: {},
|
[eEthereumNetwork.tenderly]: {},
|
||||||
},
|
},
|
||||||
ReservesConfig: {},
|
ReservesConfig: {},
|
||||||
ATokenDomainSeparator: {
|
ATokenDomainSeparator: {
|
||||||
|
|
@ -314,7 +317,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.kovan]: '',
|
[eEthereumNetwork.kovan]: '',
|
||||||
[eEthereumNetwork.ropsten]: '',
|
[eEthereumNetwork.ropsten]: '',
|
||||||
[eEthereumNetwork.main]: '',
|
[eEthereumNetwork.main]: '',
|
||||||
[eEthereumNetwork.tenderlyMain]: '',
|
[eEthereumNetwork.tenderly]: '',
|
||||||
},
|
},
|
||||||
WETH: {
|
WETH: {
|
||||||
[eEthereumNetwork.coverage]: '', // deployed in local evm
|
[eEthereumNetwork.coverage]: '', // deployed in local evm
|
||||||
|
|
@ -323,7 +326,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.kovan]: '0xd0a1e359811322d97991e03f863a0c30c2cf029c',
|
[eEthereumNetwork.kovan]: '0xd0a1e359811322d97991e03f863a0c30c2cf029c',
|
||||||
[eEthereumNetwork.ropsten]: '0xc778417e063141139fce010982780140aa0cd5ab',
|
[eEthereumNetwork.ropsten]: '0xc778417e063141139fce010982780140aa0cd5ab',
|
||||||
[eEthereumNetwork.main]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
[eEthereumNetwork.main]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
||||||
[eEthereumNetwork.tenderlyMain]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
[eEthereumNetwork.tenderly]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
||||||
},
|
},
|
||||||
WrappedNativeToken: {
|
WrappedNativeToken: {
|
||||||
[eEthereumNetwork.coverage]: '', // deployed in local evm
|
[eEthereumNetwork.coverage]: '', // deployed in local evm
|
||||||
|
|
@ -332,7 +335,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.kovan]: '0xd0a1e359811322d97991e03f863a0c30c2cf029c',
|
[eEthereumNetwork.kovan]: '0xd0a1e359811322d97991e03f863a0c30c2cf029c',
|
||||||
[eEthereumNetwork.ropsten]: '0xc778417e063141139fce010982780140aa0cd5ab',
|
[eEthereumNetwork.ropsten]: '0xc778417e063141139fce010982780140aa0cd5ab',
|
||||||
[eEthereumNetwork.main]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
[eEthereumNetwork.main]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
||||||
[eEthereumNetwork.tenderlyMain]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
[eEthereumNetwork.tenderly]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
||||||
},
|
},
|
||||||
ReserveFactorTreasuryAddress: {
|
ReserveFactorTreasuryAddress: {
|
||||||
[eEthereumNetwork.coverage]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
|
[eEthereumNetwork.coverage]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
|
||||||
|
|
@ -341,7 +344,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.kovan]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
|
[eEthereumNetwork.kovan]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
|
||||||
[eEthereumNetwork.ropsten]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
|
[eEthereumNetwork.ropsten]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
|
||||||
[eEthereumNetwork.main]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
|
[eEthereumNetwork.main]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
|
||||||
[eEthereumNetwork.tenderlyMain]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
|
[eEthereumNetwork.tenderly]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
|
||||||
},
|
},
|
||||||
IncentivesController: {
|
IncentivesController: {
|
||||||
[eEthereumNetwork.coverage]: ZERO_ADDRESS,
|
[eEthereumNetwork.coverage]: ZERO_ADDRESS,
|
||||||
|
|
@ -350,6 +353,6 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.kovan]: ZERO_ADDRESS,
|
[eEthereumNetwork.kovan]: ZERO_ADDRESS,
|
||||||
[eEthereumNetwork.ropsten]: ZERO_ADDRESS,
|
[eEthereumNetwork.ropsten]: ZERO_ADDRESS,
|
||||||
[eEthereumNetwork.main]: ZERO_ADDRESS,
|
[eEthereumNetwork.main]: ZERO_ADDRESS,
|
||||||
[eEthereumNetwork.tenderlyMain]: ZERO_ADDRESS,
|
[eEthereumNetwork.tenderly]: ZERO_ADDRESS,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -83,8 +83,7 @@ export const AmmConfig: IAmmConfiguration = {
|
||||||
BptWBTCWETH: '0x110569E3261bC0934dA637b019f6f1b6F50ec574',
|
BptWBTCWETH: '0x110569E3261bC0934dA637b019f6f1b6F50ec574',
|
||||||
BptBALWETH: '0xad01D8e0Fa9EAA8Fe76dA30CFb1BCe12707aE6c5',
|
BptBALWETH: '0xad01D8e0Fa9EAA8Fe76dA30CFb1BCe12707aE6c5',
|
||||||
},
|
},
|
||||||
[eEthereumNetwork.ropsten]: {
|
[eEthereumNetwork.ropsten]: {},
|
||||||
},
|
|
||||||
[eEthereumNetwork.main]: {
|
[eEthereumNetwork.main]: {
|
||||||
DAI: '0x6B175474E89094C44Da98b954EedeAC495271d0F',
|
DAI: '0x6B175474E89094C44Da98b954EedeAC495271d0F',
|
||||||
USDC: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
USDC: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
||||||
|
|
@ -108,7 +107,7 @@ export const AmmConfig: IAmmConfiguration = {
|
||||||
BptWBTCWETH: '0x1efF8aF5D577060BA4ac8A29A13525bb0Ee2A3D5',
|
BptWBTCWETH: '0x1efF8aF5D577060BA4ac8A29A13525bb0Ee2A3D5',
|
||||||
BptBALWETH: '0x59A19D8c652FA0284f44113D0ff9aBa70bd46fB4',
|
BptBALWETH: '0x59A19D8c652FA0284f44113D0ff9aBa70bd46fB4',
|
||||||
},
|
},
|
||||||
[eEthereumNetwork.tenderlyMain]: {
|
[eEthereumNetwork.tenderly]: {
|
||||||
DAI: '0x6B175474E89094C44Da98b954EedeAC495271d0F',
|
DAI: '0x6B175474E89094C44Da98b954EedeAC495271d0F',
|
||||||
USDC: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
USDC: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
||||||
USDT: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
|
USDT: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
VariableDebtTokenNamePrefix: 'Aave Matic Market variable debt',
|
VariableDebtTokenNamePrefix: 'Aave Matic Market variable debt',
|
||||||
SymbolPrefix: 'm',
|
SymbolPrefix: 'm',
|
||||||
ProviderId: 0, // Overriden in index.ts
|
ProviderId: 0, // Overriden in index.ts
|
||||||
|
OracleQuoteCurrency: 'ETH',
|
||||||
|
OracleQuoteUnit: oneEther.toString(),
|
||||||
ProtocolGlobalParams: {
|
ProtocolGlobalParams: {
|
||||||
TokenDistributorPercentageBase: '10000',
|
TokenDistributorPercentageBase: '10000',
|
||||||
MockUsdPriceInWei: '5848466240000000',
|
MockUsdPriceInWei: '5848466240000000',
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
VariableDebtTokenNamePrefix: 'Aave XDAI Market variable debt',
|
VariableDebtTokenNamePrefix: 'Aave XDAI Market variable debt',
|
||||||
SymbolPrefix: 'm',
|
SymbolPrefix: 'm',
|
||||||
ProviderId: 0, // Overriden in index.ts
|
ProviderId: 0, // Overriden in index.ts
|
||||||
|
OracleQuoteCurrency: 'ETH',
|
||||||
ProtocolGlobalParams: {
|
ProtocolGlobalParams: {
|
||||||
TokenDistributorPercentageBase: '10000',
|
TokenDistributorPercentageBase: '10000',
|
||||||
MockUsdPriceInWei: '5848466240000000',
|
MockUsdPriceInWei: '5848466240000000',
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import { task } from 'hardhat/config';
|
import { task } from 'hardhat/config';
|
||||||
import {
|
import {
|
||||||
|
deployATokenImplementations,
|
||||||
deployATokensAndRatesHelper,
|
deployATokensAndRatesHelper,
|
||||||
deployLendingPool,
|
deployLendingPool,
|
||||||
deployLendingPoolConfigurator,
|
deployLendingPoolConfigurator,
|
||||||
|
|
@ -13,13 +14,15 @@ import {
|
||||||
getLendingPoolConfiguratorProxy,
|
getLendingPoolConfiguratorProxy,
|
||||||
} from '../../helpers/contracts-getters';
|
} from '../../helpers/contracts-getters';
|
||||||
import { insertContractAddressInDb } from '../../helpers/contracts-helpers';
|
import { insertContractAddressInDb } from '../../helpers/contracts-helpers';
|
||||||
|
import { ConfigNames, loadPoolConfig } from '../../helpers/configuration';
|
||||||
|
|
||||||
task('dev:deploy-lending-pool', 'Deploy lending pool for dev enviroment')
|
task('dev:deploy-lending-pool', 'Deploy lending pool for dev enviroment')
|
||||||
.addFlag('verify', 'Verify contracts at Etherscan')
|
.addFlag('verify', 'Verify contracts at Etherscan')
|
||||||
.setAction(async ({ verify }, localBRE) => {
|
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
|
||||||
|
.setAction(async ({ verify, pool }, localBRE) => {
|
||||||
await localBRE.run('set-DRE');
|
await localBRE.run('set-DRE');
|
||||||
|
|
||||||
const addressesProvider = await getLendingPoolAddressesProvider();
|
const addressesProvider = await getLendingPoolAddressesProvider();
|
||||||
|
const poolConfig = loadPoolConfig(pool);
|
||||||
|
|
||||||
const lendingPoolImpl = await deployLendingPool(verify);
|
const lendingPoolImpl = await deployLendingPool(verify);
|
||||||
|
|
||||||
|
|
@ -55,4 +58,5 @@ task('dev:deploy-lending-pool', 'Deploy lending pool for dev enviroment')
|
||||||
[lendingPoolProxy.address, addressesProvider.address, lendingPoolConfiguratorProxy.address],
|
[lendingPoolProxy.address, addressesProvider.address, lendingPoolConfiguratorProxy.address],
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
await deployATokenImplementations(pool, poolConfig.ReservesConfig, verify);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -12,14 +12,14 @@ import {
|
||||||
import { ICommonConfiguration, iAssetBase, TokenContractId } from '../../helpers/types';
|
import { ICommonConfiguration, iAssetBase, TokenContractId } from '../../helpers/types';
|
||||||
import { waitForTx } from '../../helpers/misc-utils';
|
import { waitForTx } from '../../helpers/misc-utils';
|
||||||
import { getAllAggregatorsAddresses, getAllTokenAddresses } from '../../helpers/mock-helpers';
|
import { getAllAggregatorsAddresses, getAllTokenAddresses } from '../../helpers/mock-helpers';
|
||||||
import { ConfigNames, loadPoolConfig, getWethAddress } from '../../helpers/configuration';
|
import { ConfigNames, loadPoolConfig, getQuoteCurrency } from '../../helpers/configuration';
|
||||||
import {
|
import {
|
||||||
getAllMockedTokens,
|
getAllMockedTokens,
|
||||||
getLendingPoolAddressesProvider,
|
getLendingPoolAddressesProvider,
|
||||||
getPairsTokenAggregator,
|
getPairsTokenAggregator,
|
||||||
} from '../../helpers/contracts-getters';
|
} from '../../helpers/contracts-getters';
|
||||||
|
|
||||||
task('dev:deploy-oracles', 'Deploy oracles for dev enviroment')
|
task('dev:deploy-oracles', 'Deploy oracles for dev environment')
|
||||||
.addFlag('verify', 'Verify contracts at Etherscan')
|
.addFlag('verify', 'Verify 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 ({ verify, pool }, localBRE) => {
|
.setAction(async ({ verify, pool }, localBRE) => {
|
||||||
|
|
@ -29,6 +29,8 @@ task('dev:deploy-oracles', 'Deploy oracles for dev enviroment')
|
||||||
Mocks: { AllAssetsInitialPrices },
|
Mocks: { AllAssetsInitialPrices },
|
||||||
ProtocolGlobalParams: { UsdAddress, MockUsdPriceInWei },
|
ProtocolGlobalParams: { UsdAddress, MockUsdPriceInWei },
|
||||||
LendingRateOracleRatesCommon,
|
LendingRateOracleRatesCommon,
|
||||||
|
OracleQuoteCurrency,
|
||||||
|
OracleQuoteUnit,
|
||||||
} = poolConfig as ICommonConfiguration;
|
} = poolConfig as ICommonConfiguration;
|
||||||
|
|
||||||
const defaultTokenList = {
|
const defaultTokenList = {
|
||||||
|
|
@ -54,11 +56,18 @@ task('dev:deploy-oracles', 'Deploy oracles for dev enviroment')
|
||||||
|
|
||||||
const [tokens, aggregators] = getPairsTokenAggregator(
|
const [tokens, aggregators] = getPairsTokenAggregator(
|
||||||
allTokenAddresses,
|
allTokenAddresses,
|
||||||
allAggregatorsAddresses
|
allAggregatorsAddresses,
|
||||||
|
OracleQuoteCurrency
|
||||||
);
|
);
|
||||||
|
|
||||||
await deployAaveOracle(
|
await deployAaveOracle(
|
||||||
[tokens, aggregators, fallbackOracle.address, await getWethAddress(poolConfig)],
|
[
|
||||||
|
tokens,
|
||||||
|
aggregators,
|
||||||
|
fallbackOracle.address,
|
||||||
|
await getQuoteCurrency(poolConfig),
|
||||||
|
OracleQuoteUnit,
|
||||||
|
],
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
await waitForTx(await addressesProvider.setPriceOracle(fallbackOracle.address));
|
await waitForTx(await addressesProvider.setPriceOracle(fallbackOracle.address));
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ task('dev:initialize-lending-pool', 'Initialize lending pool configuration.')
|
||||||
VariableDebtTokenNamePrefix,
|
VariableDebtTokenNamePrefix,
|
||||||
SymbolPrefix,
|
SymbolPrefix,
|
||||||
WethGateway,
|
WethGateway,
|
||||||
|
ReservesConfig,
|
||||||
} = poolConfig;
|
} = poolConfig;
|
||||||
const mockTokens = await getAllMockedTokens();
|
const mockTokens = await getAllMockedTokens();
|
||||||
const allTokenAddresses = getAllTokenAddresses(mockTokens);
|
const allTokenAddresses = getAllTokenAddresses(mockTokens);
|
||||||
|
|
@ -52,14 +53,12 @@ task('dev:initialize-lending-pool', 'Initialize lending pool configuration.')
|
||||||
|
|
||||||
const testHelpers = await deployAaveProtocolDataProvider(addressesProvider.address, verify);
|
const testHelpers = await deployAaveProtocolDataProvider(addressesProvider.address, verify);
|
||||||
|
|
||||||
const reservesParams = getReservesConfigByPool(AavePools.proto);
|
|
||||||
|
|
||||||
const admin = await addressesProvider.getPoolAdmin();
|
const admin = await addressesProvider.getPoolAdmin();
|
||||||
|
|
||||||
const treasuryAddress = await getTreasuryAddress(poolConfig);
|
const treasuryAddress = await getTreasuryAddress(poolConfig);
|
||||||
|
|
||||||
await initReservesByHelper(
|
await initReservesByHelper(
|
||||||
reservesParams,
|
ReservesConfig,
|
||||||
protoPoolReservesAddresses,
|
protoPoolReservesAddresses,
|
||||||
ATokenNamePrefix,
|
ATokenNamePrefix,
|
||||||
StableDebtTokenNamePrefix,
|
StableDebtTokenNamePrefix,
|
||||||
|
|
@ -68,9 +67,10 @@ task('dev:initialize-lending-pool', 'Initialize lending pool configuration.')
|
||||||
admin,
|
admin,
|
||||||
treasuryAddress,
|
treasuryAddress,
|
||||||
ZERO_ADDRESS,
|
ZERO_ADDRESS,
|
||||||
|
pool,
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
await configureReservesByHelper(reservesParams, protoPoolReservesAddresses, testHelpers, admin);
|
await configureReservesByHelper(ReservesConfig, protoPoolReservesAddresses, testHelpers, admin);
|
||||||
|
|
||||||
const collateralManager = await deployLendingPoolCollateralManager(verify);
|
const collateralManager = await deployLendingPoolCollateralManager(verify);
|
||||||
await waitForTx(
|
await waitForTx(
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { task } from 'hardhat/config';
|
import { task } from 'hardhat/config';
|
||||||
import { getParamPerNetwork, insertContractAddressInDb } from '../../helpers/contracts-helpers';
|
import { getParamPerNetwork, insertContractAddressInDb } from '../../helpers/contracts-helpers';
|
||||||
import {
|
import {
|
||||||
|
deployATokenImplementations,
|
||||||
deployATokensAndRatesHelper,
|
deployATokensAndRatesHelper,
|
||||||
deployLendingPool,
|
deployLendingPool,
|
||||||
deployLendingPoolConfigurator,
|
deployLendingPoolConfigurator,
|
||||||
|
|
@ -78,11 +79,12 @@ task('full:deploy-lending-pool', 'Deploy lending pool for dev enviroment')
|
||||||
[lendingPoolProxy.address, addressesProvider.address, lendingPoolConfiguratorProxy.address],
|
[lendingPoolProxy.address, addressesProvider.address, lendingPoolConfiguratorProxy.address],
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
await deployATokenImplementations(pool, poolConfig.ReservesConfig, verify);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (DRE.network.name.includes('tenderly')) {
|
if (DRE.network.name.includes('tenderly')) {
|
||||||
const transactionLink = `https://dashboard.tenderly.co/${DRE.config.tenderly.username}/${
|
const transactionLink = `https://dashboard.tenderly.co/${DRE.config.tenderly.username}/${
|
||||||
DRE.config.tenderly.project
|
DRE.config.tenderly.project
|
||||||
}/fork/${DRE.tenderlyNetwork.getFork()}/simulation/${DRE.tenderlyNetwork.getHead()}`;
|
}/fork/${DRE.tenderly.network().getFork()}/simulation/${DRE.tenderly.network().getHead()}`;
|
||||||
console.error('Check tx error:', transactionLink);
|
console.error('Check tx error:', transactionLink);
|
||||||
}
|
}
|
||||||
throw error;
|
throw error;
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@ import { waitForTx, notFalsyOrZeroAddress } from '../../helpers/misc-utils';
|
||||||
import {
|
import {
|
||||||
ConfigNames,
|
ConfigNames,
|
||||||
loadPoolConfig,
|
loadPoolConfig,
|
||||||
getWethAddress,
|
|
||||||
getGenesisPoolAdmin,
|
getGenesisPoolAdmin,
|
||||||
getLendingRateOracles,
|
getLendingRateOracles,
|
||||||
|
getQuoteCurrency,
|
||||||
} from '../../helpers/configuration';
|
} from '../../helpers/configuration';
|
||||||
import {
|
import {
|
||||||
getAaveOracle,
|
getAaveOracle,
|
||||||
|
|
@ -46,16 +46,27 @@ task('full:deploy-oracles', 'Deploy oracles for dev enviroment')
|
||||||
...reserveAssets,
|
...reserveAssets,
|
||||||
USD: UsdAddress,
|
USD: UsdAddress,
|
||||||
};
|
};
|
||||||
const [tokens, aggregators] = getPairsTokenAggregator(tokensToWatch, chainlinkAggregators);
|
const [tokens, aggregators] = getPairsTokenAggregator(
|
||||||
|
tokensToWatch,
|
||||||
|
chainlinkAggregators,
|
||||||
|
poolConfig.OracleQuoteCurrency
|
||||||
|
);
|
||||||
|
|
||||||
let aaveOracle: AaveOracle;
|
let aaveOracle: AaveOracle;
|
||||||
let lendingRateOracle: LendingRateOracle;
|
let lendingRateOracle: LendingRateOracle;
|
||||||
|
|
||||||
if (notFalsyOrZeroAddress(aaveOracleAddress)) {
|
if (notFalsyOrZeroAddress(aaveOracleAddress)) {
|
||||||
aaveOracle = await await getAaveOracle(aaveOracleAddress);
|
aaveOracle = await await getAaveOracle(aaveOracleAddress);
|
||||||
|
await waitForTx(await aaveOracle.setAssetSources(tokens, aggregators));
|
||||||
} else {
|
} else {
|
||||||
aaveOracle = await deployAaveOracle(
|
aaveOracle = await deployAaveOracle(
|
||||||
[tokens, aggregators, fallbackOracleAddress, await getWethAddress(poolConfig)],
|
[
|
||||||
|
tokens,
|
||||||
|
aggregators,
|
||||||
|
fallbackOracleAddress,
|
||||||
|
await getQuoteCurrency(poolConfig),
|
||||||
|
poolConfig.OracleQuoteUnit,
|
||||||
|
],
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
await waitForTx(await aaveOracle.setAssetSources(tokens, aggregators));
|
await waitForTx(await aaveOracle.setAssetSources(tokens, aggregators));
|
||||||
|
|
@ -74,7 +85,7 @@ task('full:deploy-oracles', 'Deploy oracles for dev enviroment')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Aave Oracle: %s', lendingRateOracle.address);
|
console.log('Aave Oracle: %s', aaveOracle.address);
|
||||||
console.log('Lending Rate Oracle: %s', lendingRateOracle.address);
|
console.log('Lending Rate Oracle: %s', lendingRateOracle.address);
|
||||||
|
|
||||||
// Register the proxy price provider on the addressesProvider
|
// Register the proxy price provider on the addressesProvider
|
||||||
|
|
@ -84,7 +95,7 @@ task('full:deploy-oracles', 'Deploy oracles for dev enviroment')
|
||||||
if (DRE.network.name.includes('tenderly')) {
|
if (DRE.network.name.includes('tenderly')) {
|
||||||
const transactionLink = `https://dashboard.tenderly.co/${DRE.config.tenderly.username}/${
|
const transactionLink = `https://dashboard.tenderly.co/${DRE.config.tenderly.username}/${
|
||||||
DRE.config.tenderly.project
|
DRE.config.tenderly.project
|
||||||
}/fork/${DRE.tenderlyNetwork.getFork()}/simulation/${DRE.tenderlyNetwork.getHead()}`;
|
}/fork/${DRE.tenderly.network().getFork()}/simulation/${DRE.tenderly.network().getHead()}`;
|
||||||
console.error('Check tx error:', transactionLink);
|
console.error('Check tx error:', transactionLink);
|
||||||
}
|
}
|
||||||
throw error;
|
throw error;
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
|
||||||
admin,
|
admin,
|
||||||
treasuryAddress,
|
treasuryAddress,
|
||||||
incentivesController,
|
incentivesController,
|
||||||
|
pool,
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
await configureReservesByHelper(ReservesConfig, reserveAssets, testHelpers, admin);
|
await configureReservesByHelper(ReservesConfig, reserveAssets, testHelpers, admin);
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@ 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';
|
||||||
import { chooseATokenDeployment } from '../../helpers/init-helpers';
|
|
||||||
import { getLendingPoolAddressesProvider } from './../../helpers/contracts-getters';
|
import { getLendingPoolAddressesProvider } from './../../helpers/contracts-getters';
|
||||||
import {
|
import {
|
||||||
|
chooseATokenDeployment,
|
||||||
deployDefaultReserveInterestRateStrategy,
|
deployDefaultReserveInterestRateStrategy,
|
||||||
deployStableDebtToken,
|
deployStableDebtToken,
|
||||||
deployVariableDebtToken,
|
deployVariableDebtToken,
|
||||||
|
|
@ -47,18 +47,7 @@ WRONG RESERVE ASSET SETUP:
|
||||||
LENDING_POOL_ADDRESS_PROVIDER[network]
|
LENDING_POOL_ADDRESS_PROVIDER[network]
|
||||||
);
|
);
|
||||||
const poolAddress = await addressProvider.getLendingPool();
|
const poolAddress = await addressProvider.getLendingPool();
|
||||||
const treasuryAddress = await getTreasuryAddress(marketConfigs.AaveConfig);
|
const aToken = await deployCustomAToken(verify);
|
||||||
const aToken = await deployCustomAToken(
|
|
||||||
[
|
|
||||||
poolAddress,
|
|
||||||
reserveAssetAddress,
|
|
||||||
treasuryAddress,
|
|
||||||
ZERO_ADDRESS, // Incentives Controller
|
|
||||||
`Aave interest bearing ${symbol}`,
|
|
||||||
`a${symbol}`,
|
|
||||||
],
|
|
||||||
verify
|
|
||||||
);
|
|
||||||
const stableDebt = await deployStableDebtToken(
|
const stableDebt = await deployStableDebtToken(
|
||||||
[
|
[
|
||||||
poolAddress,
|
poolAddress,
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ task('aave:dev', 'Deploy development enviroment')
|
||||||
await localBRE.run('dev:deploy-address-provider', { verify });
|
await localBRE.run('dev:deploy-address-provider', { verify });
|
||||||
|
|
||||||
console.log('3. Deploy lending pool');
|
console.log('3. Deploy lending pool');
|
||||||
await localBRE.run('dev:deploy-lending-pool', { verify });
|
await localBRE.run('dev:deploy-lending-pool', { verify, pool: POOL_NAME });
|
||||||
|
|
||||||
console.log('4. Deploy oracles');
|
console.log('4. Deploy oracles');
|
||||||
await localBRE.run('dev:deploy-oracles', { verify, pool: POOL_NAME });
|
await localBRE.run('dev:deploy-oracles', { verify, pool: POOL_NAME });
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@ import {
|
||||||
deployUniswapRepayAdapter,
|
deployUniswapRepayAdapter,
|
||||||
deployFlashLiquidationAdapter,
|
deployFlashLiquidationAdapter,
|
||||||
authorizeWETHGateway,
|
authorizeWETHGateway,
|
||||||
|
deployATokenImplementations,
|
||||||
} 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';
|
||||||
|
|
@ -49,7 +49,7 @@ import {
|
||||||
import { DRE, waitForTx } from '../../helpers/misc-utils';
|
import { DRE, waitForTx } from '../../helpers/misc-utils';
|
||||||
import { initReservesByHelper, configureReservesByHelper } from '../../helpers/init-helpers';
|
import { initReservesByHelper, configureReservesByHelper } from '../../helpers/init-helpers';
|
||||||
import AaveConfig from '../../markets/aave';
|
import AaveConfig from '../../markets/aave';
|
||||||
import { ZERO_ADDRESS } from '../../helpers/constants';
|
import { oneEther, ZERO_ADDRESS } from '../../helpers/constants';
|
||||||
import {
|
import {
|
||||||
getLendingPool,
|
getLendingPool,
|
||||||
getLendingPoolConfiguratorProxy,
|
getLendingPoolConfiguratorProxy,
|
||||||
|
|
@ -60,7 +60,6 @@ import { WETH9Mocked } from '../../types/WETH9Mocked';
|
||||||
const MOCK_USD_PRICE_IN_WEI = AaveConfig.ProtocolGlobalParams.MockUsdPriceInWei;
|
const MOCK_USD_PRICE_IN_WEI = AaveConfig.ProtocolGlobalParams.MockUsdPriceInWei;
|
||||||
const ALL_ASSETS_INITIAL_PRICES = AaveConfig.Mocks.AllAssetsInitialPrices;
|
const ALL_ASSETS_INITIAL_PRICES = AaveConfig.Mocks.AllAssetsInitialPrices;
|
||||||
const USD_ADDRESS = AaveConfig.ProtocolGlobalParams.UsdAddress;
|
const USD_ADDRESS = AaveConfig.ProtocolGlobalParams.UsdAddress;
|
||||||
const MOCK_CHAINLINK_AGGREGATORS_PRICES = AaveConfig.Mocks.AllAssetsInitialPrices;
|
|
||||||
const LENDING_RATE_ORACLE_RATES_COMMON = AaveConfig.LendingRateOracleRatesCommon;
|
const LENDING_RATE_ORACLE_RATES_COMMON = AaveConfig.LendingRateOracleRatesCommon;
|
||||||
|
|
||||||
const deployAllMockTokens = async (deployer: Signer) => {
|
const deployAllMockTokens = async (deployer: Signer) => {
|
||||||
|
|
@ -96,9 +95,13 @@ const deployAllMockTokens = async (deployer: Signer) => {
|
||||||
const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
console.time('setup');
|
console.time('setup');
|
||||||
const aaveAdmin = await deployer.getAddress();
|
const aaveAdmin = await deployer.getAddress();
|
||||||
|
const config = loadPoolConfig(ConfigNames.Aave);
|
||||||
|
|
||||||
const mockTokens = await deployAllMockTokens(deployer);
|
const mockTokens: {
|
||||||
console.log('Deployed mocks');
|
[symbol: string]: MockContract | MintableERC20 | WETH9Mocked;
|
||||||
|
} = {
|
||||||
|
...(await deployAllMockTokens(deployer)),
|
||||||
|
};
|
||||||
const addressesProvider = await deployLendingPoolAddressesProvider(AaveConfig.MarketId);
|
const addressesProvider = await deployLendingPoolAddressesProvider(AaveConfig.MarketId);
|
||||||
await waitForTx(await addressesProvider.setPoolAdmin(aaveAdmin));
|
await waitForTx(await addressesProvider.setPoolAdmin(aaveAdmin));
|
||||||
|
|
||||||
|
|
@ -196,8 +199,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
fallbackOracle
|
fallbackOracle
|
||||||
);
|
);
|
||||||
|
|
||||||
const mockAggregators = await deployAllMockAggregators(MOCK_CHAINLINK_AGGREGATORS_PRICES);
|
const mockAggregators = await deployAllMockAggregators(ALL_ASSETS_INITIAL_PRICES);
|
||||||
console.log('Mock aggs deployed');
|
|
||||||
const allTokenAddresses = Object.entries(mockTokens).reduce(
|
const allTokenAddresses = Object.entries(mockTokens).reduce(
|
||||||
(accum: { [tokenSymbol: string]: tEthereumAddress }, [tokenSymbol, tokenContract]) => ({
|
(accum: { [tokenSymbol: string]: tEthereumAddress }, [tokenSymbol, tokenContract]) => ({
|
||||||
...accum,
|
...accum,
|
||||||
|
|
@ -213,9 +215,19 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
|
|
||||||
const [tokens, aggregators] = getPairsTokenAggregator(allTokenAddresses, allAggregatorsAddresses);
|
const [tokens, aggregators] = getPairsTokenAggregator(
|
||||||
|
allTokenAddresses,
|
||||||
|
allAggregatorsAddresses,
|
||||||
|
config.OracleQuoteCurrency
|
||||||
|
);
|
||||||
|
|
||||||
await deployAaveOracle([tokens, aggregators, fallbackOracle.address, mockTokens.WETH.address]);
|
await deployAaveOracle([
|
||||||
|
tokens,
|
||||||
|
aggregators,
|
||||||
|
fallbackOracle.address,
|
||||||
|
mockTokens.WETH.address,
|
||||||
|
oneEther.toString(),
|
||||||
|
]);
|
||||||
await waitForTx(await addressesProvider.setPriceOracle(fallbackOracle.address));
|
await waitForTx(await addressesProvider.setPriceOracle(fallbackOracle.address));
|
||||||
|
|
||||||
const lendingRateOracle = await deployLendingRateOracle();
|
const lendingRateOracle = await deployLendingRateOracle();
|
||||||
|
|
@ -232,23 +244,19 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
aaveAdmin
|
aaveAdmin
|
||||||
);
|
);
|
||||||
|
|
||||||
const reservesParams = getReservesConfigByPool(AavePools.proto);
|
// Reserve params from AAVE pool + mocked tokens
|
||||||
|
const reservesParams = {
|
||||||
|
...config.ReservesConfig,
|
||||||
|
};
|
||||||
|
|
||||||
const testHelpers = await deployAaveProtocolDataProvider(addressesProvider.address);
|
const testHelpers = await deployAaveProtocolDataProvider(addressesProvider.address);
|
||||||
|
|
||||||
await insertContractAddressInDb(eContractid.AaveProtocolDataProvider, testHelpers.address);
|
await deployATokenImplementations(ConfigNames.Aave, reservesParams, false);
|
||||||
|
|
||||||
const admin = await deployer.getAddress();
|
const admin = await deployer.getAddress();
|
||||||
|
|
||||||
console.log('Initialize configuration');
|
const { ATokenNamePrefix, StableDebtTokenNamePrefix, VariableDebtTokenNamePrefix, SymbolPrefix } =
|
||||||
|
config;
|
||||||
const config = loadPoolConfig(ConfigNames.Aave);
|
|
||||||
|
|
||||||
const {
|
|
||||||
ATokenNamePrefix,
|
|
||||||
StableDebtTokenNamePrefix,
|
|
||||||
VariableDebtTokenNamePrefix,
|
|
||||||
SymbolPrefix,
|
|
||||||
} = config;
|
|
||||||
const treasuryAddress = await getTreasuryAddress(config);
|
const treasuryAddress = await getTreasuryAddress(config);
|
||||||
|
|
||||||
await initReservesByHelper(
|
await initReservesByHelper(
|
||||||
|
|
@ -261,6 +269,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
admin,
|
admin,
|
||||||
treasuryAddress,
|
treasuryAddress,
|
||||||
ZERO_ADDRESS,
|
ZERO_ADDRESS,
|
||||||
|
ConfigNames.Aave,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -299,7 +308,7 @@ before(async () => {
|
||||||
const FORK = process.env.FORK;
|
const FORK = process.env.FORK;
|
||||||
|
|
||||||
if (FORK) {
|
if (FORK) {
|
||||||
await rawBRE.run('aave:mainnet');
|
await rawBRE.run('aave:mainnet', { skipRegistry: true });
|
||||||
} else {
|
} else {
|
||||||
console.log('-> Deploying test environment...');
|
console.log('-> Deploying test environment...');
|
||||||
await buildTestEnv(deployer, secondaryWallet);
|
await buildTestEnv(deployer, secondaryWallet);
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ import {
|
||||||
deployUniswapRepayAdapter,
|
deployUniswapRepayAdapter,
|
||||||
deployFlashLiquidationAdapter,
|
deployFlashLiquidationAdapter,
|
||||||
authorizeWETHGateway,
|
authorizeWETHGateway,
|
||||||
|
deployATokenImplementations,
|
||||||
} from '../../helpers/contracts-deployments';
|
} from '../../helpers/contracts-deployments';
|
||||||
import { Signer } from 'ethers';
|
import { Signer } from 'ethers';
|
||||||
import { TokenContractId, eContractid, tEthereumAddress, AavePools } from '../../helpers/types';
|
import { TokenContractId, eContractid, tEthereumAddress, AavePools } from '../../helpers/types';
|
||||||
|
|
@ -48,7 +49,7 @@ import {
|
||||||
import { DRE, waitForTx } from '../../helpers/misc-utils';
|
import { DRE, waitForTx } from '../../helpers/misc-utils';
|
||||||
import { initReservesByHelper, configureReservesByHelper } from '../../helpers/init-helpers';
|
import { initReservesByHelper, configureReservesByHelper } from '../../helpers/init-helpers';
|
||||||
import AmmConfig from '../../markets/amm';
|
import AmmConfig from '../../markets/amm';
|
||||||
import { ZERO_ADDRESS } from '../../helpers/constants';
|
import { oneEther, ZERO_ADDRESS } from '../../helpers/constants';
|
||||||
import {
|
import {
|
||||||
getLendingPool,
|
getLendingPool,
|
||||||
getLendingPoolConfiguratorProxy,
|
getLendingPoolConfiguratorProxy,
|
||||||
|
|
@ -95,6 +96,14 @@ const deployAllMockTokens = async (deployer: Signer) => {
|
||||||
const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
console.time('setup');
|
console.time('setup');
|
||||||
const aaveAdmin = await deployer.getAddress();
|
const aaveAdmin = await deployer.getAddress();
|
||||||
|
const config = loadPoolConfig(ConfigNames.Amm);
|
||||||
|
const {
|
||||||
|
ATokenNamePrefix,
|
||||||
|
StableDebtTokenNamePrefix,
|
||||||
|
VariableDebtTokenNamePrefix,
|
||||||
|
SymbolPrefix,
|
||||||
|
ReservesConfig,
|
||||||
|
} = config;
|
||||||
|
|
||||||
const mockTokens = await deployAllMockTokens(deployer);
|
const mockTokens = await deployAllMockTokens(deployer);
|
||||||
|
|
||||||
|
|
@ -189,6 +198,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
WMATIC: mockTokens.WMATIC.address,
|
WMATIC: mockTokens.WMATIC.address,
|
||||||
USD: USD_ADDRESS,
|
USD: USD_ADDRESS,
|
||||||
STAKE: mockTokens.STAKE.address,
|
STAKE: mockTokens.STAKE.address,
|
||||||
|
xSUSHI: ZERO_ADDRESS,
|
||||||
},
|
},
|
||||||
fallbackOracle
|
fallbackOracle
|
||||||
);
|
);
|
||||||
|
|
@ -210,9 +220,19 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
|
|
||||||
const [tokens, aggregators] = getPairsTokenAggregator(allTokenAddresses, allAggregatorsAddresses);
|
const [tokens, aggregators] = getPairsTokenAggregator(
|
||||||
|
allTokenAddresses,
|
||||||
|
allAggregatorsAddresses,
|
||||||
|
config.OracleQuoteCurrency
|
||||||
|
);
|
||||||
|
|
||||||
await deployAaveOracle([tokens, aggregators, fallbackOracle.address, mockTokens.WETH.address]);
|
await deployAaveOracle([
|
||||||
|
tokens,
|
||||||
|
aggregators,
|
||||||
|
fallbackOracle.address,
|
||||||
|
mockTokens.WETH.address,
|
||||||
|
oneEther.toString(),
|
||||||
|
]);
|
||||||
await waitForTx(await addressesProvider.setPriceOracle(fallbackOracle.address));
|
await waitForTx(await addressesProvider.setPriceOracle(fallbackOracle.address));
|
||||||
|
|
||||||
const lendingRateOracle = await deployLendingRateOracle();
|
const lendingRateOracle = await deployLendingRateOracle();
|
||||||
|
|
@ -228,8 +248,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
lendingRateOracle,
|
lendingRateOracle,
|
||||||
aaveAdmin
|
aaveAdmin
|
||||||
);
|
);
|
||||||
|
await deployATokenImplementations(ConfigNames.Amm, ReservesConfig);
|
||||||
const reservesParams = getReservesConfigByPool(AavePools.amm);
|
|
||||||
|
|
||||||
const testHelpers = await deployAaveProtocolDataProvider(addressesProvider.address);
|
const testHelpers = await deployAaveProtocolDataProvider(addressesProvider.address);
|
||||||
|
|
||||||
|
|
@ -238,18 +257,10 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
|
|
||||||
console.log('Initialize configuration');
|
console.log('Initialize configuration');
|
||||||
|
|
||||||
const config = loadPoolConfig(ConfigNames.Amm);
|
|
||||||
|
|
||||||
const {
|
|
||||||
ATokenNamePrefix,
|
|
||||||
StableDebtTokenNamePrefix,
|
|
||||||
VariableDebtTokenNamePrefix,
|
|
||||||
SymbolPrefix,
|
|
||||||
} = config;
|
|
||||||
const treasuryAddress = await getTreasuryAddress(config);
|
const treasuryAddress = await getTreasuryAddress(config);
|
||||||
|
|
||||||
await initReservesByHelper(
|
await initReservesByHelper(
|
||||||
reservesParams,
|
ReservesConfig,
|
||||||
allReservesAddresses,
|
allReservesAddresses,
|
||||||
ATokenNamePrefix,
|
ATokenNamePrefix,
|
||||||
StableDebtTokenNamePrefix,
|
StableDebtTokenNamePrefix,
|
||||||
|
|
@ -258,9 +269,10 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
admin,
|
admin,
|
||||||
treasuryAddress,
|
treasuryAddress,
|
||||||
ZERO_ADDRESS,
|
ZERO_ADDRESS,
|
||||||
|
ConfigNames.Amm,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
await configureReservesByHelper(reservesParams, allReservesAddresses, testHelpers, admin);
|
await configureReservesByHelper(ReservesConfig, allReservesAddresses, testHelpers, admin);
|
||||||
|
|
||||||
const collateralManager = await deployLendingPoolCollateralManager();
|
const collateralManager = await deployLendingPoolCollateralManager();
|
||||||
await waitForTx(
|
await waitForTx(
|
||||||
|
|
@ -294,7 +306,7 @@ before(async () => {
|
||||||
const FORK = process.env.FORK;
|
const FORK = process.env.FORK;
|
||||||
|
|
||||||
if (FORK) {
|
if (FORK) {
|
||||||
await rawBRE.run('amm:mainnet');
|
await rawBRE.run('amm:mainnet', { skipRegistry: true });
|
||||||
} else {
|
} else {
|
||||||
console.log('-> Deploying test environment...');
|
console.log('-> Deploying test environment...');
|
||||||
await buildTestEnv(deployer, secondaryWallet);
|
await buildTestEnv(deployer, secondaryWallet);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user