Skip to content

Instantly share code, notes, and snippets.

@developerfred
Created May 24, 2020 02:07
Show Gist options
  • Select an option

  • Save developerfred/f7ace84b80cab0489d3bd19a47b6ed78 to your computer and use it in GitHub Desktop.

Select an option

Save developerfred/f7ace84b80cab0489d3bd19a47b6ed78 to your computer and use it in GitHub Desktop.
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