Commit
Co-authored-by: Mazen Khalil <mazen@immunityledger.org> Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,16 @@ abstract contract ERC20FlashMint is ERC20, IERC3156FlashLender { | |
return 0; | ||
} | ||
|
||
/** | ||
* @dev Returns the receiver address of the flash fee. By default this | ||
* implementation returns the address(0) which means the fee amount will be burnt. | ||
* This function can be overloaded to change the fee receiver. | ||
* @return The address for which the flash fee will be sent to. | ||
*/ | ||
function _flashFeeReceiver() internal view virtual returns (address) { | ||
return address(0); | ||
} | ||
|
||
/** | ||
* @dev Performs a flash loan. New tokens are minted and sent to the | ||
* `receiver`, who is required to implement the {IERC3156FlashBorrower} | ||
|
@@ -73,8 +83,14 @@ abstract contract ERC20FlashMint is ERC20, IERC3156FlashLender { | |
receiver.onFlashLoan(msg.sender, token, amount, fee, data) == _RETURN_VALUE, | ||
"ERC20FlashMint: invalid return value" | ||
); | ||
address flashFeeReceiver = _flashFeeReceiver(); | ||
_spendAllowance(address(receiver), address(this), amount + fee); | ||
_burn(address(receiver), amount + fee); | ||
if (fee == 0 || flashFeeReceiver == address(0)) { | ||
_burn(address(receiver), amount + fee); | ||
} else { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
eugenioclrc
|
||
_burn(address(receiver), amount); | ||
_transfer(address(receiver), flashFeeReceiver, fee); | ||
} | ||
return true; | ||
} | ||
} |
I think is more appropiate to do;