Last active
February 11, 2023 02:27
-
-
Save coffiasd/440c42e5a0211d096080ad5b1b50b4ae to your computer and use it in GitHub Desktop.
This file contains 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
// SPDX-License-Identifier: UNLICENSED | |
pragma solidity ^0.8.0; | |
import "@balancer-labs/v2-interfaces/contracts/vault/IVault.sol"; | |
import "@balancer-labs/v2-interfaces/contracts/vault/IFlashLoanRecipient.sol"; | |
contract Swap is IFlashLoanRecipient { | |
IVault private constant vault = IVault(0xBA12222222228d8Ba445958a75a0704d566BF2C8); | |
event eventLog(string eventName); | |
function makeFlashLoan( | |
IERC20[] memory tokens, | |
uint256[] memory amounts, | |
bytes memory userData | |
) external { | |
vault.flashLoan(this, tokens, amounts, userData); | |
emit eventLog("making flash..."); | |
} | |
function receiveFlashLoan( | |
IERC20[] memory tokens, | |
uint256[] memory amounts, | |
uint256[] memory feeAmounts, | |
bytes memory userData | |
) external override { | |
require(msg.sender == address(vault)); | |
//do something here... | |
// return token0 | |
IERC20(tokens[0]).transfer(address(vault), amounts[0]); | |
emit eventLog("receive done..."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment