Skip to content

Commit 178fa9f

Browse files
committed
Applied the fix of fee round up to the contract code & test script
1 parent 1d15617 commit 178fa9f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

patterns/flash-loans/FlashLoanPool.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ contract FlashLoanPool {
4848
uint256 balanceBefore = token.balanceOf(address(this));
4949
require(balanceBefore >= borrowAmount, 'too much');
5050
// Compute the fee, rounded up.
51-
uint256 fee = FEE_BPS * (borrowAmount + 1e4-1) / 1e4;
51+
uint256 fee = (FEE_BPS * borrowAmount + 1e4-1) / 1e4;
5252
// Transfer tokens to the borrower contract.
5353
token.transfer(address(borrower), borrowAmount);
5454
// Let the borrower do its thing.

test/FlashLoanPool.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ contract FlashLoanPoolTest is TestUtils, FlashLoanValidator {
161161
}
162162

163163
function _getFee(uint256 amount) private view returns (uint256) {
164-
return pool.FEE_BPS() * (amount + 1e4-1) / 1e4;
164+
return (pool.FEE_BPS() * amount + 1e4-1) / 1e4;
165165
}
166166

167167
function test_canWithdraw() external {

0 commit comments

Comments
 (0)