Skip to content

๐Ÿš€ EASYDEX, our latest DeFi innovation, now live on Sepolia testnet! ๐ŸŽ‰ EASYDEX is a DEX simplified for everyone, which offers: โœ… Intuitive token swaps โœ… Easy liquidity provision โœ… Real-time analytics โœ… Seamless wallet integration with RainbowKit โœ… Responsive design for desktop & mobile.

License

Notifications You must be signed in to change notification settings

adelamare-blockchain/dApp_EASYDEX_DeFi-platform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

EasyDEX Logo

EasyDEX - Simplified Decentralized Exchange

Solidity Hardhat Vite.js React TailwindCSS Wagmi License: MIT

A simplified decentralized exchange (DEX) built on the blockchain, enabling users to swap tokens, manage liquidity, and track swap history in real-time with interactive charts.Empower your swaping experience with transparency and security.

EasyDEX Homepage

Explore Demo โ€ข Report Bug โ€ข Request Feature

๐Ÿ“‘ Table of Contents

๐ŸŒŸ Features

  • ๐Ÿ’ฑ Swap tokens with ease
  • ๐Ÿ’งAdd and remove liquidity
  • ๐Ÿ“Š Real-time price oracle integration
  • ๐Ÿ“ˆ Interactive swap history chart
  • ๐Ÿ”’ Secure and transparent transactions
  • ๐ŸŒ Cross-platform compatibility (Desktop & Mobile)
  • ๐Ÿ’พ Local storage for persisting user swap history

๐Ÿ› ๏ธ Tech Stack

Backend

  • Solidity ^0.8.24
  • Hardhat 2.22.5
  • OpenZeppelin Contracts 5.0.2
  • Chainlink Contracts
  • Ethers.js 6.4.0

Frontend

  • React 18.3.1
  • Vite 5.3.4
  • TailwindCSS 3.4.6
  • RainbowKit 2.1.3
  • wagmi 2.12.2
  • Recharts 2.12.7

Testing & Quality Assurance

  • Chai
  • Mocha
  • Hardhat Network Helpers
  • Solidity Coverage

๐Ÿ—๏ธ Architecture

easydex/
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ contracts/
โ”‚   โ”‚   โ”œโ”€โ”€ DEX.sol
โ”‚   โ”‚   โ”œโ”€โ”€ Token.sol
โ”‚   โ”‚   โ””โ”€โ”€ Oracle.sol
โ”‚   โ”œโ”€โ”€ test/
โ”‚   โ”‚   โ””โ”€โ”€ DEX.test.js
โ”‚   โ”œโ”€โ”€ scripts/
โ”‚   โ”‚   โ””โ”€โ”€ deploy.js
โ”‚   โ”œโ”€โ”€ hardhat.config.js
โ”‚   โ””โ”€โ”€ package.json
โ”œโ”€โ”€ frontend/
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”œโ”€โ”€ pages/
โ”‚   โ”‚   โ””โ”€โ”€ main.jsx
โ”‚   โ”œโ”€โ”€ public/
โ”‚   โ””โ”€โ”€ package.json
โ””โ”€โ”€ README.md

๐Ÿ“œ Smart Contract

Our DEX is powered by three main smart contracts:

  1. DEX.sol: The core exchange functionality
  2. Token.sol: ERC20 token implementation
  3. Oracle.sol: Price feed integration with Chainlink

Key Functions in DEX.sol

function swap(uint256 _ethAmountIn, uint256 _tokenAmountIn) external payable;
function addLiquidity(uint256 ethAmount, uint256 tokenAmount) external payable;
function removeLiquidity(uint256 ethAmount, uint256 tokenAmount) external payable;

๐Ÿš€ Deployed on SEPOLIA testnet

๐Ÿ” View full contract on Etherscan

๐Ÿ–ฅ๏ธ Frontend

