import { ILendingPoolAddressesProvider } from "./ILendingPoolAddressesProvider.sol"; // 通过该接口获取LendingPool地址
import { FlashLoanReceiverBase } from "./FlashLoanReceiverBase.sol"; // 接收闪电贷金额的合约必须通过IFlashLoanReceiver 接口实现的 executeOperation()
import { ILendingPool } from "./ILendingPool.sol"; // 通过该接口调用flashloan
import { IERC20 } from "./IERC20.sol"; // 涉及到ERC20代币所需
请注意闪电贷将扣取一定量的手续费,平台手续费为0.09%
第二步,设置FlashLoanReceiverBase
FlashLoanReceiverBase.sol
abstract contract FlashLoanReceiverBase is IFlashLoanReceiver {
using SafeERC20 for IERC20;
using SafeMath for uint256;
ILendingPoolAddressesProvider public immutable override ADDRESSES_PROVIDER;
ILendingPool public immutable override LENDING_POOL;
constructor(ILendingPoolAddressesProvider provider) public {
ADDRESSES_PROVIDER = provider;
LENDING_POOL = ILendingPool(provider.getLendingPool());
}
}