Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yuichiroaoki/flash-swap-example
Example of Flash Swaps
https://github.com/yuichiroaoki/flash-swap-example
ethtereum flashswap hardhat kybernetwork solidity uniswap
Last synced: 3 months ago
JSON representation
Example of Flash Swaps
- Host: GitHub
- URL: https://github.com/yuichiroaoki/flash-swap-example
- Owner: yuichiroaoki
- License: mit
- Created: 2021-08-13T00:23:48.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-08-13T03:50:11.000Z (over 3 years ago)
- Last Synced: 2024-10-15T01:45:22.511Z (4 months ago)
- Topics: ethtereum, flashswap, hardhat, kybernetwork, solidity, uniswap
- Language: TypeScript
- Homepage: https://medium.com/coinmonks/tutorial-of-flash-swaps-of-uniswap-v3-73c0c846b822
- Size: 152 KB
- Stars: 82
- Watchers: 4
- Forks: 38
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Flash Swap Example
Example of Flash Swaps## Installation and Setup
### 1. Install [Node.js](https://nodejs.org/en/) & [yarn](https://classic.yarnpkg.com/en/docs/install/#windows-stable), if you haven't already.
### 2. Clone This Repo
Run the following command.
```console
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](https://alchemy.com/?r=33851811-6ecf-40c3-a36d-d0452dda8634) for free.Then, you can create a .env file with the following.
```
ALCHEMY_MAINNET_RPC_URL=''
```### 2. Install Dependencies
Run the following command.
```console
yarn install
```### 3. Compile Smart Contracts
Run the following command.
```console
yarn compile
```### 4. Execute Flash Swaps 🔥
Run the following command.
```console
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](https://docs.uniswap.org/protocol/guides/flash-integrations/final-contract) / [GitHub](https://github.com/Uniswap/uniswap-v3-periphery/blob/flash-pair-example/contracts/examples/PairFlash.sol) / [Test](https://github.com/Uniswap/uniswap-v3-periphery/blob/flash-pair-example/test/PairFlash.spec.ts)