Skip to content

Aggregator2/Aggregator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

75 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SwappiQ - Advanced Cross-Chain DEX with State Channels

SwappiQ Logo

High-Performance Decentralized Exchange with State Channels for HFT
Sub-millisecond Execution β€’ Cross-Chain Settlement β€’ Enterprise Security

License TypeScript Next.js Ethereum State Channels HFT Ready

πŸš€ Overview

SwappiQ is a next-generation decentralized exchange that leverages state channels for high-frequency trading, enabling sub-millisecond trade execution with periodic on-chain settlement. Built for institutional traders and market makers, SwappiQ delivers CEX-like performance with DEX security guarantees through advanced cryptographic protocols and cross-chain infrastructure.

🎯 Key Features

  • State Channels for HFT: Sub-millisecond execution with off-chain trading
  • 100,000+ TPS Throughput: Orders matched instantly in-memory
  • Cross-Chain Settlement: Trade assets across multiple blockchains
  • Hybrid Liquidity: Combines on-chain and off-chain liquidity sources
  • Zero-Knowledge Proofs: Privacy-preserving trade verification
  • Enterprise Security: Multi-signature wallets and fraud proof system
  • WebSocket Real-time: Live market data and order updates
  • Comprehensive APIs: REST, WebSocket, and FIX protocol support

🌐 Supported Blockchains

SwappiQ supports 49+ blockchain networks for cross-chain trading:

Major Networks

  • Ethereum - The leading smart contract platform
  • Solana - High-performance blockchain with sub-second finality
  • Tron - Fast and low-cost transactions
  • BNB Smart Chain - Popular DeFi ecosystem
  • Polygon - Ethereum scaling solution
  • Arbitrum - Leading Layer 2 for Ethereum
  • Optimism - Optimistic rollup solution
  • Avalanche - High-throughput smart contracts
  • Base - Coinbase's Layer 2 network

Additional Networks

We support 40+ additional chains including zkSync, Scroll, Linea, Fantom, Gnosis, Moonbeam, Celo, Metis, Cronos, and many emerging L1s and L2s.

Liquidity Sources

  • Jupiter (Solana) - Access to Solana's deepest liquidity
  • TronScan (Tron) - Comprehensive TRC-20 token support
  • LiFi Protocol - Cross-chain liquidity aggregation
  • 0x Protocol - EVM chain liquidity
  • Native DEXs - Direct integration with chain-specific DEXs

πŸ“Š State Channel Performance

Performance Metrics

Metric Traditional DEX State Channels
Order Latency 15-30 seconds <1ms
Gas Cost per Trade $5-50 $0.10-1 (amortized)
Throughput 10-50 TPS 100,000+ TPS
Settlement Time Immediate 5 min batches
MEV Protection Limited Complete
Capital Efficiency Low High

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Frontend      │────▢│   API Gateway    │────▢│ Matching Engine β”‚
β”‚  (React/Next)   β”‚     β”‚    (Express)     β”‚     β”‚   (In-Memory)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                               β”‚                           β”‚
                               β–Ό                           β–Ό
                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                        β”‚ State Channels   β”‚     β”‚   Settlement    β”‚
                        β”‚    (HFT)         β”‚     β”‚    Engine       β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                               β”‚                           β”‚
                               β–Ό                           β–Ό
                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                        β”‚   PostgreSQL     β”‚     β”‚   Blockchain    β”‚
                        β”‚   (Database)     β”‚     β”‚   (Ethereum)    β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

⚑ State Channels for High-Frequency Trading

How It Works

  1. Channel Opening

    • Traders deposit collateral into a multi-signature smart contract
    • Both parties sign the initial channel state
    • Channel is ready for instant off-chain trading
  2. Off-Chain Trading

    • Orders matched instantly without blockchain interaction
    • Each trade updates the channel state with new balances
    • Cryptographic signatures ensure non-repudiation
    • Sub-millisecond execution with zero gas fees
  3. Settlement

    • Periodic settlement of net positions (configurable: 5-60 minutes)
    • Only final balances submitted on-chain
    • 99% reduction in transaction costs
    • Dispute resolution through fraud proofs

