Skip to content

Commit

Permalink
Applied the fix of fee round up to the contract code & test script
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean329 committed Nov 21, 2023
1 parent 1d15617 commit 178fa9f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion patterns/flash-loans/FlashLoanPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ contract FlashLoanPool {
uint256 balanceBefore = token.balanceOf(address(this));
require(balanceBefore >= borrowAmount, 'too much');
// Compute the fee, rounded up.
uint256 fee = FEE_BPS * (borrowAmount + 1e4-1) / 1e4;
uint256 fee = (FEE_BPS * borrowAmount + 1e4-1) / 1e4;
// Transfer tokens to the borrower contract.
token.transfer(address(borrower), borrowAmount);
// Let the borrower do its thing.
Expand Down
2 changes: 1 addition & 1 deletion test/FlashLoanPool.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ contract FlashLoanPoolTest is TestUtils, FlashLoanValidator {
}

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

function test_canWithdraw() external {
Expand Down

0 comments on commit 178fa9f

Please sign in to comment.