Thanks to visit codestin.com
Credit goes to github.com

Skip to content

lunes-platform/Lunex

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

81 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌟 Lunex DEX - Decentralized Exchange on Lunes Blockchain 🌟

VersΓ£o 1.0.0
Ink! Version: 5.1.1
Rede Alvo: Lunes Network (wss://ws.lunes.io)
Última Atualização: Agosto 2024

Welcome to Lunex DEX, a cutting-edge decentralized exchange built on the Lunes blockchain! Featuring innovative staking, governance, trading rewards, and a complete DeFi ecosystem with the lowest fees and highest security standards.

πŸ“‹ EspecificaΓ§Γ΅es TΓ©cnicas:

  • Framework: ink! 5.1.1 (Polkadot Smart Contracts)
  • PadrΓ£o de Token: PSP22 (Polkadot Standard Proposal)
  • Arquitetura: Baseada em Uniswap V2 (AMM - Automated Market Maker)
  • SeguranΓ§a: Implementa reentrancy guards, input validation e checked arithmetic
  • Toolchain: Rust nightly (atualizado)

πŸš€ Key Features

  • Complete DEX with Factory, Router, and Pair contracts
  • Native Staking with LUNES token and governance voting
  • Trading Rewards with anti-fraud protection and tier system
  • Hybrid Token Listing (admin + community governance)
  • Advanced Security with comprehensive audit and optimization

πŸ“œ Table of Contents

  1. Architecture Overview
  2. Smart Contracts
  3. Advanced Features
  4. Getting Started
  5. Development Setup
  6. Deployment
  7. Testing
  8. Security
  9. Networks
  10. Documentation
  11. Contributing
  12. Status
  13. Versions
  14. License

πŸ—οΈ Architecture Overview

Lunex DEX is built with a modular architecture that ensures scalability, security, and maintainability:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   🏭 Factory    │────│   πŸ”„ Pair       │────│  πŸ›£οΈ Router      β”‚
β”‚   Contract      β”‚    β”‚   Contracts     β”‚    β”‚   Contract      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                       β”‚                       β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚                             β”‚                             β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  πŸ₯© Staking     β”‚    β”‚  🎁 Trading     β”‚    β”‚  πŸͺ™ WNative     β”‚
β”‚  + Governance   β”‚    β”‚   Rewards       β”‚    β”‚   Token         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Core Philosophy

  • Uniswap V2 Compatible: Battle-tested AMM model
  • Native LUNES Integration: 8 decimal places support
  • 0.5% Total Fee Structure: Optimized distribution
  • Community Governance: Democratic token listing
  • Anti-Fraud Protection: Advanced security measures

πŸ”§ Smart Contracts

Core DEX Contracts

Contract Description Features
🏭 Factory Creates and manages trading pairs Deterministic pair creation, fee management
πŸ”„ Pair Individual AMM pools Uniswap V2 compatibility, optimized gas usage
πŸ›£οΈ Router Main trading interface Multi-hop swaps, slippage protection
πŸͺ™ WNative Wrapped LUNES token Native token wrapping/unwrapping

Advanced Contracts

Contract Description Features
πŸ₯© Staking LUNES staking + governance Tiered rewards, proposal voting, paginatedrewards
🎁 Trading Rewards Volume-based rewards Anti-fraud protection, configurable parameters, epoch system

πŸš€ Advanced Features

Fee Distribution (0.5% Total)

  • 60% β†’ Liquidity Providers (0.3%)
  • 15% β†’ Development/Team (0.075%)
  • 15% β†’ Trading Rewards (0.075%)
  • 10% β†’ Staking Rewards (0.05%)

Staking System

  • Tiered Rewards: Bronze, Silver, Gold, Platinum (up to 15% APY)
  • Governance Power: Vote on token listings and protocol changes
  • Early Adopter Bonuses: Special rewards for first 100/500/1000 stakers

Trading Rewards

  • Volume Tiers: Bronze β†’ Platinum based on monthly volume
  • Anti-Fraud: Cooldown periods, volume limits, blacklist system
  • Configurable Parameters: Admin-adjustable fraud prevention
  • Epoch System: Weekly/monthly reward distributions

Governance Features

  • Hybrid Listing: Admin + community-driven token approval
  • Dynamic Fees: Community can adjust proposal fees (starts at 1,000 LUNES)
  • Fee Redistribution: Rejected proposals fund development and rewards

πŸš€ Getting Started

For Users

  1. Connect Lunes Wallet β†’ Access the DEX interface
  2. Stake LUNES β†’ Earn rewards and governance power
  3. Add Liquidity β†’ Earn fees from trading pairs
  4. Trade Tokens β†’ Low fees, high security
  5. Claim Rewards β†’ From staking and trading activity

For Developers

  1. Clone Repository β†’ Get the latest code
  2. Setup Environment β†’ Rust, ink!, cargo-contract
  3. Build Contracts β†’ Compile and test
  4. Deploy to Lunes β†’ Use provided scripts
  5. Integrate β†’ Connect your dApp

πŸ› οΈ Development Setup

Prerequisites

  • Rust (stable toolchain)
  • cargo-contract CLI (latest version)
  • Node.js and Yarn (for scripts)
  • Lunes Network access

Installation

# Clone repository
git clone https://github.com/lunes-platform/lunex-dex.git
cd lunex-dex

# Install Rust dependencies
rustup target add wasm32-unknown-unknown
cargo install cargo-contract --force --locked

# Install Node.js dependencies  
yarn install

# Build all contracts
cargo build --workspace

# Run all tests
cargo test --workspace

πŸš€ Deployment

Deploy to Lunes Network

# Deploy to testnet
yarn deploy:testnet

# Deploy to mainnet  
yarn deploy:mainnet

# Admin list tokens (for initial setup)
yarn admin-list-token

# Verify deployment
yarn verify:deployment

Available Scripts

# Build contracts
yarn compile:all

# Deploy contracts
yarn deploy:lunes

# List tokens via governance
yarn list-token

# Verify deployment
yarn verify:deployment

πŸ§ͺ Testing

Unit Tests (76 tests total)

# Run all contract unit tests
cargo test --workspace

# Test specific contract
cd uniswap-v2/contracts/factory && cargo test
cd uniswap-v2/contracts/router && cargo test  
cd uniswap-v2/contracts/staking && cargo test
cd uniswap-v2/contracts/rewards && cargo test
cd uniswap-v2/contracts/wnative && cargo test

Integration Tests

# Run TypeScript integration tests
yarn test

# Run Rust integration tests
cargo test --test integration_e2e

Test Coverage

  • Factory Contract: 10/10 tests βœ…
  • Router Contract: 18/18 tests βœ…
  • Pair Contract: 10/10 tests βœ…
  • Staking Contract: 12/12 tests βœ…
  • Trading Rewards: 13/13 tests βœ…
  • WNative Contract: 13/13 tests βœ…

πŸ”’ Security

Security Measures

  • Reentrancy Protection β†’ Guards against malicious calls
  • Access Control β†’ Role-based permissions
  • Input Validation β†’ Comprehensive parameter checking
  • Overflow Protection β†’ Safe arithmetic operations
  • Anti-Fraud System β†’ Trading rewards protection

Audit Status (2025)

  • βœ… OpenZeppelin Security Review compliance
  • βœ… Code Review by security experts
  • βœ… Gas Optimization analysis
  • βœ… Stress Testing completed
  • βœ… Production Deployment ready
  • πŸ”„ Third-party Audit scheduled Q1 2025

🌐 Networks

Lunes Blockchain

  • Testnet: wss://ws-test.lunes.io
  • Mainnet:
    • wss://ws.lunes.io
    • wss://ws-lunes-main-01.lunes.io
    • wss://ws-lunes-main-02.lunes.io
    • wss://ws-archive.lunes.io

Native Token

  • Symbol: LUNES
  • Decimals: 8
  • Network: Lunes (Substrate-based)

πŸ“š Documentation

  • docs/guides/ β†’ Deployment and usage guides
  • docs/reports/ β†’ Security audits and reports
  • docs/ β†’ Technical documentation
  • examples/ β†’ Configuration examples
  • scripts/ β†’ Deployment and management scripts

Key Documents

🀝 Contributing

We welcome contributions! Please follow these guidelines:

Development Process

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Test your changes (cargo test --workspace)
  4. Commit with clear messages (git commit -m 'Add amazing feature')
  5. Push to branch (git push origin feature/amazing-feature)
  6. Open a Pull Request

Code Standards

  • Rust: Follow rustfmt and clippy recommendations
  • Tests: Maintain 100% test coverage for new features
  • Security: All changes must pass security review
  • Documentation: Update relevant docs and comments

Areas for Contribution

  • πŸ”’ Security audits and improvements
  • ⚑ Gas optimization enhancements
  • πŸ§ͺ Testing expansion and edge cases
  • πŸ“š Documentation and tutorials
  • 🌐 Frontend development (coming soon)

πŸ† Credits

Core Team

  • Jorge William - Lead Developer (GitHub)
  • Adelson Santos - Smart Contract Architect (GitHub)

Acknowledgments

  • Lunes Platform - Blockchain infrastructure
  • ink! - Smart contract framework
  • OpenBrush - Security standards reference
  • Uniswap V2 - AMM model inspiration

βœ… Status

Current Phase: Production Ready βœ… (2025)

Component Status Progress
Core DEX βœ… Complete Factory, Router, Pair contracts
Staking & Governance βœ… Complete LUNES staking, voting, proposals
Trading Rewards βœ… Complete Anti-fraud, tiers, epoch system
Security Audit βœ… Complete OpenZeppelin compliance
Gas Optimization βœ… Complete Optimized for production
Testing Suite βœ… Complete 76/76 tests passing
Documentation βœ… Complete Comprehensive guides
Deployment Scripts βœ… Complete Automated deployment
Mainnet Ready βœ… Complete Lunes Network compatible

Roadmap 2025

  • πŸ”„ External Audit (Q1 2025)
  • 🌐 Frontend Interface (Q2 2025)
  • πŸ“± Mobile App (Q3 2025)
  • πŸ”— Cross-chain Bridge (Q4 2025)
  • 🌍 Multi-chain Support (Q4 2025)

πŸ“¦ Versions

Current Stack (2025)

  • ink!: 5.1.1 (stable)
  • Rust: stable toolchain (2025 edition)
  • Substrate: Compatible
  • cargo-contract: latest

Dependencies

  • scale-codec: 3.x
  • scale-info: 2.10
  • ink_env: 5.1.1
  • ink_storage: 5.1.1

Technology Evolution

  • Migration Completed: ink! 4.0 β†’ ink! 5.1.1
  • Security Enhanced: OpenZeppelin compliance
  • Gas Optimized: Production-ready efficiency
  • Testing: 100% coverage maintained

πŸ“„ License

Lunex DEX is open source and released under the Apache 2.0 License.

Key Points

  • βœ… Commercial use allowed
  • βœ… Modification allowed
  • βœ… Distribution allowed
  • βœ… Private use allowed
  • ⚠️ Trademark use not granted

🌟 Built with ❀️ for the Lunes ecosystem 🌟

🌐 Lunes Platform β€’ πŸ“§ Contact β€’ πŸ’¬ Community

About

Lunex

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 83.7%
  • TypeScript 15.9%
  • JavaScript 0.4%