@@ -13,7 +13,7 @@ import {
1313 deployLendingPoolConfigurator ,
1414 deployLendingPool ,
1515 deployPriceOracle ,
16- deployAaveOracle ,
16+ deployAaveOracleV2 ,
1717 deployLendingPoolCollateralManager ,
1818 deployMockFlashLoanReceiver ,
1919 deployWalletBalancerProvider ,
@@ -28,8 +28,8 @@ import {
2828 deployUniswapRepayAdapter ,
2929 deployFlashLiquidationAdapter ,
3030 authorizeWETHGateway ,
31+ deployATokenImplementations ,
3132} from '../../helpers/contracts-deployments' ;
32- import { eEthereumNetwork } from '../../helpers/types' ;
3333import { Signer } from 'ethers' ;
3434import { TokenContractId , eContractid , tEthereumAddress , AavePools } from '../../helpers/types' ;
3535import { MintableERC20 } from '../../types/MintableERC20' ;
@@ -49,7 +49,7 @@ import {
4949import { DRE , waitForTx } from '../../helpers/misc-utils' ;
5050import { initReservesByHelper , configureReservesByHelper } from '../../helpers/init-helpers' ;
5151import AaveConfig from '../../markets/aave' ;
52- import { ZERO_ADDRESS } from '../../helpers/constants' ;
52+ import { oneEther , ZERO_ADDRESS } from '../../helpers/constants' ;
5353import {
5454 getLendingPool ,
5555 getLendingPoolConfiguratorProxy ,
@@ -60,7 +60,6 @@ import { WETH9Mocked } from '../../types/WETH9Mocked';
6060const MOCK_USD_PRICE_IN_WEI = AaveConfig . ProtocolGlobalParams . MockUsdPriceInWei ;
6161const ALL_ASSETS_INITIAL_PRICES = AaveConfig . Mocks . AllAssetsInitialPrices ;
6262const USD_ADDRESS = AaveConfig . ProtocolGlobalParams . UsdAddress ;
63- const MOCK_CHAINLINK_AGGREGATORS_PRICES = AaveConfig . Mocks . AllAssetsInitialPrices ;
6463const LENDING_RATE_ORACLE_RATES_COMMON = AaveConfig . LendingRateOracleRatesCommon ;
6564
6665const deployAllMockTokens = async ( deployer : Signer ) => {
@@ -96,9 +95,13 @@ const deployAllMockTokens = async (deployer: Signer) => {
9695const buildTestEnv = async ( deployer : Signer , secondaryWallet : Signer ) => {
9796 console . time ( 'setup' ) ;
9897 const aaveAdmin = await deployer . getAddress ( ) ;
98+ const config = loadPoolConfig ( ConfigNames . Aave ) ;
9999
100- const mockTokens = await deployAllMockTokens ( deployer ) ;
101- console . log ( 'Deployed mocks' ) ;
100+ const mockTokens : {
101+ [ symbol : string ] : MockContract | MintableERC20 | WETH9Mocked ;
102+ } = {
103+ ...( await deployAllMockTokens ( deployer ) ) ,
104+ } ;
102105 const addressesProvider = await deployLendingPoolAddressesProvider ( AaveConfig . MarketId ) ;
103106 await waitForTx ( await addressesProvider . setPoolAdmin ( aaveAdmin ) ) ;
104107
@@ -196,8 +199,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
196199 fallbackOracle
197200 ) ;
198201
199- const mockAggregators = await deployAllMockAggregators ( MOCK_CHAINLINK_AGGREGATORS_PRICES ) ;
200- console . log ( 'Mock aggs deployed' ) ;
202+ const mockAggregators = await deployAllMockAggregators ( ALL_ASSETS_INITIAL_PRICES ) ;
201203 const allTokenAddresses = Object . entries ( mockTokens ) . reduce (
202204 ( accum : { [ tokenSymbol : string ] : tEthereumAddress } , [ tokenSymbol , tokenContract ] ) => ( {
203205 ...accum ,
@@ -213,9 +215,19 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
213215 { }
214216 ) ;
215217
216- const [ tokens , aggregators ] = getPairsTokenAggregator ( allTokenAddresses , allAggregatorsAddresses ) ;
218+ const [ tokens , aggregators ] = getPairsTokenAggregator (
219+ allTokenAddresses ,
220+ allAggregatorsAddresses ,
221+ config . OracleQuoteCurrency
222+ ) ;
217223
218- await deployAaveOracle ( [ tokens , aggregators , fallbackOracle . address , mockTokens . WETH . address ] ) ;
224+ await deployAaveOracleV2 ( [
225+ tokens ,
226+ aggregators ,
227+ fallbackOracle . address ,
228+ mockTokens . WETH . address ,
229+ oneEther . toString ( ) ,
230+ ] ) ;
219231 await waitForTx ( await addressesProvider . setPriceOracle ( fallbackOracle . address ) ) ;
220232
221233 const lendingRateOracle = await deployLendingRateOracle ( ) ;
@@ -232,23 +244,19 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
232244 aaveAdmin
233245 ) ;
234246
235- const reservesParams = getReservesConfigByPool ( AavePools . proto ) ;
247+ // Reserve params from AAVE pool + mocked tokens
248+ const reservesParams = {
249+ ...config . ReservesConfig ,
250+ } ;
236251
237252 const testHelpers = await deployAaveProtocolDataProvider ( addressesProvider . address ) ;
238253
239- await insertContractAddressInDb ( eContractid . AaveProtocolDataProvider , testHelpers . address ) ;
240- const admin = await deployer . getAddress ( ) ;
241-
242- console . log ( 'Initialize configuration' ) ;
254+ await deployATokenImplementations ( ConfigNames . Aave , reservesParams , false ) ;
243255
244- const config = loadPoolConfig ( ConfigNames . Aave ) ;
256+ const admin = await deployer . getAddress ( ) ;
245257
246- const {
247- ATokenNamePrefix,
248- StableDebtTokenNamePrefix,
249- VariableDebtTokenNamePrefix,
250- SymbolPrefix,
251- } = config ;
258+ const { ATokenNamePrefix, StableDebtTokenNamePrefix, VariableDebtTokenNamePrefix, SymbolPrefix } =
259+ config ;
252260 const treasuryAddress = await getTreasuryAddress ( config ) ;
253261
254262 await initReservesByHelper (
@@ -261,6 +269,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
261269 admin ,
262270 treasuryAddress ,
263271 ZERO_ADDRESS ,
272+ ConfigNames . Aave ,
264273 false
265274 ) ;
266275
@@ -298,7 +307,7 @@ before(async () => {
298307 const FORK = process . env . FORK ;
299308
300309 if ( FORK ) {
301- await rawBRE . run ( 'aave:mainnet' ) ;
310+ await rawBRE . run ( 'aave:mainnet' , { skipRegistry : true } ) ;
302311 } else {
303312 console . log ( '-> Deploying test environment...' ) ;
304313 await buildTestEnv ( deployer , secondaryWallet ) ;
0 commit comments