Skip to content

Instantly share code, notes, and snippets.

@JuanXavier
Created July 8, 2022 23:40
Show Gist options
  • Select an option

  • Save JuanXavier/6dd4a8b8434aa733641fe3cead0146a3 to your computer and use it in GitHub Desktop.

Select an option

Save JuanXavier/6dd4a8b8434aa733641fe3cead0146a3 to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../unstoppable/UnstoppableLender.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract ReceiverUnstoppable {
UnstoppableLender private immutable pool;
address private immutable owner;
constructor(address poolAddress) {
pool = UnstoppableLender(poolAddress);
owner = msg.sender;
}
// Pool will call this function during the flash loan
function receiveTokens(address tokenAddress, uint256 amount) external {
require(msg.sender == address(pool), "Sender must be pool");
// Return all tokens to the pool
require(
IERC20(tokenAddress).transfer(msg.sender, amount),
"Transfer of tokens failed"
);
}
function executeFlashLoan(uint256 amount) external {
require(msg.sender == owner, "Only owner can execute flash loan");
pool.flashLoan(amount);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment