flashLoan gas test
This commit is contained in:
@@ -37,10 +37,6 @@ contract FlashBorrower is IERC3156FlashBorrower {
|
||||
payer = _payer;
|
||||
}
|
||||
|
||||
function flash(address token, uint256 amount) external {
|
||||
PartyPool(pool).flashLoan(IERC3156FlashBorrower(address(this)), token, amount, "");
|
||||
}
|
||||
|
||||
function onFlashLoan(
|
||||
address /*initiator*/,
|
||||
address token,
|
||||
@@ -850,7 +846,7 @@ contract PartyPoolTest is Test {
|
||||
uint256 poolToken0Before = token0.balanceOf(address(pool));
|
||||
|
||||
// Execute flash loan
|
||||
borrower.flash(address(token0), amount);
|
||||
pool.flashLoan(borrower, address(token0), amount, "");
|
||||
|
||||
// Net change for alice should equal the flash fee (principal is returned during repayment)
|
||||
uint256 fee = (amount * pool.flashFeePpm() + 1_000_000 - 1) / 1_000_000; // ceil fee calculation
|
||||
@@ -882,7 +878,7 @@ contract PartyPoolTest is Test {
|
||||
|
||||
// Execute flash loan - should revert due to insufficient allowance when pool tries to pull repayment
|
||||
vm.expectRevert();
|
||||
borrower.flash(address(token0), amount);
|
||||
pool.flashLoan(borrower, address(token0), amount, "");
|
||||
}
|
||||
|
||||
/// @notice Test flash loan with partial repayment (should revert)
|
||||
@@ -897,7 +893,7 @@ contract PartyPoolTest is Test {
|
||||
|
||||
// Execute flash loan - should revert due to insufficient allowance when pool tries to pull full repayment
|
||||
vm.expectRevert();
|
||||
borrower.flash(address(token0), amount);
|
||||
pool.flashLoan(borrower, address(token0), amount, "");
|
||||
}
|
||||
|
||||
/// @notice Test flash loan with principal repayment but no fee (should revert)
|
||||
@@ -913,10 +909,10 @@ contract PartyPoolTest is Test {
|
||||
// Execute flash loan - should revert due to insufficient allowance if fee > 0
|
||||
if (pool.flashFeePpm() > 0) {
|
||||
vm.expectRevert();
|
||||
borrower.flash(address(token0), amount);
|
||||
pool.flashLoan(borrower, address(token0), amount, "");
|
||||
} else {
|
||||
// If fee is zero, this should succeed
|
||||
borrower.flash(address(token0), amount);
|
||||
pool.flashLoan(borrower, address(token0), amount, "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -935,7 +931,7 @@ contract PartyPoolTest is Test {
|
||||
uint256 poolToken0Before = token0.balanceOf(address(pool));
|
||||
|
||||
// Execute flash loan
|
||||
borrower.flash(address(token0), amount);
|
||||
pool.flashLoan(borrower, address(token0), amount, "");
|
||||
|
||||
// Check balances: net change for alice should equal the fee
|
||||
uint256 fee = (amount * pool.flashFeePpm() + 1_000_000 - 1) / 1_000_000; // ceil fee calculation
|
||||
|
||||
Reference in New Issue
Block a user