SinglePairDexSwap is a decentralized exchange (DEX) built on the Ethereum blockchain. It allows users to swap single pair of ERC20 tokens directly from their wallets in a permissionless and decentralized manner.
- ERC20 Token Swapping: Swap any ERC20 tokens directly from your wallet.
- Liquidity Provision: Users can add liquidity to the pool and earn fees.
- Automated Market Making (AMM): SinglePairDexSwap uses the constant product formula for automated market making.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
- Node.js and npm or yarn
- Hardhat
- Ethereum wallet
- Clone the repository and navigate to the newly created folder:
git clone https://github.com/EhsanTheCoderr/SinglePairDexSwap.git cd SinglePairDexSwap
- Install the dependencies:
yarn
- Compile the smart contracts:
yarn hardhat compile
- Deploy the contracts:
yarn hardhat deploy
To run the tests, use the following command:
yarn hardhat test
Note: Please ensure that the contract is deployed on localhost/ganache/testnet and the node is running properly before running the script. Set the environment variable $env:signer
to the desired account index before executing the scripts.
-
Add Liquidity:
$env:signer="0"; yarn hardhat run .\scripts\DexSwap-AddLiquidity.js --network localhost
-
Swap Token1 or Token2 by selecting the file name:
$env:signer="0"; yarn hardhat run .\scripts\DexSwap-SwapFromToken1.js --network localhost
-
Remove Liquidity:
$env:signer="0"; yarn hardhat run .\scripts\DexSwap-RemoveLiquidity.js --network localhost
- Solidity - Ethereum's smart contract language
- Hardhat - Ethereum development environment
- OpenZeppelin - Library for secure smart contract development
This project is licensed under the MIT License.
- Ethereum Foundation
- OpenZeppelin