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

Commit bf652c2

Browse files
author
Steven Valeri
committed
fix: add validation to simpleFlashLoan
1 parent 078fa28 commit bf652c2

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

contracts/protocol/libraries/logic/ValidationLogic.sol

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,7 @@ library ValidationLogic {
454454
) internal view {
455455
require(assets.length == amounts.length, Errors.INCONSISTENT_FLASHLOAN_PARAMS);
456456
for (uint256 i = 0; i < assets.length; i++) {
457-
DataTypes.ReserveConfigurationMap memory configuration = reservesData[assets[i]]
458-
.configuration;
459-
require(!configuration.getPaused(), Errors.RESERVE_PAUSED);
460-
require(configuration.getActive(), Errors.RESERVE_INACTIVE);
461-
require(configuration.getFlashLoanEnabled(), Errors.FLASHLOAN_DISABLED);
457+
validateFlashloanSimple(reservesData[assets[i]]);
462458
}
463459
}
464460

@@ -470,6 +466,7 @@ library ValidationLogic {
470466
DataTypes.ReserveConfigurationMap memory configuration = reserve.configuration;
471467
require(!configuration.getPaused(), Errors.RESERVE_PAUSED);
472468
require(configuration.getActive(), Errors.RESERVE_INACTIVE);
469+
require(configuration.getFlashLoanEnabled(), Errors.FLASHLOAN_DISABLED);
473470
}
474471

475472
struct ValidateLiquidationCallLocalVars {

test-suites/pool-simple-flashloan.spec.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ import { waitForTx } from '@aave/deploy-v3';
1818
makeSuite('Pool: Simple FlashLoan', (testEnv: TestEnv) => {
1919
let _mockFlashLoanSimpleReceiver = {} as MockFlashLoanSimpleReceiver;
2020

21-
const { ERC20_TRANSFER_AMOUNT_EXCEEDS_BALANCE, INVALID_FLASHLOAN_EXECUTOR_RETURN } =
22-
ProtocolErrors;
21+
const {
22+
ERC20_TRANSFER_AMOUNT_EXCEEDS_BALANCE,
23+
INVALID_FLASHLOAN_EXECUTOR_RETURN,
24+
FLASHLOAN_DISABLED,
25+
} = ProtocolErrors;
2326
const TOTAL_PREMIUM = 9;
2427
const PREMIUM_TO_PROTOCOL = 3000;
2528

@@ -178,6 +181,30 @@ makeSuite('Pool: Simple FlashLoan', (testEnv: TestEnv) => {
178181
).to.be.equal(reservesBefore);
179182
});
180183

184+
it('Takes a simple ETH flashloan after flashloaning disabled', async () => {
185+
const { pool, configurator, helpersContract, weth } = testEnv;
186+
187+
expect(await configurator.setReserveFlashLoaning(weth.address, false));
188+
let wethFlashLoanEnabled = await helpersContract.getFlashLoanEnabled(weth.address);
189+
expect(wethFlashLoanEnabled).to.be.equal(false);
190+
191+
const wethFlashBorrowedAmount = ethers.utils.parseEther('0.8');
192+
193+
await expect(
194+
pool.flashLoanSimple(
195+
_mockFlashLoanSimpleReceiver.address,
196+
weth.address,
197+
wethFlashBorrowedAmount,
198+
'0x10',
199+
'0'
200+
)
201+
).to.be.revertedWith(FLASHLOAN_DISABLED);
202+
203+
expect(await configurator.setReserveFlashLoaning(weth.address, true));
204+
wethFlashLoanEnabled = await helpersContract.getFlashLoanEnabled(weth.address);
205+
expect(wethFlashLoanEnabled).to.be.equal(true);
206+
});
207+
181208
it('Takes WETH flashloan, does not return the funds (revert expected)', async () => {
182209
const { pool, weth, users } = testEnv;
183210
const caller = users[1];

0 commit comments

Comments
 (0)