当前版本存在已知问题,正在修复中:
🐛 Mint 和 Swap 功能存在 Bug:
- 错误信息:
Unable to process transaction. Dry run failed, could not automatically determine a budget: CommandArgumentError { arg_idx: 0, kind: SecondaryIndexOutOfBounds { result_idx: 0, secondary_idx: 0 } } in command 1 - 影响功能: 代币铸造和代币交换
- 合约单元测试正常通过,问题出现在前端交易构建
🔧 开发状态: 正在调试和修复中,请耐心等待更新
这是一个将 以太坊 UniswapV1 协议原生移植到 Sui 区块链的完整去中心化交易所实现,包含 Move 智能合约和 React 前端应用。
🌟 原生移植 - 从以太坊 UniswapV1 忠实转换而来
🏭 工厂合约 - 管理交易对的创建和查询
💧 交易所合约 - 处理流动性管理和代币交换
🪙 测试代币 - 两个演示用的测试代币
🌐 Web3 前端 - 完整的用户界面
- ✅ 创建代币交易对
- ✅ 添加/移除流动性
- ✅ SUI ↔ Token 交换
- ✅ Token ↔ Token 交换 (通过 SUI 作为中介)
- ✅ LP 代币管理
- ✅ 0.3% 交易手续费
- ✅ 单元测试全部通过
- ✅ 钱包连接 (Sui Wallet)
- 🐛 代币铸造界面 (存在交易构建问题)
- ✅ 交易对创建
- ✅ 流动性管理
- 🐛 代币交换界面 (存在交易构建问题)
- ✅ 交易状态跟踪
本项目完全基于以太坊 UniswapV1 的设计原理:
- 恒定乘积做市商 (x * y = k)
- 自动化做市商 (AMM) 机制
- 流动性提供者代币 (LP Token)
- 0.3% 交易手续费分配给流动性提供者
- Factory 合约 - 管理所有交易对
- Exchange 合约 - 单个交易对的核心逻辑
- 安全特性 - Move 语言的内存安全和资源管理
- React 18 + TypeScript
- Sui dApp Kit - 钱包连接和交易
- Radix UI - 现代化组件库
- Vite - 构建工具
- Sui CLI 已安装
- Node.js 18+
- Sui Wallet 浏览器扩展
# 1. 克隆项目
git clone <repository-url>
cd SuiUniSwapV1
# 2. 构建智能合约
sui move build
# 3. 运行测试 (确认合约正常)
sui move test
# 4. 启动前端
cd SuiUniSwapV1-frontend
npm install
npm run dev错误: SecondaryIndexOutOfBounds { result_idx: 0, secondary_idx: 0 }
可能原因:
- 前端交易构建语法问题
- Gas budget 设置问题
- 对象引用索引错误
临时解决方案:
- 直接使用 Sui CLI 进行合约交互
- 等待前端修复更新
- ✅ 智能合约: 完全正常,测试通过
- 🔧 前端应用: 部分功能待修复
- 📝 文档: 持续更新中
Current version has known issues being fixed:
🐛 Mint and Swap Functions Have Bugs:
- Error message:
Unable to process transaction. Dry run failed, could not automatically determine a budget: CommandArgumentError { arg_idx: 0, kind: SecondaryIndexOutOfBounds { result_idx: 0, secondary_idx: 0 } } in command 1 - Affected features: Token minting and token swapping
- Smart contract unit tests pass normally - the issue is in frontend transaction construction
🔧 Development Status: Currently debugging and fixing, please wait for updates
This is a complete decentralized exchange implementation that natively ports Ethereum's UniswapV1 protocol to the Sui blockchain, including Move smart contracts and a React frontend application.
🌟 Native Port - Faithfully converted from Ethereum UniswapV1
🏭 Factory Contract - Manages trading pair creation and queries
💧 Exchange Contract - Handles liquidity management and token swaps
🪙 Test Tokens - Two demonstration tokens
🌐 Web3 Frontend - Complete user interface
- ✅ Create token trading pairs
- ✅ Add/remove liquidity
- ✅ SUI ↔ Token swaps
- ✅ Token ↔ Token swaps (via SUI as intermediary)
- ✅ LP token management
- ✅ 0.3% trading fees
- ✅ All unit tests passing
- ✅ Wallet connection (Sui Wallet)
- 🐛 Token minting interface (transaction construction issues)
- ✅ Trading pair creation
- ✅ Liquidity management
- 🐛 Token swap interface (transaction construction issues)
- ✅ Transaction status tracking
This project is completely based on Ethereum UniswapV1's design principles:
- Constant Product Market Maker (x * y = k)
- Automated Market Maker (AMM) mechanism
- Liquidity Provider Tokens (LP Tokens)
- 0.3% trading fees distributed to liquidity providers
- Factory Contract - Manages all trading pairs
- Exchange Contract - Core logic for individual trading pairs
- Security Features - Move language's memory safety and resource management
- React 18 + TypeScript
- Sui dApp Kit - Wallet connection and transactions
- Radix UI - Modern component library
- Vite - Build tool
- Sui CLI installed
- Node.js 18+
- Sui Wallet browser extension
# 1. Clone the project
git clone <repository-url>
cd SuiUniSwapV1
# 2. Build smart contracts
sui move build
# 3. Run tests (confirm contracts work)
sui move test
# 4. Start frontend
cd SuiUniSwapV1-frontend
npm install
npm run devError: SecondaryIndexOutOfBounds { result_idx: 0, secondary_idx: 0 }
Possible Causes:
- Frontend transaction construction syntax issues
- Gas budget configuration problems
- Object reference indexing errors
Temporary Solutions:
- Use Sui CLI directly for contract interactions
- Wait for frontend fix updates
- ✅ Smart Contracts: Fully functional, tests passing
- 🔧 Frontend Application: Some features under repair
- 📝 Documentation: Continuously updating
SuiUniSwapV1/
├── sources/ # Move smart contracts
│ ├── factory.move # Factory contract
│ ├── exchange.move # Exchange contract
│ ├── test_coin.move # Test token 1
│ └── test_coin2.move # Test token 2
├── SuiUniSwapV1-frontend/ # React frontend
│ ├── src/
│ │ ├── components/ # UI components
│ │ ├── utils/ # Utility functions
│ │ └── types.ts # Type definitions
│ └── package.json
├── tests/ # Test files
├── Move.toml # Move project config
└── README.md
- ✅ Slippage protection (minimum output checks)
- ✅ Access control (Capability pattern)
- ✅ Integer overflow protection
- ✅ Reentrancy protection (Move language features)
⚠️ Note: This is a test version, do not use on mainnet
sui move test# Start local Sui network (optional)
sui start --with-faucet
# Get test SUI
sui client faucet
# Deploy to local network
sui client publish --gas-budget 50000000Welcome to submit Issues and Pull Requests!
MIT License - see LICENSE file for details.
- Sui - High-performance blockchain platform
- Uniswap - Decentralized exchange protocol design inspiration
- Move Language - Secure smart contract programming language
For questions or suggestions, please contact us through GitHub Issues.