Skip to content
This repository was archived by the owner on Oct 21, 2025. It is now read-only.

Commit 8888093

Browse files
author
Steven Valeri
committed
feat: add additional flashloan scenario
1 parent 284b492 commit 8888093

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

test-suites/pool-flashloan.spec.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ makeSuite('Pool: FlashLoan', (testEnv: TestEnv) => {
2222
ERC20_TRANSFER_AMOUNT_EXCEEDS_BALANCE,
2323
INVALID_FLASHLOAN_EXECUTOR_RETURN,
2424
FLASHLOAN_DISABLED,
25+
BORROWING_NOT_ENABLED,
2526
} = ProtocolErrors;
2627

2728
const TOTAL_PREMIUM = 9;
@@ -580,6 +581,46 @@ makeSuite('Pool: FlashLoan', (testEnv: TestEnv) => {
580581
expect(callerDebt.toString()).to.be.equal('500000000', 'Invalid user debt');
581582
});
582583

584+
it('Disable USDC borrowing. Caller deposits 5 WETH as collateral, Takes a USDC flashloan with mode = 2, does not return the funds. Revert creating borrow position (revert expected)', async () => {
585+
const {usdc, pool, weth, configurator, users, helpersContract} = testEnv;
586+
587+
const caller = users[2];
588+
589+
expect(await configurator.setReserveStableRateBorrowing(usdc.address, false));
590+
expect(await configurator.setReserveBorrowing(usdc.address, false));
591+
592+
let usdcConfiguration = await helpersContract.getReserveConfigurationData(usdc.address);
593+
expect(usdcConfiguration.borrowingEnabled).to.be.equal(false);
594+
595+
await weth
596+
.connect(caller.signer)
597+
['mint(uint256)'](await convertToCurrencyDecimals(weth.address, '5'));
598+
599+
await weth.connect(caller.signer).approve(pool.address, MAX_UINT_AMOUNT);
600+
601+
const amountToDeposit = await convertToCurrencyDecimals(weth.address, '5');
602+
603+
await pool.connect(caller.signer).deposit(weth.address, amountToDeposit, caller.address, '0');
604+
605+
await _mockFlashLoanReceiver.setFailExecutionTransfer(true);
606+
607+
const flashloanAmount = await convertToCurrencyDecimals(usdc.address, '500');
608+
609+
await expect(
610+
pool
611+
.connect(caller.signer)
612+
.flashLoan(
613+
_mockFlashLoanReceiver.address,
614+
[usdc.address],
615+
[flashloanAmount],
616+
[2],
617+
caller.address,
618+
'0x10',
619+
'0'
620+
)
621+
).to.be.revertedWith(BORROWING_NOT_ENABLED);
622+
});
623+
583624
it('Caller deposits 1000 DAI as collateral, Takes a WETH flashloan with mode = 0, does not approve the transfer of the funds', async () => {
584625
const {dai, pool, weth, users} = testEnv;
585626
const caller = users[3];

0 commit comments

Comments
 (0)