Skip to content

Commit

Permalink
Merge pull request #16 from bgd-labs/feat/uniquie-flash-loan
Browse files Browse the repository at this point in the history
Allow only uniquie assets at the flashloans
  • Loading branch information
eboadom authored May 23, 2024
2 parents 8035fa4 + 5fe6266 commit bdd0f9b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,9 @@ library ValidationLogic {
) internal view {
require(assets.length == amounts.length, Errors.INCONSISTENT_FLASHLOAN_PARAMS);
for (uint256 i = 0; i < assets.length; i++) {
for (uint256 j = i + 1; j < assets.length; j++) {
require(assets[i] != assets[j], Errors.INCONSISTENT_FLASHLOAN_PARAMS);
}
validateFlashloanSimple(reservesData[assets[i]], amounts[i]);
}
}
Expand Down
24 changes: 24 additions & 0 deletions tests/core/Pool.FlashLoans.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,30 @@ contract PoolFlashLoansTests is TestnetProcedures {
);
}

function test_reverts_flashLoan_same_asset_more_then_once(uint8 length) public {
vm.assume(length > 1);
bytes memory emptyParams;
address[] memory assets = new address[](length);
uint256[] memory amounts = new uint256[](length);
uint256[] memory modes = new uint256[](length);
for (uint256 i = 0; i < length; i++) {
assets[i] = tokenList.weth;
amounts[i] = 1;
}

vm.expectRevert(bytes(Errors.INCONSISTENT_FLASHLOAN_PARAMS));
vm.prank(alice);
contracts.poolProxy.flashLoan(
address(mockFlashReceiver),
assets,
amounts,
modes,
alice,
emptyParams,
0
);
}

function test_reverts_flashLoan_simple_invalid_return() public {
bytes memory emptyParams;

Expand Down

0 comments on commit bdd0f9b

Please sign in to comment.