Security Features

  • EIP-712 Signatures: Every state update is cryptographically signed
  • Fraud Proofs: Challenge invalid states on-chain
  • Time Locks: Secure withdrawal periods
  • Multi-Signature Control: Requires consensus for settlements

πŸ“š Documentation

Visit our comprehensive Developer Portal for:

  • Interactive API documentation with Swagger UI
  • Code examples in multiple languages
  • SDKs for JavaScript, Python, Go, Java, and Rust
  • Migration guides and best practices
  • WebSocket integration guide
  • State channel tutorials

πŸ› οΈ Quick Start

Prerequisites

  • Node.js 18+
  • PostgreSQL 14+
  • Redis 6+
  • Ethereum node (or Infura/Alchemy endpoint)

Installation

# Clone the repository
git clone https://github.com/swappiq/swappiq.git
cd swappiq

# Install dependencies
npm install

# Set up environment variables
cp .env.example .env
# Edit .env with your configuration

# Run database migrations
npm run migrate

# Start the development server
npm run dev

Basic Usage

// Initialize the client
import { SwappiQClient } from '@swappiq/sdk';

const client = new SwappiQClient({
  apiKey: 'your_api_key',
  environment: 'production'
});

// Submit an order
const order = await client.orders.submit({
  pair: 'BTC/USD',
  side: 'buy',
  type: 'limit',
  price: '50000',
  quantity: '0.5'
});

// Open a state channel for HFT
const channel = await client.channels.create({
  counterparty: '0x...',
  collateral: '1000000', // USDC
  duration: 86400 // 24 hours
});

// Execute off-chain trades
const trade = await channel.trade({
  amount: '100000',
  price: '50100'
});

πŸ”§ API Endpoints

Core Trading

  • POST /api/orders/submit - Submit new order
  • GET /api/orders/history - Order history with P&L
  • POST /api/orders/cancel - Cancel order
  • GET /api/orderbook/{pair} - Real-time order book
  • GET /api/trades/{pair} - Recent trades

State Channels

  • POST /api/channels/create - Open new channel
  • POST /api/channels/{id}/trade - Execute off-chain trade
  • GET /api/channels/{id}/state - Current channel state
  • POST /api/channels/{id}/settle - Settle channel

Market Data

  • GET /api/ticker/{pair} - 24h ticker stats
  • GET /api/candles/{pair} - OHLCV data
  • WS /socket.io - Real-time subscriptions

πŸ§ͺ Testing

# Run unit tests
npm test

# Run integration tests
npm run test:integration

# Run E2E tests
npm run test:e2e

# Generate coverage report
npm run test:coverage

πŸ’° Fees and Pricing

Transparent Fee Structure

  • Platform Fee: 0.3% on all trades (transparently displayed)
  • Gas Fees: Paid by users for on-chain transactions
  • State Channel Fees: Minimal fees for channel opening/closing

All fees are clearly shown in quotes before execution. No hidden markups or surprise charges.

πŸ”’ Security

  • All API endpoints require authentication (JWT)
  • State channels use EIP-712 signatures
  • Settlement requires multi-signature approval
  • Regular security audits by CertiK

Report security issues to: [email protected]

🚒 Deployment

Docker

# Build the image
docker build -t swappiq .

# Run with docker-compose
docker-compose up -d

Kubernetes

# Apply manifests
kubectl apply -f k8s/

# Check deployment status
kubectl get pods -n swappiq

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

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

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • LiFi Protocol for cross-chain infrastructure and other DEX partners
  • OpenZeppelin for secure contract libraries
  • The DeFi community for continuous support

🌟 Community

πŸ“ž Support


Built with ❀️ by the SwappiQ Team

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •