A minimal Uniswap-style Automated Market Maker (AMM) built in Solidity and Hardhat.
Swap ERC20 tokens, provide liquidity, and learn DeFi fundamentals!
- Swap between two ERC20 tokens using the x*y=k AMM formula
- Add liquidity to the pool
- Written in Solidity, deployable locally with Hardhat
- Node.js (v18/v20 recommended)
- Hardhat
- MetaMask
git clone https://github.com/ibrahimjspy/mini-uniswap.git
cd mini-uniswap
npm install
npx hardhat compile
npx hardhat node
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!
/contracts
- Solidity contracts (ERC20, MiniUniswap)/scripts
- Scripts to deploy and interact with contracts
- For educational/demo use only.
- No fees, LP tokens, or safety protections included.
- Do NOT deploy to mainnet as-is!
- Add a React frontend (see branch
frontend
) - Add LP tokens, swap fees, and more!
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
}
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