Welcome to DEX, a decentralized exchange (DEX) with an Automated Market Maker (AMM) model. This platform allows users to swap ETH for TOKEN and vice versa with a 1% fee. Liquidity providers can supply liquidity and receive LP tokens, which can be burned to withdraw ETH and TOKEN.
- Automated Market Maker (AMM): Facilitates ETH <> TOKEN swaps.
- 1% Swap Fee: Charged on all swaps, distributed to liquidity providers.
- Liquidity Provision: Users can supply liquidity and receive LP tokens.
- Withdraw Liquidity: Burn LP tokens to withdraw ETH and TOKEN.
- Secure and Transparent: Built with Foundry, Wagmi, and Next.js for a robust and user-friendly experience.
- Solidity: Smart contracts for the AMM and LP functionalities.
- Foundry: Development environment for Solidity.
- Wagmi: React hooks library for Ethereum.
- Next.js: Framework for the frontend.
-
Clone the repository:
git clone https://github.com/akhil888binoy/Decentralized-Exchange.git cd dex
-
Install dependencies:
npm install
-
Set up environment variables: Create a
.env
file in the root directory and add the necessary environment variables.PRIVATE_KEY="..." RPC_URL="..." ETHERSCAN_API_KEY="..."
-
Compile contracts:
forge build
-
Deploy contracts: Update
scripts/deploy.js
with your deployment logic and run:forge create --rpc-url $RPC_URL --private-key $PRIVATE_KEY --constructor-args 0x584FB53d1309625112de608567B00f474E7E4172 --etherscan-api-key $ETHERSCAN_API_KEY --verify src/Exchange.sol:Exchange
-
Run the development server:
npm run dev
- Connect your wallet.
- Navigate to the "Add Liquidity" section.
- Input the amount of ETH and TOKEN you want to add.
- Approve TOKEN transfer.
- Add liquidity.
- Connect your wallet.
- Navigate to the "Swap" section.
- Select the amount of ETH or TOKEN you want to swap.
- Approve TOKEN transfer if swapping TOKEN.
- Confirm the swap.
- Connect your wallet.
- Navigate to the "Withdraw Liquidity" section.
- Select the amount of LP tokens to burn.
- Confirm the withdrawal.
- DEX Contract:
0xC739AfadE19BB21b5BBc9750f00ecf85bbD4fE61
- TOKEN Contract:
0x584FB53d1309625112de608567B00f474E7E4172
This project is licensed under the MIT License.