Our frontend provides an intuitive interface for seamless interaction with the DEX:

  • ๐ŸŒˆ Connect wallet using RainbowKit
  • ๐Ÿ’ฑ Swap tokens with real-time price updates
  • ๐Ÿ’ง Manage liquidity pools
  • ๐Ÿ“Š View exchange rates and pool statistics
  • ๐Ÿ“ˆ Interactive swap history chart with Recharts
  • ๐Ÿ“ฑ Responsive design for optimal mobile and desktop experience

๐Ÿ“Š Real-time Swap Tracking

EasyDEX features a powerful real-time swap tracking system:

  • ๐Ÿ“ˆ Interactive line chart displaying swap history
  • ๐Ÿ’พ Persistent storage using localStorage for each user
  • ๐Ÿ”„ Automatic updates after each swap transaction
  • ๐Ÿ” Detailed tooltips showing swap information
  • ๐Ÿ“Š Y-axis displays price in USD, X-axis shows swap count

Chart Features

  • Responsive design that adapts to different screen sizes
  • Custom styling with gradients and hover effects
  • Tooltips with formatted currency display
  • Legend for easy data interpretation

This feature provides users with valuable insights into their trading activity and market trends directly within the DApp interface.

๐Ÿš€ Getting Started

  1. Clone the repository
git clone https://github.com/adelamare-blockchain/dApp_EASYDEX_DeFi-platform.git
  1. Install dependencies
cd backend && yarn
cd ../frontend && yarn
  1. Set up environment variables (refer to .env.example in both directories)

  2. Run the development server

# Terminal 1: Backend
cd backend
yarn hardhat node

# Terminal 2: Backend
cd backend
yarn hardhat run scripts/deployTest.js --network localhost

# Terminal 3: Frontend
cd frontend
yarn dev
  1. Open http://localhost:5173 in your browser

๐Ÿงช Testing

We've rigorously tested all functionalities using Hardhat. Run the test suite:

cd backend
yarn hardhat test
View Test Results
DEX.sol
Deployment
โœ” Should set the right token address and oracle
โœ” Should set the right owner for Oracle, Token and DEX contracts
โœ” Should have initial liquidity set to 0
Liquidity Management
โœ” Should add ETH liquidity
โœ” Should add token liquidity
โœ” Should remove ETH liquidity
โœ” Should remove token liquidity
โœ” Should revert if tokenAmount or ethAmount is zero or if both tokenAmount and ethAmount
โœ” Should revert if insufficient liquidity in the pool
โœ” Should allow addr1 to withdraw his removed ETH liquidity
Swapping
โœ” Should add sufficient token liquidity before swap
Exchange rate : 250 UTT/ETH
TOKEN amount out :
997.0 UTT | 9970 $USD
FEE : 3.0 UTT | 30 $USD
Eth LIQUIDITY :
14.0 ETH
Token LIQUIDITY :
1503.0 UTT | 15030 $USD
โœ” Should swap ETH for tokens and update liquidity
ETH amount out : 3.988 ETH | 9970 $USD
FEE : 0.012 ETH | 30 $USD
Eth LIQUIDITY : 6.012 ETH
Token LIQUIDITY : 3500.0 UTT | 35000 $USD
โœ” Should swap tokens for ETH and update liquidity
โœ” Should revert for a swap ETH for tokens with tokenAmount or ethAmount at zero
โœ” Should revert for a swap Tokens for ETH with both tokenAmount and ethAmount values
โœ” Should revert if both ETH and tokens are provided
โœ” Should revert if swap delay is superior to 1 minute
โœ” Should revert if swap amount is superior to the dex limit
Fees Management
โœ” Should allow owner to update the trading fee
โœ” Should fail to set fee above maximum
โœ” Should collect token fees on swaps
โœ” Should collect eth fees on swaps

Oracle.sol
Deployment
โœ” Should set the right owner
Get Price
โœ” Should return the latest price from Chainlink

Token.sol
Deployment
โœ” Should set the right owner
โœ” Should assign the total supply of tokens to the owner
โœ” Should set the max supply correctly
Minting
โœ” Should allow owner to mint tokens
โœ” Should not allow minting more than max supply
โœ” Should revert if non-owner tries to mint tokens
Burning
โœ” Should allow the owner to burn tokens
โœ” Should not allow burning more tokens than the owner's balance

