A full-stack decentralized exchange (DEX) built from scratch to learn blockchain development.
- Implemented wallet connection with RainbowKit
- Network switching and balance display
- Multi-wallet provider support
- Created SwapToken (ERC20) with mint/burn
- Deployed to Sepolia testnet
- Comprehensive test suite (7 tests)
- Frontend integration for viewing/transferring
- Implemented constant product formula (x Γ y = k)
- Liquidity pool with add/remove functionality
- Token swaps with slippage protection
- Deployed with 1000 TKA + 1000 TKB initial liquidity
- Solved real-world SafeERC20 compatibility issue
| Contract | Address | Etherscan |
|---|---|---|
| Token A (TKA) | 0xd4F8...7374 |
View |
| Token B (TKB) | 0xb8c1...fC6d |
View |
| SimpleSwap | 0x1286...4706 |
View |
Smart Contracts:
- Solidity ^0.8.20
- Foundry (testing & deployment)
- OpenZeppelin contracts
Frontend:
- Next.js 14 (App Router)
- TypeScript
- wagmi & viem
- RainbowKit
- TailwindCSS
Constant Product: x Γ y = k
Example: 1000 TKA Γ 1000 TKB = 1,000,000
Swap 100 TKB β Get 90.91 TKA
New: 909.09 TKA Γ 1100 TKB = 1,000,000 β
- SafeERC20 Compatibility: Debugged and fixed transfer issues
- Allowance Management: Proper approve/transferFrom flow
- Gas Estimation: Understanding transaction costs
- State Synchronization: Keeping frontend in sync with blockchain