@@ -13,7 +13,7 @@ import {
13
13
deployLendingPoolConfigurator ,
14
14
deployLendingPool ,
15
15
deployPriceOracle ,
16
- deployAaveOracle ,
16
+ deployAaveOracleV2 ,
17
17
deployLendingPoolCollateralManager ,
18
18
deployMockFlashLoanReceiver ,
19
19
deployWalletBalancerProvider ,
@@ -28,8 +28,8 @@ import {
28
28
deployUniswapRepayAdapter ,
29
29
deployFlashLiquidationAdapter ,
30
30
authorizeWETHGateway ,
31
+ deployATokenImplementations ,
31
32
} from '../../helpers/contracts-deployments' ;
32
- import { eEthereumNetwork } from '../../helpers/types' ;
33
33
import { Signer } from 'ethers' ;
34
34
import { TokenContractId , eContractid , tEthereumAddress , AavePools } from '../../helpers/types' ;
35
35
import { MintableERC20 } from '../../types/MintableERC20' ;
@@ -49,7 +49,7 @@ import {
49
49
import { DRE , waitForTx } from '../../helpers/misc-utils' ;
50
50
import { initReservesByHelper , configureReservesByHelper } from '../../helpers/init-helpers' ;
51
51
import AaveConfig from '../../markets/aave' ;
52
- import { ZERO_ADDRESS } from '../../helpers/constants' ;
52
+ import { oneEther , ZERO_ADDRESS } from '../../helpers/constants' ;
53
53
import {
54
54
getLendingPool ,
55
55
getLendingPoolConfiguratorProxy ,
@@ -60,7 +60,6 @@ import { WETH9Mocked } from '../../types/WETH9Mocked';
60
60
const MOCK_USD_PRICE_IN_WEI = AaveConfig . ProtocolGlobalParams . MockUsdPriceInWei ;
61
61
const ALL_ASSETS_INITIAL_PRICES = AaveConfig . Mocks . AllAssetsInitialPrices ;
62
62
const USD_ADDRESS = AaveConfig . ProtocolGlobalParams . UsdAddress ;
63
- const MOCK_CHAINLINK_AGGREGATORS_PRICES = AaveConfig . Mocks . AllAssetsInitialPrices ;
64
63
const LENDING_RATE_ORACLE_RATES_COMMON = AaveConfig . LendingRateOracleRatesCommon ;
65
64
66
65
const deployAllMockTokens = async ( deployer : Signer ) => {
@@ -96,9 +95,13 @@ const deployAllMockTokens = async (deployer: Signer) => {
96
95
const buildTestEnv = async ( deployer : Signer , secondaryWallet : Signer ) => {
97
96
console . time ( 'setup' ) ;
98
97
const aaveAdmin = await deployer . getAddress ( ) ;
98
+ const config = loadPoolConfig ( ConfigNames . Aave ) ;
99
99
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
+ } ;
102
105
const addressesProvider = await deployLendingPoolAddressesProvider ( AaveConfig . MarketId ) ;
103
106
await waitForTx ( await addressesProvider . setPoolAdmin ( aaveAdmin ) ) ;
104
107
@@ -196,8 +199,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
196
199
fallbackOracle
197
200
) ;
198
201
199
- const mockAggregators = await deployAllMockAggregators ( MOCK_CHAINLINK_AGGREGATORS_PRICES ) ;
200
- console . log ( 'Mock aggs deployed' ) ;
202
+ const mockAggregators = await deployAllMockAggregators ( ALL_ASSETS_INITIAL_PRICES ) ;
201
203
const allTokenAddresses = Object . entries ( mockTokens ) . reduce (
202
204
( accum : { [ tokenSymbol : string ] : tEthereumAddress } , [ tokenSymbol , tokenContract ] ) => ( {
203
205
...accum ,
@@ -213,9 +215,19 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
213
215
{ }
214
216
) ;
215
217
216
- const [ tokens , aggregators ] = getPairsTokenAggregator ( allTokenAddresses , allAggregatorsAddresses ) ;
218
+ const [ tokens , aggregators ] = getPairsTokenAggregator (
219
+ allTokenAddresses ,
220
+ allAggregatorsAddresses ,
221
+ config . OracleQuoteCurrency
222
+ ) ;
217
223
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
+ ] ) ;
219
231
await waitForTx ( await addressesProvider . setPriceOracle ( fallbackOracle . address ) ) ;
220
232
221
233
const lendingRateOracle = await deployLendingRateOracle ( ) ;
@@ -232,23 +244,19 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
232
244
aaveAdmin
233
245
) ;
234
246
235
- const reservesParams = getReservesConfigByPool ( AavePools . proto ) ;
247
+ // Reserve params from AAVE pool + mocked tokens
248
+ const reservesParams = {
249
+ ...config . ReservesConfig ,
250
+ } ;
236
251
237
252
const testHelpers = await deployAaveProtocolDataProvider ( addressesProvider . address ) ;
238
253
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 ) ;
243
255
244
- const config = loadPoolConfig ( ConfigNames . Aave ) ;
256
+ const admin = await deployer . getAddress ( ) ;
245
257
246
- const {
247
- ATokenNamePrefix,
248
- StableDebtTokenNamePrefix,
249
- VariableDebtTokenNamePrefix,
250
- SymbolPrefix,
251
- } = config ;
258
+ const { ATokenNamePrefix, StableDebtTokenNamePrefix, VariableDebtTokenNamePrefix, SymbolPrefix } =
259
+ config ;
252
260
const treasuryAddress = await getTreasuryAddress ( config ) ;
253
261
254
262
await initReservesByHelper (
@@ -261,6 +269,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
261
269
admin ,
262
270
treasuryAddress ,
263
271
ZERO_ADDRESS ,
272
+ ConfigNames . Aave ,
264
273
false
265
274
) ;
266
275
@@ -298,7 +307,7 @@ before(async () => {
298
307
const FORK = process . env . FORK ;
299
308
300
309
if ( FORK ) {
301
- await rawBRE . run ( 'aave:mainnet' ) ;
310
+ await rawBRE . run ( 'aave:mainnet' , { skipRegistry : true } ) ;
302
311
} else {
303
312
console . log ( '-> Deploying test environment...' ) ;
304
313
await buildTestEnv ( deployer , secondaryWallet ) ;
0 commit comments