aabdullah29 / flash-swap-example

Example of Flash Swaps

Home Page:https://medium.com/coinmonks/tutorial-of-flash-swaps-of-uniswap-v3-73c0c846b822

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Flash Swap Example

Example of Flash Swaps

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.

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

3. Compile Smart Contracts

Run the following command.

yarn compile

4. Execute Flash Swaps 🔥

Run the following command.

yarn flashswaps

Expected Outputs

$ yarn flashswaps
yarn run v1.22.5
$ npx hardhat run scripts/flashswaps.ts
No need to generate any newer typings.
deployer's initial balance 0
deployer's ending balance 4.860772792026915
Congrats! You earned 4.860772792026915 DAI !!
Done in 40.72s.

References

PairFlash

A sample flash swap contract from Uniswap official docs.

Docs / GitHub / Test

About

Example of Flash Swaps

https://medium.com/coinmonks/tutorial-of-flash-swaps-of-uniswap-v3-73c0c846b822

License:MIT License


Languages

Language:TypeScript 52.9%Language:Solidity 46.9%Language:Shell 0.2%