Skip to content

Commit

Permalink
feat: generalize token for flashLoan
Browse files Browse the repository at this point in the history
  • Loading branch information
QGarchery committed Apr 5, 2024
1 parent 8489407 commit 49a1ca0
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions test/forge/HalmosTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,13 @@ contract HalmosTest is SymTest, Test {
vm.assume(selector != morpho.createMarket.selector);

bytes memory emptyData = hex"";
uint256 amount = svm.createUint256("amount");
uint256 assets = svm.createUint256("assets");
uint256 shares = svm.createUint256("shares");
address onBehalf = svm.createAddress("onBehalf");
address receiver = svm.createAddress("receiver");

bytes memory args;

// Todo: make it possible to call any market
if (selector == morpho.supply.selector) {
args = abi.encode(marketParams, assets, shares, onBehalf, emptyData);
} else if (selector == morpho.withdraw.selector) {
Expand All @@ -103,8 +101,16 @@ contract HalmosTest is SymTest, Test {
address borrower = svm.createAddress("borrower");
args = abi.encode(marketParams, borrower, assets, shares, emptyData);
} else if (selector == morpho.flashLoan.selector) {
// Todo: make it more general
address token = address(loanToken);
uint256 rand = svm.createUint256("rand");
address token;
if (rand == 0) {
token = address(loanToken);
} else if (rand == 1) {
token = address(collateralToken);
} else {
ERC20Mock otherToken = new ERC20Mock();
token = address(otherToken);
}
args = abi.encode(marketParams, token, assets, emptyData);
} else if (selector == morpho.accrueInterest.selector) {
args = abi.encode(marketParams);
Expand Down

0 comments on commit 49a1ca0

Please sign in to comment.