2020-05-29 16:45:37 +00:00
|
|
|
// SPDX-License-Identifier: agpl-3.0
|
|
|
|
pragma solidity ^0.6.8;
|
|
|
|
|
2020-08-20 10:44:51 +00:00
|
|
|
import {SafeMath} from '@openzeppelin/contracts/math/SafeMath.sol';
|
|
|
|
import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';
|
|
|
|
import {IFlashLoanReceiver} from '../interfaces/IFlashLoanReceiver.sol';
|
|
|
|
import {ILendingPoolAddressesProvider} from '../../interfaces/ILendingPoolAddressesProvider.sol';
|
2020-08-12 17:36:58 +00:00
|
|
|
import {SafeERC20} from '@openzeppelin/contracts/token/ERC20/SafeERC20.sol';
|
2020-07-13 13:19:47 +00:00
|
|
|
import '@nomiclabs/buidler/console.sol';
|
2020-05-29 16:45:37 +00:00
|
|
|
|
|
|
|
abstract contract FlashLoanReceiverBase is IFlashLoanReceiver {
|
2020-08-12 17:36:58 +00:00
|
|
|
using SafeERC20 for IERC20;
|
2020-07-13 08:54:08 +00:00
|
|
|
using SafeMath for uint256;
|
2020-05-29 16:45:37 +00:00
|
|
|
|
2020-07-13 08:54:08 +00:00
|
|
|
ILendingPoolAddressesProvider public addressesProvider;
|
2020-05-29 16:45:37 +00:00
|
|
|
|
2020-08-21 14:03:01 +00:00
|
|
|
constructor(ILendingPoolAddressesProvider provider) public {
|
|
|
|
addressesProvider = provider;
|
2020-07-13 08:54:08 +00:00
|
|
|
}
|
2020-05-29 16:45:37 +00:00
|
|
|
|
2020-07-13 08:54:08 +00:00
|
|
|
receive() external payable {}
|
2020-05-29 16:45:37 +00:00
|
|
|
|
2020-08-21 17:10:48 +00:00
|
|
|
function _transferFundsBack(
|
2020-08-21 14:03:01 +00:00
|
|
|
address reserve,
|
|
|
|
address destination,
|
|
|
|
uint256 amount
|
2020-07-13 10:24:36 +00:00
|
|
|
) internal {
|
2020-08-21 14:03:01 +00:00
|
|
|
transferInternal(destination, reserve, amount);
|
2020-07-13 08:54:08 +00:00
|
|
|
}
|
2020-05-29 16:45:37 +00:00
|
|
|
|
2020-07-13 08:54:08 +00:00
|
|
|
function transferInternal(
|
2020-08-21 14:03:01 +00:00
|
|
|
address destination,
|
|
|
|
address reserve,
|
|
|
|
uint256 amount
|
2020-07-13 08:54:08 +00:00
|
|
|
) internal {
|
2020-08-21 14:03:01 +00:00
|
|
|
IERC20(reserve).safeTransfer(destination, amount);
|
2020-07-13 08:54:08 +00:00
|
|
|
}
|
2020-06-02 14:16:22 +00:00
|
|
|
}
|