Added correct library placheholder hashes. Fix imports.

This commit is contained in:
David Racero 2020-10-16 11:27:09 +02:00
parent 7556f25c1a
commit e0627ce66b
18 changed files with 66 additions and 72 deletions

View File

@ -15,7 +15,7 @@ import {MintableErc20 as MintableERC20} from '../types/MintableErc20';
import {readArtifact} from '@nomiclabs/buidler/plugins';
import {MockContract} from 'ethereum-waffle';
import {getReservesConfigByPool} from './configuration';
import {getFirstSigner, getGenericLogic} from './contracts-getters';
import {getFirstSigner, getReserveLogic} from './contracts-getters';
import {ZERO_ADDRESS} from './constants';
import {
AaveProtocolTestHelpersFactory,
@ -115,17 +115,22 @@ export const deployAaveLibraries = async (
const genericLogic = await deployGenericLogic(verify);
const validationLogic = await deployValidationLogic(reserveLogic, genericLogic, verify);
console.log('generic logic address LEND POOL', genericLogic.address);
// Hardcoded solidity placeholders, if any library changes path this will fail.
// Placeholder can be calculated via solidity keccak, but the LendingPoolLibraryAddresses Type seems to
// The '__$PLACEHOLDER$__ can be calculated via solidity keccak, but the LendingPoolLibraryAddresses Type seems to
// require a hardcoded string.
//
// how-to: PLACEHOLDER = solidityKeccak256(['string'], `${libPath}:${libName}`).slice(2, 36)
// '__$PLACEHOLDER$__'
// how-to:
// 1. PLACEHOLDER = solidityKeccak256(['string'], `${libPath}:${libName}`).slice(2, 36)
// 2. LIB_PLACEHOLDER = `__$${PLACEHOLDER}$__`
// or grab placeholdes from LendingPoolLibraryAddresses at Typechain generation.
//
// libPath example: contracts/libraries/logic/GenericLogic.sol
// libName example: GenericLogic
return {
['__$5201a97c05ba6aa659e2f36a933dd51801$__']: reserveLogic.address,
['__$d3b4366daeb9cadc7528af6145b50b2183$__']: genericLogic.address,
['__$4c26be947d349222af871a3168b3fe584b$__']: validationLogic.address,
['__$5201a97c05ba6aa659e2f36a933dd51801$__']: validationLogic.address,
['__$d3b4366daeb9cadc7528af6145b50b2183$__']: reserveLogic.address,
['__$4c26be947d349222af871a3168b3fe584b$__']: genericLogic.address,
};
};
@ -175,10 +180,10 @@ export const deployChainlinkProxyPriceProvider = async (
);
export const deployLendingPoolCollateralManager = async (verify?: boolean) => {
const genericLogic = await getGenericLogic();
const reservesLogic = await getReserveLogic();
const libraries = {
// See deployAaveLibraries() function
['__$d3b4366daeb9cadc7528af6145b50b2183$__']: genericLogic.address,
['__$d3b4366daeb9cadc7528af6145b50b2183$__']: reservesLogic.address,
};
return withSaveAndVerify(
@ -256,7 +261,7 @@ export const deployDefaultReserveInterestRateStrategy = async (
);
export const deployStableDebtToken = async (
args: [string, string, tEthereumAddress, tEthereumAddress, tEthereumAddress],
args: [tEthereumAddress, tEthereumAddress, string, string, tEthereumAddress],
verify: boolean
) =>
withSaveAndVerify(
@ -267,7 +272,7 @@ export const deployStableDebtToken = async (
);
export const deployVariableDebtToken = async (
args: [string, string, tEthereumAddress, tEthereumAddress, tEthereumAddress],
args: [tEthereumAddress, tEthereumAddress, string, string, tEthereumAddress],
verify: boolean
) =>
withSaveAndVerify(
@ -295,7 +300,7 @@ export const deployGenericAToken = async (
string,
tEthereumAddress
] = [poolAddress, underlyingAssetAddress, ZERO_ADDRESS, name, symbol, incentivesController];
withSaveAndVerify(
return withSaveAndVerify(
await new ATokenFactory(await getFirstSigner()).deploy(...args),
eContractid.VariableDebtToken,
args,

View File

@ -196,24 +196,16 @@ export const getLendingPoolAddressesProviderRegistry = async (address?: tEthereu
await getFirstSigner()
);
export const getReserveLogicLibrary = async (address?: tEthereumAddress) =>
export const getReserveLogic = async (address?: tEthereumAddress) =>
await ReserveLogicFactory.connect(
address ||
(
await getDb()
.get(`${eContractid.LendingPoolAddressesProviderRegistry}.${BRE.network.name}`)
.value()
).address,
(await getDb().get(`${eContractid.ReserveLogic}.${BRE.network.name}`).value()).address,
await getFirstSigner()
);
export const getGenericLogic = async (address?: tEthereumAddress) =>
await GenericLogicFactory.connect(
address ||
(
await getDb()
.get(`${eContractid.LendingPoolAddressesProviderRegistry}.${BRE.network.name}`)
.value()
).address,
(await getDb().get(`${eContractid.GenericLogic}.${BRE.network.name}`).value()).address,
await getFirstSigner()
);

View File

@ -8,7 +8,8 @@ import {
deployStableDebtToken,
deployVariableDebtToken,
deployGenericAToken,
} from './contracts-helpers';
} from './contracts-deployments';
import {getEthersSigners} from './contracts-helpers';
export const enableReservesToBorrow = async (
reservesParams: iMultiPoolsAssets<IReserveParams>,
@ -151,10 +152,10 @@ export const initReserves = async (
console.log('- Deploy stable deb totken ', assetSymbol);
const stableDebtToken = await deployStableDebtToken(
[
lendingPool.address,
tokenAddress,
`Aave stable debt bearing ${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
`stableDebt${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
tokenAddress,
lendingPool.address,
incentivesController,
],
verify
@ -163,10 +164,10 @@ export const initReserves = async (
console.log('- Deploy var deb totken ', assetSymbol);
const variableDebtToken = await deployVariableDebtToken(
[
lendingPool.address,
tokenAddress,
`Aave variable debt bearing ${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
`variableDebt${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
tokenAddress,
lendingPool.address,
incentivesController,
],
verify

View File

@ -11,7 +11,7 @@ import {
import {LendingRateOracle} from '../types/LendingRateOracle';
import {PriceOracle} from '../types/PriceOracle';
import {MockAggregator} from '../types/MockAggregator';
import {deployMockAggregator, getContract, MockTokenMap} from './contracts-helpers';
import {deployMockAggregator} from './contracts-deployments';
import {waitForTx} from './misc-utils';
import {verifyContract} from './etherscan-verification';
@ -47,9 +47,7 @@ export const setInitialAssetPricesInOracle = async (
const [, assetAddress] = (Object.entries(assetsAddresses) as [string, string][])[
assetAddressIndex
];
console.log('PRIOR');
await waitForTx(await priceOracleInstance.setAssetPrice(assetAddress, price));
console.log('AFTA');
}
};

View File

@ -1,5 +1,5 @@
import {task} from '@nomiclabs/buidler/config';
import {deployAllMockTokens} from '../../helpers/contracts-helpers';
import {deployAllMockTokens} from '../../helpers/contracts-deployments';
task('dev:deploy-mock-tokens', 'Deploy mock tokens for dev enviroment')
.addOptionalParam('verify', 'Verify contracts at Etherscan')
.setAction(async ({verify}, localBRE) => {

View File

@ -2,7 +2,7 @@ import {task} from '@nomiclabs/buidler/config';
import {
deployLendingPoolAddressesProvider,
deployLendingPoolAddressesProviderRegistry,
} from '../../helpers/contracts-helpers';
} from '../../helpers/contracts-deployments';
import {waitForTx} from '../../helpers/misc-utils';
task(

View File

@ -1,9 +1,8 @@
import {task} from '@nomiclabs/buidler/config';
import {
deployLendingPool,
insertContractAddressInDb,
deployLendingPoolConfigurator,
} from '../../helpers/contracts-helpers';
} from '../../helpers/contracts-deployments';
import {eContractid} from '../../helpers/types';
import {waitForTx} from '../../helpers/misc-utils';
import {
@ -11,6 +10,7 @@ import {
getLendingPool,
getLendingPoolConfiguratorProxy,
} from '../../helpers/contracts-getters';
import {insertContractAddressInDb} from '../../helpers/contracts-helpers';
task('dev:deploy-lending-pool', 'Deploy lending pool for dev enviroment')
.addOptionalParam('verify', 'Verify contracts at Etherscan')

View File

@ -3,7 +3,7 @@ import {
deployPriceOracle,
deployChainlinkProxyPriceProvider,
deployLendingRateOracle,
} from '../../helpers/contracts-helpers';
} from '../../helpers/contracts-deployments';
import {
setInitialAssetPricesInOracle,

View File

@ -1,17 +1,19 @@
import {task} from '@nomiclabs/buidler/config';
import {
initReserves,
deployLendingPoolCollateralManager,
insertContractAddressInDb,
deployMockFlashLoanReceiver,
deployWalletBalancerProvider,
deployAaveProtocolTestHelpers,
} from '../../helpers/contracts-helpers';
} from '../../helpers/contracts-deployments';
import {getReservesConfigByPool} from '../../helpers/configuration';
import {tEthereumAddress, AavePools, eContractid} from '../../helpers/types';
import {waitForTx, filterMapBy} from '../../helpers/misc-utils';
import {enableReservesToBorrow, enableReservesAsCollateral} from '../../helpers/init-helpers';
import {
enableReservesToBorrow,
enableReservesAsCollateral,
initReserves,
} from '../../helpers/init-helpers';
import {getAllTokenAddresses} from '../../helpers/mock-helpers';
import {ZERO_ADDRESS} from '../../helpers/constants';
import {
@ -20,6 +22,7 @@ import {
getLendingPoolConfiguratorProxy,
getLendingPoolAddressesProvider,
} from '../../helpers/contracts-getters';
import {insertContractAddressInDb} from '../../helpers/contracts-helpers';
task('dev:initialize-lending-pool', 'Initialize lending pool configuration.')
.addOptionalParam('verify', 'Verify contracts at Etherscan')

View File

@ -1,9 +1,9 @@
import {task} from '@nomiclabs/buidler/config';
import {getParamPerNetwork} from '../../helpers/contracts-helpers';
import {
deployLendingPoolAddressesProvider,
deployLendingPoolAddressesProviderRegistry,
getParamPerNetwork,
} from '../../helpers/contracts-helpers';
} from '../../helpers/contracts-deployments';
import {waitForTx} from '../../helpers/misc-utils';
import {ConfigNames, loadPoolConfig, getGenesisAaveAdmin} from '../../helpers/configuration';
import {eEthereumNetwork} from '../../helpers/types';

View File

@ -1,9 +1,9 @@
import {task} from '@nomiclabs/buidler/config';
import {insertContractAddressInDb} from '../../helpers/contracts-helpers';
import {
deployLendingPool,
insertContractAddressInDb,
deployLendingPoolConfigurator,
} from '../../helpers/contracts-helpers';
} from '../../helpers/contracts-deployments';
import {eContractid} from '../../helpers/types';
import {waitForTx} from '../../helpers/misc-utils';
import {

View File

@ -1,10 +1,9 @@
import {task} from '@nomiclabs/buidler/config';
import {getParamPerNetwork} from '../../helpers/contracts-helpers';
import {
deployChainlinkProxyPriceProvider,
deployLendingRateOracle,
getParamPerNetwork,
} from '../../helpers/contracts-helpers';
} from '../../helpers/contracts-deployments';
import {setInitialMarketRatesInRatesOracle} from '../../helpers/oracles-helpers';
import {ICommonConfiguration, eEthereumNetwork, SymbolMap} from '../../helpers/types';
import {waitForTx, filterMapBy} from '../../helpers/misc-utils';

View File

@ -1,16 +1,18 @@
import {task} from '@nomiclabs/buidler/config';
import {getParamPerNetwork} from '../../helpers/contracts-helpers';
import {
initReserves,
deployLendingPoolCollateralManager,
deployWalletBalancerProvider,
deployAaveProtocolTestHelpers,
getParamPerNetwork,
} from '../../helpers/contracts-helpers';
} from '../../helpers/contracts-deployments';
import {loadPoolConfig, ConfigNames} from '../../helpers/configuration';
import {AavePools, eContractid, eEthereumNetwork, ICommonConfiguration} from '../../helpers/types';
import {AavePools, eEthereumNetwork, ICommonConfiguration} from '../../helpers/types';
import {waitForTx} from '../../helpers/misc-utils';
import {enableReservesToBorrow, enableReservesAsCollateral} from '../../helpers/init-helpers';
import {
enableReservesToBorrow,
enableReservesAsCollateral,
initReserves,
} from '../../helpers/init-helpers';
import {ZERO_ADDRESS} from '../../helpers/constants';
import {exit} from 'process';
import {

View File

@ -1,5 +1,10 @@
import rawBRE from '@nomiclabs/buidler';
import {MockContract} from 'ethereum-waffle';
import {
insertContractAddressInDb,
getEthersSigners,
registerContractInJsonDb,
} from '../helpers/contracts-helpers';
import {
deployLendingPoolAddressesProvider,
deployMintableERC20,
@ -11,20 +16,15 @@ import {
deployLendingPoolCollateralManager,
deployMockFlashLoanReceiver,
deployWalletBalancerProvider,
insertContractAddressInDb,
deployAaveProtocolTestHelpers,
getEthersSigners,
registerContractInJsonDb,
initReserves,
deployMockSwapAdapter,
deployLendingRateOracle,
} from '../helpers/contracts-helpers';
} from '../helpers/contracts-deployments';
import {Signer} from 'ethers';
import {TokenContractId, eContractid, tEthereumAddress, AavePools} from '../helpers/types';
import {MintableErc20 as MintableERC20} from '../types/MintableErc20';
import {getReservesConfigByPool} from '../helpers/configuration';
import {initializeMakeSuite} from './helpers/make-suite';
import {AaveProtocolTestHelpers} from '../types/AaveProtocolTestHelpers';
import {
setInitialAssetPricesInOracle,
@ -32,7 +32,11 @@ import {
deployAllMockAggregators,
} from '../helpers/oracles-helpers';
import {waitForTx} from '../helpers/misc-utils';
import {enableReservesToBorrow, enableReservesAsCollateral} from '../helpers/init-helpers';
import {
enableReservesToBorrow,
enableReservesAsCollateral,
initReserves,
} from '../helpers/init-helpers';
import {AaveConfig} from '../config/aave';
import {ZERO_ADDRESS} from '../helpers/constants';
import {
@ -95,14 +99,9 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
await waitForTx(await addressesProvider.setLendingPoolImpl(lendingPoolImpl.address));
console.log('Added pool to addresses provider');
const address = await addressesProvider.getLendingPool();
console.log('Address is ', address);
const lendingPoolProxy = await getLendingPool(address);
console.log('implementation set, address:', lendingPoolProxy.address);
await insertContractAddressInDb(eContractid.LendingPool, lendingPoolProxy.address);
const lendingPoolConfiguratorImpl = await deployLendingPoolConfigurator();
@ -112,6 +111,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
const lendingPoolConfiguratorProxy = await getLendingPoolConfiguratorProxy(
await addressesProvider.getLendingPoolConfigurator()
);
console.log('proxy address', lendingPoolConfiguratorProxy.address);
await insertContractAddressInDb(
eContractid.LendingPoolConfigurator,
lendingPoolConfiguratorProxy.address
@ -152,10 +152,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
fallbackOracle
);
console.log('setted prices');
console.log('prior mocks');
const mockAggregators = await deployAllMockAggregators(MOCK_CHAINLINK_AGGREGATORS_PRICES);
console.log('aftahlocks');
const allTokenAddresses = Object.entries(mockTokens).reduce(
(accum: {[tokenSymbol: string]: tEthereumAddress}, [tokenSymbol, tokenContract]) => ({

View File

@ -28,7 +28,6 @@ import {ReserveData, UserReserveData} from './utils/interfaces';
import {ContractReceipt} from 'ethers';
import {AToken} from '../../types/AToken';
import {RateMode, tEthereumAddress} from '../../helpers/types';
import {time} from 'console';
const {expect} = chai;

View File

@ -27,7 +27,6 @@ import {LendingPoolAddressesProvider} from '../../types/LendingPoolAddressesProv
import {MockSwapAdapter} from '../../types/MockSwapAdapter';
import {LendingPoolAddressesProviderRegistry} from '../../types/LendingPoolAddressesProviderRegistry';
import {getEthersSigners} from '../../helpers/contracts-helpers';
import {AaveProtocolTestHelpersFactory} from '../../types';
chai.use(bignumberChai());
chai.use(almostEqual());

View File

@ -5,7 +5,6 @@ import {
MAX_UINT_AMOUNT,
OPTIMAL_UTILIZATION_RATE,
EXCESS_UTILIZATION_RATE,
ZERO_ADDRESS,
} from '../../../helpers/constants';
import {IReserveParams, iAavePoolAssets, RateMode, tEthereumAddress} from '../../../helpers/types';
import './math';

View File

@ -5,7 +5,7 @@ import {ProtocolErrors} from '../helpers/types';
import {ethers} from 'ethers';
import {ZERO_ADDRESS} from '../helpers/constants';
import {waitForTx} from '../helpers/misc-utils';
import {deployLendingPool} from '../helpers/contracts-helpers';
import {deployLendingPool} from '../helpers/contracts-deployments';
const {utils} = ethers;