Flash Swaps
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data);Triggering a Flash Swap
function uniswapV2Call(address sender, uint amount0, uint amount1, bytes calldata data);Using uniswapV2Call
function uniswapV2Call(address sender, uint amount0, uint amount1, bytes calldata data) {
address token0 = IUniswapV2Pair(msg.sender).token0(); // fetch the address of token0
address token1 = IUniswapV2Pair(msg.sender).token1(); // fetch the address of token1
assert(msg.sender == IUniswapV2Factory(factoryV2).getPair(token0, token1)); // ensure that msg.sender is a V2 pair
// rest of the function goes here!
}