Created
May 24, 2020 02:07
-
-
Save developerfred/f7ace84b80cab0489d3bd19a47b6ed78 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pragma solidity ^0.6.8; | |
| import 'https://github.com/aave/aave-protocol/blob/master/contracts/configuration/LendingPoolAddressesProvider.sol' | |
| import 'https://github.com/aave/aave-protocol/blob/master/contracts/lendingpool/LendingPool.sol' | |
| import 'https://github.com/aave/aave-protocol/blob/master/contracts/flashloan/base/FlashLoanReceiverBase.sol' | |
| contract Borrower is FlashLoanReceiverBase { | |
| LendingPoolAddressesProvider provider; | |
| address dai; | |
| constructor( | |
| address _provider, | |
| address _dai) | |
| FlashLoanReceiverBase(_provider) | |
| public { | |
| provider = LendingPoolAddressesProvider(_provider); | |
| dai = _dai; | |
| } | |
| function startLoan(uint amount, bytes calldata _params) external { | |
| LendingPool lendingPool = provider.getLendingPool(); | |
| lendingPool.flashLoan(address(this), dai, amount, _params); | |
| } | |
| function executeOperation( | |
| address _reserve, | |
| uint _amount, | |
| uint _fee, | |
| bytes memory _params | |
| ) external { | |
| // arbitrage, refinance loan | |
| transferFundsBackToPoolInternal(_reserve, amount + fee); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment