Flash Loan Using UniswapV2-Based AMMs

What is Flash Loan?

Performing a Swap on UniswapV2

Swapping Diagram from https://uniswap.org/docs/v2/core-concepts/swaps/
Swapping helper functions from UniswapV2Router contract
swap function in UniswapV2Pair

Performing a Flash Loan

if (data.length > 0) IUniswapV2Callee(to).uniswapV2Call(msg.sender, amount0Out, amount1Out, data);

About Inspex

Cybersecurity professional service, specialized in blockchain and smart contract auditing https://twitter.com/InspexCo