Skip to content

Mini Uniswap: A Simple DeFi Token Swap Dapp This project is a hands-on implementation of a minimal Uniswap-style decentralized exchange (DEX), built from scratch in Solidity and Hardhat. Swap ERC20 tokens, add liquidity, and learn the core concepts behind automated market makers and DeFi! 💡 Swap between two ERC20 tokens

Notifications You must be signed in to change notification settings

ibrahimjspy/mini-uniswap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mini Uniswap (DeFi Token Swap Dapp)

A minimal Uniswap-style Automated Market Maker (AMM) built in Solidity and Hardhat.
Swap ERC20 tokens, provide liquidity, and learn DeFi fundamentals!

Features

  • Swap between two ERC20 tokens using the x*y=k AMM formula
  • Add liquidity to the pool
  • Written in Solidity, deployable locally with Hardhat

Getting Started

Prerequisites

  • Node.js (v18/v20 recommended)
  • Hardhat
  • MetaMask

Install

git clone https://github.com/ibrahimjspy/mini-uniswap.git
cd mini-uniswap
npm install

Compile Contracts

npx hardhat compile

Start Local Blockchain

npx hardhat node

Deploy Contracts

Open another terminal and run:

npx hardhat run scripts/deploy.js --network localhost
npx hardhat run scripts/deployUniswap.js --network localhost
npx hardhat run scripts/addLiquidity.js --network localhost
npx hardhat run scripts/swapAforB.js --network localhost

Update contract addresses in scripts as needed!

Project Structure

  • /contracts - Solidity contracts (ERC20, MiniUniswap)
  • /scripts - Scripts to deploy and interact with contracts

Security & Warnings

  • For educational/demo use only.
  • No fees, LP tokens, or safety protections included.
  • Do NOT deploy to mainnet as-is!

Next Steps

  • Add a React frontend (see branch frontend)
  • Add LP tokens, swap fees, and more!

License

MIT


Built for learning purposes by \M Ibrahim.


---

## **4. Update Comments in Code**

Add doc comments for public functions and contracts, e.g.:

```solidity
/// @title MiniUniswap - Simple Uniswap-style AMM for two ERC20 tokens
/// @author Your Name
/// @notice Add liquidity and swap tokens with the constant product formula (x*y=k)
contract MiniUniswap {
  // ... rest of code
}

5. Push to GitHub

git init
git add .
git commit -m "Initial commit: Mini Uniswap basic DEX"
git branch -M main
git remote add origin https://github.com/ibrahimjspy/mini-uniswap.git
git push -u origin main

About

Mini Uniswap: A Simple DeFi Token Swap Dapp This project is a hands-on implementation of a minimal Uniswap-style decentralized exchange (DEX), built from scratch in Solidity and Hardhat. Swap ERC20 tokens, add liquidity, and learn the core concepts behind automated market makers and DeFi! 💡 Swap between two ERC20 tokens

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published