@@ -112,12 +112,16 @@ abstract contract HorizonBaseTest is Test {
112112 test_priceFeed (token, params);
113113 }
114114
115- function test_eMode (uint8 eModeCategory , EModeCategoryParams memory params ) internal {
115+ function test_eMode (
116+ uint8 eModeCategory ,
117+ EModeCategoryParams memory params ,
118+ bool dealCollateral
119+ ) internal {
116120 test_eMode_configuration (eModeCategory, params);
117- test_eMode_collateralization (eModeCategory, params);
121+ test_eMode_collateralization (eModeCategory, params, true );
118122 }
119123
120- function test_getConfiguration (address token , TokenListingParams memory params ) private view {
124+ function test_getConfiguration (address token , TokenListingParams memory params ) internal view {
121125 DataTypes.ReserveConfigurationMap memory config = pool.getConfiguration (token);
122126 assertEq (config.getSupplyCap (), params.supplyCap, 'supplyCap ' );
123127 assertEq (config.getBorrowCap (), params.borrowCap, 'borrowCap ' );
@@ -139,7 +143,10 @@ abstract contract HorizonBaseTest is Test {
139143 assertEq (config.getPaused (), false , 'paused ' );
140144 }
141145
142- function test_interestRateStrategy (address token , TokenListingParams memory params ) private view {
146+ function test_interestRateStrategy (
147+ address token ,
148+ TokenListingParams memory params
149+ ) internal view {
143150 assertEq (
144151 pool.getReserveData (token).interestRateStrategyAddress,
145152 address (defaultInterestRateStrategy),
@@ -148,7 +155,7 @@ abstract contract HorizonBaseTest is Test {
148155 assertEq (defaultInterestRateStrategy.getInterestRateData (token), params.interestRateData);
149156 }
150157
151- function test_aToken (address token , TokenListingParams memory params ) private {
158+ function test_aToken (address token , TokenListingParams memory params ) internal {
152159 address aToken = pool.getReserveAToken (token);
153160 assertEq (IERC20Detailed (aToken).name (), params.aTokenName, 'aTokenName ' );
154161 assertEq (IERC20Detailed (aToken).symbol (), params.aTokenSymbol, 'aTokenSymbol ' );
@@ -258,7 +265,8 @@ abstract contract HorizonBaseTest is Test {
258265
259266 function test_eMode_collateralization (
260267 uint8 eModeCategory ,
261- EModeCategoryParams memory params
268+ EModeCategoryParams memory params ,
269+ bool dealCollateral
262270 ) internal {
263271 address poolConfigurator = pool.ADDRESSES_PROVIDER ().getPoolConfigurator ();
264272
@@ -267,14 +275,16 @@ abstract contract HorizonBaseTest is Test {
267275
268276 IAaveOracle oracle = IAaveOracle (pool.ADDRESSES_PROVIDER ().getPriceOracle ());
269277 for (uint256 i = 0 ; i < params.collateralAssets.length ; i++ ) {
270- uint256 amountInBaseCurrency = 1e6 * 1e8 ;
278+ uint256 amountInBaseCurrency = 1e5 * 1e8 ;
271279
272280 uint256 supplyAmount = (amountInBaseCurrency *
273281 10 ** IERC20Detailed (params.collateralAssets[i]).decimals ()) /
274282 oracle.getAssetPrice (params.collateralAssets[i]) +
275283 1 ;
276284 address collateralAsset = params.collateralAssets[i];
277- deal (collateralAsset, alice, supplyAmount);
285+ if (dealCollateral) {
286+ deal (collateralAsset, alice, supplyAmount);
287+ }
278288
279289 vm.startPrank (alice);
280290 IERC20Detailed (collateralAsset).approve (address (pool), supplyAmount);
@@ -315,7 +325,8 @@ abstract contract HorizonBaseTest is Test {
315325 function test_nonEMode_collateralization (
316326 address token ,
317327 TokenListingParams memory params ,
318- address [] memory borrowableAssets
328+ address [] memory borrowableAssets ,
329+ bool dealCollateral
319330 ) internal {
320331 address poolConfigurator = pool.ADDRESSES_PROVIDER ().getPoolConfigurator ();
321332
@@ -326,45 +337,43 @@ abstract contract HorizonBaseTest is Test {
326337 oracle.getAssetPrice (token) +
327338 1 ;
328339
329- // deal(token, alice, supplyAmount);
330- vm.prank (0x69133f8Ef7F9A5F80D25c2DAEaea64C804aC7Cf9 );
331- IERC20 (token).transfer (alice, supplyAmount);
332-
333- // console.log('pool', address(pool));
340+ if (dealCollateral) {
341+ deal (token, alice, supplyAmount);
342+ }
334343
335344 vm.startPrank (alice);
336345 IERC20Detailed (token).approve (address (pool), supplyAmount);
337346 pool.supply (token, supplyAmount, alice, 0 );
338347 vm.stopPrank ();
339348
340- // for (uint256 j = 0; j < borrowableAssets.length; j++) {
341- // address borrowAsset = borrowableAssets[j];
342- // uint256 borrowAmount = (amountInBaseCurrency.percentMul(params.ltv) *
343- // 10 ** IERC20Detailed(borrowAsset).decimals()) /
344- // oracle.getAssetPrice(borrowAsset) -
345- // 1;
349+ for (uint256 j = 0 ; j < borrowableAssets.length ; j++ ) {
350+ address borrowAsset = borrowableAssets[j];
351+ uint256 borrowAmount = (amountInBaseCurrency.percentMul (params.ltv) *
352+ 10 ** IERC20Detailed (borrowAsset).decimals ()) /
353+ oracle.getAssetPrice (borrowAsset) -
354+ 1 ;
346355
347- // deal(borrowAsset, bob, borrowAmount);
356+ deal (borrowAsset, bob, borrowAmount);
348357
349- // vm.startPrank(bob);
350- // IERC20Detailed(borrowAsset).approve(address(pool), borrowAmount);
351- // pool.supply(borrowAsset, borrowAmount, bob, 0);
352- // vm.stopPrank();
358+ vm.startPrank (bob);
359+ IERC20Detailed (borrowAsset).approve (address (pool), borrowAmount);
360+ pool.supply (borrowAsset, borrowAmount, bob, 0 );
361+ vm.stopPrank ();
353362
354- // vm.prank(alice);
355- // pool.borrow(borrowAsset, borrowAmount, 2, 0, alice);
363+ vm.prank (alice);
364+ pool.borrow (borrowAsset, borrowAmount, 2 , 0 , alice);
356365
357- // vm.startPrank(alice);
358- // IERC20Detailed(borrowAsset).approve(address(pool), borrowAmount);
359- // pool.repay(borrowAsset, borrowAmount, 2, alice);
360- // vm.stopPrank();
366+ vm.startPrank (alice);
367+ IERC20Detailed (borrowAsset).approve (address (pool), borrowAmount);
368+ pool.repay (borrowAsset, borrowAmount, 2 , alice);
369+ vm.stopPrank ();
361370
362- // vm.prank(bob);
363- // pool.withdraw(borrowAsset, borrowAmount, bob);
364- // }
371+ vm.prank (bob);
372+ pool.withdraw (borrowAsset, borrowAmount, bob);
373+ }
365374
366- // vm.prank(alice);
367- // pool.withdraw(token, supplyAmount, alice);
375+ vm.prank (alice);
376+ pool.withdraw (token, supplyAmount, alice);
368377 }
369378
370379 function assertEq (
@@ -394,12 +403,19 @@ abstract contract HorizonBaseTest is Test {
394403 assertEq (abi.encode (a), abi.encode (b), 'assertEq(interestRateData): all fields ' );
395404 }
396405
397- function _toDynamicAddressArray (address a ) private pure returns (address [] memory ) {
406+ function _toDynamicAddressArray (address a ) internal pure returns (address [] memory ) {
398407 address [] memory array = new address [](1 );
399408 array[0 ] = a;
400409 return array;
401410 }
402411
412+ function _toDynamicAddressArray (address a , address b ) internal pure returns (address [] memory ) {
413+ address [] memory array = new address [](2 );
414+ array[0 ] = a;
415+ array[1 ] = b;
416+ return array;
417+ }
418+
403419 function _toDynamicAddressArray (
404420 address a ,
405421 address b ,
0 commit comments