ยท--------------------------------|---------------------------|-------------|-----------------------------ยท
| Solc version: 0.8.24 ยท Optimizer enabled: true ยท Runs: 200 ยท Block limit: 30000000 gas โ”‚
ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
| Methods
 โ”‚
ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยท
| Contract ยท Method ยท Min ยท Max ยท Avg ยท # calls ยท eur (avg) โ”‚
ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยท
| DEX ยท addLiquidity ยท 55473 ยท 108733 ยท 70133 ยท 10 ยท - โ”‚
ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยท
| DEX ยท removeLiquidity ยท 49877 ยท 56033 ยท 53981 ยท 6 ยท - โ”‚
ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยท
| DEX ยท setFee ยท - ยท - ยท 29750 ยท 2 ยท - โ”‚
ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยท
| DEX ยท swap ยท 77242 ยท 111442 ยท 107929 ยท 10 ยท - โ”‚
ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยท
| DEX ยท withdrawEth ยท - ยท - ยท 30981 ยท 1 ยท - โ”‚
ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยท
| DEX ยท withdrawFees ยท 33020 ยท 41944 ยท 37482 ยท 2 ยท - โ”‚
ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยท
| Token ยท approve ยท - ยท - ยท 46406 ยท 8 ยท - โ”‚
ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยท
| Token ยท burn ยท - ยท - ยท 36219 ยท 1 ยท - โ”‚
ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยท
| Token ยท transfer ยท 51610 ยท 51622 ยท 51616 ยท 2 ยท - โ”‚
ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยท
| Deployments ยท ยท % of limit ยท โ”‚
ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยท
| DEX ยท - ยท - ยท 1788584 ยท 6 % ยท - โ”‚
ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยท
| MockAggregatorV3 ยท - ยท - ยท 131616 ยท 0.4 % ยท - โ”‚
ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยท
| Token ยท - ยท - ยท 830533 ยท 2.8 % ยท - โ”‚
ยท--------------------------------|-------------|-------------|-------------|---------------|-------------ยท

32 passing (2s)

Done in 5.69s.

๐ŸŒ Deployment

  1. Deploy the smart contract
cd backend
yarn hardhat run scripts/deploy.js --network sepolia
  1. Get automatically the contract addresses & ABIs in frontend/src/constants/contractInfo.jsx

  2. Build and deploy the frontend

cd frontend
yarn build
# Deploy the 'dist' directory to your preferred hosting service

๐Ÿ“ธ Screenshots

EasyDEX Dashboard EasyDEX Swap Interface EasyDEX PoolInfo Interface EasyDEX About page

๐Ÿ›ฃ๏ธ Roadmap

  • Implement multi-token support
  • Add yield farming capabilities
  • Integrate with additional oracle providers
  • Implement governance features
  • Enhance swap history analytics with more metrics and visualizations
  • Add export functionality for swap history data

๐Ÿค Contributing

Contributions are welcome! Please check out our Contribution Guidelines for details on our code of conduct and the process for submitting pull requests.

๐Ÿ“„ License

This project is licensed under the MIT License. See the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • OpenZeppelin for secure smart contract libraries
  • Hardhat for Ethereum development environment
  • Chainlink for reliable oracle data
  • RainbowKit for wallet connection UI
  • TailwindCSS for utility-first CSS framework
Made with โค๏ธ by Blockchain & Cie (https://www.linkedin.com/company/blockchain-cie)

About

๐Ÿš€ EASYDEX, our latest DeFi innovation, now live on Sepolia testnet! ๐ŸŽ‰ EASYDEX is a DEX simplified for everyone, which offers: โœ… Intuitive token swaps โœ… Easy liquidity provision โœ… Real-time analytics โœ… Seamless wallet integration with RainbowKit โœ… Responsive design for desktop & mobile.

Topics

Resources

License

Stars

Watchers

Forks