pragma solidity ^0.6.6; import "https://github.com/aave/flashloan-box/blob/Remix/contracts/aave/FlashLoanReceiverBase.sol"; import "https://github.com/aave/flashloan-box/blob/Remix/contracts/aave/ILendingPoolAddressesProvider.sol"; import "https://github.com/aave/flashloan-box/blob/Remix/contracts/aave/ILendingPool.sol"; contract Flashloan is FlashLoanReceiverBase { constructor(address _addressProvider) FlashLoanReceiverBase(_addressProvider) public {} /** This function is called after your contract has received the flash loaned amount */ function executeOperation( address _reserve, uint256 _amount, uint256 _fee, bytes calldata _params ) external override { require(_amount <= getBalanceInternal(address(this), _reserve), "Invalid balance, was the flashLoan successful?"); // // Your logic goes here. // !! Ensure that *this contract* has enough of `_reserve` funds to payback the `_fee` !! // uint totalDebt = _amount.add(_fee); transferFundsBackToPoolInternal(_reserve, totalDebt); } // Rest of your code goes here /** Flash loan 1000000000000000000 wei (1 ether) worth of `_asset` */ function flashloan(address _asset) public onlyOwner { bytes memory data = ""; uint amount = 1 ether; ILendingPool lendingPool = ILendingPool(addressesProvider.getLendingPool()); lendingPool.flashLoan(address(this), _asset, amount, data); } }
0.6.6