Example of Flash Swaps
Run the following command.
git clone https://github.com/yuichiroaoki/flash-swap-example.git
Right now this repo only works with hardhat mainnet fork.
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>'
Run the following command.
yarn install
Run the following command.
yarn compile
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.
A sample flash swap contract from Uniswap official docs.