diff --git a/test/flashloan.spec.ts b/test/flashloan.spec.ts index 35f8b293..65fd7926 100644 --- a/test/flashloan.spec.ts +++ b/test/flashloan.spec.ts @@ -32,20 +32,16 @@ makeSuite('LendingPool FlashLoan function', (testEnv: TestEnv) => { const {pool, weth} = testEnv; const amountToDeposit = ethers.utils.parseEther('1'); - await pool.deposit(weth.address, amountToDeposit, '0', { - value: amountToDeposit, - }); + await weth.mint(amountToDeposit); + + await weth.approve(pool.address, APPROVAL_AMOUNT_LENDING_POOL); + + await pool.deposit(weth.address, amountToDeposit, '0'); }); it('Takes ETH flashloan, returns the funds correctly', async () => { const {pool, deployer, weth} = testEnv; - // move funds to the MockFlashLoanReceiver contract to pay the fee - await deployer.signer.sendTransaction({ - value: ethers.utils.parseEther('0.5'), - to: _mockFlashLoanReceiver.address, - }); - await pool.flashLoan( _mockFlashLoanReceiver.address, weth.address, @@ -56,7 +52,6 @@ makeSuite('LendingPool FlashLoan function', (testEnv: TestEnv) => { ethers.utils.parseUnits('10000'); const reserveData: any = await pool.getReserveData(weth.address); - const tokenDistributorBalance = await BRE.ethers.provider.getBalance(_tokenDistributor.address); const currentLiquidityRate = reserveData.liquidityRate; const currentLiquidityIndex = reserveData.liquidityIndex; @@ -65,21 +60,18 @@ makeSuite('LendingPool FlashLoan function', (testEnv: TestEnv) => { .plus(reserveData.totalBorrowsStable) .plus(reserveData.totalBorrowsVariable); + const tokenDistributorBalance = await weth.balanceOf(_tokenDistributor.address); + + expect(totalLiquidity.toString()).to.be.equal('1000504000000000000'); expect(currentLiquidityRate.toString()).to.be.equal('0'); expect(currentLiquidityIndex.toString()).to.be.equal('1000504000000000000000000000'); - expect(tokenDistributorBalance.toString()).to.be.equal('216000000000000'); + expect(tokenDistributorBalance).to.be.equal('216000000000000'); }); it('Takes an ETH flashloan as big as the available liquidity', async () => { const {pool, deployer, weth} = testEnv; - // move funds to the MockFlashLoanReceiver contract to pay the fee - await deployer.signer.sendTransaction({ - value: ethers.utils.parseEther('0.5'), - to: _mockFlashLoanReceiver.address, - }); - const txResult = await pool.flashLoan( _mockFlashLoanReceiver.address, weth.address, @@ -88,7 +80,8 @@ makeSuite('LendingPool FlashLoan function', (testEnv: TestEnv) => { ); const reserveData: any = await pool.getReserveData(weth.address); - const tokenDistributorBalance = await BRE.ethers.provider.getBalance(_tokenDistributor.address); + const tokenDistributorBalance = await weth.balanceOf(_tokenDistributor.address); + const currentLiqudityRate = reserveData.liquidityRate; const currentLiquidityIndex = reserveData.liquidityIndex; @@ -103,14 +96,10 @@ makeSuite('LendingPool FlashLoan function', (testEnv: TestEnv) => { expect(tokenDistributorBalance.toString()).to.be.equal('486136080000000'); }); - it('Takes ETH flashloan, does not return the funds (revert expected)', async () => { + it('Takes WETH flashloan, does not return the funds (revert expected)', async () => { const {pool, deployer, weth} = testEnv; // move funds to the MockFlashLoanReceiver contract to pay the fee - await deployer.signer.sendTransaction({ - value: ethers.utils.parseEther('0.5'), - to: _mockFlashLoanReceiver.address, - }); await _mockFlashLoanReceiver.setFailExecutionTransfer(true); diff --git a/test/scenario.spec.ts b/test/scenario.spec.ts index 2575f339..5d449d76 100644 --- a/test/scenario.spec.ts +++ b/test/scenario.spec.ts @@ -12,7 +12,7 @@ BigNumber.config({DECIMAL_PLACES: 0, ROUNDING_MODE: BigNumber.ROUND_DOWN}); const scenarioFolder = './test/helpers/scenarios/'; -const selectedScenarios: string[] = ['borrow-repay-variable.json']; +const selectedScenarios: string[] = []; fs.readdirSync(scenarioFolder).forEach((file) => { if (selectedScenarios.length > 0 && !selectedScenarios.includes(file)) return;