From 4c2cda0f63326d986a7a7e68da32f9570623a450 Mon Sep 17 00:00:00 2001 From: Steven Valeri Date: Mon, 29 Aug 2022 14:52:09 -0400 Subject: [PATCH] fix: remove formatting conflicts --- test-suites/configurator.spec.ts | 169 +++++++++++++++-------------- test-suites/pool-flashloan.spec.ts | 69 ++++++------ 2 files changed, 122 insertions(+), 116 deletions(-) diff --git a/test-suites/configurator.spec.ts b/test-suites/configurator.spec.ts index df0b9d420..34a681997 100644 --- a/test-suites/configurator.spec.ts +++ b/test-suites/configurator.spec.ts @@ -1,9 +1,9 @@ -import {expect} from 'chai'; -import {utils, BigNumber, BigNumberish} from 'ethers'; -import {strategyWETH} from '@aave/deploy-v3/dist/markets/test/reservesConfigs'; -import {getFirstSigner} from '@aave/deploy-v3/dist/helpers/utilities/signer'; -import {MAX_UINT_AMOUNT, ONE_ADDRESS, RAY, ZERO_ADDRESS} from '../helpers/constants'; -import {ProtocolErrors} from '../helpers/types'; +import { expect } from 'chai'; +import { utils, BigNumber, BigNumberish } from 'ethers'; +import { strategyWETH } from '@aave/deploy-v3/dist/markets/test/reservesConfigs'; +import { getFirstSigner } from '@aave/deploy-v3/dist/helpers/utilities/signer'; +import { MAX_UINT_AMOUNT, ONE_ADDRESS, RAY, ZERO_ADDRESS } from '../helpers/constants'; +import { ProtocolErrors } from '../helpers/types'; import { AaveProtocolDataProvider, AToken__factory, @@ -12,8 +12,8 @@ import { StableDebtToken__factory, VariableDebtToken__factory, } from '../types'; -import {TestEnv, makeSuite} from './helpers/make-suite'; -import {advanceTimeAndBlock, evmRevert, evmSnapshot} from '@aave/deploy-v3'; +import { TestEnv, makeSuite } from './helpers/make-suite'; +import { advanceTimeAndBlock, evmRevert, evmSnapshot } from '@aave/deploy-v3'; type ReserveConfigurationValues = { reserveDecimals: string; @@ -85,7 +85,8 @@ const getReserveData = async (helpersContract: AaveProtocolDataProvider, asset: makeSuite('PoolConfigurator', (testEnv: TestEnv) => { let baseConfigValues: ReserveConfigurationValues; - const {RESERVE_LIQUIDITY_NOT_ZERO, INVALID_DEBT_CEILING, RESERVE_DEBT_NOT_ZERO} = ProtocolErrors; + const { RESERVE_LIQUIDITY_NOT_ZERO, INVALID_DEBT_CEILING, RESERVE_DEBT_NOT_ZERO } = + ProtocolErrors; before(() => { const { @@ -118,7 +119,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('InitReserves via AssetListing admin', async () => { - const {addressesProvider, configurator, poolAdmin, aclManager, users, pool} = testEnv; + const { addressesProvider, configurator, poolAdmin, aclManager, users, pool } = testEnv; // const snapId const assetListingAdmin = users[4]; @@ -187,21 +188,21 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Deactivates the ETH reserve', async () => { - const {configurator, weth, helpersContract} = testEnv; + const { configurator, weth, helpersContract } = testEnv; expect(await configurator.setReserveActive(weth.address, false)); - const {isActive} = await helpersContract.getReserveConfigurationData(weth.address); + const { isActive } = await helpersContract.getReserveConfigurationData(weth.address); expect(isActive).to.be.equal(false); }); it('Reactivates the ETH reserve', async () => { - const {configurator, weth, helpersContract} = testEnv; + const { configurator, weth, helpersContract } = testEnv; expect(await configurator.setReserveActive(weth.address, true)); - const {isActive} = await helpersContract.getReserveConfigurationData(weth.address); + const { isActive } = await helpersContract.getReserveConfigurationData(weth.address); expect(isActive).to.be.equal(true); }); it('Pauses the ETH reserve by pool admin', async () => { - const {configurator, weth, helpersContract} = testEnv; + const { configurator, weth, helpersContract } = testEnv; expect(await configurator.setReservePause(weth.address, true)) .to.emit(configurator, 'ReservePaused') .withArgs(weth.address, true); @@ -213,16 +214,16 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Unpauses the ETH reserve by pool admin', async () => { - const {configurator, helpersContract, weth} = testEnv; + const { configurator, helpersContract, weth } = testEnv; expect(await configurator.setReservePause(weth.address, false)) .to.emit(configurator, 'ReservePaused') .withArgs(weth.address, false); - await expectReserveConfigurationData(helpersContract, weth.address, {...baseConfigValues}); + await expectReserveConfigurationData(helpersContract, weth.address, { ...baseConfigValues }); }); it('Pauses the ETH reserve by emergency admin', async () => { - const {configurator, weth, helpersContract, emergencyAdmin} = testEnv; + const { configurator, weth, helpersContract, emergencyAdmin } = testEnv; expect(await configurator.connect(emergencyAdmin.signer).setReservePause(weth.address, true)) .to.emit(configurator, 'ReservePaused') .withArgs(weth.address, true); @@ -234,16 +235,16 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Unpauses the ETH reserve by emergency admin', async () => { - const {configurator, helpersContract, weth, emergencyAdmin} = testEnv; + const { configurator, helpersContract, weth, emergencyAdmin } = testEnv; expect(await configurator.connect(emergencyAdmin.signer).setReservePause(weth.address, false)) .to.emit(configurator, 'ReservePaused') .withArgs(weth.address, false); - await expectReserveConfigurationData(helpersContract, weth.address, {...baseConfigValues}); + await expectReserveConfigurationData(helpersContract, weth.address, { ...baseConfigValues }); }); it('Freezes the ETH reserve by pool Admin', async () => { - const {configurator, weth, helpersContract} = testEnv; + const { configurator, weth, helpersContract } = testEnv; expect(await configurator.setReserveFreeze(weth.address, true)) .to.emit(configurator, 'ReserveFrozen') @@ -256,16 +257,16 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Unfreezes the ETH reserve by Pool admin', async () => { - const {configurator, helpersContract, weth} = testEnv; + const { configurator, helpersContract, weth } = testEnv; expect(await configurator.setReserveFreeze(weth.address, false)) .to.emit(configurator, 'ReserveFrozen') .withArgs(weth.address, false); - await expectReserveConfigurationData(helpersContract, weth.address, {...baseConfigValues}); + await expectReserveConfigurationData(helpersContract, weth.address, { ...baseConfigValues }); }); it('Freezes the ETH reserve by Risk Admin', async () => { - const {configurator, weth, helpersContract, riskAdmin} = testEnv; + const { configurator, weth, helpersContract, riskAdmin } = testEnv; expect(await configurator.connect(riskAdmin.signer).setReserveFreeze(weth.address, true)) .to.emit(configurator, 'ReserveFrozen') .withArgs(weth.address, true); @@ -277,16 +278,16 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Unfreezes the ETH reserve by Risk admin', async () => { - const {configurator, helpersContract, weth, riskAdmin} = testEnv; + const { configurator, helpersContract, weth, riskAdmin } = testEnv; expect(await configurator.connect(riskAdmin.signer).setReserveFreeze(weth.address, false)) .to.emit(configurator, 'ReserveFrozen') .withArgs(weth.address, false); - await expectReserveConfigurationData(helpersContract, weth.address, {...baseConfigValues}); + await expectReserveConfigurationData(helpersContract, weth.address, { ...baseConfigValues }); }); it('Deactivates the ETH reserve for borrowing via pool admin while stable borrowing is active (revert expected)', async () => { - const {configurator, helpersContract, weth} = testEnv; + const { configurator, helpersContract, weth } = testEnv; await expect(configurator.setReserveBorrowing(weth.address, false)).to.be.revertedWith( ProtocolErrors.STABLE_BORROWING_ENABLED ); @@ -296,7 +297,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Deactivates the ETH reserve for borrowing via risk admin while stable borrowing is active (revert expected)', async () => { - const {configurator, helpersContract, weth, riskAdmin} = testEnv; + const { configurator, helpersContract, weth, riskAdmin } = testEnv; await expect( configurator.connect(riskAdmin.signer).setReserveBorrowing(weth.address, false) @@ -309,7 +310,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { it('Disable stable borrow rate on the ETH reserve via pool admin', async () => { const snap = await evmSnapshot(); - const {configurator, helpersContract, weth} = testEnv; + const { configurator, helpersContract, weth } = testEnv; expect(await configurator.setReserveStableRateBorrowing(weth.address, false)) .to.emit(configurator, 'ReserveStableRateBorrowing') .withArgs(weth.address, false); @@ -322,7 +323,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Disable stable borrow rate on the ETH reserve via risk admin', async () => { - const {configurator, helpersContract, weth, riskAdmin} = testEnv; + const { configurator, helpersContract, weth, riskAdmin } = testEnv; expect( await configurator .connect(riskAdmin.signer) @@ -339,7 +340,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { it('Deactivates the ETH reserve for borrowing via pool admin', async () => { const snap = await evmSnapshot(); - const {configurator, helpersContract, weth} = testEnv; + const { configurator, helpersContract, weth } = testEnv; expect(await configurator.setReserveBorrowing(weth.address, false)) .to.emit(configurator, 'ReserveBorrowing') .withArgs(weth.address, false); @@ -353,7 +354,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Deactivates the ETH reserve for borrowing via risk admin', async () => { - const {configurator, helpersContract, weth, riskAdmin} = testEnv; + const { configurator, helpersContract, weth, riskAdmin } = testEnv; expect(await configurator.connect(riskAdmin.signer).setReserveBorrowing(weth.address, false)) .to.emit(configurator, 'ReserveBorrowing') .withArgs(weth.address, false); @@ -366,7 +367,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Enables stable borrow rate on the ETH reserve via pool admin while borrowing is disabled (revert expected)', async () => { - const {configurator, helpersContract, weth} = testEnv; + const { configurator, helpersContract, weth } = testEnv; await expect(configurator.setReserveStableRateBorrowing(weth.address, true)).to.be.revertedWith( ProtocolErrors.BORROWING_NOT_ENABLED ); @@ -379,7 +380,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Enables stable borrow rate on the ETH reserve via risk admin while borrowing is disabled (revert expected)', async () => { - const {configurator, helpersContract, weth, riskAdmin} = testEnv; + const { configurator, helpersContract, weth, riskAdmin } = testEnv; await expect( configurator.connect(riskAdmin.signer).setReserveStableRateBorrowing(weth.address, true) ).to.be.revertedWith(ProtocolErrors.BORROWING_NOT_ENABLED); @@ -393,12 +394,12 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { it('Activates the ETH reserve for borrowing via pool admin', async () => { const snap = await evmSnapshot(); - const {configurator, weth, helpersContract} = testEnv; + const { configurator, weth, helpersContract } = testEnv; expect(await configurator.setReserveBorrowing(weth.address, true)) .to.emit(configurator, 'ReserveBorrowing') .withArgs(weth.address, true); - const {variableBorrowIndex} = await helpersContract.getReserveData(weth.address); + const { variableBorrowIndex } = await helpersContract.getReserveData(weth.address); await expectReserveConfigurationData(helpersContract, weth.address, { ...baseConfigValues, @@ -409,12 +410,12 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Activates the ETH reserve for borrowing via risk admin', async () => { - const {configurator, weth, helpersContract, riskAdmin} = testEnv; + const { configurator, weth, helpersContract, riskAdmin } = testEnv; expect(await configurator.connect(riskAdmin.signer).setReserveBorrowing(weth.address, true)) .to.emit(configurator, 'ReserveBorrowing') .withArgs(weth.address, true); - const {variableBorrowIndex} = await helpersContract.getReserveData(weth.address); + const { variableBorrowIndex } = await helpersContract.getReserveData(weth.address); await expectReserveConfigurationData(helpersContract, weth.address, { ...baseConfigValues, @@ -425,7 +426,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { it('Enables stable borrow rate on the ETH reserve via pool admin', async () => { const snap = await evmSnapshot(); - const {configurator, helpersContract, weth} = testEnv; + const { configurator, helpersContract, weth } = testEnv; expect(await configurator.setReserveStableRateBorrowing(weth.address, true)) .to.emit(configurator, 'ReserveStableRateBorrowing') .withArgs(weth.address, true); @@ -437,7 +438,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Enables stable borrow rate on the ETH reserve via risk admin', async () => { - const {configurator, helpersContract, weth, riskAdmin} = testEnv; + const { configurator, helpersContract, weth, riskAdmin } = testEnv; expect( await configurator.connect(riskAdmin.signer).setReserveStableRateBorrowing(weth.address, true) ) @@ -450,7 +451,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Deactivates the ETH reserve as collateral via pool admin', async () => { - const {configurator, helpersContract, weth} = testEnv; + const { configurator, helpersContract, weth } = testEnv; expect(await configurator.configureReserveAsCollateral(weth.address, 0, 0, 0)) .to.emit(configurator, 'CollateralConfigurationChanged') .withArgs(weth.address, 0, 0, 0); @@ -465,7 +466,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Activates the ETH reserve as collateral via pool admin', async () => { - const {configurator, helpersContract, weth} = testEnv; + const { configurator, helpersContract, weth } = testEnv; expect(await configurator.configureReserveAsCollateral(weth.address, '8000', '8250', '10500')) .to.emit(configurator, 'CollateralConfigurationChanged') .withArgs(weth.address, '8000', '8250', '10500'); @@ -479,7 +480,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Deactivates the ETH reserve as collateral via risk admin', async () => { - const {configurator, helpersContract, weth, riskAdmin} = testEnv; + const { configurator, helpersContract, weth, riskAdmin } = testEnv; expect( await configurator .connect(riskAdmin.signer) @@ -498,7 +499,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Activates the ETH reserve as collateral via risk admin', async () => { - const {configurator, helpersContract, weth, riskAdmin} = testEnv; + const { configurator, helpersContract, weth, riskAdmin } = testEnv; expect( await configurator .connect(riskAdmin.signer) @@ -516,9 +517,9 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Changes the reserve factor of WETH via pool admin', async () => { - const {configurator, helpersContract, weth} = testEnv; + const { configurator, helpersContract, weth } = testEnv; - const {reserveFactor: oldReserveFactor} = await helpersContract.getReserveConfigurationData( + const { reserveFactor: oldReserveFactor } = await helpersContract.getReserveConfigurationData( weth.address ); @@ -534,9 +535,9 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Changes the reserve factor of WETH via risk admin', async () => { - const {configurator, helpersContract, weth, riskAdmin} = testEnv; + const { configurator, helpersContract, weth, riskAdmin } = testEnv; - const {reserveFactor: oldReserveFactor} = await helpersContract.getReserveConfigurationData( + const { reserveFactor: oldReserveFactor } = await helpersContract.getReserveConfigurationData( weth.address ); @@ -555,9 +556,9 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { it('Updates the reserve factor of WETH equal to PERCENTAGE_FACTOR', async () => { const snapId = await evmSnapshot(); - const {configurator, helpersContract, weth, poolAdmin} = testEnv; + const { configurator, helpersContract, weth, poolAdmin } = testEnv; - const {reserveFactor: oldReserveFactor} = await helpersContract.getReserveConfigurationData( + const { reserveFactor: oldReserveFactor } = await helpersContract.getReserveConfigurationData( weth.address ); @@ -576,7 +577,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Updates the unbackedMintCap of WETH via pool admin', async () => { - const {configurator, helpersContract, weth} = testEnv; + const { configurator, helpersContract, weth } = testEnv; const oldWethUnbackedMintCap = await helpersContract.getUnbackedMintCap(weth.address); @@ -589,7 +590,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Updates the unbackedMintCap of WETH via risk admin', async () => { - const {configurator, helpersContract, weth} = testEnv; + const { configurator, helpersContract, weth } = testEnv; const oldWethUnbackedMintCap = await helpersContract.getUnbackedMintCap(weth.address); @@ -602,9 +603,9 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Updates the borrowCap of WETH via pool admin', async () => { - const {configurator, helpersContract, weth} = testEnv; + const { configurator, helpersContract, weth } = testEnv; - const {borrowCap: wethOldBorrowCap} = await helpersContract.getReserveCaps(weth.address); + const { borrowCap: wethOldBorrowCap } = await helpersContract.getReserveCaps(weth.address); const newBorrowCap = '3000000'; expect(await configurator.setBorrowCap(weth.address, newBorrowCap)) @@ -618,9 +619,9 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Updates the borrowCap of WETH risk admin', async () => { - const {configurator, helpersContract, weth, riskAdmin} = testEnv; + const { configurator, helpersContract, weth, riskAdmin } = testEnv; - const {borrowCap: wethOldBorrowCap} = await helpersContract.getReserveCaps(weth.address); + const { borrowCap: wethOldBorrowCap } = await helpersContract.getReserveCaps(weth.address); const newBorrowCap = '3000000'; expect(await configurator.connect(riskAdmin.signer).setBorrowCap(weth.address, newBorrowCap)) @@ -634,9 +635,9 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Updates the supplyCap of WETH via pool admin', async () => { - const {configurator, helpersContract, weth} = testEnv; + const { configurator, helpersContract, weth } = testEnv; - const {supplyCap: oldWethSupplyCap} = await helpersContract.getReserveCaps(weth.address); + const { supplyCap: oldWethSupplyCap } = await helpersContract.getReserveCaps(weth.address); const newBorrowCap = '3000000'; const newSupplyCap = '3000000'; @@ -652,9 +653,9 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Updates the supplyCap of WETH via risk admin', async () => { - const {configurator, helpersContract, weth, riskAdmin} = testEnv; + const { configurator, helpersContract, weth, riskAdmin } = testEnv; - const {supplyCap: oldWethSupplyCap} = await helpersContract.getReserveCaps(weth.address); + const { supplyCap: oldWethSupplyCap } = await helpersContract.getReserveCaps(weth.address); const newBorrowCap = '3000000'; const newSupplyCap = '3000000'; @@ -670,9 +671,9 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Updates the ReserveInterestRateStrategy address of WETH via pool admin', async () => { - const {poolAdmin, pool, configurator, weth} = testEnv; + const { poolAdmin, pool, configurator, weth } = testEnv; - const {interestRateStrategyAddress: interestRateStrategyAddressBefore} = + const { interestRateStrategyAddress: interestRateStrategyAddressBefore } = await pool.getReserveData(weth.address); expect( @@ -682,7 +683,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { ) .to.emit(configurator, 'ReserveInterestRateStrategyChanged') .withArgs(weth.address, interestRateStrategyAddressBefore, ZERO_ADDRESS); - const {interestRateStrategyAddress: interestRateStrategyAddressAfter} = + const { interestRateStrategyAddress: interestRateStrategyAddressAfter } = await pool.getReserveData(weth.address); expect(interestRateStrategyAddressBefore).to.not.be.eq(ZERO_ADDRESS); @@ -695,9 +696,9 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Updates the ReserveInterestRateStrategy address of WETH via risk admin', async () => { - const {riskAdmin, pool, configurator, weth} = testEnv; + const { riskAdmin, pool, configurator, weth } = testEnv; - const {interestRateStrategyAddress: interestRateStrategyAddressBefore} = + const { interestRateStrategyAddress: interestRateStrategyAddressBefore } = await pool.getReserveData(weth.address); expect( @@ -707,7 +708,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { ) .to.emit(configurator, 'ReserveInterestRateStrategyChanged') .withArgs(weth.address, interestRateStrategyAddressBefore, ONE_ADDRESS); - const {interestRateStrategyAddress: interestRateStrategyAddressAfter} = + const { interestRateStrategyAddress: interestRateStrategyAddressAfter } = await pool.getReserveData(weth.address); expect(interestRateStrategyAddressBefore).to.not.be.eq(ONE_ADDRESS); @@ -720,7 +721,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Register a new risk Admin', async () => { - const {aclManager, poolAdmin, users, riskAdmin} = testEnv; + const { aclManager, poolAdmin, users, riskAdmin } = testEnv; const riskAdminRole = await aclManager.RISK_ADMIN_ROLE(); @@ -734,7 +735,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Unregister the new risk admin', async () => { - const {aclManager, poolAdmin, users, riskAdmin} = testEnv; + const { aclManager, poolAdmin, users, riskAdmin } = testEnv; const riskAdminRole = await aclManager.RISK_ADMIN_ROLE(); @@ -748,7 +749,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Authorized a new flash borrower', async () => { - const {aclManager, poolAdmin, users} = testEnv; + const { aclManager, poolAdmin, users } = testEnv; const authorizedFlashBorrowerRole = await aclManager.FLASH_BORROWER_ROLE(); @@ -761,7 +762,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Unauthorized flash borrower', async () => { - const {aclManager, poolAdmin, users} = testEnv; + const { aclManager, poolAdmin, users } = testEnv; const authorizedFlashBorrowerRole = await aclManager.FLASH_BORROWER_ROLE(); @@ -774,7 +775,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Updates bridge protocol fee equal to PERCENTAGE_FACTOR', async () => { - const {pool, configurator} = testEnv; + const { pool, configurator } = testEnv; const newProtocolFee = 10000; const oldBridgeProtocolFee = await pool.BRIDGE_PROTOCOL_FEE(); @@ -787,7 +788,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Updates bridge protocol fee', async () => { - const {pool, configurator} = testEnv; + const { pool, configurator } = testEnv; const oldBridgeProtocolFee = await pool.BRIDGE_PROTOCOL_FEE(); @@ -803,7 +804,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { it('Updates flash loan premiums equal to PERCENTAGE_FACTOR: 10000 toProtocol, 10000 total', async () => { const snapId = await evmSnapshot(); - const {pool, configurator} = testEnv; + const { pool, configurator } = testEnv; const oldFlashloanPremiumTotal = await pool.FLASHLOAN_PREMIUM_TOTAL(); const oldFlashloanPremiumToProtocol = await pool.FLASHLOAN_PREMIUM_TO_PROTOCOL(); @@ -825,7 +826,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Updates flash loan premiums: 10 toProtocol, 40 total', async () => { - const {pool, configurator} = testEnv; + const { pool, configurator } = testEnv; const oldFlashloanPremiumTotal = await pool.FLASHLOAN_PREMIUM_TOTAL(); const oldFlashloanPremiumToProtocol = await pool.FLASHLOAN_PREMIUM_TO_PROTOCOL(); @@ -845,7 +846,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Adds a new eMode category for stablecoins', async () => { - const {configurator, pool, poolAdmin} = testEnv; + const { configurator, pool, poolAdmin } = testEnv; expect( await configurator @@ -869,7 +870,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Set a eMode category to an asset', async () => { - const {configurator, pool, helpersContract, poolAdmin, dai} = testEnv; + const { configurator, pool, helpersContract, poolAdmin, dai } = testEnv; const oldCategoryId = await helpersContract.getReserveEModeCategory(dai.address); @@ -893,7 +894,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Sets siloed borrowing through the pool admin', async () => { - const {configurator, helpersContract, weth, poolAdmin} = testEnv; + const { configurator, helpersContract, weth, poolAdmin } = testEnv; const oldSiloedBorrowing = await helpersContract.getSiloedBorrowing(weth.address); @@ -907,7 +908,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Sets siloed borrowing through the risk admin', async () => { - const {configurator, helpersContract, weth, riskAdmin} = testEnv; + const { configurator, helpersContract, weth, riskAdmin } = testEnv; const oldSiloedBorrowing = await helpersContract.getSiloedBorrowing(weth.address); @@ -960,7 +961,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Sets a debt ceiling through the pool admin', async () => { - const {configurator, helpersContract, weth, poolAdmin} = testEnv; + const { configurator, helpersContract, weth, poolAdmin } = testEnv; const oldDebtCeiling = await helpersContract.getDebtCeiling(weth.address); @@ -977,7 +978,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Sets a debt ceiling through the risk admin', async () => { - const {configurator, helpersContract, weth, riskAdmin} = testEnv; + const { configurator, helpersContract, weth, riskAdmin } = testEnv; const oldDebtCeiling = await helpersContract.getDebtCeiling(weth.address); @@ -994,7 +995,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Sets a debt ceiling larger than max (revert expected)', async () => { - const {configurator, helpersContract, weth, riskAdmin} = testEnv; + const { configurator, helpersContract, weth, riskAdmin } = testEnv; const MAX_VALID_DEBT_CEILING = BigNumber.from('1099511627775'); const debtCeiling = MAX_VALID_DEBT_CEILING.add(1); @@ -1071,12 +1072,12 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Read debt ceiling decimals', async () => { - const {helpersContract} = testEnv; + const { helpersContract } = testEnv; expect(await helpersContract.getDebtCeilingDecimals()).to.be.eq(2); }); it('Check that the reserves have flashloans enabled', async () => { - const {weth, aave, usdc, dai, helpersContract} = testEnv; + const { weth, aave, usdc, dai, helpersContract } = testEnv; const wethFlashLoanEnabled = await helpersContract.getFlashLoanEnabled(weth.address); expect(wethFlashLoanEnabled).to.be.equal(true); @@ -1092,7 +1093,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => { }); it('Disable weth flashloans', async () => { - const {weth, configurator, helpersContract} = testEnv; + const { weth, configurator, helpersContract } = testEnv; expect(await configurator.setReserveFlashLoaning(weth.address, false)); diff --git a/test-suites/pool-flashloan.spec.ts b/test-suites/pool-flashloan.spec.ts index 4fb4b843e..1a0e4e709 100644 --- a/test-suites/pool-flashloan.spec.ts +++ b/test-suites/pool-flashloan.spec.ts @@ -1,17 +1,18 @@ -import {expect} from 'chai'; -import {BigNumber, ethers, Event, utils} from 'ethers'; -import {MAX_UINT_AMOUNT} from '../helpers/constants'; -import {convertToCurrencyDecimals} from '../helpers/contracts-helpers'; -import {MockFlashLoanReceiver} from '../types/MockFlashLoanReceiver'; -import {ProtocolErrors} from '../helpers/types'; +import { expect } from 'chai'; +import { BigNumber, ethers, Event, utils } from 'ethers'; +import { MAX_UINT_AMOUNT } from '../helpers/constants'; +import { convertToCurrencyDecimals } from '../helpers/contracts-helpers'; +import { MockFlashLoanReceiver } from '../types/MockFlashLoanReceiver'; +import { ProtocolErrors } from '../helpers/types'; + import { getMockFlashLoanReceiver, getStableDebtToken, getVariableDebtToken, } from '@aave/deploy-v3/dist/helpers/contract-getters'; -import {TestEnv, makeSuite} from './helpers/make-suite'; +import { TestEnv, makeSuite } from './helpers/make-suite'; import './helpers/utils/wadraymath'; -import {waitForTx} from '@aave/deploy-v3'; +import { waitForTx } from '@aave/deploy-v3'; makeSuite('Pool: FlashLoan', (testEnv: TestEnv) => { let _mockFlashLoanReceiver = {} as MockFlashLoanReceiver; @@ -30,7 +31,7 @@ makeSuite('Pool: FlashLoan', (testEnv: TestEnv) => { }); it('Configurator sets total premium = 9 bps, premium to protocol = 30%', async () => { - const {configurator, pool} = testEnv; + const { configurator, pool } = testEnv; await configurator.updateFlashloanPremiumTotal(TOTAL_PREMIUM); await configurator.updateFlashloanPremiumToProtocol(PREMIUM_TO_PROTOCOL); @@ -38,7 +39,7 @@ makeSuite('Pool: FlashLoan', (testEnv: TestEnv) => { expect(await pool.FLASHLOAN_PREMIUM_TO_PROTOCOL()).to.be.equal(PREMIUM_TO_PROTOCOL); }); it('Deposits WETH into the reserve', async () => { - const {pool, weth, aave, dai} = testEnv; + const { pool, weth, aave, dai } = testEnv; const userAddress = await pool.signer.getAddress(); const amountToDeposit = ethers.utils.parseEther('1'); @@ -61,7 +62,7 @@ makeSuite('Pool: FlashLoan', (testEnv: TestEnv) => { }); it('Takes WETH + Dai flash loan with mode = 0, returns the funds correctly', async () => { - const {pool, helpersContract, weth, aWETH, dai, aDai} = testEnv; + const { pool, helpersContract, weth, aWETH, dai, aDai } = testEnv; const wethFlashBorrowedAmount = ethers.utils.parseEther('0.8'); const daiFlashBorrowedAmount = ethers.utils.parseEther('0.3'); @@ -138,7 +139,7 @@ makeSuite('Pool: FlashLoan', (testEnv: TestEnv) => { // Check event values for `ReserveDataUpdated` const reserveDataUpdatedEvents = tx.events?.filter( - ({event}) => event === 'ReserveDataUpdated' + ({ event }) => event === 'ReserveDataUpdated' ) as Event[]; for (const reserveDataUpdatedEvent of reserveDataUpdatedEvents) { const reserveData = await helpersContract.getReserveData( @@ -196,7 +197,7 @@ makeSuite('Pool: FlashLoan', (testEnv: TestEnv) => { }); it('Takes an ETH flashloan with mode = 0 as big as the available liquidity', async () => { - const {pool, helpersContract, weth, aWETH, deployer} = testEnv; + const { pool, helpersContract, weth, aWETH, deployer } = testEnv; let reserveData = await helpersContract.getReserveData(weth.address); @@ -256,7 +257,7 @@ makeSuite('Pool: FlashLoan', (testEnv: TestEnv) => { }); it('Disable ETH flashloan and takes an ETH flashloan (revert expected)', async () => { - const {pool, configurator, helpersContract, weth, deployer} = testEnv; + const { pool, configurator, helpersContract, weth, deployer } = testEnv; expect(await configurator.setReserveFlashLoaning(weth.address, false)); @@ -288,7 +289,7 @@ makeSuite('Pool: FlashLoan', (testEnv: TestEnv) => { }); it('Takes WETH flashloan, does not return the funds with mode = 0 (revert expected)', async () => { - const {pool, weth, users} = testEnv; + const { pool, weth, users } = testEnv; const caller = users[1]; await _mockFlashLoanReceiver.setFailExecutionTransfer(true); @@ -308,7 +309,7 @@ makeSuite('Pool: FlashLoan', (testEnv: TestEnv) => { }); it('Takes WETH flashloan, simulating a receiver as EOA (revert expected)', async () => { - const {pool, weth, users} = testEnv; + const { pool, weth, users } = testEnv; const caller = users[1]; await _mockFlashLoanReceiver.setFailExecutionTransfer(true); await _mockFlashLoanReceiver.setSimulateEOA(true); @@ -329,7 +330,7 @@ makeSuite('Pool: FlashLoan', (testEnv: TestEnv) => { }); it('Takes a WETH flashloan with an invalid mode (revert expected)', async () => { - const {pool, weth, users} = testEnv; + const { pool, weth, users } = testEnv; const caller = users[1]; await _mockFlashLoanReceiver.setSimulateEOA(false); await _mockFlashLoanReceiver.setFailExecutionTransfer(true); @@ -350,7 +351,7 @@ makeSuite('Pool: FlashLoan', (testEnv: TestEnv) => { }); it('Caller deposits 1000 DAI as collateral, Takes WETH flashloan with mode = 2, does not return the funds. A variable loan for caller is created', async () => { - const {dai, pool, weth, users, helpersContract} = testEnv; + const { dai, pool, weth, users, helpersContract } = testEnv; const caller = users[1]; @@ -396,7 +397,7 @@ makeSuite('Pool: FlashLoan', (testEnv: TestEnv) => { 0 ); - const {variableDebtTokenAddress} = await helpersContract.getReserveTokensAddresses( + const { variableDebtTokenAddress } = await helpersContract.getReserveTokensAddresses( weth.address ); reserveData = await helpersContract.getReserveData(weth.address); @@ -417,7 +418,7 @@ makeSuite('Pool: FlashLoan', (testEnv: TestEnv) => { await pool.connect(caller.signer).repay(weth.address, MAX_UINT_AMOUNT, 2, caller.address); }); it('Tries to take a flashloan that is bigger than the available liquidity (revert expected)', async () => { - const {pool, weth, users} = testEnv; + const { pool, weth, users } = testEnv; const caller = users[1]; await expect( @@ -435,7 +436,7 @@ makeSuite('Pool: FlashLoan', (testEnv: TestEnv) => { }); it('Tries to take a flashloan using a non contract address as receiver (revert expected)', async () => { - const {pool, deployer, weth, users} = testEnv; + const { pool, deployer, weth, users } = testEnv; const caller = users[1]; await expect( @@ -452,7 +453,7 @@ makeSuite('Pool: FlashLoan', (testEnv: TestEnv) => { }); it('Deposits USDC into the reserve', async () => { - const {usdc, pool} = testEnv; + const { usdc, pool } = testEnv; const userAddress = await pool.signer.getAddress(); await usdc['mint(uint256)'](await convertToCurrencyDecimals(usdc.address, '1000')); @@ -465,7 +466,7 @@ makeSuite('Pool: FlashLoan', (testEnv: TestEnv) => { }); it('Takes out a 500 USDC flashloan, returns the funds correctly', async () => { - const {usdc, aUsdc, pool, helpersContract, deployer: depositor} = testEnv; + const { usdc, aUsdc, pool, helpersContract, deployer: depositor } = testEnv; await _mockFlashLoanReceiver.setFailExecutionTransfer(false); @@ -513,7 +514,7 @@ makeSuite('Pool: FlashLoan', (testEnv: TestEnv) => { }); it('Takes out a 500 USDC flashloan with mode = 0, does not return the funds (revert expected)', async () => { - const {usdc, pool, users} = testEnv; + const { usdc, pool, users } = testEnv; const caller = users[2]; const flashloanAmount = await convertToCurrencyDecimals(usdc.address, '500'); @@ -536,7 +537,7 @@ makeSuite('Pool: FlashLoan', (testEnv: TestEnv) => { }); it('Caller deposits 5 WETH as collateral, Takes a USDC flashloan with mode = 2, does not return the funds. A loan for caller is created', async () => { - const {usdc, pool, weth, users, helpersContract} = testEnv; + const { usdc, pool, weth, users, helpersContract } = testEnv; const caller = users[2]; @@ -565,7 +566,7 @@ makeSuite('Pool: FlashLoan', (testEnv: TestEnv) => { '0x10', '0' ); - const {variableDebtTokenAddress} = await helpersContract.getReserveTokensAddresses( + const { variableDebtTokenAddress } = await helpersContract.getReserveTokensAddresses( usdc.address ); @@ -577,7 +578,7 @@ makeSuite('Pool: FlashLoan', (testEnv: TestEnv) => { }); it('Caller deposits 1000 DAI as collateral, Takes a WETH flashloan with mode = 0, does not approve the transfer of the funds', async () => { - const {dai, pool, weth, users} = testEnv; + const { dai, pool, weth, users } = testEnv; const caller = users[3]; await dai @@ -611,7 +612,7 @@ makeSuite('Pool: FlashLoan', (testEnv: TestEnv) => { }); it('Caller takes a WETH flashloan with mode = 1', async () => { - const {pool, weth, users, helpersContract} = testEnv; + const { pool, weth, users, helpersContract } = testEnv; const caller = users[3]; @@ -635,7 +636,9 @@ makeSuite('Pool: FlashLoan', (testEnv: TestEnv) => { .to.emit(pool, 'FlashLoan') .withArgs(_mockFlashLoanReceiver.address, caller.address, weth.address, flashAmount, 1, 0, 0); - const {stableDebtTokenAddress} = await helpersContract.getReserveTokensAddresses(weth.address); + const { stableDebtTokenAddress } = await helpersContract.getReserveTokensAddresses( + weth.address + ); const wethDebtToken = await getStableDebtToken(stableDebtTokenAddress); @@ -645,7 +648,7 @@ makeSuite('Pool: FlashLoan', (testEnv: TestEnv) => { }); it('Caller takes a WETH flashloan with mode = 1 onBehalfOf user without allowance', async () => { - const {dai, pool, weth, users, helpersContract} = testEnv; + const { dai, pool, weth, users, helpersContract } = testEnv; const caller = users[5]; const onBehalfOf = users[4]; @@ -683,7 +686,7 @@ makeSuite('Pool: FlashLoan', (testEnv: TestEnv) => { }); it('Caller takes a WETH flashloan with mode = 1 onBehalfOf user with allowance. A loan for onBehalfOf is creatd.', async () => { - const {pool, weth, users, helpersContract} = testEnv; + const { pool, weth, users, helpersContract } = testEnv; const caller = users[5]; const onBehalfOf = users[4]; @@ -711,7 +714,9 @@ makeSuite('Pool: FlashLoan', (testEnv: TestEnv) => { '0' ); - const {stableDebtTokenAddress} = await helpersContract.getReserveTokensAddresses(weth.address); + const { stableDebtTokenAddress } = await helpersContract.getReserveTokensAddresses( + weth.address + ); const wethDebtToken = await getStableDebtToken(stableDebtTokenAddress);