@@ -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
@@ -195,8 +198,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
195198 fallbackOracle
196199 ) ;
197200
198- const mockAggregators = await deployAllMockAggregators ( MOCK_CHAINLINK_AGGREGATORS_PRICES ) ;
199- console . log ( 'Mock aggs deployed' ) ;
201+ const mockAggregators = await deployAllMockAggregators ( ALL_ASSETS_INITIAL_PRICES ) ;
200202 const allTokenAddresses = Object . entries ( mockTokens ) . reduce (
201203 ( accum : { [ tokenSymbol : string ] : tEthereumAddress } , [ tokenSymbol , tokenContract ] ) => ( {
202204 ...accum ,
@@ -212,9 +214,19 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
212214 { }
213215 ) ;
214216
215- const [ tokens , aggregators ] = getPairsTokenAggregator ( allTokenAddresses , allAggregatorsAddresses ) ;
217+ const [ tokens , aggregators ] = getPairsTokenAggregator (
218+ allTokenAddresses ,
219+ allAggregatorsAddresses ,
220+ config . OracleQuoteCurrency
221+ ) ;
216222
217- await deployAaveOracle ( [ tokens , aggregators , fallbackOracle . address , mockTokens . WETH . address ] ) ;
223+ await deployAaveOracleV2 ( [
224+ tokens ,
225+ aggregators ,
226+ fallbackOracle . address ,
227+ mockTokens . WETH . address ,
228+ oneEther . toString ( ) ,
229+ ] ) ;
218230 await waitForTx ( await addressesProvider . setPriceOracle ( fallbackOracle . address ) ) ;
219231
220232 const lendingRateOracle = await deployLendingRateOracle ( ) ;
@@ -231,23 +243,19 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
231243 aaveAdmin
232244 ) ;
233245
234- const reservesParams = getReservesConfigByPool ( AavePools . proto ) ;
246+ // Reserve params from AAVE pool + mocked tokens
247+ const reservesParams = {
248+ ...config . ReservesConfig ,
249+ } ;
235250
236251 const testHelpers = await deployAaveProtocolDataProvider ( addressesProvider . address ) ;
237252
238- await insertContractAddressInDb ( eContractid . AaveProtocolDataProvider , testHelpers . address ) ;
239- const admin = await deployer . getAddress ( ) ;
240-
241- console . log ( 'Initialize configuration' ) ;
253+ await deployATokenImplementations ( ConfigNames . Aave , reservesParams , false ) ;
242254
243- const config = loadPoolConfig ( ConfigNames . Aave ) ;
255+ const admin = await deployer . getAddress ( ) ;
244256
245- const {
246- ATokenNamePrefix,
247- StableDebtTokenNamePrefix,
248- VariableDebtTokenNamePrefix,
249- SymbolPrefix,
250- } = config ;
257+ const { ATokenNamePrefix, StableDebtTokenNamePrefix, VariableDebtTokenNamePrefix, SymbolPrefix } =
258+ config ;
251259 const treasuryAddress = await getTreasuryAddress ( config ) ;
252260
253261 await initReservesByHelper (
@@ -260,6 +268,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
260268 admin ,
261269 treasuryAddress ,
262270 ZERO_ADDRESS ,
271+ ConfigNames . Aave ,
263272 false
264273 ) ;
265274
@@ -297,7 +306,7 @@ before(async () => {
297306 const FORK = process . env . FORK ;
298307
299308 if ( FORK ) {
300- await rawBRE . run ( 'aave:mainnet' ) ;
309+ await rawBRE . run ( 'aave:mainnet' , { skipRegistry : true } ) ;
301310 } else {
302311 console . log ( '-> Deploying test environment...' ) ;
303312 await buildTestEnv ( deployer , secondaryWallet ) ;
0 commit comments