Tutorial of Flash Swaps of Uniswap V3

Let’s execute Flash Swaps on hardhat forking network!

yuichiro aoki
Coinmonks
Published in
4 min readAug 13, 2021

--

Photo by Shahadat Rahman on Unsplash

Today I’m going to show you the basic tutorial of Flash Swaps of Uniswap V3. This might be helpful when you want to make a profit from arbitrage trading.

The tutorial repo is here.

Let’s Get Started😁

Installation and Setup

  1. Install Node.js & yarn, if you haven’t already.

2. Clone This Repo

Run the following command.

git clone https://github.com/yuichiroaoki/flash-swap-example.git

Quickstart

Right now this repo only works with hardhat mainnet fork. With hardhat, you can run your smart contracts on mainnet fork. For more: Harhdat Docs

  1. Setup Environment Variables

You’ll need an ALCHEMY_MAINNET_RPC_URL environment variable. You can get one from Alchemy website for free.

Then, you can create a .env file with the following.

ALCHEMY_MAINNET_RPC_URL='<your-own-alchemy-mainnet-rpc-url>'

2. Install Dependencies

Run the following command.

yarn install

--

--